diff --git a/.gitignore b/.gitignore index 7033c6e..4ce1e7d 100644 --- a/.gitignore +++ b/.gitignore @@ -50,9 +50,9 @@ moc_*.cpp prototypes/gst/ qrc_*.cpp *.moc -src/*/mocs/ -src/*/objs/ -src/*/qrc/ +src/*/mocs/* +src/*/objs/* +src/*/qrc/* # Folders not to be included html/ diff --git a/.travis.yml b/.travis.yml index 8b4db7c..2e0ac2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,38 @@ +language: c++ +compiler: gcc + +matrix: + include: + - os: linux + dist: trusty + env: TARGET="linux64" + + - os: osx + osx_image: xcode8 + env: TARGET="osx" + +before_install: + - if [ "$TARGET" == "linux64" ]; then + sudo apt-get update; + fi + + - if [ "$TARGET" == "osx" ]; then + brew update; + fi + install: - - sudo apt-get update - # Qt - - sudo apt-get install qt5-default qttools5-dev-tools - # Liblo - - sudo apt-get install liblo-dev liblo-tools - # GStreamer - - sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-vaapi gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-x gstreamer1.0-tools - # QtMultimedia (unused) - - sudo apt-get install qtmultimedia5-dev + - if [ "$TARGET" == "linux64" ]; then + sudo apt-get install qt5-default qttools5-dev-tools; + sudo apt-get install liblo-dev liblo-tools; + sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-vaapi gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-x gstreamer1.0-tools; + sudo apt-get install qtmultimedia5-dev; + fi + + - if [ "$TARGET" == "osx" ]; then + brew install qt; + brew install liblo; + brew install gstreamer gst-plugins-bad gst-plugins-base gst-plugins-good gst-libav; + fi script: - qmake mapmap.pro diff --git a/INSTALL b/INSTALL.md similarity index 58% rename from INSTALL rename to INSTALL.md index c8a35eb..4fc1c46 100644 --- a/INSTALL +++ b/INSTALL.md @@ -1,38 +1,43 @@ Build instructions ================== -This file is written in rst, so that one can use rst2pdf to create a PDF out of it. - Build on GNU/Linux ------------------ -Install the dependencies. (see below) +Install the dependencies. -Build it:: +Build it: - qmake mapmap.pro - make +``` +qmake mapmap.pro +make +``` -Alternatively:: +Alternatively: - ./scripts/build.sh +``` +./scripts/build.sh +``` -Ubuntu 13.10, 14.04, 15.04 and 16.04 LTS -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +### Ubuntu -Install basic development tools fot Qt projects, plus liblo for OSC support:: +NOTE: Tested on 13.10, 14.04, 15.04 and 16.04 - sudo apt-get install -y \ +Install basic development tools fot Qt projects, plus liblo for OSC support: + +``` +sudo apt-get install -y \ liblo-dev liblo-tools \ qttools5-dev-tools \ qt5-default \ qtmultimedia5-dev \ libqt5multimedia5-plugins +``` +Install GStreamer 1.0 libraries and plugins: -Install GStreamer 1.0 libraries and plugins:: - - sudo apt-get install -y \ +``` +sudo apt-get install -y \ libgstreamer1.0-dev \ libgstreamer-plugins-base1.0-dev \ gstreamer1.0-plugins-bad \ @@ -44,24 +49,29 @@ Install GStreamer 1.0 libraries and plugins:: gstreamer1.0-plugins-ugly \ gstreamer1.0-x \ gstreamer1.0-tools +``` -Install extra packages if you want to build the documentation:: +Install extra packages if you want to build the documentation: - sudo apt-get install -y \ +``` +sudo apt-get install -y \ doxygen \ graphviz \ rst2pdf \ markdown +``` -Arch Linux -~~~~~~~~~~ +### Arch Linux -Install basic development tools fot Qt projects, GStreamer 1.0 and liblo for OSC support:: +Install basic development tools fot Qt projects, GStreamer 1.0 and liblo for OSC support: +``` sudo pacman -S qt5-tools qt5-multimedia liblo gstreamer +``` Install GStreamer 1.0 libraries and plugins:: +``` sudo pacman -S gst-libav \ gstreamer-vaapi \ gst-plugins-bad \ @@ -69,17 +79,7 @@ sudo pacman -S gst-libav \ gst-plugins-base-libs \ gst-plugins-good \ gst-plugins-ugly - -To edit translations --------------------- -You might need to update the files:: - - cd src/mapmap - lupdate mapmap.pro - -Then, do this:: - - lrelease mapmap.pro +``` Build on Mac OS X ----------------- @@ -93,7 +93,7 @@ Install tools and dependencies: 2) Install Qt5 - You can get the open source version from http://www.qt.io/download-open-source/ - Run the installer and choose the default location (which should be ~/Qt). - - Latest tested version: 5.5.1 + - Latest tested version: 5.5.1= 3) Install liblo - Use the following guide: http://macappstore.org/liblo/ - OR compile from the tar.gz - it should install it to /usr/local @@ -102,53 +102,75 @@ Install tools and dependencies: - https://gstreamer.freedesktop.org/data/pkg/osx/1.6.0/gstreamer-1.0-devel-1.6.0-x86_64.pkg - http://gstreamer.freedesktop.org/data/pkg/osx/1.6.0/gstreamer-1.0-1.6.0-x86_64-packages.dmg -Do this:: +Do this: - ./build.sh +``` +./build.sh +``` It will create a .app and a .dmg. DMGVERSION.txt should be created automatically with "1" as its contents. Update to "2", and so on, if needed. +### Troubleshooting -Use on OS X ------------ -Download GStreamer from: -http://gstreamer.freedesktop.org/data/pkg/osx/1.6.0/gstreamer-1.0-1.6.0-x86_64-packages.dmg -http://gstreamer.freedesktop.org/data/pkg/osx/1.6.0/gstreamer-1.0-1.6.0-x86_64.pkg +#### GStreamer header not found -Download MapMap.dmg, decompress the app and copy it to /Applications. +If you have a compilation error saying that file `````` cannot be found: make sure your GStreamer.framework folder is installed and is _not_ read-protected. -If the appearance of the window of the OSC port number in the preferences seem corrupted, you might want to reset MapMap's preferences:: +#### Corrupted OSC port - rm -f ~/Library/Preferences/info.mapmap.MapMap.plist +If the appearance of the window of the OSC port number in the preferences seem corrupted, you might want to reset MapMap's preferences: + +``` +rm -f ~/Library/Preferences/info.mapmap.MapMap.plist +``` To print debugging informations, launch it from the Terminal app like this:: - GST_PLUGIN_PATH=/Library/Frameworks/GStreamer.framework/Libraries GST_DEBUG=2 /Applications/MapMap.app/Contents/MacOS/MapMap +``` +GSTPLUGIN_PATH=/Library/Frameworks/GStreamer.framework/Libraries GST_DEBUG=2 /Applications/MapMap.app/Contents/MacOS/MapMap +``` +Build on Windows +---------------- -Build for release on Windows ----------------------------- -- Download gstreamer-x86 runtime& devel -https://gstreamer.freedesktop.org/data/pkg/windows/1.10.2/gstreamer-1.0-x86-1.10.2.msi https://gstreamer.freedesktop.org/data/pkg/windows/1.10.2/gstreamer-1.0-devel-x86-1.10.2.msi - +Download gstreamer-x86 runtime& devel + - https://gstreamer.freedesktop.org/data/pkg/windows/1.10.2/gstreamer-1.0-x86-1.10.2.msi + - https://gstreamer.freedesktop.org/data/pkg/windows/1.10.2/gstreamer-1.0-devel-x86-1.10.2.msi +Then: - Choose complete option during installation process wizard - Build Mapmap with Qt Creator (qmake, build release) - Add the bin directory of your Qt installation (e.g. e.g. C:\Qt\Qt5.6.0\5.6\mingw49_32\bin) to the PATH variable -- Open Windows console then run the following command: - windeployqt --release --no-system-d3d-compiler +- Open Windows console then run the following command: ```windeployqt --release --no-system-d3d-compiler ``` -- Copy the followings DLL into the target folder together with Mapmap.exe +Copy the followings DLL into the target folder together with Mapmap.exe: +``` libffi-6.dll libgobject-2.0-0.dll libgstbase-1.0-0.dll libgsttag-1.0-0.dll liborc-0.4-0.dll libglib-2.0-0.dll libgstapp-1.0-0.dll libgstpbutils-1.0-0.dll libgstvideo-1.0-0.dll libz.dll libgmodule-2.0-0.dll libgstaudio-1.0-0.dll libgstreamer-1.0-0.dll libintl-8.dll -- Copy all DLL files of the Gstreamer's bin folder (e.g. C:\gstreamer\1.0\x86\bin) into a new folder named 'lib' in the target folder together with mapmap.exe +``` -- Copy all DLL files of the Gstreamer's plugin folder (e.g. C:\gstreamer\1.0\x86\lib\gstreamer-1.0) into a new folder named 'plugins' in parallel of lib folder +Copy all DLL files of the Gstreamer's bin folder (e.g. C:\gstreamer\1.0\x86\bin) into a new folder named 'lib' in the target folder together with mapmap.exe +Copy all DLL files of the Gstreamer's plugin folder (e.g. C:\gstreamer\1.0\x86\lib\gstreamer-1.0) into a new folder named 'plugins' in parallel of lib folder -- Remove lib\libopenh264.dll, lib\libSoundTouch-0.dll, lib\libtag.dll +Remove lib\libopenh264.dll, lib\libSoundTouch-0.dll, lib\libtag.dll -- Run Mapamp.exe +Run Mapamp.exe + +Editing translations +-------------------- +You might need to update the files: + +``` +cd src/mapmap +lupdate mapmap.pro +``` + +Then, do this: + +``` +lrelease mapmap.pro +``` diff --git a/README b/README.md similarity index 90% rename from README rename to README.md index e3e1b3f..dbb2d63 100644 --- a/README +++ b/README.md @@ -15,6 +15,11 @@ extra dimensions, optical illusions, and notions of movement onto previously static objects. The video is commonly combined with, or triggered by, audio to create an audio-visual narrative. + +Build status +--------------- +Linux [![Build Status](https://travis-ci.org/mapmapteam/mapmap.svg?branch=develop)](https://travis-ci.org/mapmapteam/mapmap) + Ackowledgements --------------- This project was made possible by the support of the International @@ -57,3 +62,7 @@ Contributors More info --------- Get more info from http://mapmap.info + +Licence +--------- +[GNU GPL v3](https://github.com/mapmapteam/mapmap/blob/develop/LICENSE) diff --git a/mapmap.pro b/mapmap.pro index d2b4750..e361b5b 100644 --- a/mapmap.pro +++ b/mapmap.pro @@ -1,4 +1,6 @@ -CONFIG += c++11 +CONFIG += qt debug c++11 + +TEMPLATE = app # Always use major.minor.micro version number format VERSION = 0.5.1 @@ -15,7 +17,7 @@ include(src/app/app.pri) TRANSLATIONS = \ translations/mapmap_en.ts \ translations/mapmap_fr.ts \ - translations/mapmap_es.ts + translations/mapmap_es.ts RESOURCES = \ translations/translation.qrc \ docs/documentation.qrc \ @@ -41,91 +43,92 @@ system($$QMAKE_LRELEASE mapmap.pro) # Run lrelease # Linux-specific: unix:!macx { - mapmapfile.files = mapmap - mapmapfile.path = /usr/bin - INSTALLS += mapmapfile - desktopfile.files = resources/texts/mapmap.desktop - desktopfile.path = /usr/share/applications - INSTALLS += desktopfile - iconfile.files = resources/images/logo/mapmap.svg - iconfile.path = /usr/share/icons/hicolor/scalable/apps - INSTALLS += iconfile - mimetypesfile.files = resources/texts/mapmap.xml - mimetypesfile.path = /usr/share/mime/packages - INSTALLS += mimetypesfile +QMAKE_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0 +# mapmapfile.files = mapmap +# mapmapfile.path = /usr/bin +# INSTALLS += mapmapfile +# desktopfile.files = resources/texts/mapmap.desktop +# desktopfile.path = /usr/share/applications +# INSTALLS += desktopfile +# iconfile.files = resources/images/logo/mapmap.svg +# iconfile.path = /usr/share/icons/hicolor/scalable/apps +# INSTALLS += iconfile +# mimetypesfile.files = resources/texts/mapmap.xml +# mimetypesfile.path = /usr/share/mime/packages +# INSTALLS += mimetypesfile - # REQUIRES ROOT PRIVILEDGES: (does not comply to the standards of Debian) - # ------------------------- - # updatemimetypes.path = /usr/share/mime/packages - # updatemimetypes.commands = update-mime-database /usr/share/mime - # INSTALLS += updatemimetypes - # updatemimeappdefault.path = /usr/share/applications - # updatemimeappdefault.commands='grep mapmap.desktop /usr/share/applications/defaults.list >/dev/null|| sudo echo "application/mapmap=mapmap.desktop;" >> /usr/share/applications/defaults.list' - # INSTALLS += updatemimeappdefault - # ------------------------- +# # REQUIRES ROOT PRIVILEDGES: (does not comply to the standards of Debian) +# # ------------------------- +# # updatemimetypes.path = /usr/share/mime/packages +# # updatemimetypes.commands = update-mime-database /usr/share/mime +# # INSTALLS += updatemimetypes +# # updatemimeappdefault.path = /usr/share/applications +# # updatemimeappdefault.commands='grep mapmap.desktop /usr/share/applications/defaults.list >/dev/null|| sudo echo "application/mapmap=mapmap.desktop;" >> /usr/share/applications/defaults.list' +# # INSTALLS += updatemimeappdefault +# # ------------------------- - # Add the docs target: - docs.depends = $(HEADERS) $(SOURCES) - docs.commands = (cat Doxyfile; echo "INPUT = $?") | doxygen - - QMAKE_EXTRA_TARGETS += docs +# # Add the docs target: +# docs.depends = $(HEADERS) $(SOURCES) +# docs.commands = (cat Doxyfile; echo "INPUT = $?") | doxygen - +# QMAKE_EXTRA_TARGETS += docs } # macOS-specific: -macx { - TARGET = MapMap - DEFINES += MACOSX - QMAKE_CXXFLAGS += -D__MACOSX_CORE__ - QMAKE_CXXFLAGS += -stdlib=libc++ - INCLUDEPATH += /Library/Frameworks/GStreamer.framework/Versions/1.0/Headers - LIBS += -F /Library/Frameworks/ -framework GStreamer - LIBS += -framework OpenGL -framework GLUT - # With Xcode Tools > 1.5, to reduce the size of your binary even more: - # LIBS += -dead_strip - # This tells qmake not to put the executable inside a bundle. - # just for reference. Do not uncomment. - # CONFIG-=app_bundle +#macx { +# TARGET = MapMap +# DEFINES += MACOSX +# QMAKE_CXXFLAGS += -D__MACOSX_CORE__ +# QMAKE_CXXFLAGS += -stdlib=libc++ +# INCLUDEPATH += /Library/Frameworks/GStreamer.framework/Versions/1.0/Headers +# LIBS += -F /Library/Frameworks/ -framework GStreamer +# LIBS += -framework OpenGL -framework GLUT +# # With Xcode Tools > 1.5, to reduce the size of your binary even more: +# # LIBS += -dead_strip +# # This tells qmake not to put the executable inside a bundle. +# # just for reference. Do not uncomment. +# # CONFIG-=app_bundle - # For OSC support: (if pkg-config was installed) - # CONFIG += link_pkgconfig - # PKGCONFIG += lo +# # For OSC support: (if pkg-config was installed) +# # CONFIG += link_pkgconfig +# # PKGCONFIG += lo - # FIXME: No OSC for now: - # LIBS += -L/usr/local/lib -llo - # INCLUDEPATH += /usr/local/include - # QMAKE_CXXFLAGS += -DHAVE_OSC -} +# # FIXME: No OSC for now: +# # LIBS += -L/usr/local/lib -llo +# # INCLUDEPATH += /usr/local/include +# # QMAKE_CXXFLAGS += -DHAVE_OSC +#} # Windows-specific: -win32 { - DEFINES += WIN32 - TARGET = Mapmap - GST_HOME = $$quote($$(GSTREAMER_1_0_ROOT_X86)) - isEmpty(GST_HOME) { - message(\"GSTREAMER_1_0_ROOT_X86\" not detected ...) - } - else { - message(\"GSTREAMER_1_0_ROOT_X86\" detected in \"$${GST_HOME}\") - } - # DESTDIR = ../../Mapmap # Just for packaging +#win32 { +# DEFINES += WIN32 +# TARGET = Mapmap +# GST_HOME = $$quote($$(GSTREAMER_1_0_ROOT_X86)) +# isEmpty(GST_HOME) { +# message(\"GSTREAMER_1_0_ROOT_X86\" not detected ...) +# } +# else { +# message(\"GSTREAMER_1_0_ROOT_X86\" detected in \"$${GST_HOME}\") +# } +# # DESTDIR = ../../Mapmap # Just for packaging -# INCLUDEPATH += $${GST_HOME}/lib/gstreamer-1.0/include \ -# $${GST_HOME}/include/glib-2.0 \ -# $${GST_HOME}/lib/glib-2.0/include \ -# $${GST_HOME}/include/gstreamer-1.0 +## INCLUDEPATH += $${GST_HOME}/lib/gstreamer-1.0/include \ +## $${GST_HOME}/include/glib-2.0 \ +## $${GST_HOME}/lib/glib-2.0/include \ +## $${GST_HOME}/include/gstreamer-1.0 -# LIBS += $${GST_HOME}/lib/gstapp-1.0.lib \ -# $${GST_HOME}/lib/gstbase-1.0.lib \ -# $${GST_HOME}/lib/gstpbutils-1.0.lib \ -# $${GST_HOME}/lib/gstreamer-1.0.lib \ -# $${GST_HOME}/lib/gobject-2.0.lib \ -# $${GST_HOME}/lib/glib-2.0.lib \ -# -lopengl32 +## LIBS += $${GST_HOME}/lib/gstapp-1.0.lib \ +## $${GST_HOME}/lib/gstbase-1.0.lib \ +## $${GST_HOME}/lib/gstpbutils-1.0.lib \ +## $${GST_HOME}/lib/gstreamer-1.0.lib \ +## $${GST_HOME}/lib/gobject-2.0.lib \ +## $${GST_HOME}/lib/glib-2.0.lib \ +## -lopengl32 - CONFIG += release +# CONFIG += release - RC_FILE = resources/windows_resource.rc - QMAKE_CXXFLAGS += -D_USE_MATH_DEFINES -} +# RC_FILE = resources/windows_resource.rc +# QMAKE_CXXFLAGS += -D_USE_MATH_DEFINES +#} # Adds the tarball target tarball.target = mapmap-$${VERSION}.tar.gz diff --git a/src/core/Mapping.cpp b/src/core/Mapping.cpp index 95c5139..8cf4bf5 100644 --- a/src/core/Mapping.cpp +++ b/src/core/Mapping.cpp @@ -84,15 +84,28 @@ void Mapping::setLocked(bool locked) Element::setLocked(locked); } +void Mapping::setPaint(Paint::ptr paint) +{ + if (paintIsCompatible(paint)) + { + _paint = paint; + _emitPropertyChanged("paintId"); + } +} + +void Mapping::setPaintById(uid paintId) +{ + setPaint(MainWindow::window()->getMappingManager().getPaintById(paintId)); +} void Mapping::read(const QDomElement& obj) { // Read basic data. Element::read(obj); - // Read paint. + // // Read paint (stored in attributes for backward compatibility). int paintId = obj.attribute(ProjectLabels::PAINT_ID).toInt(); - setPaint(MainWindow::window()->getMappingManager().getPaintById(paintId)); + setPaintById(paintId); // Read output shape. _readShape(obj, true); @@ -110,8 +123,8 @@ void Mapping::write(QDomElement& obj) // Write basic data. Element::write(obj); - // Write paint ID. - obj.setAttribute("paintId", getPaint()->getId()); + // // Write paint ID. + obj.setAttribute("paintId", getPaintId()); // Write output shape. _writeShape(obj, true); @@ -168,4 +181,14 @@ void Mapping::_writeShape(QDomElement& obj, bool isOutput) obj.appendChild(shapeObj); } +bool ColorMapping::paintIsCompatible(Paint::ptr paint) const +{ + return paint->inherits("mmp::Color"); +} + +bool TextureMapping::paintIsCompatible(Paint::ptr paint) const +{ + return paint->inherits("mmp::Texture"); +} + } diff --git a/src/core/Mapping.h b/src/core/Mapping.h index 94298e7..f0a0894 100644 --- a/src/core/Mapping.h +++ b/src/core/Mapping.h @@ -64,6 +64,7 @@ class Mapping : public Element // Q_PROPERTY(MShape::ptr inputShape READ getInputShape) Q_PROPERTY(bool hasInputShape READ hasInputShape STORED false) + Q_PROPERTY(uid paintId READ getPaintId WRITE setPaintById STORED false) // Q_PROPERTY(Paint::ptr paint READ getPaint WRITE setPaint) protected: @@ -110,9 +111,15 @@ public: /// The type of the mapping (expressed as a string). virtual QString getType() const = 0; + /// Returns true iff paint is compatible with mapping. + virtual bool paintIsCompatible(Paint::ptr paint) const = 0; + /// Returns the paint. Paint::ptr getPaint() const { return _paint; } + /// Returns paint id. + uid getPaintId() const { return _paint->getId(); } + /// Returns the (output) shape. MShape::ptr getShape() const { return _shape; } @@ -137,7 +144,8 @@ public: virtual float getComputedOpacity() const { return getOpacity() * _paint->getOpacity(); } - virtual void setPaint(Paint::ptr p) { _paint = p; } + virtual void setPaint(Paint::ptr paint); + virtual void setPaintById(uid paintId); virtual void setShape(MShape::ptr s) { _shape = s; } virtual void setInputShape(MShape::ptr s) { _inputShape = s; } @@ -169,6 +177,9 @@ public: /// Returns true iff the mapping possesses an input (source) shape. virtual bool hasInputShape() const { return false; } + /// Returns true iff paint is compatible with mapping. + virtual bool paintIsCompatible(Paint::ptr paint) const; + virtual QString getType() const { return getShape()->getType() + "_color"; } @@ -198,6 +209,9 @@ public: /// Returns true iff the mapping possesses an input (source) shape. virtual bool hasInputShape() const { return true; } + /// Returns true iff paint is compatible with mapping. + virtual bool paintIsCompatible(Paint::ptr paint) const; + virtual QString getType() const { return getShape()->getType() + "_texture"; } diff --git a/src/core/MappingManager.cpp b/src/core/MappingManager.cpp index 4441ab2..f99c9cc 100644 --- a/src/core/MappingManager.cpp +++ b/src/core/MappingManager.cpp @@ -53,6 +53,17 @@ QVector MappingManager::getPaintsByNameRegExp(QString namePattern) return _getElementsByNameRegExp(paintVector, namePattern); } +QVector MappingManager::getPaintsCompatibleWith(Mapping::ptr mapping) +{ + QVector paints; + for (QVector::const_iterator it = paintVector.constBegin(); + it != paintVector.constEnd(); ++it) + if (mapping->paintIsCompatible(*it)) + paints.append(*it); + qDebug() << "Compatible paints: " << paints << endl; + return paints; +} + Mapping::ptr MappingManager::getMappingByName(QString name) { return _getElementByName(mappingVector, name); diff --git a/src/core/MappingManager.h b/src/core/MappingManager.h index 928587d..ebe7c56 100644 --- a/src/core/MappingManager.h +++ b/src/core/MappingManager.h @@ -87,6 +87,9 @@ public: /// Returns all mappings with given regexp. QVector getPaintsByNameRegExp(QString namePattern); + /// Get paints compatible with given mapping. + QVector getPaintsCompatibleWith(Mapping::ptr mapping); + /// Adds a mapping and returns its uid. uid addMapping(Mapping::ptr mapping); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index c944745..0a0a34b 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -298,6 +298,11 @@ void MainWindow::mappingPropertyChanged(uid id, QString propertyName, QVariant v { mappingLockedAction->setChecked(value.toBool()); } + else if (propertyName == "paintId") + { + mappingGui->updatePaints(); + updatePlayingState(); + } } // Send to list items. @@ -567,8 +572,7 @@ bool MainWindow::saveAs() void MainWindow::importMedia() { // Stop video playback, if it is playing, to avoid lags. XXX Hack - if (pauseAction->isVisible()) - pause(false); + pause(!pauseAction->isVisible()); // Pop-up file-choosing dialog to choose media file. // TODO: restrict the type of files that can be imported @@ -579,8 +583,7 @@ void MainWindow::importMedia() .arg(MM::VIDEO_FILES_FILTER) .arg(MM::IMAGE_FILES_FILTER)); // Restart video playback if it was previously playing. XXX Hack - if (pauseAction->isVisible()) - play(false); + play(!pauseAction->isVisible()); // Check if file is image or not // according to file extension @@ -2689,7 +2692,7 @@ void MainWindow::addPaintItem(uid paintId, const QIcon& icon, const QString& nam // Set size. item->setSizeHint(QSize(item->sizeHint().width(), MainWindow::PAINT_LIST_ITEM_HEIGHT)); - + // Set tooltip. item->setToolTip(QString("ID: %1").arg(paint->getId())); @@ -2700,6 +2703,9 @@ void MainWindow::addPaintItem(uid paintId, const QIcon& icon, const QString& nam paintList->addItem(item); paintList->setCurrentItem(item); + // Update mapping guis. + updateMappers(); + // Window was modified. windowModified(); @@ -2715,6 +2721,9 @@ void MainWindow::updatePaintItem(uid paintId, const QIcon& icon, const QString& item->setIcon(icon); item->setText(name); + // Update mapping guis. + updateMappers(); + // Window was modified. windowModified(); } @@ -2794,6 +2803,10 @@ void MainWindow::addMappingItem(uid mappingId) connect(mapper.data(), SIGNAL(valueChanged()), this, SLOT(updateCanvases())); + // Also update playing state in case paint was changed. + connect(mapper.data(), SIGNAL(valueChanged()), + this, SLOT(updatePlayingState())); + connect(sourceCanvas, SIGNAL(shapeChanged(MShape*)), mapper.data(), SLOT(updateShape(MShape*))); @@ -2886,6 +2899,8 @@ void MainWindow::removePaintItem(uid paintId) paintPropertyPanel->removeWidget(paintGuis[paintId]->getPropertiesEditor()); paintGuis.remove(paintId); + updateMappers(); + // Remove widget from paintList. int row = getItemRowFromId(*paintList, paintId); Q_ASSERT( row >= 0 ); @@ -3011,6 +3026,14 @@ void MainWindow::updateCanvases() updateStatusBar(); } +void MainWindow::updateMappers() { + // Update mapping guis. + for (QMap::iterator it = mappers.begin(); + it != mappers.end(); ++it) { + it.value()->updatePaints(); + } +} + void MainWindow::processFrame() { // Number of frames processed (restarted every second). diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 1e0d79d..a8503e0 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -229,6 +229,9 @@ public slots: /// Updates all canvases. void updateCanvases(); + /// Update all mapping guis. + void updateMappers(); + /** * This function is triggered framesPerSeconds() times per second. It makes sure * the image is refreshed (updateCanvases()) and performs other necessary operations. diff --git a/src/gui/MappingGui.cpp b/src/gui/MappingGui.cpp index 4aef3e8..fe4a7f4 100644 --- a/src/gui/MappingGui.cpp +++ b/src/gui/MappingGui.cpp @@ -19,6 +19,7 @@ */ #include "MappingGui.h" +#include "MainWindow.h" namespace mmp { @@ -36,7 +37,9 @@ MappingGui::MappingGui(Mapping::ptr mapping) _variantFactory = new VariantFactory; _propertyBrowser->setFactoryForManager(_variantManager, _variantFactory); - + + _paintEnumManager = new QtEnumPropertyManager(this); + // Mapping UID. _idItem = _variantManager->addProperty(QVariant::Int, QObject::tr("ID")); _idItem->setEnabled(false); @@ -51,6 +54,10 @@ MappingGui::MappingGui(Mapping::ptr mapping) _opacityItem->setValue(_mapping->getOpacity()*100.0); _propertyBrowser->addProperty(_opacityItem); + _paintItem = _variantManager->addProperty(QtVariantPropertyManager::enumTypeId(), "Paint"); + _propertyBrowser->addProperty(_paintItem); + updatePaints(); + // Output shape. _outputItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), QObject::tr("Output shape")); @@ -78,6 +85,15 @@ void MappingGui::setValue(QtProperty* property, const QVariant& value) emit valueChanged(); } } + else if (property == _paintItem) + { + int paintIndex = value.toInt(); + Paint::ptr newPaint = MainWindow::window()->getMappingManager().getPaint(paintIndex); + if (newPaint != _mapping->getPaint() && _mapping->paintIsCompatible(newPaint)) { + _mapping->setPaint(newPaint); + emit valueChanged(); + } + } else { std::map >::iterator it = _propertyToVertex.find(property); @@ -109,6 +125,22 @@ void MappingGui::updateShape(MShape* shape) } } +void MappingGui::updatePaints() +{ + int currentPaint = -1; + MappingManager& manager = MainWindow::window()->getMappingManager(); + QStringList paintList; + QVector paints = manager.getPaintsCompatibleWith(_mapping); + for (int i=0; igetName()); + if (paints[i] == _mapping->getPaint()) + currentPaint = i; + } + _paintItem->setAttribute("enumNames", paintList); + _paintItem->setValue(currentPaint); +} + void MappingGui::_buildShapeProperty(QtProperty* shapeItem, MShape* shape) { for (int i=0; inVertices(); i++) @@ -162,7 +194,7 @@ MeshColorMappingGui::MeshColorMappingGui(Mapping::ptr mapping) _meshItem = _variantManager->addProperty(QVariant::Size, QObject::tr("Dimensions")); _meshItem->setValue(QSize(mesh->nColumns(), mesh->nRows())); _meshItem->setAttribute("minimum", QSize(2,2)); - _propertyBrowser->insertProperty(_meshItem, _opacityItem); // insert at the beginning + _propertyBrowser->insertProperty(_meshItem, _paintItem); // insert at the beginning } void MeshColorMappingGui::setValue(QtProperty* property, const QVariant& value) @@ -248,9 +280,6 @@ TextureMappingGui::TextureMappingGui(QSharedPointer mapping) textureMapping = qSharedPointerCast(_mapping); Q_CHECK_PTR(textureMapping); - texture = qSharedPointerCast(_mapping->getPaint()); - Q_CHECK_PTR(texture); - inputShape = textureMapping.toStrongRef()->getInputShape(); Q_CHECK_PTR(inputShape); @@ -258,7 +287,7 @@ TextureMappingGui::TextureMappingGui(QSharedPointer mapping) _inputItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), QObject::tr("Input shape")); _buildShapeProperty(_inputItem, inputShape.data()); - _propertyBrowser->insertProperty(_inputItem, _opacityItem); // insert + _propertyBrowser->insertProperty(_inputItem, _paintItem); // insert // Collapse input shape. _propertyBrowser->setExpanded(_propertyBrowser->items(_inputItem).at(0), false); @@ -394,7 +423,7 @@ MeshTextureMappingGui::MeshTextureMappingGui(QSharedPointer mapp _meshItem = _variantManager->addProperty(QVariant::Size, QObject::tr("Dimensions")); _meshItem->setValue(QSize(mesh->nColumns(), mesh->nRows())); _meshItem->setAttribute("minimum", QSize(2,2)); - _propertyBrowser->insertProperty(_meshItem, _opacityItem); // insert at the beginning + _propertyBrowser->insertProperty(_meshItem, _paintItem); // insert at the beginning } void MeshTextureMappingGui::setValue(QtProperty* property, const QVariant& value) diff --git a/src/gui/MappingGui.h b/src/gui/MappingGui.h index aeffb34..fc244ab 100644 --- a/src/gui/MappingGui.h +++ b/src/gui/MappingGui.h @@ -36,6 +36,7 @@ #include "Shape.h" #include "Paint.h" #include "Mapping.h" +#include "MappingManager.h" #include "MapperGLCanvas.h" @@ -55,6 +56,8 @@ namespace mmp { +class MainWindow; + /** * This is the "view" side of the Mapping class (model). It contains the graphic items for * both input and output as well as the properties editor. @@ -87,6 +90,7 @@ public slots: virtual void setValue(QtProperty* property, const QVariant& value); virtual void setValue(QString propertyName, QVariant value); virtual void updateShape(MShape* shape); + virtual void updatePaints(); signals: void valueChanged(); @@ -97,9 +101,11 @@ protected: QSharedPointer _propertyBrowser; QtVariantEditorFactory* _variantFactory; QtVariantPropertyManager* _variantManager; + QtEnumPropertyManager* _paintEnumManager; QtVariantProperty* _idItem; QtVariantProperty* _opacityItem; + QtVariantProperty* _paintItem; QtProperty* _outputItem; std::map > _propertyToVertex; @@ -178,7 +184,6 @@ protected: // FIXME: use typedefs, member of the class for type names that are too long to type: QWeakPointer textureMapping; - QWeakPointer texture; QWeakPointer inputShape; }; diff --git a/src/gui/ShapeGraphicsItem.cpp b/src/gui/ShapeGraphicsItem.cpp index 1ca9bfc..a33a00e 100644 --- a/src/gui/ShapeGraphicsItem.cpp +++ b/src/gui/ShapeGraphicsItem.cpp @@ -208,9 +208,6 @@ TextureGraphicsItem::TextureGraphicsItem(Mapping::ptr mapping, bool output) _textureMapping = qSharedPointerCast(mapping); Q_CHECK_PTR(_textureMapping); - _texture = qSharedPointerCast(_textureMapping.toStrongRef()->getPaint()); - Q_CHECK_PTR(_texture); - _inputShape = qSharedPointerCast(_textureMapping.toStrongRef()->getInputShape()); Q_CHECK_PTR(_inputShape); } @@ -234,7 +231,7 @@ void TextureGraphicsItem::_doDrawInput(QPainter* painter) // FIXME: Does this draw the quad counterclockwise? glBegin (GL_QUADS); { - QRectF rect = mapFromScene(_texture.toStrongRef()->getRect()).boundingRect(); + QRectF rect = mapFromScene(_getTexture()->getRect()).boundingRect(); Util::correctGlTexCoord(0, 0); glVertex3f (rect.x(), rect.y(), 0); @@ -255,8 +252,10 @@ void TextureGraphicsItem::_doDrawInput(QPainter* painter) void TextureGraphicsItem::_prePaint(QPainter* painter, const QStyleOptionGraphicsItem *option) { + QSharedPointer texture = _getTexture(); + Q_CHECK_PTR(texture); + Q_UNUSED(option); - QSharedPointer texture = _texture.toStrongRef(); painter->beginNativePainting(); // Project source texture and sent it to destination. @@ -311,6 +310,11 @@ void TextureGraphicsItem::_postPaint(QPainter* painter, painter->endNativePainting(); } +QSharedPointer TextureGraphicsItem::_getTexture() +{ + return qSharedPointerCast(_textureMapping.toStrongRef()->getPaint()); +} + QPainterPath PolygonTextureGraphicsItem::shape() const { QPainterPath path; @@ -334,7 +338,7 @@ void TriangleTextureGraphicsItem::_doDrawOutput(QPainter* painter) { for (int i=0; inVertices(); i++) { - Util::setGlTexPoint(*_texture.toStrongRef(), inputShape->getVertex(i), mapFromScene(getShape()->getVertex(i))); + Util::setGlTexPoint(*_getTexture(), inputShape->getVertex(i), mapFromScene(getShape()->getVertex(i))); } } glEnd(); @@ -420,7 +424,7 @@ void MeshTextureGraphicsItem::_doDrawOutput(QPainter* painter) glBegin(GL_QUADS); for (int i = 0; i < outputQuad->nVertices(); i++) { - Util::setGlTexPoint(*_texture.toStrongRef(), m.input->getVertex(i), mapFromScene(m.output->getVertex(i))); + Util::setGlTexPoint(*_getTexture(), m.input->getVertex(i), mapFromScene(m.output->getVertex(i))); } glEnd(); } @@ -578,7 +582,7 @@ void EllipseTextureGraphicsItem::_doDrawOutput(QPainter* painter) // Get input and output ellipses. QSharedPointer inputEllipse = qSharedPointerCast(_inputShape); QSharedPointer outputEllipse = qSharedPointerCast(_shape); - QSharedPointer texture = _texture.toStrongRef(); + QSharedPointer texture = _getTexture(); // Data for calculating drawing. DrawingData inputData(inputEllipse); diff --git a/src/gui/ShapeGraphicsItem.h b/src/gui/ShapeGraphicsItem.h index b263c22..3428e86 100644 --- a/src/gui/ShapeGraphicsItem.h +++ b/src/gui/ShapeGraphicsItem.h @@ -186,8 +186,9 @@ protected: protected: QWeakPointer _textureMapping; - QWeakPointer _texture; QWeakPointer _inputShape; + + QSharedPointer _getTexture(); }; /// Graphics item for textured polygons (eg. triangles). diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 742f1b8..4c4872a 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -1,8 +1,8 @@ include(../src.pri) -include(contrib/qtpropertybrowser/src/qtpropertybrowser.pri) -include(contrib/qtpropertybrowser-extension/qtpropertybrowser-extension.pri) +include($$PWD/contrib/qtpropertybrowser/src/qtpropertybrowser.pri) +include($$PWD/contrib/qtpropertybrowser-extension/qtpropertybrowser-extension.pri) HEADERS += $$PWD/AboutDialog.h \ $$PWD/ConsoleWindow.h \ diff --git a/src/src.pri b/src/src.pri index 28f064f..c9e6fe1 100644 --- a/src/src.pri +++ b/src/src.pri @@ -26,6 +26,32 @@ unix:!macx { QMAKE_CXXFLAGS += -DHAVE_OSC } +# macOS-specific: +macx { + TARGET = MapMap + DEFINES += MACOSX + QMAKE_CXXFLAGS += -D__MACOSX_CORE__ + QMAKE_CXXFLAGS += -stdlib=libc++ + INCLUDEPATH += /Library/Frameworks/GStreamer.framework/Versions/1.0/Headers + LIBS += -F /Library/Frameworks/ -framework GStreamer + LIBS += -framework OpenGL -framework GLUT + # With Xcode Tools > 1.5, to reduce the size of your binary even more: + # LIBS += -dead_strip + # This tells qmake not to put the executable inside a bundle. + # just for reference. Do not uncomment. + # CONFIG-=app_bundle + + # For OSC support: (if pkg-config was installed) + # CONFIG += link_pkgconfig + # PKGCONFIG += lo + + # FIXME: No OSC for now: + # LIBS += -L/usr/local/lib -llo + # INCLUDEPATH += /usr/local/include + # QMAKE_CXXFLAGS += -DHAVE_OSC +} + + # Windows-specific: win32 { INCLUDEPATH += $${GST_HOME}/lib/gstreamer-1.0/include \