Browse Source

Merge branch 'master' into buffersKnowIfTheyAreActive

master
lobodelmar 7 years ago
committed by GitHub
parent
commit
656209ab88
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      .appveyor.yml
  2. 14
      .gitignore
  3. 199
      .travis.yml
  4. 5
      README.md
  5. 23
      example/CMakeLists.txt
  6. 2
      example/addons.make
  7. 15
      example/bin/data/magslideshow_settings.xml
  8. 79
      example/bin/data/ofxpimapper.xml
  9. 1130
      example/example.xcodeproj/project.pbxproj
  10. 4
      example/openFrameworks-Info.plist
  11. 4
      example/src/CustomSource.h
  12. 6
      example/src/main.cpp
  13. 11
      example/src/ofApp.cpp
  14. 37
      example/src/ofApp.h
  15. 4
      example_camera/addons.make
  16. 1136
      example_camera/example_camera.xcodeproj/project.pbxproj
  17. 10
      example_camera/example_camera.xcodeproj/xcshareddata/xcschemes/example_camera Debug.xcscheme
  18. 10
      example_camera/example_camera.xcodeproj/xcshareddata/xcschemes/example_camera Release.xcscheme
  19. 2
      example_camera/src/CameraSource.cpp
  20. 2
      example_camera/src/main.cpp
  21. 3
      example_gamepad/addons.make
  22. 1136
      example_gamepad/example_gamepad.xcodeproj/project.pbxproj
  23. 2
      example_gamepad/src/InputHandler.h
  24. 2
      example_gamepad/src/main.cpp
  25. 8
      example_gamepad/src/ofApp.cpp
  26. 3
      example_gamepad/src/ofApp.h
  27. 0
      example_pocketvj/.gitignore
  28. 2
      example_pocketvj/Makefile
  29. 1
      example_pocketvj/Project.xcconfig
  30. 2
      example_pocketvj/addons.make
  31. 0
      example_pocketvj/bin/data/ofxpimapper.xml
  32. 0
      example_pocketvj/bin/data/sources/images/image1.jpg
  33. 5085
      example_pocketvj/example_pocketvj.xcodeproj/project.pbxproj
  34. 43
      example_pocketvj/example_pocketvj.xcodeproj/xcshareddata/xcschemes/example_pocketvj Debug.xcscheme
  35. 43
      example_pocketvj/example_pocketvj.xcodeproj/xcshareddata/xcschemes/example_pocketvj Release.xcscheme
  36. 4
      example_pocketvj/openFrameworks-Info.plist
  37. 0
      example_pocketvj/src/main.cpp
  38. 126
      example_pocketvj/src/ofApp.cpp
  39. 1
      example_pocketvj/src/ofApp.h
  40. 1273
      example_shortcuts/example_shortcuts.xcodeproj/project.pbxproj
  41. 1
      example_simpler/addons.make
  42. 4
      example_simpler/src/CustomSource.h
  43. 2
      example_simpler/src/main.cpp
  44. 32
      src/Application/Application.cpp
  45. 17
      src/Application/Application.h
  46. 75
      src/Application/Modes/ProjectionMappingMode.cpp
  47. 7
      src/Application/Modes/ProjectionMappingMode.h
  48. 3
      src/Application/Modes/SourceSelectionMode.cpp
  49. 28
      src/Application/Modes/TextureMappingMode.cpp
  50. 5
      src/Application/Modes/TextureMappingMode.h
  51. 212
      src/Application/SettingsLoader.cpp
  52. 12
      src/Application/SettingsLoader.h
  53. 6
      src/Commands/AddGridColCmd.cpp
  54. 6
      src/Commands/AddGridColCmd.h
  55. 6
      src/Commands/AddGridRowCmd.cpp
  56. 6
      src/Commands/AddGridRowCmd.h
  57. 2
      src/Commands/ClearSurfacesCmd.h
  58. 4
      src/Commands/CmdManager.h
  59. 2
      src/Commands/DeselectTexCoordCmd.cpp
  60. 2
      src/Commands/DuplicateSurfaceCmd.cpp
  61. 1
      src/Commands/DuplicateSurfaceCmd.h
  62. 2
      src/Commands/MvAllTexCoordsCmd.cpp
  63. 3
      src/Commands/MvAllTexCoordsCmd.h
  64. 2
      src/Commands/MvSelectionCmd.cpp
  65. 5
      src/Commands/MvSelectionCmd.h
  66. 3
      src/Commands/MvSurfaceVertCmd.h
  67. 2
      src/Commands/MvTexCoordCmd.cpp
  68. 7
      src/Commands/MvTexCoordCmd.h
  69. 8
      src/Commands/RmGridColCmd.cpp
  70. 6
      src/Commands/RmGridColCmd.h
  71. 8
      src/Commands/RmGridRowCmd.cpp
  72. 6
      src/Commands/RmGridRowCmd.h
  73. 2
      src/Commands/SaveTexCoordPosCmd.cpp
  74. 5
      src/Commands/SaveTexCoordPosCmd.h
  75. 2
      src/Commands/SetNextSourceCmd.cpp
  76. 4
      src/Commands/SetNextSourceCmd.h
  77. 2
      src/Commands/SetSourceCmd.cpp
  78. 6
      src/Commands/SetSourceCmd.h
  79. 3
      src/Commands/StartDragSurfaceCmd.cpp
  80. 3
      src/Commands/StartDragSurfaceCmd.h
  81. 2
      src/Gui/Widgets/LayerPanelWidget.cpp
  82. 46
      src/Gui/Widgets/ProjectionEditorWidget.cpp
  83. 14
      src/Gui/Widgets/ProjectionEditorWidget.h
  84. 24
      src/Gui/Widgets/ScaleWidget.cpp
  85. 40
      src/Gui/Widgets/SourcesEditorWidget.cpp
  86. 38
      src/Gui/Widgets/SourcesEditorWidget.h
  87. 78
      src/Gui/Widgets/TextureEditorWidget.cpp
  88. 15
      src/Gui/Widgets/TextureEditorWidget.h
  89. 2
      src/Gui/Widgets/TextureHighlightWidget.h
  90. 13
      src/Info/Info.cpp
  91. 4
      src/Info/Info.h
  92. 52
      src/MediaServer/DirectoryWatcher.cpp
  93. 29
      src/MediaServer/DirectoryWatcher.h
  94. 109
      src/MediaServer/MediaServer.cpp
  95. 68
      src/MediaServer/MediaServer.h
  96. 15
      src/Sources/BaseSource.cpp
  97. 10
      src/Sources/BaseSource.h
  98. 2
      src/Sources/ImageSource.cpp
  99. 4
      src/Sources/ImageSource.h
  100. 4
      src/Sources/OMXPlayerCache.cpp

38
.appveyor.yml

@ -0,0 +1,38 @@
version: 1.0.{build}
os: Visual Studio 2015 RC
environment:
global:
APPVEYOR_OS_NAME: windows
matrix:
#MSYS2 Building
- platform: x86
BUILDER: MSYS2
#VisualStudio Building
- platform: x86
BUILDER : VS
BITS: 32
- platform: x64
BUILDER : VS
BITS: 64
configuration: Debug
shallow_clone: true
clone_depth: 10
init:
- set MSYS2_PATH=c:\msys64
- set CHERE_INVOKING=1
- if "%BUILDER%_%PLATFORM%"=="MSYS2_x86" set MSYSTEM=MINGW32
- if "%BUILDER%_%PLATFORM%"=="MSYS2_x64" set MSYSTEM=MINGW64
- if "%BUILDER%"=="VS" set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
install:
- cd ..
- git clone --depth=1 --branch=master https://github.com/openframeworks/openFrameworks
- call openFrameworks\scripts\ci\addons\install.cmd
build_script:
- cd %OF_PATH%
- scripts\ci\addons\build.cmd

14
.gitignore

@ -105,3 +105,17 @@ Desktop.ini
*.log
*.sql
*.sqlite
example/cmake-build-debug/
example/\.idea/
example/cmake-build-release/
example/example\.xcodeproj/xcshareddata/xcschemes/
.idea/
cmake-build-debug/
CMakeLists\.txt

199
.travis.yml

@ -0,0 +1,199 @@
# This file allows testing your addon using travis CI servers to use it you'll need to
# create an account in travis.org and enable your addon there.
#
# By default it will test linux 64bit and osx against the master and stable OF branches.
# Other platforms can be enabled by uncommenting the corresponding sections.
#
# If any extra install is needed to use the addon it can be included in the corresponding
# install script in:
#
# scripts/ci/$TARGET/install.sh
#
language: c++
compiler: gcc
sudo: true
matrix:
include:
# fully specify builds, include can't dynamically expand matrix entries
# relative order of sudo and env is important so that addons: is recognized
# Linux 64bit, OF master
- os: linux
dist: trusty
sudo: required
env: TARGET="linux64" OF_BRANCH="master"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.9
- g++-4.9
- gdb
# Linux 64bit, OF stable: Not supported yet
# - os: linux
# dist: trusty
# sudo: required
# env: TARGET="linux64" OF_BRANCH="stable"
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - gcc-4.9
# - g++-4.9
# - gdb
# OSX, OF master
- os: osx
osx_image: xcode8
compiler: clang
env: TARGET="osx" OF_BRANCH="master"
# OSX, OF stable: Not supported yet
# - os: osx
# osx_image: xcode8
# compiler: clang
# env: TARGET="osx" OF_BRANCH="stable"
# Linux ARM6, OF master: Uncomment following lines to enable
# - os: linux
# sudo: required
# dist: trusty
# env: TARGET="linuxarmv6l" OF_BRANCH="master"
# Linux ARM6, OF stable: Not supported yet
# - os: linux
# sudo: required
# dist: trusty
# env: TARGET="linuxarmv6l" OF_BRANCH="stable"
# Linux ARM7, OF master: Uncomment following lines to enable
# - os: linux
# sudo: false
# env: TARGET="linuxarmv7l" OF_BRANCH="master"
# cache:
# directories:
# - ~/rpi2_toolchain
# - ~/firmware-master
# - ~/archlinux
# Linux ARM7, OF stable: Not supported yet
# - os: linux
# sudo: false
# env: TARGET="linuxarmv7l" OF_BRANCH="stable"
# cache:
# directories:
# - ~/rpi2_toolchain
# - ~/firmware-master
# - ~/archlinux
# Emscripten, OF master: Uncomment following lines to enable
# - os: linux
# sudo: false
# env: TARGET="emscripten" OF_BRANCH="master"
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - libstdc++6
# Emscripten, OF stable: Not supported yet
# - os: linux
# sudo: false
# env: TARGET="emscripten" OF_BRANCH="stable"
# addons:
# apt:
# sources:
# - ubuntu-toolchain-r-test
# packages:
# - libstdc++6
# iOS, OF master: Not supported yet
# - os: osx
# osx_image: xcode8
# compiler: clang
# env: TARGET="ios" OF_BRANCH="master"
# iOS, OF stable: Not supported yet
# - os: osx
# osx_image: xcode8
# compiler: clang
# env: TARGET="ios" OF_BRANCH="stable"
# tvOS, OF master: Not supported yet
# - os: osx
# osx_image: xcode8
# compiler: clang
# env: TARGET="tvos" OF_BRANCH="master"
# tvOS, OF stable: Not supported yet
# - os: osx
# osx_image: xcode8
# compiler: clang
# env: TARGET="tvos" OF_BRANCH="stable"
# Android armv7, OF master: Uncomment following lines to enable
# - os: linux
# sudo: false
# env: TARGET="android" OPT="armv7" OF_BRANCH="master"
# cache:
# directories:
# - ~/android-ndk-r12b
# Android armv7, OF stable: Not supported yet
# - os: linux
# sudo: false
# env: TARGET="android" OPT="armv7" OF_BRANCH="stable"
# cache:
# directories:
# - ~/android-ndk-r12b
# Android x86, OF master: Uncomment following lines to enable
# - os: linux
# sudo: false
# env: TARGET="android" OPT="x86" OF_BRANCH="master"
# cache:
# directories:
# - ~/android-ndk-r12b
# Android x86, OF stable: Not supported yet
# - os: linux
# sudo: false
# env: TARGET="android" OPT="x86" OF_BRANCH="stable"
# cache:
# directories:
# - ~/android-ndk-r12b
# Exclude the default build that would otherwise be generated
# see https://github.com/travis-ci/travis-ci/issues/1228
exclude:
- compiler: gcc
install:
- cd ~
- git clone --depth=1 --branch=$OF_BRANCH https://github.com/openframeworks/openFrameworks
- cd openFrameworks
- scripts/ci/addons/install.sh
script:
- scripts/ci/addons/build.sh
git:
depth: 10

5
README.md

@ -1,6 +1,6 @@
# ofxPiMapper
[![Join the chat at https://gitter.im/kr15h/ofxPiMapper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kr15h/ofxPiMapper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join the chat at https://gitter.im/kr15h/ofxPiMapper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/kr15h/ofxPiMapper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/kr15h/ofxPiMapper.svg?branch=master)](https://travis-ci.org/kr15h/ofxPiMapper) [![Build status](https://ci.appveyor.com/api/projects/status/j6mn85tt2agk4dk6?svg=true)](https://ci.appveyor.com/project/kr15h/ofxpimapper)
Projection mapping addon for openFrameworks that runs on the Raspberry Pi.
@ -166,6 +166,7 @@ i | Show info
t | Add triangle surface
q | Add quad surface
g | Add grid warp surface
c | Add circle surface
d | duplicate selected surface
\+ | Scale surface up
\- | Scale surface down
@ -191,4 +192,4 @@ BACKSPACE ('\' via SSH) | Delete surface.
SPACE | Toggle pause for video sources (texture and projection mapping modes)
TAB | Select next source (no need to use the source selection interface)
Arrow keys | Move selection. If no surface is selected in the projection mapping mode, all surfaces are moved.
\/ | Toggle 1px/10px steps for keyboard moves on Raspberry Pi
\/ | Toggle 1px/10px steps for keyboard moves on Raspberry Pi

23
example/CMakeLists.txt

@ -4,6 +4,7 @@
# ===================== CMake Settings ===================
# ========================================================
cmake_minimum_required( VERSION 3.3 )
project( openframeworks )
# ========================================================
@ -17,21 +18,23 @@ set( APP_NAME example_ofxPiMapper )
set( OF_DIRECTORY_BY_USER "../../.." )
# --------------------- Source Files ---------------------
file( GLOB_RECURSE
APP_SRC
"src/*.cpp"
)
set( ${APP_NAME}_SOURCE_FILES
src/main.cpp
src/ofApp.cpp
src/CrossSource.cpp
src/CustomSource.cpp
src/Settings.cpp)
${APP_SRC} )
# ------------------------ AddOns -----------------------
set( OFX_ADDONS_ACTIVE
ofxXmlSettings
ofxGui
ofxPiMapper
ofxIO
)
ofxXmlSettings
ofxGui
ofxPiMapper
# ofxIO
)
# =========================================================================
# ============================== OpenFrameworks ===========================

2
example/addons.make

@ -1,4 +1,4 @@
ofxGui
ofxPiMapper
ofxXmlSettings
ofxGui
ofxOMXPlayer

15
example/bin/data/magslideshow_settings.xml

@ -0,0 +1,15 @@
<magSlideShow>
<Width>800</Width>
<Height>600</Height>
<SlideDuration>2</SlideDuration> <!-- Optional default duration for each slide-->
<Loop>
<Type>NORMAL</Type> <!-- NONE | NORMAL | PING-PONG -->
<Count>0</Count> <!-- 0 = forever -->
</Loop>
<Transition>
<Type>Dissolve</Type>
<Duration>3</Duration>
</Transition>
<!-- NoResize | Native | Fit | FitProportionally | FillProportionally -->
<ResizeOption>FitProportionally</ResizeOption>
</magSlideShow>

79
example/bin/data/ofxpimapper.xml

@ -1,22 +1,30 @@
<surfaces>
<surface type="0">
<surface type="5">
<vertices>
<vertex>
<x>194.000000000</x>
<y>57.187255859</y>
<x>337.195068359</x>
<y>362.146270752</y>
</vertex>
<vertex>
<x>337.195068359</x>
<y>595.853759766</y>
</vertex>
<vertex>
<x>467.000000000</x>
<y>412.000000000</y>
<x>648.804992676</x>
<y>595.853759766</y>
</vertex>
<vertex>
<x>40.374511719</x>
<y>210.812774658</y>
<x>648.804992676</x>
<y>362.146270752</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.500000000</x>
<x>0.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
@ -32,24 +40,27 @@
<source-type>image</source-type>
<source-name>image4.jpg</source-name>
</source>
<properties>
<perspectiveWarping>1</perspectiveWarping>
</properties>
</surface>
<surface type="1">
<vertices>
<vertex>
<x>407.565002441</x>
<y>111.782531738</y>
<x>522.590332031</x>
<y>188.924621582</y>
</vertex>
<vertex>
<x>700.434936523</x>
<y>111.782531738</y>
<x>835.409606934</x>
<y>188.924621582</y>
</vertex>
<vertex>
<x>700.434936523</x>
<y>258.217407227</y>
<x>835.409606934</x>
<y>415.075378418</y>
</vertex>
<vertex>
<x>407.565002441</x>
<y>258.217407227</y>
<x>522.590332031</x>
<y>415.075378418</y>
</vertex>
</vertices>
<texCoords>
@ -72,10 +83,44 @@
</texCoords>
<source>
<source-type>fbo</source-type>
<source-name>Custom FBO Source</source-name>
<source-name>Slide Show Source</source-name>
</source>
<properties>
<perspectiveWarping>1</perspectiveWarping>
</properties>
</surface>
<surface type="0">
<vertices>
<vertex>
<x>325.000000000</x>
<y>196.999847412</y>
</vertex>
<vertex>
<x>479.922424316</x>
<y>421.000091553</y>
</vertex>
<vertex>
<x>170.077636719</x>
<y>421.000091553</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.500000000</x>
<y>0.000000000</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>1.000000000</y>
</texCoord>
<texCoord>
<x>0.000000000</x>
<y>1.000000000</y>
</texCoord>
</texCoords>
<source>
<source-type>image</source-type>
<source-name>image2.jpg</source-name>
</source>
</surface>
</surfaces>

1130
example/example.xcodeproj/project.pbxproj

File diff suppressed because it is too large

4
example/openFrameworks-Info.plist

@ -6,8 +6,6 @@
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>${ICON}</string>
<key>CFBundleIdentifier</key>
<string>cc.openFrameworks.ofapp</string>
<key>CFBundleInfoDictionaryVersion</key>
@ -18,5 +16,7 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleIconFile</key>
<string>${ICON}</string>
</dict>
</plist>

4
example/src/CustomSource.h

@ -9,6 +9,6 @@ class CustomSource : public ofx::piMapper::FboSource {
void update();
void draw();
vector <ofRectangle> rects;
vector <float> rectSpeeds;
std::vector<ofRectangle> rects;
std::vector<float> rectSpeeds;
};

6
example/src/main.cpp

@ -7,16 +7,16 @@
int main(int argc, char * argv[]){
bool fullscreen = false;
vector<string> arguments = vector<string>(argv, argv + argc);
std::vector<std::string> arguments = std::vector<std::string>(argv, argv + argc);
for(int i = 0; i < arguments.size(); ++i){
if(arguments.at(i) == "-f"){
fullscreen = true;
break;
}
}
Settings::instance()->setFullscreen(fullscreen);
ofSetupOpenGL(800, 450, OF_WINDOW);
ofSetupOpenGL(1024, 768, OF_WINDOW);
ofRunApp(new ofApp());
}

11
example/src/ofApp.cpp

@ -14,15 +14,24 @@ void ofApp::setup(){
// a surface in XML settings.
crossSource = new CrossSource();
customSource = new CustomSource();
// Create the slide show source.
slideShowSource = new magSlideShowSource();
// Register our sources:
piMapper.registerFboSource(crossSource);
piMapper.registerFboSource(customSource);
piMapper.registerFboSource(slideShowSource);
piMapper.setup();
// The info layer is hidden by default, press <i> to toggle
// piMapper.showInfo();
ofSetFullscreen(Settings::instance()->getFullscreen());
ofSetEscapeQuitsApp(false);
ofSetLogLevel(OF_LOG_VERBOSE);
slideShowSource->play();
}
void ofApp::update(){

37
example/src/ofApp.h

@ -6,24 +6,27 @@
#include "CustomSource.h"
#include "CrossSource.h"
#include "VideoSource.h"
#include "magSlideShowSource.h"
class ofApp : public ofBaseApp {
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseDragged(int x, int y, int button);
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
ofxPiMapper piMapper;
void keyPressed(int key);
void keyReleased(int key);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseDragged(int x, int y, int button);
ofxPiMapper piMapper;
// By using a custom source that is derived from FboSource
// you will be able to see the source listed in sources editor
CustomSource *customSource;
CrossSource *crossSource;
magSlideShowSource *slideShowSource;
// By using a custom source that is derived from FboSource
// you will be able to see the source listed in sources editor
CustomSource * customSource;
CrossSource * crossSource;
};

4
example_camera/addons.make

@ -1,4 +1,4 @@
ofxGui
ofxPiMapper
ofxXmlSettings
ofxGui
ofxRPiCameraVideoGrabber
ofxOMXPlayer

1136
example_camera/example_camera.xcodeproj/project.pbxproj

File diff suppressed because it is too large

10
example_camera/example_camera.xcodeproj/xcshareddata/xcschemes/example_camera Debug.xcscheme

@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_cameraDebug.app"
BuildableName = "example_camera.app"
BlueprintName = "example_camera"
ReferencedContainer = "container:example_camera.xcodeproj">
</BuildableReference>
@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
@ -33,7 +34,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_cameraDebug.app"
BuildableName = "example_camera.app"
BlueprintName = "example_camera"
ReferencedContainer = "container:example_camera.xcodeproj">
</BuildableReference>
@ -45,6 +46,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@ -56,7 +58,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_cameraDebug.app"
BuildableName = "example_camera.app"
BlueprintName = "example_camera"
ReferencedContainer = "container:example_camera.xcodeproj">
</BuildableReference>
@ -75,7 +77,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_cameraDebug.app"
BuildableName = "example_camera.app"
BlueprintName = "example_camera"
ReferencedContainer = "container:example_camera.xcodeproj">
</BuildableReference>

10
example_camera/example_camera.xcodeproj/xcshareddata/xcschemes/example_camera Release.xcscheme

@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_cameraDebug.app"
BuildableName = "example_camera.app"
BlueprintName = "example_camera"
ReferencedContainer = "container:example_camera.xcodeproj">
</BuildableReference>
@ -26,6 +26,7 @@
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
@ -33,7 +34,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_cameraDebug.app"
BuildableName = "example_camera.app"
BlueprintName = "example_camera"
ReferencedContainer = "container:example_camera.xcodeproj">
</BuildableReference>
@ -45,6 +46,7 @@
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
@ -56,7 +58,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_cameraDebug.app"
BuildableName = "example_camera.app"
BlueprintName = "example_camera"
ReferencedContainer = "container:example_camera.xcodeproj">
</BuildableReference>
@ -75,7 +77,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_cameraDebug.app"
BuildableName = "example_camera.app"
BlueprintName = "example_camera"
ReferencedContainer = "container:example_camera.xcodeproj">
</BuildableReference>

2
example_camera/src/CameraSource.cpp

@ -15,7 +15,7 @@ CameraSource::CameraSource(){
_videoGrabber.setup(_omxCameraSettings);
#else
vector<ofVideoDevice> devices = _videoGrabber.listDevices();
std::vector<ofVideoDevice> devices = _videoGrabber.listDevices();
_cameraFound = false;
for(int i = 0; i < devices.size(); i++){

2
example_camera/src/main.cpp

@ -6,7 +6,7 @@
int main(int argc, char * argv[]){
bool fullscreen = false;
vector<string> arguments = vector<string>(argv, argv + argc);
std::vector<std::string> arguments = std::vector<std::string>(argv, argv + argc);
for(int i = 0; i < arguments.size(); ++i){
if(arguments.at(i) == "-f"){
fullscreen = true;

3
example_gamepad/addons.make

@ -1,5 +1,4 @@
ofxGui
ofxPiMapper
ofxIO
ofxXmlSettings
ofxGui
ofxOMXPlayer

1136
example_gamepad/example_gamepad.xcodeproj/project.pbxproj

File diff suppressed because it is too large

2
example_gamepad/src/InputHandler.h

@ -1,6 +1,6 @@
#pragma once
// These are the strings reported by SDL2's SDL_JoystickGetGUIDString:
// These are the std::strings reported by SDL2's SDL_JoystickGetGUIDString:
// https://wiki.libsdl.org/SDL_JoystickGetGUIDString
#include <vector>

2
example_gamepad/src/main.cpp

@ -6,7 +6,7 @@
int main(int argc, char * argv[]){
bool fullscreen = false;
vector<string> arguments = vector<string>(argv, argv + argc);
std::vector<std::string> arguments = std::vector<std::string>(argv, argv + argc);
for(int i = 0; i < arguments.size(); ++i){
if(arguments.at(i) == "-f"){
fullscreen = true;

8
example_gamepad/src/ofApp.cpp

@ -49,13 +49,13 @@ void ofApp::messageReceived(ofMessage & message){
*/
void ofApp::handleController(ControllerCommand com){
if(com == ControllerCommand::COMMAND_LEFT){
mapper.moveSelection(ofVec2f(-5.0f, 0.0f));
mapper.moveSelection(ofx::piMapper::Vec3(-5.0f, 0.0f, 0.0f));
}else if(com == ControllerCommand::COMMAND_RIGHT){
mapper.moveSelection(ofVec2f(5.0f, 0.0f));
mapper.moveSelection(ofx::piMapper::Vec3(5.0f, 0.0f, 0.0f));
}else if(com == ControllerCommand::COMMAND_UP){
mapper.moveSelection(ofVec2f(0.0f, -5.0f));
mapper.moveSelection(ofx::piMapper::Vec3(0.0f, -5.0f, 0.0f));
}else if(com == ControllerCommand::COMMAND_DOWN){
mapper.moveSelection(ofVec2f(0.0f, 5.0f));
mapper.moveSelection(ofx::piMapper::Vec3(0.0f, 5.0f, 0.0f));
}else if(com == ControllerCommand::COMMAND_A){
if(mapper.getMode() == ofx::piMapper::Mode::MAPPING_MODE){
mapper.selectNextVertex();

3
example_gamepad/src/ofApp.h

@ -3,6 +3,7 @@
#include "ofMain.h"
#include "ofxPiMapper.h"
#include "InputHandler.h"
#include "Vec3.h"
class ofApp : public ofBaseApp {
public:
@ -22,4 +23,4 @@ class ofApp : public ofBaseApp {
void handleController(ControllerCommand com);
ofxPiMapper mapper;
};
};

0
example_shortcuts/.gitignore → example_pocketvj/.gitignore

2
example_shortcuts/Makefile → example_pocketvj/Makefile

@ -6,7 +6,7 @@ endif
# make sure the the OF_ROOT location is defined
ifndef OF_ROOT
OF_ROOT=$(realpath ../../..)
OF_ROOT=$(realpath ../../..)
endif
# call the project makefile!

1
example_shortcuts/Project.xcconfig → example_pocketvj/Project.xcconfig

@ -13,5 +13,6 @@ ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/
//IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to:
//ICON_FILE_PATH = bin/data/
OTHER_CFLAGS = $(OF_CORE_CFLAGS)
OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS)
HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS)

2
example_shortcuts/addons.make → example_pocketvj/addons.make

@ -1,4 +1,4 @@
ofxGui
ofxPiMapper
ofxXmlSettings
ofxGui
ofxOMXPlayer

0
example_shortcuts/bin/data/ofxpimapper.xml → example_pocketvj/bin/data/ofxpimapper.xml

0
example_shortcuts/bin/data/sources/images/image1.jpg → example_pocketvj/bin/data/sources/images/image1.jpg

Before

Width:  |  Height:  |  Size: 262 KiB

After

Width:  |  Height:  |  Size: 262 KiB

5085
example_pocketvj/example_pocketvj.xcodeproj/project.pbxproj

File diff suppressed because it is too large

43
example_shortcuts/example_shortcuts.xcodeproj/xcshareddata/xcschemes/example_shortcuts Debug.xcscheme → example_pocketvj/example_pocketvj.xcodeproj/xcshareddata/xcschemes/example_pocketvj Debug.xcscheme

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -15,69 +15,64 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_shortcutsDebug.app"
BlueprintName = "example_shortcuts"
ReferencedContainer = "container:example_shortcuts.xcodeproj">
BuildableName = "example_pocketvj.app"
BlueprintName = "example_pocketvj"
ReferencedContainer = "container:example_pocketvj.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_shortcutsDebug.app"
BlueprintName = "example_shortcuts"
ReferencedContainer = "container:example_shortcuts.xcodeproj">
BuildableName = "example_pocketvj.app"
BlueprintName = "example_pocketvj"
ReferencedContainer = "container:example_pocketvj.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_shortcutsDebug.app"
BlueprintName = "example_shortcuts"
ReferencedContainer = "container:example_shortcuts.xcodeproj">
BuildableName = "example_pocketvj.app"
BlueprintName = "example_pocketvj"
ReferencedContainer = "container:example_pocketvj.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Debug"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_shortcutsDebug.app"
BlueprintName = "example_shortcuts"
ReferencedContainer = "container:example_shortcuts.xcodeproj">
BuildableName = "example_pocketvj.app"
BlueprintName = "example_pocketvj"
ReferencedContainer = "container:example_pocketvj.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>

43
example_shortcuts/example_shortcuts.xcodeproj/xcshareddata/xcschemes/example_shortcuts Release.xcscheme → example_pocketvj/example_pocketvj.xcodeproj/xcshareddata/xcschemes/example_pocketvj Release.xcscheme

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0720"
LastUpgradeVersion = "0600"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -15,69 +15,64 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_shortcutsDebug.app"
BlueprintName = "example_shortcuts"
ReferencedContainer = "container:example_shortcuts.xcodeproj">
BuildableName = "example_pocketvj.app"
BlueprintName = "example_pocketvj"
ReferencedContainer = "container:example_pocketvj.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Release">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_shortcutsDebug.app"
BlueprintName = "example_shortcuts"
ReferencedContainer = "container:example_shortcuts.xcodeproj">
BuildableName = "example_pocketvj.app"
BlueprintName = "example_pocketvj"
ReferencedContainer = "container:example_pocketvj.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_shortcutsDebug.app"
BlueprintName = "example_shortcuts"
ReferencedContainer = "container:example_shortcuts.xcodeproj">
BuildableName = "example_pocketvj.app"
BlueprintName = "example_pocketvj"
ReferencedContainer = "container:example_pocketvj.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "E4B69B5A0A3A1756003C02F2"
BuildableName = "example_shortcutsDebug.app"
BlueprintName = "example_shortcuts"
ReferencedContainer = "container:example_shortcuts.xcodeproj">
BuildableName = "example_pocketvj.app"
BlueprintName = "example_pocketvj"
ReferencedContainer = "container:example_pocketvj.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>

4
example_shortcuts/openFrameworks-Info.plist → example_pocketvj/openFrameworks-Info.plist

@ -6,8 +6,6 @@
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>${ICON}</string>
<key>CFBundleIdentifier</key>
<string>cc.openFrameworks.ofapp</string>
<key>CFBundleInfoDictionaryVersion</key>
@ -18,5 +16,7 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleIconFile</key>
<string>${ICON}</string>
</dict>
</plist>

0
example_shortcuts/src/main.cpp → example_pocketvj/src/main.cpp

126
example_shortcuts/src/ofApp.cpp → example_pocketvj/src/ofApp.cpp

@ -3,6 +3,14 @@
void ofApp::setup(){
ofBackground(0);
mapper.setup();
// Set different info text for PocketVJ
std::string multilineInfoText =
"Custom ofxPiMapper shortcuts\n\n"
"Good day user.\n"
"Shortcuts have been customized.\n"
"Please make sure to provide your own documentation.";
mapper.setInfoText(multilineInfoText);
}
void ofApp::update(){
@ -17,72 +25,86 @@ void ofApp::keyPressed(int key){
if(key == '1'){
mapper.setMode(ofx::piMapper::PRESENTATION_MODE);
}else if(key == '2'){
mapper.setMode(ofx::piMapper::MAPPING_MODE);
}else if(key == '3'){
mapper.setMode(ofx::piMapper::TEXTURE_MODE);
}else if(key == '3'){
mapper.setMode(ofx::piMapper::MAPPING_MODE);
}else if(key == '4'){
mapper.setMode(ofx::piMapper::SOURCE_MODE);
}else if(key == 'w'){
}else if(key == 'c'){
mapper.toggleInfo();
}else if(key == 't'){
mapper.createSurface(ofx::piMapper::TRIANGLE_SURFACE);
}else if(key == 'q'){
mapper.createSurface(ofx::piMapper::QUAD_SURFACE);
}else if(key == 'e'){
mapper.createSurface(ofx::piMapper::HEXAGON_SURFACE);
}else if(key == 'r'){
mapper.createSurface(ofx::piMapper::CIRCLE_SURFACE);
}else if(key == 'x'){
mapper.createSurface(ofx::piMapper::HEXAGON_SURFACE);
}else if(key == 'g'){
mapper.createSurface(ofx::piMapper::GRID_WARP_SURFACE);
}else if(key == 't'){
mapper.createSurface(ofx::piMapper::TRIANGLE_SURFACE);
}else if(key == OF_KEY_BACKSPACE){
mapper.eraseSurface(mapper.getNumSurfaces() - 1);
}else if(key == OF_KEY_LEFT){
mapper.moveSelection(ofVec2f(-20.0f, 0.0f));
}else if(key == OF_KEY_RIGHT){
mapper.moveSelection(ofVec2f(20.0f, 0.0f));
}else if(key == OF_KEY_UP){
mapper.moveSelection(ofVec2f(0.0f, -20.0f));
}else if(key == OF_KEY_DOWN){
mapper.moveSelection(ofVec2f(0.0f, 20.0f));
}else if(key == 'k'){
}else if(key == 'a'){
mapper.duplicateSurface();
}else if(key == 'o'){
mapper.scaleUp();
}else if(key == 'i'){
mapper.scaleDown();
}else if(key == 'p'){
mapper.togglePerspective();
}else if(key == 'v'){
mapper.addGridColumn();
}else if(key == 'b'){
mapper.removeGridColumn();
}else if(key == 'n'){
mapper.addGridRow();
}else if(key == 'm'){
mapper.removeGridRow();
}else if(key == '.'){
mapper.selectNextSurface();
}else if(key == 'j'){
}else if(key == ','){
mapper.selectPrevSurface();
}else if(key == 'v'){
mapper.setNextSource();
}else if(key == 'd'){
mapper.duplicateSurface();
}else if(key == 'k'){
mapper.selectNextVertex();
}else if(key == 'l'){
if(mapper.getMode() == ofx::piMapper::Mode::MAPPING_MODE){
mapper.selectNextVertex();
}else if(mapper.getMode() == ofx::piMapper::Mode::TEXTURE_MODE){
mapper.selectNextTexCoord();
}
mapper.selectPrevVertex();
}else if(key == 'h'){
if(mapper.getMode() == ofx::piMapper::Mode::MAPPING_MODE){
mapper.selectPrevVertex();
}else if(mapper.getMode() == ofx::piMapper::Mode::TEXTURE_MODE){
mapper.selectPrevTexCoord();
}
}else if(key == 'i'){
mapper.moveLayerUp();
}else if(key == 'u'){
}else if(key == 'j'){
mapper.moveLayerDown();
}else if(key == 'p'){
mapper.togglePerspective();
}else if(key == '+'){
mapper.scaleUp();
}else if(key == '-'){
mapper.scaleDown();
}else if(key == '\\'){
}else if(key == 's'){
mapper.saveProject();
}else if(key == 'y'){
mapper.toggleLayerPanel();
}else if(key == 'z'){
mapper.undo();
}else if(key == 'd'){
mapper.eraseSurface(mapper.getSelectedSurface());
}else if(key == 'w'){
mapper.togglePause();
}else if(key == 'n'){
string multilineInfoText =
"Custom ofxPiMapper shortcuts\n\n"
"Good day user.\n"
"Shortcuts have been customized.\n"
"Please make sure to provide your own documentation.";
mapper.setInfoText(multilineInfoText);
mapper.toggleInfo();
}else{
mapper.keyPressed(key);
}else if(key == '5'){
mapper.setNextSource();
}else if(key == '8'){
mapper.moveSelection(ofx::piMapper::Vec3(0.0f, -1.0f, 0.0f));
}else if(key == '9'){
mapper.moveSelection(ofx::piMapper::Vec3(0.0f, 1.0f, 0.0f));
}else if(key == '7'){
mapper.moveSelection(ofx::piMapper::Vec3(-1.0f, 0.0f, 0.0f));
}else if(key == '0'){
mapper.moveSelection(ofx::piMapper::Vec3(1.0f, 0.0f, 0.0f));
}else if(key == '/'){
bool shiftIsDown = mapper.toggleShift();
if(shiftIsDown){
ofLogNotice("ofApp") << "Shift key is down";
}else{
ofLogNotice("ofApp") << "Shift key is up";
}
}
/* For these one has to figure out her own ways.
* rbt Reboot (Raspberry Pi only)
* sdn Shutdown (Raspberry Pi only)
* new Clear composition (remove all surfaces)
* ext Exit application and return to command line
*/
}
void ofApp::keyReleased(int key){

1
example_shortcuts/src/ofApp.h → example_pocketvj/src/ofApp.h

@ -2,6 +2,7 @@
#include "ofMain.h"
#include "ofxPiMapper.h"
#include "Vec3.h"
class ofApp : public ofBaseApp {
public:

1273
example_shortcuts/example_shortcuts.xcodeproj/project.pbxproj

File diff suppressed because it is too large

1
example_simpler/addons.make

@ -1,3 +1,4 @@
ofxGui
ofxPiMapper
ofxXmlSettings
ofxOMXPlayer

4
example_simpler/src/CustomSource.h

@ -9,6 +9,6 @@ class CustomSource : public ofx::piMapper::FboSource {
void update();
void draw();
vector <ofRectangle> rects;
vector <float> rectSpeeds;
std::vector<ofRectangle> rects;
std::vector<float> rectSpeeds;
};

2
example_simpler/src/main.cpp

@ -7,7 +7,7 @@
int main(int argc, char * argv[]){
bool fullscreen = false;
vector<string> arguments = vector<string>(argv, argv + argc);
std::vector<std::string> arguments = std::vector<std::string>(argv, argv + argc);
for(int i = 0; i < arguments.size(); ++i){
if(arguments.at(i) == "-f"){
fullscreen = true;

32
src/Application/Application.cpp

@ -102,7 +102,7 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
break;
case '/':
_shiftKeyDown = !_shiftKeyDown;
toggleShift();
break;
case '1':
@ -132,8 +132,8 @@ void Application::onKeyPressed(ofKeyEventArgs & args){
case 'z':
undo();
break;
case 'n':
case 'f':
setNextPreset();
break;
@ -199,7 +199,7 @@ void Application::eraseSurface(int i){
}
}
void Application::setInfoText(string text){
void Application::setInfoText(std::string text){
_info.setText(text);
}
@ -231,6 +231,11 @@ bool Application::isShiftKeyDown(){
return _shiftKeyDown;
}
bool Application::toggleShift(){
_shiftKeyDown = !_shiftKeyDown;
return _shiftKeyDown;
}
void Application::setPreset(unsigned int i){
_cmdManager.exec(new SetPresetCmd(this, i));
}
@ -265,13 +270,13 @@ void Application::shutdown(){
#endif
}
bool Application::loadXmlSettings(string fileName){
bool Application::loadXmlSettings(std::string fileName){
if(!ofFile::doesFileExist(fileName)){
ofLogError("Application::loadXmlSettings()") << fileName << " does not exist";
return false;
}
if(!_surfaceManager.loadXmlSettings(fileName)){
ofLogError("Application::loadXmlSettings()") << "Failed to load " << fileName << endl;
ofLogError("Application::loadXmlSettings()") << "Failed to load " << fileName << std::endl;
return false;
}
return true;
@ -356,13 +361,14 @@ void Application::selectPrevTexCoord(){
}
}
void Application::moveSelection(ofVec2f by){
void Application::moveSelection(Vec3 by){
if(_state == ProjectionMappingMode::instance()){
getCmdManager()->exec(new MvSelectionCmd(getSurfaceManager(), by));
}else if(_state == TextureMappingMode::instance()){
Vec2 tcBy(by.x, by.y);
int selectedTexCoord = Gui::instance()->getTextureEditorWidget().getSelectedTexCoord();
if(selectedTexCoord >= 0){
moveTexCoord(selectedTexCoord, by);
moveTexCoord(selectedTexCoord, tcBy);
}
}
}
@ -463,7 +469,7 @@ void Application::setNextSource(){
}
}
void Application::setFboSource(string sourceId){
void Application::setFboSource(std::string sourceId){
if(getSurfaceManager()->getSelectedSurface() != 0){
getCmdManager()->exec(
new SetSourceCmd(
@ -541,7 +547,7 @@ void Application::togglePause(){
}
}
void Application::moveTexCoord(int texCoordIndex, ofVec2f by){
void Application::moveTexCoord(int texCoordIndex, Vec2 by){
if(texCoordIndex >= 0){
getCmdManager()->exec(new MvTexCoordCmd(texCoordIndex, by));
}else{
@ -563,5 +569,11 @@ void Application::deselect(){
}
}
void Application::toggleLayerPanel(){
if(getState() == ProjectionMappingMode::instance()){
ProjectionMappingMode::instance()->toggleLayerPanel();
}
}
} // namespace piMapper
} // namespace ofx

17
src/Application/Application.h

@ -1,5 +1,7 @@
#pragma once
#include <string>
// OpenFrameworks components
#include "ofEvents.h"
#include "ofLog.h"
@ -9,6 +11,7 @@
#include "Info.h"
#include "SurfaceStack.h"
#include "Gui.h"
#include "Vec2.h"
// Commands
#include "SetApplicationModeCmd.h"
@ -86,13 +89,14 @@ class Application {
void addFboSource(FboSource * fboSource);
void createSurface(SurfaceType type);
void eraseSurface(int i);
void setInfoText(string text);
void setInfoText(std::string text);
void toggleInfo();
void togglePerspective();
void saveProject();
bool loadXmlSettings(string fileName);
bool loadXmlSettings(std::string fileName);
bool isShiftKeyDown();
bool toggleShift();
SurfaceManager * getSurfaceManager(){ return &_surfaceManager; }
CmdManager * getCmdManager(){ return &_cmdManager; }
@ -113,7 +117,7 @@ class Application {
Moves vertex when in projection mapping mode.
Moves texture coordinate when in texture mapping mode.
*/
void moveSelection(ofVec2f by);
void moveSelection(Vec3 by);
void setPresentationMode();
void setTextureMode();
@ -125,17 +129,18 @@ class Application {
void scaleDown();
void duplicateSurface();
void setNextSource();
void setFboSource(string sourceId);
void setFboSource(std::string sourceId);
void addGridRow();
void addGridColumn();
void removeGridRow();
void removeGridColumn();
void togglePause();
void moveTexCoord(int texCoordIndex, ofVec2f by);
void moveTexCoord(int texCoordIndex, Vec2 by);
// TODO: Add moveVertex.
// Make it so that other parts of the application react to the change.
void undo();
void deselect();
void toggleLayerPanel();
void setPreset(unsigned int i);
void setNextPreset();
@ -163,7 +168,7 @@ class Application {
float _lastSaveTime;
float _autoSaveInterval;
string _keySequence;
std::string _keySequence;
};

75
src/Application/Modes/ProjectionMappingMode.cpp

@ -49,9 +49,13 @@ void ProjectionMappingMode::draw(Application * app){
Gui::instance()->getSurfaceHighlightWidget().draw();
}
void ProjectionMappingMode::toggleLayerPanel(){
_bDrawLayerPanel = !_bDrawLayerPanel;
}
void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & args){
switch(args.key){
case 't':
app->createSurface(SurfaceType::TRIANGLE_SURFACE);
break;
@ -59,7 +63,7 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg
case 'q':
app->createSurface(SurfaceType::QUAD_SURFACE);
break;
case 'g':
app->createSurface(SurfaceType::GRID_WARP_SURFACE);
break;
@ -67,6 +71,10 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg
case 'h':
app->createSurface(SurfaceType::HEXAGON_SURFACE);
break;
case 'c':
app->createSurface(SurfaceType::CIRCLE_SURFACE);
break;
case OF_KEY_BACKSPACE:
app->eraseSurface(app->getSurfaceManager()->getSelectedSurfaceIndex());
@ -87,19 +95,19 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg
case ']':
app->addGridColumn();
break;
case '[':
app->removeGridColumn();
break;
case '.':
app->selectNextSurface();
break;
case ',':
app->selectPrevSurface();
break;
case '>':
app->selectNextVertex();
break;
@ -110,40 +118,40 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg
case OF_KEY_UP:
if(app->isShiftKeyDown()){
app->moveSelection(ofVec2f(0.0f, -10.0f));
app->moveSelection(Vec3(0.0f, -10.0f, 0.0f));
}else{
app->moveSelection(ofVec2f(0.0f, -1.0f));
app->moveSelection(Vec3(0.0f, -1.0f, 0.0f));
}
break;
case OF_KEY_DOWN:
if(app->isShiftKeyDown()){
app->moveSelection(ofVec2f(0.0f, 10.0f));
app->moveSelection(Vec3(0.0f, 10.0f, 0.0f));
}else{
app->moveSelection(ofVec2f(0.0f, 1.0f));
app->moveSelection(Vec3(0.0f, 1.0f, 0.0f));
}
break;
case OF_KEY_LEFT:
if(app->isShiftKeyDown()){
app->moveSelection(ofVec2f(-10.0f, 0.0f));
app->moveSelection(Vec3(-10.0f, 0.0f, 0.0f));
}else{
app->moveSelection(ofVec2f(-1.0f, 0.0f));
app->moveSelection(Vec3(-1.0f, 0.0f, 0.0f));
}
break;
case OF_KEY_RIGHT:
if(app->isShiftKeyDown()){
app->moveSelection(ofVec2f(10.0f, 0.0f));
app->moveSelection(Vec3(10.0f, 0.0f, 0.0f));
}else{
app->moveSelection(ofVec2f(1.0f, 0.0f));
app->moveSelection(Vec3(1.0f, 0.0f, 0.0f));
}
break;
case ' ':
app->togglePause();
break;
case OF_KEY_TAB:
app->setNextSource();
break;
@ -151,7 +159,7 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg
case 'd':
app->duplicateSurface();
break;
case '0': // Move selected surface up the layer stack
app->moveLayerUp();
break;
@ -159,7 +167,7 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg
case '9': // Move selected surface down the layer stack
app->moveLayerDown();
break;
case '+': // Scale surface up
app->scaleUp();
break;
@ -169,7 +177,7 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg
break;
case 'l':
_bDrawLayerPanel = !_bDrawLayerPanel;
toggleLayerPanel();
break;
/*
@ -177,7 +185,7 @@ void ProjectionMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & arg
app->getSurfaceManager()->setNextPreset();
break;
*/
default:
break;
}
@ -190,8 +198,8 @@ void ProjectionMappingMode::onMousePressed(Application * app, ofMouseEventArgs &
int hitJointIndex = -1;
BaseSurface * hitSurface = 0;
hitJoint = Gui::instance()->getProjectionEditorWidget().hitTestJoints(ofVec2f(args.x, args.y));
hitJoint = Gui::instance()->getProjectionEditorWidget().hitTestJoints(Vec2(args.x, args.y));
if(hitJoint){
for(int i = Gui::instance()->getProjectionEditorWidget().getJoints()->size() - 1; i >= 0 ; --i){
if((*Gui::instance()->getProjectionEditorWidget().getJoints())[i] == hitJoint){
@ -201,13 +209,13 @@ void ProjectionMappingMode::onMousePressed(Application * app, ofMouseEventArgs &
}
}else{
for(int i = app->getSurfaceManager()->size() - 1; i >= 0; --i){
if(app->getSurfaceManager()->getSurface(i)->hitTest(ofVec2f(args.x, args.y))){
if(app->getSurfaceManager()->getSurface(i)->hitTest(Vec2(args.x, args.y))){
hitSurface = app->getSurfaceManager()->getSurface(i);
break;
}
}
}
if(Gui::instance()->getScaleWidget().inside(args.x, args.y)){
//
}else if(hitJoint){
@ -215,7 +223,7 @@ void ProjectionMappingMode::onMousePressed(Application * app, ofMouseEventArgs &
hitJoint->startDrag();
Gui::instance()->notifyJointPressed(args, hitJointIndex);
}else if(hitSurface){
_clickPosition = ofVec2f(args.x, args.y); // TODO: redesign this so we can use a kind of
_clickPosition = Vec2(args.x, args.y); // TODO: redesign this so we can use a kind of
// display stack.
_bSurfaceDrag = true; // TODO: Should be something like `hitSurface->startDrag()`
Gui::instance()->notifySurfacePressed(args, hitSurface);
@ -230,15 +238,18 @@ void ProjectionMappingMode::onMouseReleased(Application * app, ofMouseEventArgs
Gui::instance()->getProjectionEditorWidget().stopDragJoints();
}
void ProjectionMappingMode::onMouseDragged(Application * app, ofMouseEventArgs & args){
void ProjectionMappingMode::onMouseDragged(Application * app, ofMouseEventArgs & args){
Gui::instance()->onMouseDragged(args);
Gui::instance()->getProjectionEditorWidget().mouseDragged(args);
// TODO: Handle app->getGui()->clickPosition and app->getGui()->bDrag locally.
if(_bSurfaceDrag){
ofVec2f mousePosition = ofVec2f(args.x, args.y);
ofVec2f distance = mousePosition - _clickPosition;
Gui::instance()->getProjectionEditorWidget().moveSelectedSurface(distance);
Vec2 mousePosition = Vec2(args.x, args.y);
Vec2 distance = mousePosition - _clickPosition;
Gui::instance()->getProjectionEditorWidget().moveSelectedSurface(Vec3(
distance.x,
distance.y,
0.0f));
_clickPosition = mousePosition;
}
}
@ -295,4 +306,4 @@ void ProjectionMappingMode::onGuiEvent(Application * app, GuiEvent & e){
}
} // namespace piMapper
} // namespace ofx
} // namespace ofx

7
src/Application/Modes/ProjectionMappingMode.h

@ -9,6 +9,8 @@
#include "SurfaceType.h"
#include "Gui.h"
#include "ScaleWidget.h"
#include "Vec2.h"
#include "Vec3.h"
namespace ofx {
namespace piMapper {
@ -21,6 +23,9 @@ class ProjectionMappingMode : public ApplicationBaseMode {
void setup(Application * app);
void update(Application * app);
void draw(Application * app);
void toggleLayerPanel();
void onKeyPressed(Application * app, ofKeyEventArgs & args);
void onMousePressed(Application * app, ofMouseEventArgs & args);
void onMouseReleased(Application * app, ofMouseEventArgs & args);
@ -38,7 +43,7 @@ class ProjectionMappingMode : public ApplicationBaseMode {
float _surfaceScaleBeforeTransform;
ofVec2f _clickPosition;
Vec2 _clickPosition;
bool _bSurfaceDrag;
bool _bDrawLayerPanel;

3
src/Application/Modes/SourceSelectionMode.cpp

@ -33,4 +33,5 @@ void SourceSelectionMode::draw(Application * app){
}
} // namespace piMapper
} // namespace ofx
} // namespace ofx

28
src/Application/Modes/TextureMappingMode.cpp

@ -73,7 +73,6 @@ void TextureMappingMode::draw(Application * app){
}
void TextureMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & args){
int key = args.key;
float moveStep;
if(app->isShiftKeyDown()){
@ -85,25 +84,25 @@ void TextureMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & args){
switch(args.key){
case OF_KEY_LEFT:
moveSelectedTexCoord(app, ofVec2f(-moveStep, 0.0f));
moveSelectedTexCoord(app, Vec2(-moveStep, 0.0f));
break;
case OF_KEY_RIGHT:
moveSelectedTexCoord(app, ofVec2f(moveStep, 0.0f));
moveSelectedTexCoord(app, Vec2(moveStep, 0.0f));
break;
case OF_KEY_UP:
moveSelectedTexCoord(app, ofVec2f(0.0f, -moveStep));
moveSelectedTexCoord(app, Vec2(0.0f, -moveStep));
break;
case OF_KEY_DOWN:
moveSelectedTexCoord(app, ofVec2f(0.0f, moveStep));
moveSelectedTexCoord(app, Vec2(0.0f, moveStep));
break;
case '>':
app->selectNextTexCoord();
break;
case '<':
app->selectPrevTexCoord();
break;
@ -111,7 +110,7 @@ void TextureMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & args){
case ' ':
app->togglePause();
break;
case OF_KEY_TAB:
app->setNextSource();
break;
@ -123,7 +122,7 @@ void TextureMappingMode::onKeyPressed(Application * app, ofKeyEventArgs & args){
case '9': // Prew draw mode
app->getCmdManager()->exec(new SetTexMapDrawModeCmd( this, getPrevDrawMode() ));
break;
}
}
@ -159,7 +158,7 @@ void TextureMappingMode::onMousePressed(Application * app, ofMouseEventArgs & ar
CircleJoint * hitJoint =
Gui::instance()->getTextureEditorWidget().hitTestJoints(
ofVec2f(args.x, args.y));
Vec2(args.x, args.y));
if(hitJoint != 0){
hitJoint->mousePressed(args);
@ -220,7 +219,7 @@ void TextureMappingMode::onMouseReleased(Application * app, ofMouseEventArgs & a
// create an undoable move tex coord command.
int selectedTexCoord = Gui::instance()->getTextureEditorWidget().getSelectedTexCoord();
if(selectedTexCoord >= 0){
ofVec2f texCoordCurrent =
Vec2 texCoordCurrent =
app->getSurfaceManager()->getSelectedSurface()->getTexCoords()[selectedTexCoord];
if(texCoordCurrent != _texCoordOnClick){
@ -247,7 +246,8 @@ void TextureMappingMode::onMouseDragged(Application * app, ofMouseEventArgs & ar
if(_bCropAreaDrag){
ofPoint mousePosition = ofPoint(args.x, args.y);
ofPoint distance = mousePosition - _clickPosition;
Gui::instance()->getTextureEditorWidget().moveTexCoords(distance);
Vec2 d = Vec2(distance.x, distance.y);
Gui::instance()->getTextureEditorWidget().moveTexCoords(d);
_clickPosition = mousePosition;
}
}else{
@ -263,7 +263,7 @@ void TextureMappingMode::drawTexture(Application * app){
ofEnableNormalizedTexCoords();
ofSetColor(255, 255, 255, 255);
app->getSurfaceManager()->getSelectedSurface()->drawTexture(ofVec2f(0, 0));
app->getSurfaceManager()->getSelectedSurface()->drawTexture(Vec3(0.0f, 0.0f, 0.0f));
if(!normalizedTexCoords){
ofDisableNormalizedTexCoords();
@ -271,7 +271,7 @@ void TextureMappingMode::drawTexture(Application * app){
}
}
void TextureMappingMode::moveSelectedTexCoord(Application * app, ofVec2f by){
void TextureMappingMode::moveSelectedTexCoord(Application * app, Vec2 by){
if(app->getSurfaceManager()->getSelectedSurface() != 0){
int selectedTexCoord = Gui::instance()->getTextureEditorWidget().getSelectedTexCoord();
app->moveTexCoord(selectedTexCoord, by);
@ -316,4 +316,4 @@ int TextureMappingMode::getPrevDrawMode(){
}
} // namespace piMapper
} // namespace ofx
} // namespace ofx

5
src/Application/Modes/TextureMappingMode.h

@ -13,6 +13,7 @@
#include "SaveTexCoordPosCmd.h"
#include "SelTexCoordCmd.h"
#include "Gui.h"
#include "Vec2.h"
namespace ofx {
namespace piMapper {
@ -34,7 +35,7 @@ class TextureMappingMode : public ApplicationBaseMode {
void onGuiEvent(Application * app, GuiEvent & e){}
void drawTexture(Application * app);
void moveSelectedTexCoord(Application * app, ofVec2f by);
void moveSelectedTexCoord(Application * app, Vec2 by);
void selectNextVertex(Application * app);
void selectPrevVertex(Application * app);
@ -62,7 +63,7 @@ class TextureMappingMode : public ApplicationBaseMode {
ofPoint _prevCanvasTranslate;
ofPoint _clickCanvasTranslate;
ofVec2f _texCoordOnClick;
Vec2 _texCoordOnClick;
};

212
src/Application/SettingsLoader.cpp

@ -19,47 +19,47 @@ SettingsLoader::SettingsLoader(){
bool SettingsLoader::load(
SurfaceManager & surfaceManager,
MediaServer & mediaServer,
string fileName){
std::string fileName){
ofxXmlSettings * xmlSettings = new ofxXmlSettings();
string sourceType = "";
string sourceName = "";
std::string sourceType = "";
std::string sourceName = "";
BaseSource * source = 0;
if(!xmlSettings->loadFile(fileName)){
ofLogWarning("SettingsLoader::load()") << "Could not load XML settings";
return false;
}
if(!xmlSettings->tagExists("surfaces")){
xmlSettings->addTag("surfaces");
}
// Count <surfaces> tags.
unsigned int numPresets = xmlSettings->getNumTags("surfaces");
cout << "numPresets: " << numPresets << endl;
std::cout << "numPresets: " << numPresets << std::endl;
// Clear previous presets and surfaces first.
surfaceManager.clearPresets();
// Loop through <surfaces> tags in the XML.
for(unsigned int i = 0; i < numPresets; ++i){
xmlSettings->pushTag("surfaces", i);
SurfaceStack * surfaces = surfaceManager.createPreset();
int numSurfaces = xmlSettings->getNumTags("surface");
for(int i = 0; i < numSurfaces; i++){
if(xmlSettings->tagExists("surface", i)){
SurfaceType type = SurfaceType::NONE;
if(xmlSettings->attributeExists("surface", "type")){
type = static_cast<SurfaceType>(
xmlSettings->getAttribute("surface", "type", 0, i));
}
xmlSettings->pushTag("surface", i);
// attempt to load surface source
@ -79,10 +79,10 @@ bool SettingsLoader::load(
}else{
// Construct full path
string dir = mediaServer.getDefaultMediaDir(typeEnum);
stringstream pathss;
std::string dir = mediaServer.getDefaultMediaDir(typeEnum);
std::stringstream pathss;
pathss << ofToDataPath(dir, true) << sourceName;
string sourcePath = pathss.str();
std::string sourcePath = pathss.str();
// Load media by using full path
source = mediaServer.loadMedia(sourcePath, typeEnum);
@ -122,6 +122,13 @@ bool SettingsLoader::load(
quadSurface->setSource(source);
}
surfaces->push_back(quadSurface);
}else if(type == SurfaceType::CIRCLE_SURFACE){
QuadSurface * base = (QuadSurface*)getQuadSurface(xmlSettings);
CircleSurface * circleSurface = new CircleSurface(*base);
if(sourceName != "none" && source != 0){
circleSurface->setSource(source);
}
surfaces->push_back(circleSurface);
}else if(type == SurfaceType::GRID_WARP_SURFACE){
BaseSurface * gridWarpSurface = getGridWarpSurface(xmlSettings);
if(sourceName != "none" && source != 0){
@ -150,7 +157,7 @@ bool SettingsLoader::load(
}
// TODO: Save all presets, not just the active one.
bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){
bool SettingsLoader::save(SurfaceManager & surfaceManager, std::string fileName){
ofxXmlSettings * xmlSettings = new ofxXmlSettings();
@ -171,11 +178,11 @@ bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){
xmlSettings->pushTag("surface", i);
xmlSettings->addTag("vertices");
xmlSettings->pushTag("vertices");
vector <ofVec3f> * vertices = &surface->getVertices();
for(int j = 0; j < vertices->size(); j++){
std::vector<Vec3> vertices = surface->getVertices();
for(int j = 0; j < vertices.size(); j++){
xmlSettings->addTag("vertex");
xmlSettings->pushTag("vertex", j);
ofVec3f * vertex = &(*vertices)[j];
Vec3 * vertex = &vertices[j];
xmlSettings->addValue("x", vertex->x);
xmlSettings->addValue("y", vertex->y);
@ -187,11 +194,11 @@ bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){
xmlSettings->addTag("texCoords");
xmlSettings->pushTag("texCoords");
vector <ofVec2f> * texCoords = &surface->getTexCoords();
for(int j = 0; j < texCoords->size(); j++){
std::vector<Vec2> texCoords = surface->getTexCoords();
for(int j = 0; j < texCoords.size(); j++){
xmlSettings->addTag("texCoord");
xmlSettings->pushTag("texCoord", j);
ofVec2f * texCoord = &(*texCoords)[j];
Vec2 * texCoord = &texCoords[j];
xmlSettings->addValue("x", texCoord->x);
xmlSettings->addValue("y", texCoord->y);
xmlSettings->popTag(); // texCoord
@ -200,16 +207,17 @@ bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){
xmlSettings->addTag("source");
xmlSettings->pushTag("source");
string sourceTypeName = SourceTypeHelper::GetSourceTypeHelperName(surface->getSource()->getType());
std::string sourceTypeName = SourceTypeHelper::GetSourceTypeHelperName(surface->getSource()->getType());
xmlSettings->addValue("source-type", sourceTypeName);
string sourceName = surface->getSource()->getName();
std::string sourceName = surface->getSource()->getName();
xmlSettings->addValue("source-name", (sourceName == "") ? "none" : sourceName);
xmlSettings->popTag(); // source
// Save surface options
// For now only if quad surface
if(surface->getType() == SurfaceType::QUAD_SURFACE){
if (surface->getType() == SurfaceType::QUAD_SURFACE ||
surface->getType() == SurfaceType::CIRCLE_SURFACE) {
QuadSurface * qs = (QuadSurface *)surface;
if(!xmlSettings->tagExists("properties")){
xmlSettings->addTag("properties");
@ -227,74 +235,80 @@ bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){
xmlSettings->addValue("gridRows", gws->getGridRows());
xmlSettings->popTag();
}
xmlSettings->popTag(); // surface
}
xmlSettings->popTag(); // surfaces
} // for
xmlSettings->save(fileName);
return xmlSettings->save(fileName);
}
bool SettingsLoader::create(string fileName){
bool SettingsLoader::create(std::string fileName){
ofxXmlSettings xml;
xml.addTag("surfaces");
return xml.save(fileName);
}
BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
vector <ofVec2f> vertices;
std::vector<Vec3> vertices;
if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices");
if(xmlSettings->tagExists("vertex", 0)){
xmlSettings->pushTag("vertex", 0);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
vertices.push_back(Vec3(
xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f),
0.0f));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("vertex", 1)){
xmlSettings->pushTag("vertex", 1);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 100.0f),
xmlSettings->getValue("y", 0.0f)));
vertices.push_back(Vec3(
xmlSettings->getValue("x", 100.0f),
xmlSettings->getValue("y", 0.0f),
0.0f));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("vertex", 2)){
xmlSettings->pushTag("vertex", 2);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 100.0f)));
vertices.push_back(Vec3(
xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 100.0f),
0.0f));
xmlSettings->popTag();
}
xmlSettings->popTag(); // vertices
}
vector <ofVec2f> texCoords;
std::vector<Vec2> texCoords;
if(xmlSettings->tagExists("texCoords")){
xmlSettings->pushTag("texCoords");
if(xmlSettings->tagExists("texCoord", 0)){
xmlSettings->pushTag("texCoord", 0);
texCoords.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
texCoords.push_back(Vec2(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("texCoord", 1)){
xmlSettings->pushTag("texCoord", 1);
texCoords.push_back(ofVec2f(xmlSettings->getValue("x", 1.0f),
texCoords.push_back(Vec2(xmlSettings->getValue("x", 1.0f),
xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("texCoord", 2)){
xmlSettings->pushTag("texCoord", 2);
texCoords.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
texCoords.push_back(Vec2(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 1.0f)));
xmlSettings->popTag();
}
@ -308,90 +322,98 @@ BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
SurfaceType::TRIANGLE_SURFACE);
triangleSurface->setVertices(vertices);
triangleSurface->setTexCoords(texCoords);
return triangleSurface;
}
BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){
vector <ofVec2f> vertices;
std::vector<Vec3> vertices;
if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices");
if(xmlSettings->tagExists("vertex", 0)){
xmlSettings->pushTag("vertex", 0);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
vertices.push_back(Vec3(
xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f),
0.0f));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("vertex", 1)){
xmlSettings->pushTag("vertex", 1);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 100.0f),
xmlSettings->getValue("y", 0.0f)));
vertices.push_back(Vec3(
xmlSettings->getValue("x", 100.0f),
xmlSettings->getValue("y", 0.0f),
0.0f));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("vertex", 2)){
xmlSettings->pushTag("vertex", 2);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 100.0f),
xmlSettings->getValue("y", 100.0f)));
vertices.push_back(Vec3(
xmlSettings->getValue("x", 100.0f),
xmlSettings->getValue("y", 100.0f),
0.0f));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("vertex", 3)){
xmlSettings->pushTag("vertex", 3);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 100.0f)));
vertices.push_back(Vec3(
xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 100.0f),
0.0f));
xmlSettings->popTag();
}
xmlSettings->popTag(); // vertices
}
vector <ofVec2f> texCoords;
std::vector<Vec2> texCoords;
if(xmlSettings->tagExists("texCoords")){
xmlSettings->pushTag("texCoords");
if(xmlSettings->tagExists("texCoord", 0)){
xmlSettings->pushTag("texCoord", 0);
texCoords.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
texCoords.push_back(Vec2(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("texCoord", 1)){
xmlSettings->pushTag("texCoord", 1);
texCoords.push_back(ofVec2f(xmlSettings->getValue("x", 1.0f),
texCoords.push_back(Vec2(xmlSettings->getValue("x", 1.0f),
xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("texCoord", 2)){
xmlSettings->pushTag("texCoord", 2);
texCoords.push_back(ofVec2f(xmlSettings->getValue("x", 1.0f),
texCoords.push_back(Vec2(xmlSettings->getValue("x", 1.0f),
xmlSettings->getValue("y", 1.0f)));
xmlSettings->popTag();
}
if(xmlSettings->tagExists("texCoord", 3)){
xmlSettings->pushTag("texCoord", 3);
texCoords.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
texCoords.push_back(Vec2(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 1.0f)));
xmlSettings->popTag();
}
xmlSettings->popTag(); // texCoords
}
// Create and add quad surface
BaseSurface * quadSurface =
SurfaceFactory::instance()->createSurface(
SurfaceType::QUAD_SURFACE);
quadSurface->setVertices(vertices);
quadSurface->setTexCoords(texCoords);
// Read properties
// Only perspective warping for now
bool perspectiveWarping = false;
@ -402,39 +424,41 @@ BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){
}
QuadSurface * qs = (QuadSurface *)quadSurface;
qs->setPerspectiveWarping(perspectiveWarping);
return quadSurface;
}
BaseSurface * SettingsLoader::getGridWarpSurface(ofxXmlSettings * xmlSettings){
vector <ofVec2f> vertices;
std::vector<Vec3> vertices;
if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices");
int iv = 0;
while(xmlSettings->tagExists("vertex", iv)){
xmlSettings->pushTag("vertex", iv);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
vertices.push_back(Vec3(
xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f),
0.0f));
xmlSettings->popTag();
++iv;
}
xmlSettings->popTag(); // vertices
}
vector <ofVec2f> texCoords;
std::vector<Vec2> texCoords;
if(xmlSettings->tagExists("texCoords")){
xmlSettings->pushTag("texCoords");
int it = 0;
while(xmlSettings->tagExists("texCoord", it)){
xmlSettings->pushTag("texCoord", it);
texCoords.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
texCoords.push_back(Vec2(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag();
++it;
@ -442,7 +466,7 @@ BaseSurface * SettingsLoader::getGridWarpSurface(ofxXmlSettings * xmlSettings){
xmlSettings->popTag(); // texCoords
}
// Read properties
// Only perspective warping for now
int gridCols = 0;
@ -453,7 +477,7 @@ BaseSurface * SettingsLoader::getGridWarpSurface(ofxXmlSettings * xmlSettings){
gridRows = xmlSettings->getValue("gridRows", 0);
xmlSettings->popTag(); // properties
}
// Create and add quad surface
BaseSurface * gridWarpSurface =
SurfaceFactory::instance()->createSurface(
@ -463,21 +487,23 @@ BaseSurface * SettingsLoader::getGridWarpSurface(ofxXmlSettings * xmlSettings){
((GridWarpSurface *)gridWarpSurface)->createGridMesh();
gridWarpSurface->setVertices(vertices);
gridWarpSurface->setTexCoords(texCoords);
return gridWarpSurface;
}
BaseSurface * SettingsLoader::getHexagonSurface(ofxXmlSettings * xmlSettings){
vector <ofVec2f> vertices;
std::vector<Vec3> vertices;
if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices");
unsigned int v = 0;
while(xmlSettings->tagExists("vertex", v)){
xmlSettings->pushTag("vertex", v);
vertices.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
vertices.push_back(Vec3(
xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f),
0.0f));
xmlSettings->popTag(); // vertex
v += 1;
}
@ -485,15 +511,15 @@ BaseSurface * SettingsLoader::getHexagonSurface(ofxXmlSettings * xmlSettings){
xmlSettings->popTag(); // vertices
}
vector <ofVec2f> texCoords;
std::vector<Vec2> texCoords;
if(xmlSettings->tagExists("texCoords")){
xmlSettings->pushTag("texCoords");
unsigned int t = 0;
while(xmlSettings->tagExists("texCoord", t)){
xmlSettings->pushTag("texCoord", t);
texCoords.push_back(ofVec2f(xmlSettings->getValue("x", 0.0f),
texCoords.push_back(Vec2(xmlSettings->getValue("x", 0.0f),
xmlSettings->getValue("y", 0.0f)));
xmlSettings->popTag(); // texCoord
t += 1;
@ -508,7 +534,7 @@ BaseSurface * SettingsLoader::getHexagonSurface(ofxXmlSettings * xmlSettings){
SurfaceType::HEXAGON_SURFACE);
hexagonSurface->setVertices(vertices);
hexagonSurface->setTexCoords(texCoords);
return hexagonSurface;
}

12
src/Application/SettingsLoader.h

@ -8,6 +8,8 @@
#include "SurfaceFactory.h"
#include "SurfaceType.h"
#include "SourceTypeHelper.h"
#include "Vec2.h"
#include "Vec3.h"
namespace ofx {
namespace piMapper {
@ -18,11 +20,11 @@ class SettingsLoader {
public:
static SettingsLoader * instance();
bool load(SurfaceManager & surfaceManager, MediaServer & mediaServer, string fileName);
bool save(SurfaceManager & surfaceManager, string fileName);
bool create(string fileName);
bool load(SurfaceManager & surfaceManager, MediaServer & mediaServer, std::string fileName);
bool save(SurfaceManager & surfaceManager, std::string fileName);
bool create(std::string fileName);
string getLastLoadedFilename(){ return _lastLoadedFilename; };
std::string getLastLoadedFilename(){ return _lastLoadedFilename; };
private:
static SettingsLoader * _instance;
@ -34,7 +36,7 @@ class SettingsLoader {
BaseSurface * getGridWarpSurface(ofxXmlSettings * xmlSettings);
BaseSurface * getHexagonSurface(ofxXmlSettings * xmlSettings);
string _lastLoadedFilename;
std::string _lastLoadedFilename;
};
} // namespace piMapper

6
src/Commands/AddGridColCmd.cpp

@ -18,11 +18,7 @@ void AddGridColCmd::exec(){
void AddGridColCmd::undo(){
ofLogNotice("AddGridColCmd", "undo");
_surface->setGridCols(_surface->getGridCols() - 1);
vector <ofVec2f> v;
for(int i = 0; i < _vertices.size(); ++i){
v.push_back( ofVec2f(_vertices[i].x, _vertices[i].y) );
}
_surface->setVertices(v);
_surface->setVertices(_vertices);
_surface->setTexCoords(_texCoords);
}

6
src/Commands/AddGridColCmd.h

@ -4,6 +4,8 @@
#include "BaseCmd.h"
#include "GridWarpSurface.h"
#include "ProjectionEditorWidget.h"
#include "Vec2.h"
#include "Vec3.h"
class ofxPiMapper;
@ -18,8 +20,8 @@ class AddGridColCmd : public BaseUndoCmd {
void undo();
private:
vector <ofVec3f> _vertices;
vector <ofVec2f> _texCoords;
std::vector<Vec3> _vertices;
std::vector<Vec2> _texCoords;
GridWarpSurface * _surface;
};

6
src/Commands/AddGridRowCmd.cpp

@ -18,11 +18,7 @@ void AddGridRowCmd::exec(){
void AddGridRowCmd::undo(){
ofLogNotice("AddGridRowCmd", "undo");
_surface->setGridRows(_surface->getGridRows() - 1);
vector <ofVec2f> v;
for(int i = 0; i < _vertices.size(); ++i){
v.push_back( ofVec2f(_vertices[i].x, _vertices[i].y) );
}
_surface->setVertices(v);
_surface->setVertices(_vertices);
_surface->setTexCoords(_texCoords);
}

6
src/Commands/AddGridRowCmd.h

@ -4,6 +4,8 @@
#include "BaseCmd.h"
#include "GridWarpSurface.h"
#include "ProjectionEditorWidget.h"
#include "Vec2.h"
#include "Vec3.h"
class ofxPiMapper;
@ -18,8 +20,8 @@ class AddGridRowCmd : public BaseUndoCmd {
void undo();
private:
vector <ofVec3f> _vertices;
vector <ofVec2f> _texCoords;
std::vector<Vec3> _vertices;
std::vector<Vec2> _texCoords;
GridWarpSurface * _surface;
};

2
src/Commands/ClearSurfacesCmd.h

@ -22,7 +22,7 @@ class ClearSurfacesCmd : public BaseUndoCmd {
private:
// Here it would make sense to have another instance of SurfaceStack
vector<BaseSurface *> _surfaces;
std::vector<BaseSurface *> _surfaces;
SurfaceManager * _surfaceManager;
BaseSurface * _selectedSurface;

4
src/Commands/CmdManager.h

@ -14,9 +14,9 @@ class CmdManager {
void undo();
private:
vector <BaseUndoCmd *> cmdStack;
std::vector<BaseUndoCmd *> cmdStack;
};
} // namespace piMapper
} // namespace ofx
} // namespace ofx

2
src/Commands/DeselectTexCoordCmd.cpp

@ -11,7 +11,7 @@ void DeselectTexCoordCmd::exec(){
ofLogNotice("DeselectTexCoordCmd", "exec");
_selectedTexCoord = -1;
vector <CircleJoint *> joints = _textureEditor->getJoints();
std::vector<CircleJoint *> joints = _textureEditor->getJoints();
for(unsigned int i = 0; i < joints.size(); ++i){
if(joints[i]->isSelected()){
_selectedTexCoord = i;

2
src/Commands/DuplicateSurfaceCmd.cpp

@ -12,7 +12,7 @@ void DuplicateSurfaceCmd::exec(){
ofLogNotice("DuplicateSurfaceCmd", "exec");
_duplicate = _surface->clone();
_surfaceManager->addSurface(_duplicate);
_duplicate->moveBy(ofVec2f(10.0f, 10.0f));
_duplicate->moveBy(Vec3(10.0f, 10.0f, 0.0f));
_surfaceManager->selectSurface(_duplicate);
}

1
src/Commands/DuplicateSurfaceCmd.h

@ -7,6 +7,7 @@
#include "BaseCmd.h"
#include "BaseSurface.h"
#include "SurfaceManager.h"
#include "Vec3.h"
namespace ofx {
namespace piMapper {

2
src/Commands/MvAllTexCoordsCmd.cpp

@ -15,7 +15,7 @@ void MvAllTexCoordsCmd::exec(){
void MvAllTexCoordsCmd::undo(){
ofLogNotice("MvAllTexCoordsCmd", "undo");
ofVec2f dist = _texCoords[0] - _surface->getTexCoords()[0];
Vec2 dist = _texCoords[0] - _surface->getTexCoords()[0];
dist.x = _surface->getSource()->getTexture()->getWidth() * dist.x;
dist.y = _surface->getSource()->getTexture()->getHeight() * dist.y;
_texEditor->moveTexCoords(dist);

3
src/Commands/MvAllTexCoordsCmd.h

@ -7,6 +7,7 @@
#include "BaseCmd.h"
#include "BaseSurface.h"
#include "TextureEditorWidget.h"
#include "Vec2.h"
namespace ofx {
namespace piMapper {
@ -19,7 +20,7 @@ class MvAllTexCoordsCmd : public BaseUndoCmd {
void undo();
private:
vector <ofVec2f> _texCoords;
std::vector<Vec2> _texCoords;
BaseSurface * _surface;
TextureEditorWidget * _texEditor;

2
src/Commands/MvSelectionCmd.cpp

@ -3,7 +3,7 @@
namespace ofx {
namespace piMapper {
MvSelectionCmd::MvSelectionCmd(SurfaceManager * sm, ofVec2f moveBy){
MvSelectionCmd::MvSelectionCmd(SurfaceManager * sm, Vec3 moveBy){
_surfaceManager = sm;
_movedBy = moveBy;
}

5
src/Commands/MvSelectionCmd.h

@ -2,6 +2,7 @@
#include "BaseCmd.h"
#include "SurfaceManager.h"
#include "Vec3.h"
namespace ofx {
namespace piMapper {
@ -9,13 +10,13 @@ namespace piMapper {
class MvSelectionCmd : public BaseUndoCmd {
public:
MvSelectionCmd(SurfaceManager * sm, ofVec2f moveBy);
MvSelectionCmd(SurfaceManager * sm, Vec3 moveBy);
void exec();
void undo();
private:
SurfaceManager * _surfaceManager;
ofVec2f _movedBy;
Vec3 _movedBy;
};

3
src/Commands/MvSurfaceVertCmd.h

@ -8,6 +8,7 @@
#include "BaseSurface.h"
#include "ProjectionEditorWidget.h"
#include "BaseJoint.h"
#include "Vec3.h"
namespace ofx {
namespace piMapper {
@ -21,7 +22,7 @@ class MvSurfaceVertCmd : public BaseUndoCmd {
private:
int _vertIndex;
ofVec2f _prevVertPos;
Vec3 _prevVertPos;
BaseSurface * _surface;
};

2
src/Commands/MvTexCoordCmd.cpp

@ -3,7 +3,7 @@
namespace ofx {
namespace piMapper {
MvTexCoordCmd::MvTexCoordCmd(int texCoordIndex, ofVec2f by){
MvTexCoordCmd::MvTexCoordCmd(int texCoordIndex, Vec2 by){
_texCoordIndex = texCoordIndex;
_moveBy = by;
}

7
src/Commands/MvTexCoordCmd.h

@ -7,6 +7,7 @@
#include "BaseCmd.h"
#include "CircleJoint.h"
#include "Gui.h"
#include "Vec2.h"
namespace ofx {
namespace piMapper {
@ -14,14 +15,14 @@ namespace piMapper {
class MvTexCoordCmd : public BaseUndoCmd {
public:
MvTexCoordCmd(int texCoordIndex, ofVec2f by);
MvTexCoordCmd(int texCoordIndex, Vec2 by);
void exec();
void undo();
private:
int _texCoordIndex;
ofVec2f _moveBy;
ofVec2f _positionBefore;
Vec2 _moveBy;
Vec2 _positionBefore;
};

8
src/Commands/RmGridColCmd.cpp

@ -30,13 +30,7 @@ void RmGridColCmd::undo(){
}
_surface->setGridCols(_surface->getGridCols() + 1);
vector <ofVec2f> v;
for(int i = 0; i < _vertices.size(); ++i){
v.push_back( ofVec2f(_vertices[i].x, _vertices[i].y) );
}
_surface->setVertices(v);
_surface->setVertices(_vertices);
_surface->setTexCoords(_texCoords);
}

6
src/Commands/RmGridColCmd.h

@ -4,6 +4,8 @@
#include "BaseCmd.h"
#include "GridWarpSurface.h"
#include "ProjectionEditorWidget.h"
#include "Vec2.h"
#include "Vec3.h"
class ofxPiMapper;
@ -18,8 +20,8 @@ class RmGridColCmd : public BaseUndoCmd {
void undo();
private:
vector <ofVec3f> _vertices;
vector <ofVec2f> _texCoords;
std::vector<Vec3> _vertices;
std::vector<Vec2> _texCoords;
GridWarpSurface * _surface;
bool _doNotUndo;

8
src/Commands/RmGridRowCmd.cpp

@ -30,13 +30,7 @@ void RmGridRowCmd::undo(){
}
_surface->setGridRows(_surface->getGridRows() + 1);
vector <ofVec2f> v;
for(int i = 0; i < _vertices.size(); ++i){
v.push_back( ofVec2f(_vertices[i].x, _vertices[i].y) );
}
_surface->setVertices(v);
_surface->setVertices(_vertices);
_surface->setTexCoords(_texCoords);
}

6
src/Commands/RmGridRowCmd.h

@ -4,6 +4,8 @@
#include "BaseCmd.h"
#include "GridWarpSurface.h"
#include "ProjectionEditorWidget.h"
#include "Vec2.h"
#include "Vec3.h"
class ofxPiMapper;
@ -18,8 +20,8 @@ class RmGridRowCmd : public BaseUndoCmd {
void undo();
private:
vector <ofVec3f> _vertices;
vector <ofVec2f> _texCoords;
std::vector<Vec3> _vertices;
std::vector<Vec2> _texCoords;
GridWarpSurface * _surface;
bool _doNotUndo;

2
src/Commands/SaveTexCoordPosCmd.cpp

@ -3,7 +3,7 @@
namespace ofx {
namespace piMapper {
SaveTexCoordPosCmd::SaveTexCoordPosCmd(int texCoordIndex, ofVec2f position){
SaveTexCoordPosCmd::SaveTexCoordPosCmd(int texCoordIndex, Vec2 position){
_texCoordIndex = texCoordIndex;
_position = position;
}

5
src/Commands/SaveTexCoordPosCmd.h

@ -7,6 +7,7 @@
#include "BaseCmd.h"
#include "CircleJoint.h"
#include "Gui.h"
#include "Vec2.h"
namespace ofx {
namespace piMapper {
@ -14,13 +15,13 @@ namespace piMapper {
class SaveTexCoordPosCmd : public BaseUndoCmd {
public:
SaveTexCoordPosCmd(int texCoordIndex, ofVec2f position);
SaveTexCoordPosCmd(int texCoordIndex, Vec2 position);
void exec();
void undo();
private:
int _texCoordIndex;
ofVec2f _position;
Vec2 _position;
};

2
src/Commands/SetNextSourceCmd.cpp

@ -15,7 +15,7 @@ void SetNextSourceCmd::exec(){
BaseSource * source = _surface->getSource();
int sourceType = source->getType();
string sourceId;
std::string sourceId;
if(source->isLoadable()){
sourceId = source->getPath();
}else{

4
src/Commands/SetNextSourceCmd.h

@ -11,7 +11,7 @@ namespace piMapper {
struct SourceData {
int type;
string id;
std::string id;
};
class SourcesEditorWidget;
@ -26,7 +26,7 @@ class SetNextSourceCmd : public BaseUndoCmd {
private:
BaseSurface * _surface;
SourcesEditorWidget * _sourcesEditor;
vector <SourceData> _sources;
std::vector<SourceData> _sources;
int _sourceIndex; // Previous source index
int _nextSourceIndex;

2
src/Commands/SetSourceCmd.cpp

@ -4,7 +4,7 @@ namespace ofx {
namespace piMapper {
SetSourceCmd::SetSourceCmd(int sourceType,
string sourceId,
std::string sourceId,
BaseSurface * surface,
SourcesEditorWidget * sourcesEditor){

6
src/Commands/SetSourceCmd.h

@ -17,7 +17,7 @@ class SetSourceCmd : public BaseUndoCmd {
public:
SetSourceCmd(int sourceType,
string sourceId,
std::string sourceId,
BaseSurface * surface,
SourcesEditorWidget * sourcesEditor);
void exec();
@ -25,12 +25,12 @@ class SetSourceCmd : public BaseUndoCmd {
private:
int _sourceType;
string _sourceId;
std::string _sourceId;
BaseSurface * _surface;
SourcesEditorWidget * _sourcesEditor;
int _oldSourceTypeHelper;
string _oldSourceId;
std::string _oldSourceId;
};

3
src/Commands/StartDragSurfaceCmd.cpp

@ -15,7 +15,8 @@ void StartDragSurfaceCmd::exec(){
void StartDragSurfaceCmd::undo(){
ofLogNotice("StartDragSurfaceCmd", "undo");
_surface->moveBy(_previousVertices[0] - _surface->getVertices()[0]);
Vec3 step = _previousVertices[0] - _surface->getVertices()[0];
_surface->moveBy(step);
}
} // namespace piMapper

3
src/Commands/StartDragSurfaceCmd.h

@ -2,6 +2,7 @@
#include "BaseCmd.h"
#include "BaseSurface.h"
#include "Vec3.h"
namespace ofx {
namespace piMapper {
@ -15,7 +16,7 @@ class StartDragSurfaceCmd : public BaseUndoCmd {
private:
BaseSurface * _surface;
vector <ofVec3f> _previousVertices;
std::vector<Vec3> _previousVertices;
};

2
src/Gui/Widgets/LayerPanelWidget.cpp

@ -35,7 +35,7 @@ void LayerPanelWidget::draw(){
int layerIconX = ofGetWidth() - offsetRight - layerIconWidth;
int layerIconY = offsetTop + ((layerIconHeight + verticalSpacing) * (numSurfaces - i - 1));
string label = "Layers";
std::string label = "Layers";
ofDrawBitmapString(label, ofGetWidth() - 66, 30);
ofRectangle layerIcon = ofRectangle(

46
src/Gui/Widgets/ProjectionEditorWidget.cpp

@ -15,7 +15,10 @@ void ProjectionEditorWidget::update(){
if(joints[i]->isDragged() || joints[i]->isSelected()){
if(surfaceManager->getSelectedSurface() != 0){
// update vertex to new location
surfaceManager->getSelectedSurface()->setVertex(i, joints[i]->position);
surfaceManager->getSelectedSurface()->setVertex(i, Vec3(
joints[i]->position.x,
joints[i]->position.y,
0.0f));
}else{
// clear joints if there is no surface selected
// as the remove selected surface in the surface manager
@ -47,17 +50,19 @@ void ProjectionEditorWidget::mouseDragged(ofMouseEventArgs & args){
joints[i]->mouseDragged(args);
}
ofVec2f mousePosition = ofVec2f(args.x, args.y);
Vec2 mousePosition = Vec2(args.x, args.y);
// Collect all vertices of the projection surfaces
vector <ofVec3f *> allVertices;
std::vector<Vec3> allVertices;
for(int i = 0; i < surfaceManager->size(); i++){
BaseSurface * surface = surfaceManager->getSurface(i);
if(surface == surfaceManager->getSelectedSurface()){
continue; // Don't add vertices of selected surface
continue; // Don't add vertices of the selected surface
}
for(int j = 0; j < surface->getVertices().size(); j++){
allVertices.push_back(&surface->getVertices()[j]);
allVertices.push_back(surface->getVertices()[j]);
}
}
@ -65,10 +70,12 @@ void ProjectionEditorWidget::mouseDragged(ofMouseEventArgs & args){
for(int i = 0; i < joints.size(); i++){
if(joints[i]->isDragged()){
for(int j = 0; j < allVertices.size(); j++){
float distance = mousePosition.distance(*allVertices[j]);
Vec2 v(allVertices[j].x, allVertices[j].y);
float distance = mousePosition.distance(v);
if(distance < fSnapDistance){
joints[i]->position = *allVertices[j];
ofVec2f clickDistance = joints[i]->position - ofVec2f(args.x, args.y);
joints[i]->position = v;
Vec2 clickDistance = joints[i]->position - Vec2(args.x, args.y);
joints[i]->setClickDistance(clickDistance);
break;
}
@ -130,21 +137,20 @@ void ProjectionEditorWidget::createJoints(){
return;
}
vector <ofVec3f> & vertices =
surfaceManager->getSelectedSurface()->getVertices();
std::vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices();
for(int i = 0; i < vertices.size(); i++){
joints.push_back(new CircleJoint());
joints.back()->position = ofVec2f(vertices[i].x, vertices[i].y);
joints.back()->position = Vec2(vertices[i].x, vertices[i].y);
}
}
void ProjectionEditorWidget::updateJoints(){
if(surfaceManager->getSelectedSurface()){
vector <ofVec3f> & vertices =
surfaceManager->getSelectedSurface()->getVertices();
std::vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices();
for(int i = 0; i < vertices.size(); i++){
joints[i]->position = ofVec2f(vertices[i].x, vertices[i].y);
joints[i]->position = Vec2(vertices[i].x, vertices[i].y);
}
}
@ -156,13 +162,15 @@ void ProjectionEditorWidget::unselectAllJoints(){
}
}
void ProjectionEditorWidget::moveSelectedSurface(ofVec2f by){
void ProjectionEditorWidget::moveSelectedSurface(Vec3 by){
if(surfaceManager == 0){
return;
}
if(surfaceManager->getSelectedSurface() == 0){
return;
}
surfaceManager->getSelectedSurface()->moveBy(by);
updateJoints();
}
@ -177,7 +185,7 @@ void ProjectionEditorWidget::setSnapDistance(float newSnapDistance){
fSnapDistance = newSnapDistance;
}
CircleJoint * ProjectionEditorWidget::hitTestJoints(ofVec2f pos){
CircleJoint * ProjectionEditorWidget::hitTestJoints(Vec2 pos){
if(surfaceManager->getSelectedSurface() == 0){
return 0;
}
@ -189,7 +197,7 @@ CircleJoint * ProjectionEditorWidget::hitTestJoints(ofVec2f pos){
return 0;
}
vector <CircleJoint *> * ProjectionEditorWidget::getJoints(){
std::vector<CircleJoint *> * ProjectionEditorWidget::getJoints(){
return &joints;
}
@ -204,7 +212,7 @@ void ProjectionEditorWidget::onVertexChanged(int & i){
}
}
void ProjectionEditorWidget::onVerticesChanged(vector<ofVec3f> & vertices){
void ProjectionEditorWidget::onVerticesChanged(std::vector<Vec3> & vertices){
createJoints();
}
@ -236,4 +244,4 @@ void ProjectionEditorWidget::drawJoints(){
}
} // namespace piMapper
} // namespace ofx
} // namespace ofx

14
src/Gui/Widgets/ProjectionEditorWidget.h

@ -2,6 +2,8 @@
#include "SurfaceManager.h"
#include "CircleJoint.h"
#include "Vec2.h"
#include "Vec3.h"
namespace ofx {
namespace piMapper {
@ -22,22 +24,22 @@ class ProjectionEditorWidget {
void createJoints();
void updateJoints();
void unselectAllJoints();
void moveSelectedSurface(ofVec2f by);
void moveSelectedSurface(Vec3 by);
void stopDragJoints();
void updateVertices();
void setSnapDistance(float newSnapDistance);
CircleJoint * hitTestJoints(ofVec2f pos);
vector <CircleJoint *> * getJoints();
CircleJoint * hitTestJoints(Vec2 pos);
std::vector<CircleJoint *> * getJoints();
void onVertexChanged(int & i);
void onVerticesChanged(vector<ofVec3f> & vertices);
void onVerticesChanged(std::vector<Vec3> & vertices);
void onSurfaceSelected(int & surfaceIndex);
void onVertexSelected(int & vertexIndex);
void onVertexUnselected(int & vertexIndex);
private:
SurfaceManager * surfaceManager;
vector <CircleJoint *> joints;
std::vector<CircleJoint *> joints;
bool bShiftKeyDown;
float fSnapDistance;
@ -46,4 +48,4 @@ class ProjectionEditorWidget {
};
} // namespace piMapper
} // namespace ofx
} // namespace ofx

24
src/Gui/Widgets/ScaleWidget.cpp

@ -1,5 +1,9 @@
#include "ScaleWidget.h"
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR > 9
#include "glm/geometric.hpp"
#endif
namespace ofx {
namespace piMapper {
@ -57,7 +61,11 @@ void ScaleWidget::draw(){
_line[1].y -= dy;
// Continue
float scale = lineLength / _line[0].distance(_line[1]);
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
float scale = lineLength / _line[0].distance(_line[1]);
#else
float scale = lineLength / glm::distance(_line[0], _line[1]);
#endif
_line[1].x = _line[0].x + (_line[1].x - _line[0].x) * scale;
_line[1].y = _line[0].y + (_line[1].y - _line[0].y) * scale;
@ -122,15 +130,19 @@ void ScaleWidget::onMouseDragged(ofMouseEventArgs & args){
}
ofRectangle box = _surfaceManager->getSelectedSurface()->getBoundingBox();
float boxAspect = box.width / box.height;
ofPolyline newLine = _line;
newLine[1].x = args.x;
newLine[1].y = args.y;
_scale = _surfaceManager->getSelectedSurface()->getScale() /
_line[0].distance(_line[1]) *
newLine[0].distance(newLine[1]);
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
_scale = _surfaceManager->getSelectedSurface()->getScale() /
_line[0].distance(_line[1]) *
newLine[0].distance(newLine[1]);
#else
_scale = _surfaceManager->getSelectedSurface()->getScale() /
glm::distance(_line[0], _line[1]) *
glm::distance(newLine[0], newLine[1]);
#endif
_line = newLine;

40
src/Gui/Widgets/SourcesEditorWidget.cpp

@ -23,17 +23,17 @@ void SourcesEditorWidget::createSelectors(){
// Depending on media count, decide what to load and initialize
if(numImages){
// Get image names from media server
vector <string> imageNames = mediaServer->getImageNames();
std::vector<std::string> imageNames = mediaServer->getImageNames();
imageSelector->setup("Images", imageNames, mediaServer->getImagePaths());
ofAddListener(imageSelector->onRadioSelected, this, &SourcesEditorWidget::handleImageSelected);
}
if(numVideos){
vector <string> videoNames = mediaServer->getVideoNames();
std::vector<std::string> videoNames = mediaServer->getVideoNames();
videoSelector->setup("Videos", videoNames, mediaServer->getVideoPaths());
ofAddListener(videoSelector->onRadioSelected, this, &SourcesEditorWidget::handleVideoSelected);
}
if(numFbos){
vector <string> fboNames = mediaServer->getFboSourceNames();
std::vector<std::string> fboNames = mediaServer->getFboSourceNames();
fboSelector->setup("FBOs", fboNames, fboNames);
ofAddListener(fboSelector->onRadioSelected, this, &SourcesEditorWidget::handleFboSelected);
}
@ -135,7 +135,7 @@ MediaServer * SourcesEditorWidget::getMediaServer(){
return mediaServer;
}
void SourcesEditorWidget::selectSourceRadioButton(string & sourcePath){
void SourcesEditorWidget::selectSourceRadioButton(std::string & sourcePath){
if(sourcePath == ""){
ofLogNotice("SourcesEditorWidget") << "Path is empty";
if(imageSelector->size()){
@ -210,14 +210,14 @@ void SourcesEditorWidget::removeMediaServerListeners(){
ofRemoveListener(mediaServer->onFboSourceUnloaded, this, &SourcesEditorWidget::handleFboSourceUnloaded);
}
void SourcesEditorWidget::handleImageSelected(string & imagePath){
void SourcesEditorWidget::handleImageSelected(std::string & imagePath){
_cmdManager->exec(new SetSourceCmd(SourceType::SOURCE_TYPE_IMAGE,
imagePath,
surfaceManager->getSelectedSurface(),
(SourcesEditorWidget *)this));
}
void SourcesEditorWidget::setImageSource(string & imagePath){
void SourcesEditorWidget::setImageSource(std::string & imagePath){
// Unselect selected items
videoSelector->unselectAll();
fboSelector->unselectAll();
@ -240,14 +240,14 @@ void SourcesEditorWidget::setImageSource(string & imagePath){
surface->setSource(mediaServer->loadImage(imagePath));
}
void SourcesEditorWidget::handleVideoSelected(string & videoPath){
void SourcesEditorWidget::handleVideoSelected(std::string & videoPath){
_cmdManager->exec(new SetSourceCmd(SourceType::SOURCE_TYPE_VIDEO,
videoPath,
surfaceManager->getSelectedSurface(),
(SourcesEditorWidget *)this));
}
void SourcesEditorWidget::setVideoSource(string & videoPath){
void SourcesEditorWidget::setVideoSource(std::string & videoPath){
// Unselect any selected items
fboSelector->unselectAll();
imageSelector->unselectAll();
@ -270,14 +270,14 @@ void SourcesEditorWidget::setVideoSource(string & videoPath){
surface->setSource(mediaServer->loadVideo(videoPath));
}
void SourcesEditorWidget::handleFboSelected(string & fboName){
void SourcesEditorWidget::handleFboSelected(std::string & fboName){
_cmdManager->exec(new SetSourceCmd(SourceType::SOURCE_TYPE_FBO,
fboName,
surfaceManager->getSelectedSurface(),
(SourcesEditorWidget *)this));
}
void SourcesEditorWidget::setFboSource(string & fboName){
void SourcesEditorWidget::setFboSource(std::string & fboName){
videoSelector->unselectAll();
imageSelector->unselectAll();
@ -325,21 +325,21 @@ void SourcesEditorWidget::clearMediaServer(){
}
// TODO: There is no need for those at the moment. They add too much overhead.
void SourcesEditorWidget::handleImageAdded(string & path){
void SourcesEditorWidget::handleImageAdded(std::string & path){
ofLogNotice("SourcesEditorWidget::handleImageAdded")
<< "Image path: "
<< path;
}
void SourcesEditorWidget::handleImageRemoved(string & path){}
void SourcesEditorWidget::handleVideoAdded(string & path){}
void SourcesEditorWidget::handleVideoRemoved(string & path){}
void SourcesEditorWidget::handleImageLoaded(string & path){}
void SourcesEditorWidget::handleImageUnloaded(string & path){}
void SourcesEditorWidget::handleFboSourceAdded(string & name){}
void SourcesEditorWidget::handleFboSourceRemoved(string & name){}
void SourcesEditorWidget::handleFboSourceLoaded(string & name){}
void SourcesEditorWidget::handleFboSourceUnloaded(string & name){}
void SourcesEditorWidget::handleImageRemoved(std::string & path){}
void SourcesEditorWidget::handleVideoAdded(std::string & path){}
void SourcesEditorWidget::handleVideoRemoved(std::string & path){}
void SourcesEditorWidget::handleImageLoaded(std::string & path){}
void SourcesEditorWidget::handleImageUnloaded(std::string & path){}
void SourcesEditorWidget::handleFboSourceAdded(std::string & name){}
void SourcesEditorWidget::handleFboSourceRemoved(std::string & name){}
void SourcesEditorWidget::handleFboSourceLoaded(std::string & name){}
void SourcesEditorWidget::handleFboSourceUnloaded(std::string & name){}
} // namespace piMapper
} // namespace ofx

38
src/Gui/Widgets/SourcesEditorWidget.h

@ -17,7 +17,7 @@ class SourcesEditorWidget {
void setup();
void draw();
void loadImage(string name, string path);
void loadImage(std::string name, std::string path);
void disable();
void enable();
void setSurfaceManager(SurfaceManager * newSurfaceManager);
@ -26,15 +26,15 @@ class SourcesEditorWidget {
// Sets external MediaServer
void setMediaServer(MediaServer * newMediaServer);
MediaServer * getMediaServer();
//void selectImageSourceRadioButton(string name);
void selectSourceRadioButton(string & sourcePath);
//void selectImageSourceRadioButton(std::string name);
void selectSourceRadioButton(std::string & sourcePath);
int getLoadedTexCount();
ofTexture * getTexture(int index);
void setImageSource(string & imagePath);
void setVideoSource(string & videoPath);
void setFboSource(string & fboName);
void setImageSource(std::string & imagePath);
void setVideoSource(std::string & videoPath);
void setFboSource(std::string & fboName);
void clearSource();
private:
@ -53,25 +53,25 @@ class SourcesEditorWidget {
void removeMediaServerListeners();
// Handles GUI event, whenever someone has clicked on a radio button
void handleImageSelected(string & imagePath);
void handleVideoSelected(string & videoPath);
void handleFboSelected(string & fboName);
void handleImageSelected(std::string & imagePath);
void handleVideoSelected(std::string & videoPath);
void handleFboSelected(std::string & fboName);
// Careful clearing of the media server,
// clears only if the media server has been initialized locally
void clearMediaServer();
// MediaServer event handlers
void handleImageAdded(string & path);
void handleImageRemoved(string & path);
void handleVideoAdded(string & path);
void handleVideoRemoved(string & path);
void handleImageLoaded(string & path);
void handleImageUnloaded(string & path);
void handleFboSourceAdded(string & name);
void handleFboSourceRemoved(string & name);
void handleFboSourceLoaded(string & name);
void handleFboSourceUnloaded(string & name);
void handleImageAdded(std::string & path);
void handleImageRemoved(std::string & path);
void handleVideoAdded(std::string & path);
void handleVideoRemoved(std::string & path);
void handleImageLoaded(std::string & path);
void handleImageUnloaded(std::string & path);
void handleFboSourceAdded(std::string & name);
void handleFboSourceRemoved(std::string & name);
void handleFboSourceLoaded(std::string & name);
void handleFboSourceUnloaded(std::string & name);
};

78
src/Gui/Widgets/TextureEditorWidget.cpp

@ -23,7 +23,7 @@ void TextureEditorWidget::update(){
}
// update surface if one of the joints is being dragged
ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(),
Vec2 textureSize = Vec2(surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight());
// Get selected joint index
@ -44,9 +44,10 @@ void TextureEditorWidget::update(){
if(surface->getType() == SurfaceType::GRID_WARP_SURFACE){
GridWarpSurface * s = (GridWarpSurface *)surface;
vector <ofVec2f> & texCoords = surface->getTexCoords();
ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight());
std::vector<Vec2> texCoords = surface->getTexCoords();
Vec2 textureSize = Vec2(
surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight());
int rows = s->getGridRows();
int cols = s->getGridCols();
@ -65,7 +66,7 @@ void TextureEditorWidget::update(){
int i = 0;
for(int iy = 0; iy <= rows; ++iy){
for(int ix = 0; ix <= cols; ++ix){
ofVec2f t;
Vec2 t;
t.x = sx + dx * ix;
t.y = sy + dy * iy;
surface->setTexCoord(i, t);
@ -131,8 +132,9 @@ void TextureEditorWidget::createJoints(){
if(surface == 0){
return;
}
clearJoints();
vector <ofVec2f> & texCoords = surface->getTexCoords();
std::vector<Vec2> texCoords = surface->getTexCoords();
if(surface->getSource()->getTexture()->isAllocated()){
_pollCreateJoints = false;
@ -141,15 +143,17 @@ void TextureEditorWidget::createJoints(){
return;
}
ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight());
Vec2 textureSize = Vec2(
surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight());
// Select joints depending on the surface type
vector <ofVec2f> tc;
std::vector<Vec2> tc;
if(surface->getType() == SurfaceType::TRIANGLE_SURFACE){
tc = texCoords;
}else if(surface->getType() == SurfaceType::QUAD_SURFACE){
}else if(surface->getType() == SurfaceType::QUAD_SURFACE ||
surface->getType() == SurfaceType::CIRCLE_SURFACE){
tc = texCoords;
}else if(surface->getType() == SurfaceType::HEXAGON_SURFACE){
tc = texCoords;
@ -273,14 +277,15 @@ void TextureEditorWidget::selectPrevTexCoord(){
selectTexCoord(joints.size() - 1);
}
void TextureEditorWidget::moveTexCoords(ofVec2f by){
void TextureEditorWidget::moveTexCoords(Vec2 by){
if(surface == 0){
return;
}
vector <ofVec2f> & texCoords = surface->getTexCoords();
ofVec2f textureSize = ofVec2f(surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight());
std::vector<Vec2> texCoords = surface->getTexCoords();
Vec2 textureSize = Vec2(
surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight());
for(int i = 0; i < joints.size(); i++){
joints[i]->position += by;
@ -291,13 +296,6 @@ void TextureEditorWidget::moveTexCoords(ofVec2f by){
int rows = s->getGridRows();
int cols = s->getGridCols();
int vertsPerRow = cols + 1;
int vertsPerCol = rows + 1;
int a = 0;
int b = cols;
int c = (rows * vertsPerRow) + (vertsPerRow - 1);
int d = (rows * vertsPerRow);
// Distance between horizontal tex coords
float sx = joints[0]->position.x / textureSize.x;
@ -312,7 +310,7 @@ void TextureEditorWidget::moveTexCoords(ofVec2f by){
int i = 0;
for(int iy = 0; iy <= rows; ++iy){
for(int ix = 0; ix <= cols; ++ix){
ofVec2f t;
Vec2 t;
t.x = sx + dx * ix;
t.y = sy + dy * iy;
surface->setTexCoord(i, t);
@ -326,7 +324,7 @@ void TextureEditorWidget::moveTexCoords(ofVec2f by){
}
}
void TextureEditorWidget::moveTexCoordTo(int texCoordIndex, ofVec2f position){
void TextureEditorWidget::moveTexCoordTo(int texCoordIndex, Vec2 position){
if(surface == 0){
return;
}
@ -334,7 +332,7 @@ void TextureEditorWidget::moveTexCoordTo(int texCoordIndex, ofVec2f position){
ofLogNotice("TextureEditorWidget::moveTexCoordTo") << texCoordIndex << ", " << position.x << ", " << position.y;
surface->setTexCoord(texCoordIndex, position);
ofVec2f textureSize = ofVec2f(
Vec2 textureSize = Vec2(
surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight());
joints[texCoordIndex]->position = position * textureSize;
@ -346,7 +344,7 @@ void TextureEditorWidget::stopDragJoints(){
}
}
void TextureEditorWidget::moveSelection(ofVec2f by){
void TextureEditorWidget::moveSelection(Vec2 by){
// check if joints selected
bool bJointSelected = false;
BaseJoint * selectedJoint;
@ -368,32 +366,32 @@ void TextureEditorWidget::moveSelection(ofVec2f by){
void TextureEditorWidget::constrainJointsToQuad(int selectedJointIndex){
switch(selectedJointIndex){
case 0:
joints[1]->position = ofVec2f(joints[1]->position.x, joints[0]->position.y);
joints[2]->position = ofVec2f(joints[1]->position.x, joints[3]->position.y);
joints[3]->position = ofVec2f(joints[0]->position.x, joints[3]->position.y);
joints[1]->position = Vec2(joints[1]->position.x, joints[0]->position.y);
joints[2]->position = Vec2(joints[1]->position.x, joints[3]->position.y);
joints[3]->position = Vec2(joints[0]->position.x, joints[3]->position.y);
break;
case 1:
joints[0]->position = ofVec2f(joints[0]->position.x, joints[1]->position.y);
joints[2]->position = ofVec2f(joints[1]->position.x, joints[2]->position.y);
joints[3]->position = ofVec2f(joints[0]->position.x, joints[2]->position.y);
joints[0]->position = Vec2(joints[0]->position.x, joints[1]->position.y);
joints[2]->position = Vec2(joints[1]->position.x, joints[2]->position.y);
joints[3]->position = Vec2(joints[0]->position.x, joints[2]->position.y);
break;
case 2:
joints[1]->position = ofVec2f(joints[2]->position.x, joints[1]->position.y);
joints[3]->position = ofVec2f(joints[3]->position.x, joints[2]->position.y);
joints[0]->position = ofVec2f(joints[3]->position.x, joints[1]->position.y);
joints[1]->position = Vec2(joints[2]->position.x, joints[1]->position.y);
joints[3]->position = Vec2(joints[3]->position.x, joints[2]->position.y);
joints[0]->position = Vec2(joints[3]->position.x, joints[1]->position.y);
break;
case 3:
joints[0]->position = ofVec2f(joints[3]->position.x, joints[0]->position.y);
joints[2]->position = ofVec2f(joints[2]->position.x, joints[3]->position.y);
joints[1]->position = ofVec2f(joints[2]->position.x, joints[0]->position.y);
joints[0]->position = Vec2(joints[3]->position.x, joints[0]->position.y);
joints[2]->position = Vec2(joints[2]->position.x, joints[3]->position.y);
joints[1]->position = Vec2(joints[2]->position.x, joints[0]->position.y);
break;
} // switch
}
CircleJoint * TextureEditorWidget::hitTestJoints(ofVec2f pos){
CircleJoint * TextureEditorWidget::hitTestJoints(Vec2 pos){
for(int i = 0; i < joints.size(); i++){
if(joints[i]->hitTest(pos)){
return joints[i];
@ -402,9 +400,9 @@ CircleJoint * TextureEditorWidget::hitTestJoints(ofVec2f pos){
return 0;
}
vector <CircleJoint *> & TextureEditorWidget::getJoints(){
std::vector<CircleJoint *> & TextureEditorWidget::getJoints(){
return joints;
}
} // namespace piMapper
} // namespace ofx
} // namespace ofx

15
src/Gui/Widgets/TextureEditorWidget.h

@ -7,6 +7,7 @@
#include "CircleJoint.h"
#include "SurfaceType.h"
#include "GuiBaseWidget.h"
#include "Vec2.h"
namespace ofx {
namespace piMapper {
@ -38,18 +39,18 @@ class TextureEditorWidget : public GuiBaseWidget {
void selectNextTexCoord();
void selectPrevTexCoord();
void moveTexCoords(ofVec2f by);
void moveTexCoordTo(int texCoordIndex, ofVec2f position);
void moveTexCoords(Vec2 by);
void moveTexCoordTo(int texCoordIndex, Vec2 position);
void stopDragJoints();
void moveSelection(ofVec2f by);
void moveSelection(Vec2 by);
void constrainJointsToQuad(int selectedJointIndex);
CircleJoint * hitTestJoints(ofVec2f pos);
vector <CircleJoint *> & getJoints();
CircleJoint * hitTestJoints(Vec2 pos);
std::vector<CircleJoint *> & getJoints();
private:
BaseSurface * surface;
vector <CircleJoint *> joints;
std::vector<CircleJoint *> joints;
bool bShiftKeyDown;
bool _pollCreateJoints;
@ -57,4 +58,4 @@ class TextureEditorWidget : public GuiBaseWidget {
};
} // namespace piMapper
} // namespace ofx
} // namespace ofx

2
src/Gui/Widgets/TextureHighlightWidget.h

@ -27,7 +27,7 @@ class TextureHighlightWidget : public GuiBaseWidget {
private:
SurfaceManager * _sm;
vector<BaseSurface *> _consumerSurfaces;
std::vector<BaseSurface *> _consumerSurfaces;
};
} // namespace piMapper

13
src/Info/Info.cpp

@ -13,15 +13,16 @@ Info::Info(){
" 3. Projection mapping mode\n"
" - Press <,> and <.> to select previous or next surface\n"
" - Press \"<\" and \">\" to select previous or next vertex\n"
" - Press <t> to add new triangle surface\n"
" - Press <q> to add new quad surface\n"
" - Press <p> to toggle perspective warping while quad surface selected\n"
" - Press <g> to add new grid surface\n"
" - Press <t> to add new Triangle surface\n"
" - Press <q> to add new Quad surface\n"
" - Press <r> to add a new ciRcle surface\n"
" - Press <p> to toggle Perspective warping while quad surface selected\n"
" - Press <g> to add new Grid surface\n"
" - Press <[> and <]> to remove or add columns to selected grid surface\n"
" - Press <{> and <}> to remove or add rows to selected grid surface\n"
" - Press <+> and <-> to scale surface up and down\n"
" - Press <9> and <0> to move selected surface one layer up or down\n"
" - Press <l> to hide/show layer panel\n"
" - Press <l> to hide/show Layer panel\n"
" - Press <BACKSPACE> to delete selection\n"
" - Press <SPACE> to play/pause the video\n"
" - Type <new> to clear composition\n"
@ -50,7 +51,7 @@ void Info::toggle(){
_visible = !_visible;
}
void Info::setText(string text){
void Info::setText(std::string text){
_text = text;
}

4
src/Info/Info.h

@ -11,11 +11,11 @@ class Info {
void draw();
void toggle();
void setText(string text);
void setText(std::string text);
private:
bool _visible;
string _text;
std::string _text;
};
} // namespace piMapper

52
src/MediaServer/DirectoryWatcher.cpp

@ -3,9 +3,10 @@
namespace ofx {
namespace piMapper {
DirectoryWatcher::DirectoryWatcher(string path, int watcherMediaType){
DirectoryWatcher::DirectoryWatcher(std::string path, int watcherMediaType){
directoryPath = path;
_mediaType = watcherMediaType;
if(_mediaType == SourceType::SOURCE_TYPE_VIDEO){
_directory.allowExt("mp4");
_directory.allowExt("h264");
@ -21,23 +22,31 @@ DirectoryWatcher::DirectoryWatcher(string path, int watcherMediaType){
ofLogFatalError("DirectoryWatcher::DirectoryWatcher", "Unkonwn media type");
exit(EXIT_FAILURE);
}
_directory.listDir(path);
_directory.listDir(directoryPath);
_directory.sort();
for(int i = 0; i < _directory.size(); ++i){
_filePaths.push_back(path + _directory.getName(i));
ofFile file(path + _directory.getName(i));
_filePaths.push_back(directoryPath + _directory.getName(i));
ofFile file(directoryPath + _directory.getName(i));
if(_mediaType == SourceType::SOURCE_TYPE_VIDEO){
file.copyTo("sources/videos/" + _directory.getName(i));
}else if(_mediaType == SourceType::SOURCE_TYPE_IMAGE){
file.copyTo("sources/images/" + _directory.getName(i));
}
}
dirSize = _directory.size();
}
DirectoryWatcher::~DirectoryWatcher() {
if(isThreadRunning()){
stopThread();
}
}
vector <string> & DirectoryWatcher::getFilePaths(){
std::vector<std::string> & DirectoryWatcher::getFilePaths(){
return _filePaths;
}
@ -45,5 +54,30 @@ int DirectoryWatcher::getMediaType(){
return _mediaType;
}
void DirectoryWatcher::beginWatch(int intervalInMillis) {
watchInterval = intervalInMillis;
startThread();
}
void DirectoryWatcher::threadedFunction() {
while (isThreadRunning()) {
int newSize = _directory.listDir();
if (newSize > dirSize) {
ofLogVerbose("DirectoryWatcher") << "Directory changed";
dirSize = newSize;
ofNotifyEvent(directoryFileAddedEvent, this);
} else if (newSize < dirSize) {
dirSize = newSize;
ofNotifyEvent(directoryFileRemovedEvent, this);
}
sleep(watchInterval);
}
}
} // namespace piMapper
} // namespace ofx

29
src/MediaServer/DirectoryWatcher.h

@ -6,17 +6,36 @@
namespace ofx {
namespace piMapper {
class DirectoryWatcher {
class DirectoryWatcher : public ofThread {
public:
DirectoryWatcher(string path, int watcherMediaType);
vector<string> & getFilePaths();
DirectoryWatcher(std::string path, int watcherMediaType);
virtual ~DirectoryWatcher();
std::vector<std::string> &getFilePaths();
int getMediaType();
void beginWatch(int intervalInMillis = 5000);
void threadedFunction();
/**
* Notifies when files are added to this directory.
* Sender is a pointer to this DirectoryWatcher
*/
ofEvent<void> directoryFileAddedEvent;
/**
* Notifies when files are removed from this directory.
* Sender is a pointer to this DirectoryWatcher
*/
ofEvent<void> directoryFileRemovedEvent;
private:
ofDirectory _directory;
vector<string> _filePaths;
std::vector<std::string> _filePaths;
std::string directoryPath;
int _mediaType;
int dirSize;
long watchInterval; // in millis.
};
} // namespace piMapper
} // namespace ofx
} // namespace ofx

109
src/MediaServer/MediaServer.cpp

@ -19,14 +19,17 @@ MediaServer::MediaServer():
{
// By initialising all above we also copy files from external media
// to the ofxPiMapper storage.
imageWatcher = DirectoryWatcher(
ofToDataPath(DEFAULT_IMAGES_DIR, true),
SourceType::SOURCE_TYPE_IMAGE);
videoWatcher = DirectoryWatcher(
ofToDataPath(DEFAULT_VIDEOS_DIR, true),
SourceType::SOURCE_TYPE_VIDEO);
imageWatcher.beginWatch();
// imageWatcher = DirectoryWatcher(
// ofToDataPath(DEFAULT_IMAGES_DIR, true),
// SourceType::SOURCE_TYPE_IMAGE);
// imageWatcher.beginWatch();
//
// videoWatcher = DirectoryWatcher(
// ofToDataPath(DEFAULT_VIDEOS_DIR, true),
// SourceType::SOURCE_TYPE_VIDEO);
}
void MediaServer::setup(){
@ -58,47 +61,47 @@ int MediaServer::getNumFboSources(){
return fboSources.size();
}
vector <string> & MediaServer::getImagePaths(){
std::vector<std::string> & MediaServer::getImagePaths(){
return imageWatcher.getFilePaths();
}
vector <string> MediaServer::getImageNames(){
vector <string> imageNames;
std::vector<std::string> MediaServer::getImageNames(){
std::vector<std::string> imageNames;
for(int i = 0; i < getNumImages(); i++){
// Split image path
vector <string> pathParts = ofSplitString(getImagePaths()[i], "/");
std::vector<std::string> pathParts = ofSplitString(getImagePaths()[i], "/");
// And get only the last piece
string name = pathParts[pathParts.size() - 1];
std::string name = pathParts[pathParts.size() - 1];
imageNames.push_back(name);
}
return imageNames;
}
vector <string> MediaServer::getFboSourceNames(){
vector <string> fboSourceNames;
std::vector<std::string> MediaServer::getFboSourceNames(){
std::vector<std::string> fboSourceNames;
for(int i = 0; i < fboSources.size(); i++){
fboSourceNames.push_back(fboSources[i]->getName());
}
return fboSourceNames;
}
vector <string> & MediaServer::getVideoPaths(){
std::vector<std::string> & MediaServer::getVideoPaths(){
return videoWatcher.getFilePaths();
}
vector <string> MediaServer::getVideoNames(){
vector <string> videoNames;
std::vector<std::string> MediaServer::getVideoNames(){
std::vector<std::string> videoNames;
for(int i = 0; i < getNumVideos(); i++){
// Split video path
vector <string> pathParts = ofSplitString(getVideoPaths()[i], "/");
std::vector<std::string> pathParts = ofSplitString(getVideoPaths()[i], "/");
// And get only the last piece
string name = pathParts[pathParts.size() - 1];
std::string name = pathParts[pathParts.size() - 1];
videoNames.push_back(name);
}
return videoNames;
}
BaseSource * MediaServer::loadMedia(string & path, int mediaType){
BaseSource * MediaServer::loadMedia(std::string & path, int mediaType){
// Chose load method depending on type
if(mediaType == SourceType::SOURCE_TYPE_IMAGE){
return loadImage(path);
@ -107,7 +110,7 @@ BaseSource * MediaServer::loadMedia(string & path, int mediaType){
}else if(mediaType == SourceType::SOURCE_TYPE_FBO){
return loadFboSource(path);
}else{
stringstream ss;
std::stringstream ss;
ss << "Can not load media of unknown type: " << mediaType;
ofLogFatalError("MediaServer") << ss.str();
std::exit(EXIT_FAILURE);
@ -115,7 +118,7 @@ BaseSource * MediaServer::loadMedia(string & path, int mediaType){
return 0;
}
BaseSource * MediaServer::loadImage(string & path){
BaseSource * MediaServer::loadImage(std::string & path){
ImageSource * imageSource = 0;
// Check if this image is already loaded
bool isImageLoaded = false;
@ -128,11 +131,11 @@ BaseSource * MediaServer::loadImage(string & path){
// Increase reference count of this source
//referenceCount[path]++;
imageSource->referenceCount++;
stringstream refss;
std::stringstream refss;
refss << "Current reference count for " << path << " = " << imageSource->referenceCount;
ofLogNotice("MediaServer") << refss.str();
// Notify objects registered to onImageLoaded event
stringstream ss;
std::stringstream ss;
ss << "Image " << path << " already loaded";
ofLogNotice("MediaServer") << ss.str();
ofNotifyEvent(onImageLoaded, path, this);
@ -144,7 +147,7 @@ BaseSource * MediaServer::loadImage(string & path){
loadedSources[path] = imageSource;
// Set reference count of this image path to 1
//referenceCount[path] = 1;
stringstream refss;
std::stringstream refss;
refss << "Initialized reference count of " << path << " to " << imageSource->referenceCount;
ofLogNotice("MediaServer") << refss.str();
// Notify objects registered to onImageLoaded event
@ -152,7 +155,7 @@ BaseSource * MediaServer::loadImage(string & path){
return imageSource;
}
void MediaServer::unloadImage(string & path){
void MediaServer::unloadImage(std::string & path){
ImageSource * source = static_cast <ImageSource *>(getSourceByPath(path));
ofLogNotice("MediaServer") << "Unload image, current reference count: " << source->referenceCount;
source->referenceCount--;
@ -163,28 +166,28 @@ void MediaServer::unloadImage(string & path){
return;
}
// Reference count 0 or less, unload image
stringstream ss;
std::stringstream ss;
ss << "Removing image " << path;
ofLogNotice("MediaServer") << ss.str();
// Destroy image source
if(loadedSources.count(path)){
ofLogNotice("MediaServer") << "Source count BEFORE image removal: " << loadedSources.size() << endl;
ofLogNotice("MediaServer") << "Source count BEFORE image removal: " << loadedSources.size() << std::endl;
loadedSources[path]->clear();
map <string, BaseSource *>::iterator it = loadedSources.find(path);
map <std::string, BaseSource *>::iterator it = loadedSources.find(path);
delete it->second;
loadedSources.erase(it);
ofLogNotice("MediaServer") << "Source count AFTER image removal: " << loadedSources.size() << endl;
ofLogNotice("MediaServer") << "Source count AFTER image removal: " << loadedSources.size() << std::endl;
ofNotifyEvent(onImageUnloaded, path, this);
return;
}
// Something wrong here, we should be out of the routine by now
stringstream failss;
std::stringstream failss;
failss << "Failed to remove image source: " << path;
ofLogFatalError("MediaServer") << failss.str();
std::exit(EXIT_FAILURE);
}
BaseSource * MediaServer::loadVideo(string & path){
BaseSource * MediaServer::loadVideo(std::string & path){
VideoSource * videoSource = 0;
// Check if this video is already loaded
bool isVideoLoaded = false;
@ -196,11 +199,11 @@ BaseSource * MediaServer::loadVideo(string & path){
if(isVideoLoaded){
// Increase reference count of this source
videoSource->referenceCount++;
stringstream refss;
std::stringstream refss;
refss << "Current reference count for " << path << " = " << videoSource->referenceCount;
ofLogNotice("MediaServer") << refss.str();
// Notify objects registered to onImageLoaded event
stringstream ss;
std::stringstream ss;
ss << "Video " << path << " already loaded";
ofLogNotice("MediaServer") << ss.str();
ofNotifyEvent(onVideoLoaded, path, this);
@ -212,14 +215,14 @@ BaseSource * MediaServer::loadVideo(string & path){
loadedSources[path] = videoSource;
// Set reference count of this image path to 1
//referenceCount[path] = 1;
stringstream refss;
std::stringstream refss;
refss << "Initialized reference count of " << path << " to " << videoSource->referenceCount;
ofLogNotice("MediaServer") << refss.str();
ofNotifyEvent(onVideoLoaded, path, this);
return videoSource;
}
void MediaServer::unloadVideo(string & path){
void MediaServer::unloadVideo(std::string & path){
VideoSource * videoSource = static_cast <VideoSource *>(getSourceByPath(path));
// Decrease reference count of the video
//referenceCount[path]--;
@ -236,26 +239,26 @@ void MediaServer::unloadVideo(string & path){
if(loadedSources.count(path)){
ofLogNotice("MediaServer")
<< "Source count before video removal: "
<< loadedSources.size() << endl;
<< loadedSources.size() << std::endl;
videoSource->clear();
map <string, BaseSource *>::iterator it = loadedSources.find(path);
map <std::string, BaseSource *>::iterator it = loadedSources.find(path);
delete it->second;
loadedSources.erase(it);
ofLogNotice("MediaServer")
<< "Source count after video removal: "
<< loadedSources.size() << endl;
<< loadedSources.size() << std::endl;
ofNotifyEvent(onVideoUnloaded, path, this);
return;
}
// Something wrong here, we should be out of the routine by now
stringstream failss;
std::stringstream failss;
failss << "Failed to remove video source: " << path;
ofLogFatalError("MediaServer") << failss.str();
std::exit(EXIT_FAILURE);
}
void MediaServer::unloadMedia(string & path){
void MediaServer::unloadMedia(std::string & path){
if(loadedSources.count(path)){
BaseSource * mediaSource = getSourceByPath(path);
if(mediaSource->getType() == SourceType::SOURCE_TYPE_IMAGE){
@ -276,7 +279,7 @@ void MediaServer::unloadMedia(string & path){
// Clear all loaded media
void MediaServer::clear(){
typedef map <string, BaseSource *>::iterator it_type;
typedef map <std::string, BaseSource *>::iterator it_type;
for(it_type i = loadedSources.begin(); i != loadedSources.end(); i++){
// Do not delete FBO source pointers as they are (and should be) initialized elsewhere
if(i->second->getType() != SourceType::SOURCE_TYPE_FBO){
@ -287,32 +290,32 @@ void MediaServer::clear(){
}
// TODO: getLoadedSourceByPath
BaseSource * MediaServer::getSourceByPath(string & mediaPath){
BaseSource * MediaServer::getSourceByPath(std::string & mediaPath){
if(loadedSources.count(mediaPath)){
return loadedSources[mediaPath];
}
// Source not found, exit with error
stringstream ss;
std::stringstream ss;
ss << "Could not find source by path: " << mediaPath;
ofLogFatalError("MediaServer") << ss.str();
std::exit(EXIT_FAILURE);
}
string MediaServer::getDefaultImageDir(){
std::string MediaServer::getDefaultImageDir(){
return DEFAULT_IMAGES_DIR;
}
string MediaServer::getDefaultVideoDir(){
std::string MediaServer::getDefaultVideoDir(){
return DEFAULT_VIDEOS_DIR;
}
string MediaServer::getDefaultMediaDir(int sourceType){
std::string MediaServer::getDefaultMediaDir(int sourceType){
if(sourceType == SourceType::SOURCE_TYPE_IMAGE){
return getDefaultImageDir();
}else if(sourceType == SourceType::SOURCE_TYPE_VIDEO){
return getDefaultVideoDir();
}else{
stringstream ss;
std::stringstream ss;
ss << "Could not get default media dir. Unknown source type: " << sourceType;
ofLogFatalError("MediaServer") << ss.str();
std::exit(EXIT_FAILURE);
@ -343,7 +346,7 @@ void MediaServer::addFboSource(FboSource * fboSource){
fboSource->setup();
}
BaseSource * MediaServer::loadFboSource(string & fboSourceName){
BaseSource * MediaServer::loadFboSource(std::string & fboSourceName){
ofLogNotice("MediaServer") << "Attempting to load FBO source with name " << fboSourceName;
// Search for FBO source name in our storage
FboSource * source = 0;
@ -377,7 +380,7 @@ BaseSource * MediaServer::loadFboSource(string & fboSourceName){
return loadedSources[fboSourceName];
} // loadFboSource
void MediaServer::unloadFboSource(string & fboSourceName){
void MediaServer::unloadFboSource(std::string & fboSourceName){
ofLogNotice("MediaServer") << "Attempt to unload FBO source " << fboSourceName;
// Check if loaded at all
if(!loadedSources.count(fboSourceName)){
@ -396,9 +399,9 @@ void MediaServer::unloadFboSource(string & fboSourceName){
source->referenceCount = 0;
source->setActive(false);
//source->removeAppListeners();
map <string, BaseSource *>::iterator it = loadedSources.find(fboSourceName);
map <std::string, BaseSource *>::iterator it = loadedSources.find(fboSourceName);
loadedSources.erase(it);
ofLogNotice("MediaServer") << "Source count after FBO source removal: " << loadedSources.size() << endl;
ofLogNotice("MediaServer") << "Source count after FBO source removal: " << loadedSources.size() << std::endl;
ofNotifyEvent(onFboSourceUnloaded, fboSourceName, this);
}
} // unloadFboSource

68
src/MediaServer/MediaServer.h

@ -55,45 +55,45 @@ class MediaServer {
int getNumVideos();
int getNumImages();
int getNumFboSources(); // new
vector <string> & getVideoPaths();
vector <string> getVideoNames();
vector <string> & getImagePaths();
vector <string> getImageNames();
vector <string> getFboSourceNames(); // new
BaseSource * loadMedia(string & path, int mediaType);
BaseSource * loadImage(string & path);
void unloadImage(string & path);
BaseSource * loadVideo(string & path);
void unloadVideo(string & path);
void unloadMedia(string & path);
std::vector<std::string> & getVideoPaths();
std::vector<std::string> getVideoNames();
std::vector<std::string> & getImagePaths();
std::vector<std::string> getImageNames();
std::vector<std::string> getFboSourceNames(); // new
BaseSource * loadMedia(std::string & path, int mediaType);
BaseSource * loadImage(std::string & path);
void unloadImage(std::string & path);
BaseSource * loadVideo(std::string & path);
void unloadVideo(std::string & path);
void unloadMedia(std::string & path);
void clear(); // Force all loaded source unload
BaseSource * getSourceByPath(string & mediaPath);
string getDefaultImageDir();
string getDefaultVideoDir();
string getDefaultMediaDir(int sourceType);
BaseSource * getSourceByPath(std::string & mediaPath);
std::string getDefaultImageDir();
std::string getDefaultVideoDir();
std::string getDefaultMediaDir(int sourceType);
// Do things with FBO sources
void addFboSource(FboSource & fboSource); // could be called also as register FBO source
void addFboSource(FboSource * fboSource);
BaseSource * loadFboSource(string & fboSourceName);
void unloadFboSource(string & fboSourceName);
BaseSource * loadFboSource(std::string & fboSourceName);
void unloadFboSource(std::string & fboSourceName);
// Custom events, add/remove
ofEvent <string> onImageAdded;
ofEvent <string> onImageRemoved;
ofEvent <string> onVideoAdded;
ofEvent <string> onVideoRemoved;
ofEvent <string> onFboSourceAdded;
ofEvent <string> onFboSourceRemoved;
ofEvent <std::string> onImageAdded;
ofEvent <std::string> onImageRemoved;
ofEvent <std::string> onVideoAdded;
ofEvent <std::string> onVideoRemoved;
ofEvent <std::string> onFboSourceAdded;
ofEvent <std::string> onFboSourceRemoved;
// load/unload
ofEvent <string> onImageLoaded;
ofEvent <string> onImageUnloaded;
ofEvent <string> onVideoLoaded;
ofEvent <string> onVideoUnloaded;
ofEvent <string> onFboSourceLoaded;
ofEvent <string> onFboSourceUnloaded;
ofEvent <std::string> onImageLoaded;
ofEvent <std::string> onImageUnloaded;
ofEvent <std::string> onVideoLoaded;
ofEvent <std::string> onVideoUnloaded;
ofEvent <std::string> onFboSourceLoaded;
ofEvent <std::string> onFboSourceUnloaded;
private:
// Directory Watchers
@ -111,13 +111,13 @@ class MediaServer {
DirectoryWatcher usb2ImageWatcher;
DirectoryWatcher usb3ImageWatcher;
vector <string> _tempImagePaths;
vector <string> _tempVideoPaths;
std::vector<std::string> _tempImagePaths;
std::vector<std::string> _tempVideoPaths;
map <string, BaseSource *> loadedSources;
map <std::string, BaseSource *> loadedSources;
// FBO source storage before they go to loadedSources
vector <FboSource *> fboSources; // FBO source storage
std::vector<FboSource *> fboSources; // FBO source storage
};
} // namespace piMapper

15
src/Sources/BaseSource.cpp

@ -4,7 +4,7 @@ namespace ofx {
namespace piMapper {
BaseSource::BaseSource(){
//cout << "BaseSource" << endl;
//std::cout << "BaseSource" << std::endl;
init();
runInBackground = false;
displayed = false;
@ -21,7 +21,7 @@ ofTexture * BaseSource::getTexture(){
return texture;
}
string & BaseSource::getName(){
std::string & BaseSource::getName(){
return name;
}
@ -37,7 +37,7 @@ SourceType BaseSource::getType(){
return type;
}
string & BaseSource::getPath(){
std::string & BaseSource::getPath(){
return path;
}
@ -63,11 +63,12 @@ bool BaseSource::runsInBackground(){
return runInBackground;
}
void BaseSource::setNameFromPath(string & fullPath){
vector <string> pathParts;
//cout << "fullPath: " << fullPath << endl;
void BaseSource::setNameFromPath(std::string & fullPath){
std::vector<std::string> pathParts;
//std::cout << "fullPath: " << fullPath << std::endl;
pathParts = ofSplitString(fullPath, "/"); // Maybe on win "/" is "\", have to test
//cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << endl;
//std::cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << std::endl;
name = pathParts[pathParts.size() - 1];
}

10
src/Sources/BaseSource.h

@ -13,11 +13,11 @@ class BaseSource {
BaseSource(ofTexture * newTexture); // Only one clean way of passing the texture
~BaseSource();
ofTexture * getTexture();
string & getName();
std::string & getName();
bool isLoadable(); // Maybe the loading features shoud go to a derrived class
bool isLoaded(); // as BaseSourceLoadable
SourceType getType();
string & getPath();
std::string & getPath();
virtual void clear(){}
virtual void togglePause(){}
bool isActive();
@ -34,10 +34,10 @@ class BaseSource {
void init();
protected:
void setNameFromPath(string & fullPath);
void setNameFromPath(std::string & fullPath);
ofTexture * texture;
string name;
string path; // This is set only if loadable is true
std::string name;
std::string path; // This is set only if loadable is true
bool loadable; // If the source can be loaded from disk like image and video
bool loaded; // Is the source loaded?
SourceType type;

2
src/Sources/ImageSource.cpp

@ -11,7 +11,7 @@ ImageSource::ImageSource(){
ImageSource::~ImageSource(){}
void ImageSource::loadImage(string & filePath){
void ImageSource::loadImage(std::string & filePath){
path = filePath;
setNameFromPath(filePath);
image = new ofImage();

4
src/Sources/ImageSource.h

@ -10,8 +10,8 @@ class ImageSource : public BaseSource {
public:
ImageSource();
~ImageSource();
string & getPath();
void loadImage(string & filePath);
std::string & getPath();
void loadImage(std::string & filePath);
void clear();
private:
ofImage * image;

4
src/Sources/OMXPlayerCache.cpp

@ -14,7 +14,7 @@ OMXPlayerCache * OMXPlayerCache::instance(){
return _instance;
}
ofxOMXPlayer * OMXPlayerCache::load(string moviePath){
ofxOMXPlayer * OMXPlayerCache::load(std::string moviePath){
if(_players.find(moviePath) == _players.end()){
ofxOMXPlayerSettings settings;
settings.videoPath = moviePath;
@ -34,7 +34,7 @@ ofxOMXPlayer * OMXPlayerCache::load(string moviePath){
return _players[moviePath];
}
void OMXPlayerCache::unload(string moviePath){
void OMXPlayerCache::unload(std::string moviePath){
if(_players.find(moviePath) != _players.end()){
_players[moviePath]->setPaused(true);
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save