diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-02-24 03:54:53 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-02-24 03:54:53 (GMT) |
commit | ca41979ee514f642c506e4f4d81461f19b587bf2 (patch) | |
tree | f31feb004d0b724d5240c8a227c7f0c886939a1b | |
parent | eff16283358217b43b310269a72e0cb47357a8b3 (diff) | |
parent | abc9da96c89b337377ee62ac29ee54e4e7b0a514 (diff) |
Merge branch 'master' of github.com:openscad/openscad into issue11_2
Conflicts:
RELEASE_NOTES
openscad.pro
src/mainwin.cc
39 files changed, 625 insertions, 102 deletions
@@ -2,6 +2,8 @@ <!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd"> <plist version="0.9"> <dict> + <key>CFBundleName</key> + <string>OpenSCAD</string> <key>CFBundleIconFile</key> <string>@ICON@</string> <key>CFBundlePackageType</key> @@ -12,6 +14,10 @@ <string>OpenSCAD</string> <key>CFBundleIdentifier</key> <string>org.openscad.OpenSCAD</string> + <key>CFBundleVersion</key> + <string>@SHORT_VERSION@</string> + <key>CFBundleShortVersionString</key> + <string>@SHORT_VERSION@</string> <key>CFBundleDocumentTypes</key> <array> <dict> @@ -27,6 +33,8 @@ <string>OpenSCAD Design</string> <key>CFBundleTypeRole</key> <string>Editor</string> + <key>CFBundleTypeIconFile</key> + <string>SCAD.icns</string> <key>LSIsAppleDefaultForType</key> <true/> </dict> @@ -35,5 +43,7 @@ <true/> <key>OSAScriptingDefinition</key> <string>OpenSCAD.sdef</string> + <key>SUPublicDSAKeyFile</key> + <string>dsa_pub.pem</string> </dict> </plist> diff --git a/RELEASE_NOTES b/RELEASE_NOTES index b22621f..00e752e 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -4,6 +4,8 @@ OpenSCAD 2013.XX Features: o Console output is now enabled on Windows through the openscad.com executable o Added basic syntax highlighting in the editor +o Mac: Added document icon +o Mac: Added auto-update check o Commandline output of CGAL render to png image using '-o f.png --render' o Regression test now creates single monolithic .html file for easier uploading diff --git a/appcast-snapshots.xml.in b/appcast-snapshots.xml.in new file mode 100644 index 0000000..f46c814 --- /dev/null +++ b/appcast-snapshots.xml.in @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"> + <channel> + <title>OpenSCAD Development Snapshots</title> + <link>http://openscad.org/appcast-snapshots.xml</link> + <language>en</language> + <item> + <title>OpenSCAD @VERSION@</title> + <pubDate>@VERSIONDATE@</pubDate> + <sparkle:releaseNotesLink>https://raw.github.com/openscad/openscad/master/RELEASE_NOTES</sparkle:releaseNotesLink> + <enclosure url="https://openscad.googlecode.com/files/OpenSCAD-@VERSION@.dmg" + sparkle:version="@VERSIONDATE@" + sparkle:shortVersionString="@VERSION@" + sparkle:dsaSignature="@DSASIGNATURE@" + length="@FILESIZE@" + type="application/octet-stream"/> + </item> + </channel> +</rss> diff --git a/appcast.xml.in b/appcast.xml.in new file mode 100644 index 0000000..f61710c --- /dev/null +++ b/appcast.xml.in @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle"> + <channel> + <title>OpenSCAD Updates</title> + <link>http://openscad.org/appcast.xml</link> + <language>en</language> + <item> + <title>OpenSCAD @VERSION@</title> + <pubDate>@VERSIONDATE@</pubDate> + <sparkle:releaseNotesLink>https://raw.github.com/openscad/openscad/openscad-@VERSION@/RELEASE_NOTES</sparkle:releaseNotesLink> + <enclosure url="https://openscad.googlecode.com/files/OpenSCAD-@VERSION@.dmg" + sparkle:version="@VERSIONDATE@" + sparkle:shortVersionString="@VERSION@" + sparkle:dsaSignature="@DSASIGNATURE@" + length="@FILESIZE@" + type="application/octet-stream"/> + </item> + </channel> +</rss> diff --git a/doc/checklist-macosx.txt b/doc/checklist-macosx.txt deleted file mode 100644 index a72a8d3..0000000 --- a/doc/checklist-macosx.txt +++ /dev/null @@ -1,20 +0,0 @@ -NB! This is the Mac OS X deployment checklist. - See build-macosx.txt for how to build a development build of - OpenSCAD for your system only without manually compiling all - dependencies. - -o Macports: - sudo port install cmake ImageMagick - -o Qt4 - - Download and install the combined 32-bit and 64-bit build for 10.5-10.6 from here: - http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x - -o Build dependencies from source - - scripts/macosx-build-dependencies.sh - -o Build and Deploy OpenSCAD - -# Update VERSION in publish-macosx.sh - scripts/publish-macosx.sh diff --git a/doc/release-checklist.txt b/doc/release-checklist.txt index c51c919..f5bb759 100644 --- a/doc/release-checklist.txt +++ b/doc/release-checklist.txt @@ -3,9 +3,12 @@ OpenSCAD Release Checklist (See bottom of this file for how to build release binaries) -o Update VERSION environment variable +o Set VERSION and VERSIONDATE environment variable + (VERSIONDATE is new and used to identify releases. VERSION is for humans. + For development builds, set VERSION and VERSIONDATE to the same value) export VERSION=2013.01 + export VERSIONDATE=2013.01.17 It will be used by the commands below, as well as these files: @@ -38,13 +41,15 @@ o Update external resources: - http://en.wikipedia.org/wiki/OpenSCAD o Notify package managers - Ubuntu: https://launchpad.net/~chrysn + - Fedora: Miro HronĨok <miro@hroncok.cz> or <mhroncok@redhat.com> - MacPorts: Build and Upload Release Binaries --------------------------------- -$ export VERSION=<openscad version, e.g. 2013.01> +$ export VERSIONDATE=<date of release in YYYY.MM.DD format, e.g. 2013.01.17> +$ export VERSION=<openscad version, e.g. 2013.01> # If development snapshot, you don't need version is the same as VERSIONDATE $ tar xzf openscad-$VERSION.src.tar.gz $ cd openscad-$VERSION diff --git a/dsa_pub.pem b/dsa_pub.pem new file mode 100644 index 0000000..f0aee27 --- /dev/null +++ b/dsa_pub.pem @@ -0,0 +1,12 @@ +-----BEGIN PUBLIC KEY----- +MIIBtjCCASsGByqGSM44BAEwggEeAoGBAMP6y57wSCnUvfwehhit5K8EU4W3uf6s +zCFUGWIxWaweWjkezHIZLz7pTv0dLm5Va0vKTIWgrNseTtdTaJ491lyGAHWlu9sP +LAe/vG+UpIA6uNZX3gB7dDxunRUenTczYgnVoQWSIVRhZUEjci9WgbJJrguTPQvi +cCfuI6Hox6cDAhUA3duJXWi3eaOIMqCfm6RpEt/fRC8CgYApHNQB5Ar/SIPobxtJ +Ox05xhhgm/YOJbGUcSZjsMgEP6rj+269vCBnYG+eE3nelXfOA5SXbOfY6Ju6+RBS +OdPeNbWZah88QJK8bqBH7KS/EkMaiEXerPEIEIC5xOjKjYXs1z8AtNGUGORwWwjm +85et2nY/WXvIJkUQtET/bWEYPQOBhAACgYB7hBLdC5rXpV0nqEmI4QYYt63OdP4D +Lf2XISyKi9H1F+6mwoeU4It7fMdGC1MBXyx/3sv8U1YbYIeDHB+lDy6QN2UxSBTN +VI9UPUqdcoYZwQiaHHgqWcoyPDqzEVsFtHi3/pXLckuszA19NT8980o+7noiKxUm +3pDa4C+oANPFCQ== +-----END PUBLIC KEY----- diff --git a/icons/SCAD.icns b/icons/SCAD.icns Binary files differnew file mode 100644 index 0000000..12abb48 --- /dev/null +++ b/icons/SCAD.icns diff --git a/icons/prefsUpdate.png b/icons/prefsUpdate.png Binary files differnew file mode 100644 index 0000000..a7dc02e --- /dev/null +++ b/icons/prefsUpdate.png @@ -1 +1,2 @@ set environment DYLD_LIBRARY_PATH=/Users/kintel/code/OpenSCAD/libraries/install/lib +set environment DYLD_FRAMEWORK_PATH=/Users/kintel/code/OpenSCAD/libraries/install/lib diff --git a/openscad.pro b/openscad.pro index 15f76f8..5d71d91 100644 --- a/openscad.pro +++ b/openscad.pro @@ -66,9 +66,9 @@ macx { ICON = icons/OpenSCAD.icns QMAKE_INFO_PLIST = Info.plist APP_RESOURCES.path = Contents/Resources - APP_RESOURCES.files = OpenSCAD.sdef + APP_RESOURCES.files = OpenSCAD.sdef dsa_pub.pem icons/SCAD.icns QMAKE_BUNDLE_DATA += APP_RESOURCES - LIBS += -framework Cocoa + LIBS += -framework Cocoa -framework Sparkle } else { TARGET = openscad @@ -242,6 +242,8 @@ HEADERS += src/version_check.h \ src/imageutils.h \ src/system-gl.h \ src/CsgInfo.h + \ + src/AutoUpdater.h SOURCES += src/version_check.cc \ src/ProgressWidget.cc \ @@ -289,6 +291,7 @@ SOURCES += src/version_check.cc \ src/editor.cc \ src/qglview.cc \ src/GLView.cc \ + src/AutoUpdater.cc \ \ src/builtin.cc \ src/export.cc \ @@ -352,8 +355,12 @@ SOURCES += src/cgalutils.cc \ macx { HEADERS += src/AppleEvents.h \ - src/EventFilter.h + src/EventFilter.h \ + src/SparkleAutoUpdater.h \ + src/CocoaUtils.h SOURCES += src/AppleEvents.cc + OBJECTIVE_SOURCES += src/SparkleAutoUpdater.mm \ + src/CocoaUtils.mm } isEmpty(PREFIX):PREFIX = /usr/local diff --git a/openscad.qrc b/openscad.qrc index 84745e9..28b6a72 100644 --- a/openscad.qrc +++ b/openscad.qrc @@ -4,6 +4,7 @@ <file>icons/prefsAdvanced.png</file> <file>icons/prefs3DView.png</file> <file>icons/prefsEditor.png</file> + <file>icons/prefsUpdate.png</file> <file>icons/flattr.png</file> <file>src/AboutDialog.html</file> </qresource> diff --git a/patches/sparkle.patch b/patches/sparkle.patch new file mode 100644 index 0000000..11e86e0 --- /dev/null +++ b/patches/sparkle.patch @@ -0,0 +1,12 @@ +--- Sparkle-0ed83cf9f2eeb425d4fdd141c01a29d843970c20/SUConstants.h 2013-02-04 08:18:48.000000000 -0500 ++++ Sparkle-new/SUConstants.h 2013-02-06 17:47:31.000000000 -0500 +@@ -24,7 +24,7 @@ + // If your app file on disk is named "MyApp 1.1b4", Sparkle usually updates it + // in place, giving you an app named 1.1b4 that is actually 1.2. Turn the + // following on to always reset the name back to "MyApp": +-#define NORMALIZE_INSTALLED_APP_NAME 0 ++#define NORMALIZE_INSTALLED_APP_NAME 1 + + + #define TRY_TO_APPEND_VERSION_NUMBER 1 +diff -ru Sparkle-0ed83cf9f2eeb425d4fdd141c01a29d843970c20/SUPlainInstallerInternals.m Sparkle-new/SUPlainInstallerInternals.m diff --git a/scripts/macosx-build-dependencies.sh b/scripts/macosx-build-dependencies.sh index bfe0ede..57dd3bf 100755 --- a/scripts/macosx-build-dependencies.sh +++ b/scripts/macosx-build-dependencies.sh @@ -325,6 +325,30 @@ build_eigen() make install } +build_sparkle() +{ + # Let Sparkle use the default compiler + unset CC + unset CXX + version=$1 + echo "Building Sparkle" $version "..." + cd $BASEDIR/src + rm -rf Sparkle-$version + if [ ! -f Sparkle-$version.zip ]; then + curl -o Sparkle-$version.zip https://nodeload.github.com/andymatuschak/Sparkle/zip/$version + fi + unzip -q Sparkle-$version.zip + cd Sparkle-$version + patch -p1 < $OPENSCADDIR/patches/sparkle.patch + if $OPTION_32BIT; then + SPARKLE_EXTRA_FLAGS="-arch i386" + fi + xcodebuild -project Sparkle.xcodeproj -scheme Sparkle -configuration Release -arch x86_64 $SPARKLE_EXTRA_FLAGS + rm -r $DEPLOYDIR/lib/Sparkle.framework + cp -Rf build/Release/Sparkle.framework $DEPLOYDIR/lib/ + install_name_tool -id $DEPLOYDIR/lib/Sparkle.framework/Versions/A/Sparkle $DEPLOYDIR/lib/Sparkle.framework/Sparkle +} + if [ ! -f $OPENSCADDIR/openscad.pro ]; then echo "Must be run from the OpenSCAD source root directory" exit 0 @@ -391,3 +415,4 @@ build_boost 1.51.0 build_cgal 4.1 build_glew 1.9.0 build_opencsg 1.3.2 +build_sparkle 0ed83cf9f2eeb425d4fdd141c01a29d843970c20
\ No newline at end of file diff --git a/scripts/macosx-sanity-check.py b/scripts/macosx-sanity-check.py index 3938d74..4927de9 100755 --- a/scripts/macosx-sanity-check.py +++ b/scripts/macosx-sanity-check.py @@ -108,6 +108,9 @@ if __name__ == '__main__': assert(deps) for d in deps: absfile = lookup_library(d) + if not re.match(executable_path, absfile): + print "Error: External dependency " + d + sys.exit(1) if absfile == None: print "Not found: " + d print " ..required by " + str(processed[dep]) diff --git a/scripts/publish-macosx.sh b/scripts/publish-macosx.sh index e22e5bd..3aeeaf9 100755 --- a/scripts/publish-macosx.sh +++ b/scripts/publish-macosx.sh @@ -1,10 +1,13 @@ #!/bin/sh -# NB! To build a release build, the VERSION environment variable needs to be set. +# NB! To build a release build, the VERSION and VERSIONDATE environment variables needs to be set. # See doc/release-checklist.txt +if test -z "$VERSIONDATE"; then + VERSIONDATE=`date "+%Y.%m.%d"` +fi if test -z "$VERSION"; then - VERSION=`date "+%Y.%m.%d"` + VERSION=$VERSIONDATE COMMIT=-c SNAPSHOT=true fi @@ -29,10 +32,24 @@ if [[ $? != 0 ]]; then exit 1 fi +SIGNATURE=$(openssl dgst -sha1 -binary < OpenSCAD-$VERSION.dmg | openssl dgst -dss1 -sign dsa_priv.pem | openssl enc -base64) + +if [[ $VERSION == $VERSIONDATE ]]; then + APPCASTFILE=appcast-snapshots.xml +else + APPCASTFILE=appcast.xml +fi +echo "Creating appcast $APPCASTFILE..." +sed -e "s,@VERSION@,$VERSION,g" -e "s,@VERSIONDATE@,$VERSIONDATE,g" -e "s,@DSASIGNATURE@,$SIGNATURE,g" -e "s,@FILESIZE@,$(stat -f "%z" OpenSCAD-$VERSION.dmg),g" $APPCASTFILE.in > $APPCASTFILE +cp $APPCASTFILE ../openscad.github.com +if [[ $VERSION == $VERSIONDATE ]]; then + cp $APPCASTFILE ../openscad.github.com/appcast-snapshots.xml +fi + echo "Uploading..." LABELS=OpSys-OSX,Type-Executable if ! $SNAPSHOT; then LABELS=$LABELS,Featured; fi `dirname $0`/googlecode_upload.py -s 'Mac OS X Snapshot' -p openscad OpenSCAD-$VERSION.dmg -l $LABELS -# Update snapshot filename on wab page +# Update snapshot filename on web page `dirname $0`/update-web.sh OpenSCAD-$VERSION.dmg diff --git a/scripts/release-common.sh b/scripts/release-common.sh index de14cb1..a30d43a 100755 --- a/scripts/release-common.sh +++ b/scripts/release-common.sh @@ -9,10 +9,12 @@ # # Usage: release-common.sh [-v <versionstring>] [-c] [-x32] # -v Version string (e.g. -v 2010.01) +# -d Version date (e.g. -d 2010.01.23) # -c Build with commit info # -mingw32 Cross-compile for win32 using MXE # -# If no version string is given, todays date will be used (YYYY-MM-DD) +# If no version string or version date is given, todays date will be used (YYYY-MM-DD) +# If only verion date is given, it will be used also as version string. # If no make target is given, release will be used on Windows, none one Mac OS X # # The commit info will extracted from git and be passed to qmake as OPENSCAD_COMMIT @@ -23,7 +25,7 @@ printUsage() { - echo "Usage: $0 -v <versionstring> -c -mingw32 + echo "Usage: $0 -v <versionstring> -d <versiondate> -c -mingw32 echo echo " Example: $0 -v 2010.01 } @@ -59,16 +61,20 @@ else exit fi -while getopts 'v:c' c +while getopts 'v:d:c' c do case $c in v) VERSION=$OPTARG;; + d) VERSIONDATE=$OPTARG;; c) OPENSCAD_COMMIT=`git log -1 --pretty=format:"%h"` esac done +if test -z "$VERSIONDATE"; then + VERSIONDATE=`date "+%Y.%m.%d"` +fi if test -z "$VERSION"; then - VERSION=`date "+%Y.%m.%d"` + VERSION=$VERSIONDATE fi @@ -102,7 +108,7 @@ if [ -d .git ]; then git submodule update fi -echo "Building openscad-$VERSION $CONFIGURATION..." +echo "Building openscad-$VERSION ($VERSIONDATE) $CONFIGURATION..." case $OS in LINUX|MACOSX) @@ -230,6 +236,7 @@ echo "Creating archive.." case $OS in MACOSX) + /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $VERSIONDATE" OpenSCAD.app/Contents/Info.plist macdeployqt OpenSCAD.app -dmg -no-strip mv OpenSCAD.dmg OpenSCAD-$VERSION.dmg hdiutil internet-enable -yes -quiet OpenSCAD-$VERSION.dmg diff --git a/setenv_mjau.sh b/setenv_mjau.sh index 943ae6b..7976c60 100644 --- a/setenv_mjau.sh +++ b/setenv_mjau.sh @@ -1,5 +1,6 @@ export OPENSCAD_LIBRARIES=$PWD/../libraries/install export DYLD_LIBRARY_PATH=$OPENSCAD_LIBRARIES/lib +export DYLD_FRAMEWORK_PATH=$OPENSCAD_LIBRARIES/lib export QMAKESPEC=macx-g++ #export OPENCSGDIR=$PWD/../OpenCSG-1.3.0 diff --git a/src/AutoUpdater.cc b/src/AutoUpdater.cc new file mode 100644 index 0000000..b64cc82 --- /dev/null +++ b/src/AutoUpdater.cc @@ -0,0 +1,3 @@ +#include "AutoUpdater.h" + +AutoUpdater *AutoUpdater::updater_instance = NULL; diff --git a/src/AutoUpdater.h b/src/AutoUpdater.h new file mode 100644 index 0000000..18527c8 --- /dev/null +++ b/src/AutoUpdater.h @@ -0,0 +1,25 @@ +#ifndef AUTOUPDATER_H_ +#define AUTOUPDATER_H_ + +#include <QString> + +class AutoUpdater +{ +public: + virtual ~AutoUpdater() {} + + virtual void checkForUpdates() = 0; + virtual void setAutomaticallyChecksForUpdates(bool on) = 0; + virtual bool automaticallyChecksForUpdates() = 0; + virtual void setEnableSnapshots(bool on) = 0; + virtual bool enableSnapshots() = 0; + virtual QString lastUpdateCheckDate() = 0; + + static AutoUpdater *updater() { return updater_instance; } + static void setUpdater(AutoUpdater *updater) { updater_instance = updater; } + +protected: + static AutoUpdater *updater_instance; +}; + +#endif diff --git a/src/CocoaUtils.h b/src/CocoaUtils.h new file mode 100644 index 0000000..ad5518b --- /dev/null +++ b/src/CocoaUtils.h @@ -0,0 +1,13 @@ +#ifndef COCOAUTILS_H_ +#define COCOAUTILS_H_ + +#include <string> + +class CocoaUtils +{ +public: + static void endApplication(); + static std::string documentsPath(); +}; + +#endif diff --git a/src/CocoaUtils.mm b/src/CocoaUtils.mm new file mode 100644 index 0000000..295ceb9 --- /dev/null +++ b/src/CocoaUtils.mm @@ -0,0 +1,15 @@ +#include "CocoaUtils.h" +#import <Foundation/Foundation.h> +#include <stdio.h> + +void CocoaUtils::endApplication() +{ + [[NSNotificationCenter defaultCenter] + postNotificationName:@"NSApplicationWillTerminateNotification" + object:nil]; +} + +std::string CocoaUtils::documentsPath() +{ + return std::string([[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] UTF8String]); +} diff --git a/src/GLView.cc b/src/GLView.cc index c851497..2f6d69f 100644 --- a/src/GLView.cc +++ b/src/GLView.cc @@ -5,14 +5,29 @@ GLView::GLView() { - std::cout << "glview();" << std::endl; - this->renderer = NULL; + viewer_distance = 500; + object_trans << 0, 0, 0; + camera_eye << 0, 0, 0; + camera_center << 0, 0, 0; + showedges = false; + showfaces = true; + orthomode = false; + showaxes = false; + showcrosshairs = false; + renderer = NULL; +#ifdef ENABLE_OPENCSG + is_opencsg_capable = false; + has_shaders = false; + opencsg_support = true; + static int sId = 0; + this->opencsg_id = sId++; + for (int i = 0; i < 10; i++) this->shaderinfo[i] = 0; +#endif } void GLView::setRenderer(Renderer* r) { - std::cout << "setr " << r << "\n" << std::endl; - this->renderer = r; + renderer = r; } void GLView::resizeGL(int w, int h) diff --git a/src/GLView.h b/src/GLView.h index 39ec0a6..f7ae5a7 100644 --- a/src/GLView.h +++ b/src/GLView.h @@ -54,6 +54,7 @@ public: bool showaxes; bool showfaces; bool showedges; + bool showcrosshairs; Eigen::Vector3d object_trans; Eigen::Vector3d object_rot; Eigen::Vector3d camera_eye; @@ -61,6 +62,11 @@ public: #ifdef ENABLE_OPENCSG GLint shaderinfo[11]; + bool is_opencsg_capable; + bool has_shaders; +// void enable_opencsg_shaders(); + bool opencsg_support; + int opencsg_id; #endif /* void paintGL(); // diff --git a/src/MainWindow.h b/src/MainWindow.h index 4848db6..8745b8b 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -90,6 +90,7 @@ private: class QMessageBox *openglbox; private slots: + void actionUpdateCheck(); void actionNew(); void actionOpen(); void actionOpenRecent(); diff --git a/src/MainWindow.ui b/src/MainWindow.ui index 9dfc5dc..8e995cd 100644 --- a/src/MainWindow.ui +++ b/src/MainWindow.ui @@ -223,6 +223,7 @@ <addaction name="helpActionHomepage"/> <addaction name="helpActionManual"/> <addaction name="helpActionLibraryInfo"/> + <addaction name="appActionUpdateCheck"/> </widget> <addaction name="menu_File"/> <addaction name="menu_Edit"/> @@ -611,6 +612,9 @@ </property> </action> <action name="helpActionAbout"> + <property name="enabled"> + <bool>true</bool> + </property> <property name="text"> <string>About</string> </property> @@ -676,6 +680,14 @@ <string>Library info</string> </property> </action> + <action name="appActionUpdateCheck"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Check for Update..</string> + </property> + </action> </widget> <customwidgets> <customwidget> diff --git a/src/OffscreenView.cc b/src/OffscreenView.cc index b7d1deb..aa8570e 100644 --- a/src/OffscreenView.cc +++ b/src/OffscreenView.cc @@ -16,25 +16,9 @@ OffscreenView::OffscreenView(size_t width, size_t height) { - orthomode = false; - showaxes = false; - showfaces = true; - showedges = false; object_rot << 35, 0, 25; - camera_eye << 0, 0, 0; - camera_center << 0, 0, 0; - -#ifdef ENABLE_OPENCSG - is_opencsg_capable = false; - has_shaders = false; - opencsg_support = true; - static int sId = 0; - this->opencsg_id = sId++; - for (int i = 0; i < 10; i++) this->shaderinfo[i] = 0; -#endif this->ctx = create_offscreen_context(width, height); if ( this->ctx == NULL ) throw -1; - initializeGL(); GLView::resizeGL(width, height); } diff --git a/src/OffscreenView.h b/src/OffscreenView.h index 69bda4c..81fa88d 100644 --- a/src/OffscreenView.h +++ b/src/OffscreenView.h @@ -17,22 +17,15 @@ class OffscreenView : public GLView public: OffscreenView(size_t width, size_t height); // not ~OffscreenView(); // not - + void enable_opencsg_shaders(); void initializeGL(); // void paintGL(); // - - bool save(const char *filename); bool save(std::ostream &output); - std::string getRendererInfo() const; OffscreenContext *ctx; // not -#ifdef ENABLE_OPENCSG - bool is_opencsg_capable; - bool has_shaders; - void enable_opencsg_shaders(); - bool opencsg_support; - int opencsg_id; -#endif + // overrides + bool save(const char *filename); + std::string getRendererInfo() const; }; #endif diff --git a/src/Preferences.cc b/src/Preferences.cc index ec66094..7c7aee4 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -26,10 +26,13 @@ #include "Preferences.h" +#include <QMessageBox> #include <QFontDatabase> #include <QKeyEvent> #include <QSettings> +#include <QStatusBar> #include "PolySetCache.h" +#include "AutoUpdater.h" #ifdef ENABLE_CGAL #include "CGALCache.h" #endif @@ -88,6 +91,7 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) QActionGroup *group = new QActionGroup(this); group->addAction(prefsAction3DView); group->addAction(prefsActionEditor); + group->addAction(prefsActionUpdate); group->addAction(prefsActionAdvanced); connect(group, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered(QAction*))); @@ -155,6 +159,9 @@ Preferences::actionTriggered(QAction *action) else if (action == this->prefsActionEditor) { this->stackedWidget->setCurrentWidget(this->pageEditor); } + else if (action == this->prefsActionUpdate) { + this->stackedWidget->setCurrentWidget(this->pageUpdate); + } else if (action == this->prefsActionAdvanced) { this->stackedWidget->setCurrentWidget(this->pageAdvanced); } @@ -186,6 +193,40 @@ void Preferences::on_fontSize_editTextChanged(const QString &size) emit fontChanged(getValue("editor/fontfamily").toString(), intsize); } +void unimplemented_msg() +{ + QMessageBox mbox; + mbox.setText("Sorry, this feature is not implemented on your Operating System"); + mbox.exec(); +} + +void Preferences::on_updateCheckBox_toggled(bool on) +{ + if (AutoUpdater *updater =AutoUpdater::updater()) { + updater->setAutomaticallyChecksForUpdates(on); + } else { + unimplemented_msg(); + } +} + +void Preferences::on_snapshotCheckBox_toggled(bool on) +{ + if (AutoUpdater *updater =AutoUpdater::updater()) { + updater->setEnableSnapshots(on); + } else { + unimplemented_msg(); + } +} + +void Preferences::on_checkNowButton_clicked() +{ + if (AutoUpdater *updater =AutoUpdater::updater()) { + updater->checkForUpdates(); + } else { + unimplemented_msg(); + } +} + void Preferences::on_openCSGWarningBox_toggled(bool state) { @@ -289,6 +330,12 @@ void Preferences::updateGUI() this->fontSize->setEditText(fontsize); } + if (AutoUpdater *updater = AutoUpdater::updater()) { + this->updateCheckBox->setChecked(updater->automaticallyChecksForUpdates()); + this->snapshotCheckBox->setChecked(updater->enableSnapshots()); + this->lastCheckedLabel->setText(updater->lastUpdateCheckDate()); + } + this->openCSGWarningBox->setChecked(getValue("advanced/opencsg_show_warning").toBool()); this->enableOpenCSGBox->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool()); this->cgalCacheSizeEdit->setText(getValue("advanced/cgalCacheSize").toString()); diff --git a/src/Preferences.h b/src/Preferences.h index 48e07b4..4656793 100644 --- a/src/Preferences.h +++ b/src/Preferences.h @@ -30,6 +30,9 @@ public slots: void on_polysetCacheSizeEdit_textChanged(const QString &); void on_opencsgLimitEdit_textChanged(const QString &); void on_forceGoldfeatherBox_toggled(bool); + void on_updateCheckBox_toggled(bool); + void on_snapshotCheckBox_toggled(bool); + void on_checkNowButton_clicked(); signals: void requestRedraw() const; diff --git a/src/Preferences.ui b/src/Preferences.ui index 9b4671a..d67db6a 100644 --- a/src/Preferences.ui +++ b/src/Preferences.ui @@ -6,10 +6,16 @@ <rect> <x>0</x> <y>0</y> - <width>531</width> - <height>418</height> + <width>473</width> + <height>320</height> </rect> </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="windowTitle"> <string>Preferences</string> </property> @@ -173,6 +179,150 @@ </item> </layout> </widget> + <widget class="QWidget" name="pageUpdate"> + <layout class="QVBoxLayout" name="verticalLayout_16"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_9"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_8"> + <item> + <widget class="QCheckBox" name="updateCheckBox"> + <property name="text"> + <string>Automatically check for updates</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="snapshotCheckBox"> + <property name="text"> + <string>Include development snapshots</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_7"> + <property name="spacing"> + <number>0</number> + </property> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_11"> + <item> + <spacer name="horizontalSpacer_10"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="checkNowButton"> + <property name="text"> + <string>Check Now</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_9"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_10"> + <item> + <spacer name="horizontalSpacer_11"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="lastCheckedLabel"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="font"> + <font> + <pointsize>11</pointsize> + </font> + </property> + <property name="text"> + <string>Last checked: </string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_12"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer_7"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>89</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> <widget class="QWidget" name="pageAdvanced"> <layout class="QVBoxLayout" name="verticalLayout_3"> <item> @@ -227,9 +377,6 @@ </widget> </item> </layout> - <zorder>openCSGWarningBox</zorder> - <zorder>enableOpenCSGBox</zorder> - <zorder>forceGoldfeatherBox</zorder> </widget> </item> <item> @@ -317,6 +464,7 @@ </attribute> <addaction name="prefsAction3DView"/> <addaction name="prefsActionEditor"/> + <addaction name="prefsActionUpdate"/> <addaction name="prefsActionAdvanced"/> </widget> <action name="prefsAction3DView"> @@ -355,6 +503,18 @@ <string>Editor</string> </property> </action> + <action name="prefsActionUpdate"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="icon"> + <iconset resource="../openscad.qrc"> + <normaloff>:/icons/prefsUpdate.png</normaloff>:/icons/prefsUpdate.png</iconset> + </property> + <property name="text"> + <string>Update</string> + </property> + </action> </widget> <resources> <include location="../openscad.qrc"/> diff --git a/src/QGLView.h b/src/QGLView.h index 77c5baf..5cb1872 100644 --- a/src/QGLView.h +++ b/src/QGLView.h @@ -43,11 +43,6 @@ public: public: QLabel *statusLabel; -#ifdef ENABLE_OPENCSG - bool opencsg_support; - int opencsg_id; -#endif - private: void init(); @@ -71,8 +66,6 @@ private: void normalizeAngle(GLdouble& angle); #ifdef ENABLE_OPENCSG - bool is_opencsg_capable; - bool has_shaders; private slots: void display_opencsg_warning(); #endif diff --git a/src/SparkleAutoUpdater.h b/src/SparkleAutoUpdater.h new file mode 100644 index 0000000..786a190 --- /dev/null +++ b/src/SparkleAutoUpdater.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2008 Remko Troncon. BSD license + * Copyright (C) 2013 Marius Kintel. BSD license + */ +#ifndef SPARKLEAUTOUPDATER_H +#define SPARKLEAUTOUPDATER_H + +#include <QString> + +#include "AutoUpdater.h" + +class SparkleAutoUpdater : public AutoUpdater +{ +public: + SparkleAutoUpdater(); + ~SparkleAutoUpdater(); + + void checkForUpdates(); + void setAutomaticallyChecksForUpdates(bool on); + bool automaticallyChecksForUpdates(); + void setEnableSnapshots(bool on); + bool enableSnapshots(); + QString lastUpdateCheckDate(); + +private: + void updateFeed(); + + class Private; + Private *d; +}; + +#endif diff --git a/src/SparkleAutoUpdater.mm b/src/SparkleAutoUpdater.mm new file mode 100644 index 0000000..c52e2bb --- /dev/null +++ b/src/SparkleAutoUpdater.mm @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2008 Remko Troncon. BSD license + * Copyright (C) 2013 Marius Kintel. BSD license + */ + +#include "SparkleAutoUpdater.h" + +#include <Cocoa/Cocoa.h> +#include <Sparkle/Sparkle.h> + +NSString *const SUEnableSnapshotsKey = @"SUEnableSnapshots"; + +class SparkleAutoUpdater::Private +{ +public: + SUUpdater* updater; +}; + +SparkleAutoUpdater::SparkleAutoUpdater() +{ + d = new Private; + + d->updater = [SUUpdater sharedUpdater]; + [d->updater retain]; + + updateFeed(); +} + +SparkleAutoUpdater::~SparkleAutoUpdater() +{ + [d->updater release]; + delete d; +} + +void SparkleAutoUpdater::checkForUpdates() +{ + [d->updater checkForUpdatesInBackground]; +} + +void SparkleAutoUpdater::setAutomaticallyChecksForUpdates(bool on) +{ + [d->updater setAutomaticallyChecksForUpdates:on]; +} + +bool SparkleAutoUpdater::automaticallyChecksForUpdates() +{ + return [d->updater automaticallyChecksForUpdates]; +} + +void SparkleAutoUpdater::setEnableSnapshots(bool on) +{ + [[NSUserDefaults standardUserDefaults] setBool:on forKey:SUEnableSnapshotsKey]; + updateFeed(); +} + +bool SparkleAutoUpdater::enableSnapshots() +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:SUEnableSnapshotsKey]; +} + +QString SparkleAutoUpdater::lastUpdateCheckDate() +{ + NSDate *date = [d->updater lastUpdateCheckDate]; + NSString *datestring = date ? [NSString stringWithFormat:@"Last checked: %@", date] : @""; + return QString::fromUtf8([datestring UTF8String]); +} + +void SparkleAutoUpdater::updateFeed() +{ + NSString *urlstring = [NSString stringWithFormat:@"http://openscad.org/appcast%@.xml", enableSnapshots() ? @"-snapshots" : @""]; + [d->updater setFeedURL:[NSURL URLWithString:urlstring]]; +} diff --git a/src/mainwin.cc b/src/mainwin.cc index b603113..0280bbe 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -49,6 +49,10 @@ #include "ThrownTogetherRenderer.h" #include "csgtermnormalizer.h" #include "QGLView.h" +#include "AutoUpdater.h" +#ifdef Q_OS_MAC +#include "CocoaUtils.h" +#endif #include <QMenu> #include <QTime> @@ -206,6 +210,16 @@ MainWindow::MainWindow(const QString &filename) animate_panel->hide(); + // Application menu +#ifdef DEBUG + this->appActionUpdateCheck->setEnabled(false); +#else +#ifdef Q_OS_MAC + this->appActionUpdateCheck->setMenuRole(QAction::ApplicationSpecificRole); + this->appActionUpdateCheck->setEnabled(true); + connect(this->appActionUpdateCheck, SIGNAL(triggered()), this, SLOT(actionUpdateCheck())); +#endif +#endif // File menu connect(this->fileActionNew, SIGNAL(triggered()), this, SLOT(actionNew())); connect(this->fileActionOpen, SIGNAL(triggered()), this, SLOT(actionOpen())); @@ -773,6 +787,13 @@ void MainWindow::compileCSG(bool procevents) } } +void MainWindow::actionUpdateCheck() +{ + if (AutoUpdater *updater =AutoUpdater::updater()) { + updater->checkForUpdates(); + } +} + void MainWindow::actionNew() { #ifdef ENABLE_MDI @@ -1815,6 +1836,9 @@ void MainWindow::quit() QApplication::sendEvent(QApplication::instance(), &ev); if (ev.isAccepted()) QApplication::instance()->quit(); // FIXME: Cancel any CGAL calculations +#ifdef Q_OS_MAC + CocoaUtils::endApplication(); +#endif } void MainWindow::consoleOutput(const std::string &msg, void *userdata) diff --git a/src/openscad.cc b/src/openscad.cc index 0baba24..0b5466e 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -54,6 +54,7 @@ #ifdef Q_WS_MAC #include "EventFilter.h" #include "AppleEvents.h" +#include "SparkleAutoUpdater.h" #endif #include <boost/program_options.hpp> @@ -412,6 +413,14 @@ int main(int argc, char **argv) installAppleEventHandlers(); #endif +#ifndef DEBUG +#ifdef Q_WS_MAC + AutoUpdater *updater = new SparkleAutoUpdater; + AutoUpdater::setUpdater(updater); + if (updater->automaticallyChecksForUpdates()) updater->checkForUpdates(); +#endif +#endif + QString qfilename; if (filename) qfilename = QString::fromStdString(boosty::stringy(boosty::absolute(filename))); diff --git a/src/parsersettings.cc b/src/parsersettings.cc index 3dda132..54f9713 100644 --- a/src/parsersettings.cc +++ b/src/parsersettings.cc @@ -2,7 +2,9 @@ #include <boost/filesystem.hpp> #include <boost/foreach.hpp> #include "boosty.h" +#include <boost/algorithm/string.hpp> #include <qglobal.h> // Needed for Q_ defines - move the offending code somewhere else +#include "CocoaUtils.h" namespace fs = boost::filesystem; @@ -28,15 +30,24 @@ std::string locate_file(const std::string &filename) void parser_init(const std::string &applicationpath) { - // Add path from OPENSCADPATH before adding built-in paths - const char *openscadpath = getenv("OPENSCADPATH"); - if (openscadpath) { - add_librarydir(boosty::absolute(fs::path(openscadpath)).string()); + // Add paths from OPENSCADPATH before adding built-in paths + const char *openscadpaths = getenv("OPENSCADPATH"); + if (openscadpaths) { + std::string paths(openscadpaths); + typedef boost::split_iterator<std::string::iterator> string_split_iterator; + for (string_split_iterator it = + make_split_iterator(paths, first_finder(":", boost::is_iequal())); + it != string_split_iterator(); + ++it) { + add_librarydir(boosty::absolute(fs::path(boost::copy_range<std::string>(*it))).string()); + } } - // FIXME: Support specifying more than one path in OPENSCADPATH // FIXME: Add ~/.openscad/libraries - // FIXME: Add ~/Documents/OpenSCAD/libraries on Mac? +#ifdef __APPLE__ + fs::path docdir(CocoaUtils::documentsPath()); + add_librarydir(boosty::stringy(docdir / "OpenSCAD" / "libraries")); +#endif std::string librarydir; fs::path libdir(applicationpath); diff --git a/src/qglview.cc b/src/qglview.cc index 0e07b52..8e228e4 100644 --- a/src/qglview.cc +++ b/src/qglview.cc @@ -71,31 +71,12 @@ static bool running_under_wine = false; void QGLView::init() { - this->viewer_distance = 500; this->object_rot << 35, 0, -25; - this->object_trans << 0, 0, 0; this->mouse_drag_active = false; - - this->showedges = false; - this->showfaces = true; - this->orthomode = false; - this->showaxes = false; - this->showcrosshairs = false; - - for (int i = 0; i < 10; i++) - this->shaderinfo[i] = 0; - this->statusLabel = NULL; setMouseTracking(true); -#ifdef ENABLE_OPENCSG - this->is_opencsg_capable = false; - this->has_shaders = false; - this->opencsg_support = true; - static int sId = 0; - this->opencsg_id = sId++; -#endif // see paintGL() + issue160 + wine FAQ #ifdef _WIN32 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e62fbfd..733a87a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -101,7 +101,6 @@ if(CMAKE_CXX_COMPILER MATCHES ".*clang.*") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-extensions") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare") - string(REPLACE -frounding-math "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) endif() # @@ -372,6 +371,10 @@ if("${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}" VERSION_LESS 3.6) endif() inclusion(CGAL_DIR CGAL_INCLUDE_DIRS) +if(CMAKE_CXX_COMPILER MATCHES ".*clang.*") + string(REPLACE "-frounding-math" "" CGAL_CXX_FLAGS_INIT ${CGAL_CXX_FLAGS_INIT}) +endif() + # Imagemagick if (SKIP_IMAGEMAGICK) |