Browse Source

Make it work with openFrameworks master branch

master
Krisjanis Rijnieks 8 years ago
parent
commit
26326733cc
  1. 4
      example/src/CustomSource.h
  2. 2
      example/src/main.cpp
  3. 3
      example/src/ofApp.h
  4. 2
      example_camera/src/CameraSource.cpp
  5. 2
      example_camera/src/main.cpp
  6. 2
      example_gamepad/src/InputHandler.h
  7. 2
      example_gamepad/src/main.cpp
  8. 2
      example_shortcuts/src/ofApp.cpp
  9. 4
      example_simpler/src/CustomSource.h
  10. 2
      example_simpler/src/main.cpp
  11. 8
      src/Application/Application.cpp
  12. 10
      src/Application/Application.h
  13. 42
      src/Application/SettingsLoader.cpp
  14. 10
      src/Application/SettingsLoader.h
  15. 4
      src/Commands/AddGridColCmd.h
  16. 4
      src/Commands/AddGridRowCmd.h
  17. 2
      src/Commands/ClearSurfacesCmd.h
  18. 4
      src/Commands/CmdManager.h
  19. 2
      src/Commands/DeselectTexCoordCmd.cpp
  20. 2
      src/Commands/MvAllTexCoordsCmd.h
  21. 4
      src/Commands/RmGridColCmd.h
  22. 4
      src/Commands/RmGridRowCmd.h
  23. 2
      src/Commands/SetNextSourceCmd.cpp
  24. 4
      src/Commands/SetNextSourceCmd.h
  25. 2
      src/Commands/SetSourceCmd.cpp
  26. 6
      src/Commands/SetSourceCmd.h
  27. 2
      src/Commands/StartDragSurfaceCmd.h
  28. 2
      src/Gui/Widgets/LayerPanelWidget.cpp
  29. 10
      src/Gui/Widgets/ProjectionEditorWidget.cpp
  30. 6
      src/Gui/Widgets/ProjectionEditorWidget.h
  31. 19
      src/Gui/Widgets/ScaleWidget.cpp
  32. 40
      src/Gui/Widgets/SourcesEditorWidget.cpp
  33. 38
      src/Gui/Widgets/SourcesEditorWidget.h
  34. 10
      src/Gui/Widgets/TextureEditorWidget.cpp
  35. 4
      src/Gui/Widgets/TextureEditorWidget.h
  36. 2
      src/Gui/Widgets/TextureHighlightWidget.h
  37. 2
      src/Info/Info.cpp
  38. 4
      src/Info/Info.h
  39. 13
      src/MediaServer/DirectoryWatcher.cpp
  40. 9
      src/MediaServer/DirectoryWatcher.h
  41. 90
      src/MediaServer/MediaServer.cpp
  42. 68
      src/MediaServer/MediaServer.h
  43. 14
      src/Sources/BaseSource.cpp
  44. 10
      src/Sources/BaseSource.h
  45. 2
      src/Sources/ImageSource.cpp
  46. 4
      src/Sources/ImageSource.h
  47. 4
      src/Sources/OMXPlayerCache.cpp
  48. 6
      src/Sources/OMXPlayerCache.h
  49. 8
      src/Sources/SourceTypeHelper.h
  50. 2
      src/Sources/VideoSource.cpp
  51. 4
      src/Sources/VideoSource.h
  52. 28
      src/Sources/magSlideShowSource.cpp
  53. 7
      src/Sources/magSlideShowSource.h
  54. 2
      src/Sources/magSlideTransition.h
  55. 2
      src/Sources/magSlideTransitionFactory.h
  56. 2
      src/Surfaces/BaseSurface.cpp
  57. 10
      src/Surfaces/BaseSurface.h
  58. 12
      src/Surfaces/CircleSurface.h
  59. 21
      src/Surfaces/GridWarpSurface.cpp
  60. 8
      src/Surfaces/GridWarpSurface.h
  61. 26
      src/Surfaces/HexagonSurface.cpp
  62. 12
      src/Surfaces/HexagonSurface.h
  63. 20
      src/Surfaces/QuadSurface.cpp
  64. 8
      src/Surfaces/QuadSurface.h
  65. 8
      src/Surfaces/SurfaceFactory.cpp
  66. 8
      src/Surfaces/SurfaceManager.cpp
  67. 10
      src/Surfaces/SurfaceManager.h
  68. 2
      src/Surfaces/SurfaceStack.cpp
  69. 8
      src/Surfaces/SurfaceStack.h
  70. 20
      src/Surfaces/TriangleSurface.cpp
  71. 8
      src/Surfaces/TriangleSurface.h
  72. 44
      src/Types/Vec2.cpp
  73. 13
      src/Types/Vec2.h
  74. 34
      src/Types/Vec3.cpp
  75. 13
      src/Types/Vec3.h
  76. 22
      src/UserInterface/RadioList.cpp
  77. 26
      src/UserInterface/RadioList.h
  78. 8
      src/ofxPiMapper.cpp
  79. 6
      src/ofxPiMapper.h

4
example/src/CustomSource.h

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

2
example/src/main.cpp

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

3
example/src/ofApp.h

@ -8,8 +8,7 @@
#include "VideoSource.h" #include "VideoSource.h"
#include "magSlideShowSource.h" #include "magSlideShowSource.h"
class ofApp : public ofBaseApp class ofApp : public ofBaseApp{
{
public: public:
void setup(); void setup();
void update(); void update();

2
example_camera/src/CameraSource.cpp

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

2
example_camera/src/main.cpp

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

2
example_gamepad/src/InputHandler.h

@ -1,6 +1,6 @@
#pragma once #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 // https://wiki.libsdl.org/SDL_JoystickGetGUIDString
#include <vector> #include <vector>

2
example_gamepad/src/main.cpp

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

2
example_shortcuts/src/ofApp.cpp

@ -73,7 +73,7 @@ void ofApp::keyPressed(int key){
}else if(key == '\\'){ }else if(key == '\\'){
mapper.togglePause(); mapper.togglePause();
}else if(key == 'n'){ }else if(key == 'n'){
string multilineInfoText = std::string multilineInfoText =
"Custom ofxPiMapper shortcuts\n\n" "Custom ofxPiMapper shortcuts\n\n"
"Good day user.\n" "Good day user.\n"
"Shortcuts have been customized.\n" "Shortcuts have been customized.\n"

4
example_simpler/src/CustomSource.h

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

2
example_simpler/src/main.cpp

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

8
src/Application/Application.cpp

@ -199,7 +199,7 @@ void Application::eraseSurface(int i){
} }
} }
void Application::setInfoText(string text){ void Application::setInfoText(std::string text){
_info.setText(text); _info.setText(text);
} }
@ -265,13 +265,13 @@ void Application::shutdown(){
#endif #endif
} }
bool Application::loadXmlSettings(string fileName){ bool Application::loadXmlSettings(std::string fileName){
if(!ofFile::doesFileExist(fileName)){ if(!ofFile::doesFileExist(fileName)){
ofLogError("Application::loadXmlSettings()") << fileName << " does not exist"; ofLogError("Application::loadXmlSettings()") << fileName << " does not exist";
return false; return false;
} }
if(!_surfaceManager.loadXmlSettings(fileName)){ if(!_surfaceManager.loadXmlSettings(fileName)){
ofLogError("Application::loadXmlSettings()") << "Failed to load " << fileName << endl; ofLogError("Application::loadXmlSettings()") << "Failed to load " << fileName << std::endl;
return false; return false;
} }
return true; return true;
@ -464,7 +464,7 @@ void Application::setNextSource(){
} }
} }
void Application::setFboSource(string sourceId){ void Application::setFboSource(std::string sourceId){
if(getSurfaceManager()->getSelectedSurface() != 0){ if(getSurfaceManager()->getSelectedSurface() != 0){
getCmdManager()->exec( getCmdManager()->exec(
new SetSourceCmd( new SetSourceCmd(

10
src/Application/Application.h

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <string>
// OpenFrameworks components // OpenFrameworks components
#include "ofEvents.h" #include "ofEvents.h"
#include "ofLog.h" #include "ofLog.h"
@ -87,11 +89,11 @@ class Application {
void addFboSource(FboSource * fboSource); void addFboSource(FboSource * fboSource);
void createSurface(SurfaceType type); void createSurface(SurfaceType type);
void eraseSurface(int i); void eraseSurface(int i);
void setInfoText(string text); void setInfoText(std::string text);
void toggleInfo(); void toggleInfo();
void togglePerspective(); void togglePerspective();
void saveProject(); void saveProject();
bool loadXmlSettings(string fileName); bool loadXmlSettings(std::string fileName);
bool isShiftKeyDown(); bool isShiftKeyDown();
@ -126,7 +128,7 @@ class Application {
void scaleDown(); void scaleDown();
void duplicateSurface(); void duplicateSurface();
void setNextSource(); void setNextSource();
void setFboSource(string sourceId); void setFboSource(std::string sourceId);
void addGridRow(); void addGridRow();
void addGridColumn(); void addGridColumn();
void removeGridRow(); void removeGridRow();
@ -164,7 +166,7 @@ class Application {
float _lastSaveTime; float _lastSaveTime;
float _autoSaveInterval; float _autoSaveInterval;
string _keySequence; std::string _keySequence;
}; };

42
src/Application/SettingsLoader.cpp

@ -19,11 +19,11 @@ SettingsLoader::SettingsLoader(){
bool SettingsLoader::load( bool SettingsLoader::load(
SurfaceManager & surfaceManager, SurfaceManager & surfaceManager,
MediaServer & mediaServer, MediaServer & mediaServer,
string fileName){ std::string fileName){
ofxXmlSettings * xmlSettings = new ofxXmlSettings(); ofxXmlSettings * xmlSettings = new ofxXmlSettings();
string sourceType = ""; std::string sourceType = "";
string sourceName = ""; std::string sourceName = "";
BaseSource * source = 0; BaseSource * source = 0;
@ -38,7 +38,7 @@ bool SettingsLoader::load(
// Count <surfaces> tags. // Count <surfaces> tags.
unsigned int numPresets = xmlSettings->getNumTags("surfaces"); unsigned int numPresets = xmlSettings->getNumTags("surfaces");
cout << "numPresets: " << numPresets << endl; std::cout << "numPresets: " << numPresets << std::endl;
// Clear previous presets and surfaces first. // Clear previous presets and surfaces first.
surfaceManager.clearPresets(); surfaceManager.clearPresets();
@ -79,10 +79,10 @@ bool SettingsLoader::load(
}else{ }else{
// Construct full path // Construct full path
string dir = mediaServer.getDefaultMediaDir(typeEnum); std::string dir = mediaServer.getDefaultMediaDir(typeEnum);
stringstream pathss; std::stringstream pathss;
pathss << ofToDataPath(dir, true) << sourceName; pathss << ofToDataPath(dir, true) << sourceName;
string sourcePath = pathss.str(); std::string sourcePath = pathss.str();
// Load media by using full path // Load media by using full path
source = mediaServer.loadMedia(sourcePath, typeEnum); source = mediaServer.loadMedia(sourcePath, typeEnum);
@ -157,7 +157,7 @@ bool SettingsLoader::load(
} }
// TODO: Save all presets, not just the active one. // 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(); ofxXmlSettings * xmlSettings = new ofxXmlSettings();
@ -178,7 +178,7 @@ bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){
xmlSettings->pushTag("surface", i); xmlSettings->pushTag("surface", i);
xmlSettings->addTag("vertices"); xmlSettings->addTag("vertices");
xmlSettings->pushTag("vertices"); xmlSettings->pushTag("vertices");
vector<Vec3> vertices = surface->getVertices(); std::vector<Vec3> vertices = surface->getVertices();
for(int j = 0; j < vertices.size(); j++){ for(int j = 0; j < vertices.size(); j++){
xmlSettings->addTag("vertex"); xmlSettings->addTag("vertex");
xmlSettings->pushTag("vertex", j); xmlSettings->pushTag("vertex", j);
@ -194,7 +194,7 @@ bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){
xmlSettings->addTag("texCoords"); xmlSettings->addTag("texCoords");
xmlSettings->pushTag("texCoords"); xmlSettings->pushTag("texCoords");
vector<Vec2> texCoords = surface->getTexCoords(); std::vector<Vec2> texCoords = surface->getTexCoords();
for(int j = 0; j < texCoords.size(); j++){ for(int j = 0; j < texCoords.size(); j++){
xmlSettings->addTag("texCoord"); xmlSettings->addTag("texCoord");
xmlSettings->pushTag("texCoord", j); xmlSettings->pushTag("texCoord", j);
@ -207,10 +207,10 @@ bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){
xmlSettings->addTag("source"); xmlSettings->addTag("source");
xmlSettings->pushTag("source"); xmlSettings->pushTag("source");
string sourceTypeName = SourceTypeHelper::GetSourceTypeHelperName(surface->getSource()->getType()); std::string sourceTypeName = SourceTypeHelper::GetSourceTypeHelperName(surface->getSource()->getType());
xmlSettings->addValue("source-type", sourceTypeName); xmlSettings->addValue("source-type", sourceTypeName);
string sourceName = surface->getSource()->getName(); std::string sourceName = surface->getSource()->getName();
xmlSettings->addValue("source-name", (sourceName == "") ? "none" : sourceName); xmlSettings->addValue("source-name", (sourceName == "") ? "none" : sourceName);
xmlSettings->popTag(); // source xmlSettings->popTag(); // source
@ -245,14 +245,14 @@ bool SettingsLoader::save(SurfaceManager & surfaceManager, string fileName){
xmlSettings->save(fileName); xmlSettings->save(fileName);
} }
bool SettingsLoader::create(string fileName){ bool SettingsLoader::create(std::string fileName){
ofxXmlSettings xml; ofxXmlSettings xml;
xml.addTag("surfaces"); xml.addTag("surfaces");
return xml.save(fileName); return xml.save(fileName);
} }
BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){ BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
vector <Vec3> vertices; std::vector<Vec3> vertices;
if(xmlSettings->tagExists("vertices")){ if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices"); xmlSettings->pushTag("vertices");
@ -287,7 +287,7 @@ BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
xmlSettings->popTag(); // vertices xmlSettings->popTag(); // vertices
} }
vector <Vec2> texCoords; std::vector<Vec2> texCoords;
if(xmlSettings->tagExists("texCoords")){ if(xmlSettings->tagExists("texCoords")){
xmlSettings->pushTag("texCoords"); xmlSettings->pushTag("texCoords");
@ -327,7 +327,7 @@ BaseSurface * SettingsLoader::getTriangleSurface(ofxXmlSettings * xmlSettings){
} }
BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){ BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){
vector<Vec3> vertices; std::vector<Vec3> vertices;
if(xmlSettings->tagExists("vertices")){ if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices"); xmlSettings->pushTag("vertices");
@ -371,7 +371,7 @@ BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){
xmlSettings->popTag(); // vertices xmlSettings->popTag(); // vertices
} }
vector <Vec2> texCoords; std::vector<Vec2> texCoords;
if(xmlSettings->tagExists("texCoords")){ if(xmlSettings->tagExists("texCoords")){
xmlSettings->pushTag("texCoords"); xmlSettings->pushTag("texCoords");
@ -429,7 +429,7 @@ BaseSurface * SettingsLoader::getQuadSurface(ofxXmlSettings * xmlSettings){
} }
BaseSurface * SettingsLoader::getGridWarpSurface(ofxXmlSettings * xmlSettings){ BaseSurface * SettingsLoader::getGridWarpSurface(ofxXmlSettings * xmlSettings){
vector <Vec3> vertices; std::vector<Vec3> vertices;
if(xmlSettings->tagExists("vertices")){ if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices"); xmlSettings->pushTag("vertices");
@ -449,7 +449,7 @@ BaseSurface * SettingsLoader::getGridWarpSurface(ofxXmlSettings * xmlSettings){
xmlSettings->popTag(); // vertices xmlSettings->popTag(); // vertices
} }
vector <Vec2> texCoords; std::vector<Vec2> texCoords;
if(xmlSettings->tagExists("texCoords")){ if(xmlSettings->tagExists("texCoords")){
xmlSettings->pushTag("texCoords"); xmlSettings->pushTag("texCoords");
@ -492,7 +492,7 @@ BaseSurface * SettingsLoader::getGridWarpSurface(ofxXmlSettings * xmlSettings){
} }
BaseSurface * SettingsLoader::getHexagonSurface(ofxXmlSettings * xmlSettings){ BaseSurface * SettingsLoader::getHexagonSurface(ofxXmlSettings * xmlSettings){
vector <Vec3> vertices; std::vector<Vec3> vertices;
if(xmlSettings->tagExists("vertices")){ if(xmlSettings->tagExists("vertices")){
xmlSettings->pushTag("vertices"); xmlSettings->pushTag("vertices");
@ -511,7 +511,7 @@ BaseSurface * SettingsLoader::getHexagonSurface(ofxXmlSettings * xmlSettings){
xmlSettings->popTag(); // vertices xmlSettings->popTag(); // vertices
} }
vector <Vec2> texCoords; std::vector<Vec2> texCoords;
if(xmlSettings->tagExists("texCoords")){ if(xmlSettings->tagExists("texCoords")){
xmlSettings->pushTag("texCoords"); xmlSettings->pushTag("texCoords");

10
src/Application/SettingsLoader.h

@ -20,11 +20,11 @@ class SettingsLoader {
public: public:
static SettingsLoader * instance(); static SettingsLoader * instance();
bool load(SurfaceManager & surfaceManager, MediaServer & mediaServer, string fileName); bool load(SurfaceManager & surfaceManager, MediaServer & mediaServer, std::string fileName);
bool save(SurfaceManager & surfaceManager, string fileName); bool save(SurfaceManager & surfaceManager, std::string fileName);
bool create(string fileName); bool create(std::string fileName);
string getLastLoadedFilename(){ return _lastLoadedFilename; }; std::string getLastLoadedFilename(){ return _lastLoadedFilename; };
private: private:
static SettingsLoader * _instance; static SettingsLoader * _instance;
@ -36,7 +36,7 @@ class SettingsLoader {
BaseSurface * getGridWarpSurface(ofxXmlSettings * xmlSettings); BaseSurface * getGridWarpSurface(ofxXmlSettings * xmlSettings);
BaseSurface * getHexagonSurface(ofxXmlSettings * xmlSettings); BaseSurface * getHexagonSurface(ofxXmlSettings * xmlSettings);
string _lastLoadedFilename; std::string _lastLoadedFilename;
}; };
} // namespace piMapper } // namespace piMapper

4
src/Commands/AddGridColCmd.h

@ -20,8 +20,8 @@ class AddGridColCmd : public BaseUndoCmd {
void undo(); void undo();
private: private:
vector<Vec3> _vertices; std::vector<Vec3> _vertices;
vector<Vec2> _texCoords; std::vector<Vec2> _texCoords;
GridWarpSurface * _surface; GridWarpSurface * _surface;
}; };

4
src/Commands/AddGridRowCmd.h

@ -20,8 +20,8 @@ class AddGridRowCmd : public BaseUndoCmd {
void undo(); void undo();
private: private:
vector <Vec3> _vertices; std::vector<Vec3> _vertices;
vector <Vec2> _texCoords; std::vector<Vec2> _texCoords;
GridWarpSurface * _surface; GridWarpSurface * _surface;
}; };

2
src/Commands/ClearSurfacesCmd.h

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

4
src/Commands/CmdManager.h

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

2
src/Commands/DeselectTexCoordCmd.cpp

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

2
src/Commands/MvAllTexCoordsCmd.h

@ -20,7 +20,7 @@ class MvAllTexCoordsCmd : public BaseUndoCmd {
void undo(); void undo();
private: private:
vector <Vec2> _texCoords; std::vector<Vec2> _texCoords;
BaseSurface * _surface; BaseSurface * _surface;
TextureEditorWidget * _texEditor; TextureEditorWidget * _texEditor;

4
src/Commands/RmGridColCmd.h

@ -20,8 +20,8 @@ class RmGridColCmd : public BaseUndoCmd {
void undo(); void undo();
private: private:
vector <Vec3> _vertices; std::vector<Vec3> _vertices;
vector <Vec2> _texCoords; std::vector<Vec2> _texCoords;
GridWarpSurface * _surface; GridWarpSurface * _surface;
bool _doNotUndo; bool _doNotUndo;

4
src/Commands/RmGridRowCmd.h

@ -20,8 +20,8 @@ class RmGridRowCmd : public BaseUndoCmd {
void undo(); void undo();
private: private:
vector <Vec3> _vertices; std::vector<Vec3> _vertices;
vector <Vec2> _texCoords; std::vector<Vec2> _texCoords;
GridWarpSurface * _surface; GridWarpSurface * _surface;
bool _doNotUndo; bool _doNotUndo;

2
src/Commands/SetNextSourceCmd.cpp

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

4
src/Commands/SetNextSourceCmd.h

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

2
src/Commands/SetSourceCmd.cpp

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

6
src/Commands/SetSourceCmd.h

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

2
src/Commands/StartDragSurfaceCmd.h

@ -16,7 +16,7 @@ class StartDragSurfaceCmd : public BaseUndoCmd {
private: private:
BaseSurface * _surface; BaseSurface * _surface;
vector <Vec3> _previousVertices; std::vector<Vec3> _previousVertices;
}; };

2
src/Gui/Widgets/LayerPanelWidget.cpp

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

10
src/Gui/Widgets/ProjectionEditorWidget.cpp

@ -53,7 +53,7 @@ void ProjectionEditorWidget::mouseDragged(ofMouseEventArgs & args){
Vec2 mousePosition = Vec2(args.x, args.y); Vec2 mousePosition = Vec2(args.x, args.y);
// Collect all vertices of the projection surfaces // Collect all vertices of the projection surfaces
vector<Vec3> allVertices; std::vector<Vec3> allVertices;
for(int i = 0; i < surfaceManager->size(); i++){ for(int i = 0; i < surfaceManager->size(); i++){
BaseSurface * surface = surfaceManager->getSurface(i); BaseSurface * surface = surfaceManager->getSurface(i);
@ -137,7 +137,7 @@ void ProjectionEditorWidget::createJoints(){
return; return;
} }
vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices(); std::vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices();
for(int i = 0; i < vertices.size(); i++){ for(int i = 0; i < vertices.size(); i++){
joints.push_back(new CircleJoint()); joints.push_back(new CircleJoint());
@ -147,7 +147,7 @@ void ProjectionEditorWidget::createJoints(){
void ProjectionEditorWidget::updateJoints(){ void ProjectionEditorWidget::updateJoints(){
if(surfaceManager->getSelectedSurface()){ if(surfaceManager->getSelectedSurface()){
vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices(); std::vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices();
for(int i = 0; i < vertices.size(); i++){ for(int i = 0; i < vertices.size(); i++){
joints[i]->position = Vec2(vertices[i].x, vertices[i].y); joints[i]->position = Vec2(vertices[i].x, vertices[i].y);
@ -197,7 +197,7 @@ CircleJoint * ProjectionEditorWidget::hitTestJoints(Vec2 pos){
return 0; return 0;
} }
vector <CircleJoint *> * ProjectionEditorWidget::getJoints(){ std::vector<CircleJoint *> * ProjectionEditorWidget::getJoints(){
return &joints; return &joints;
} }
@ -212,7 +212,7 @@ void ProjectionEditorWidget::onVertexChanged(int & i){
} }
} }
void ProjectionEditorWidget::onVerticesChanged(vector<Vec3> & vertices){ void ProjectionEditorWidget::onVerticesChanged(std::vector<Vec3> & vertices){
createJoints(); createJoints();
} }

6
src/Gui/Widgets/ProjectionEditorWidget.h

@ -29,17 +29,17 @@ class ProjectionEditorWidget {
void updateVertices(); void updateVertices();
void setSnapDistance(float newSnapDistance); void setSnapDistance(float newSnapDistance);
CircleJoint * hitTestJoints(Vec2 pos); CircleJoint * hitTestJoints(Vec2 pos);
vector <CircleJoint *> * getJoints(); std::vector<CircleJoint *> * getJoints();
void onVertexChanged(int & i); void onVertexChanged(int & i);
void onVerticesChanged(vector<Vec3> & vertices); void onVerticesChanged(std::vector<Vec3> & vertices);
void onSurfaceSelected(int & surfaceIndex); void onSurfaceSelected(int & surfaceIndex);
void onVertexSelected(int & vertexIndex); void onVertexSelected(int & vertexIndex);
void onVertexUnselected(int & vertexIndex); void onVertexUnselected(int & vertexIndex);
private: private:
SurfaceManager * surfaceManager; SurfaceManager * surfaceManager;
vector <CircleJoint *> joints; std::vector<CircleJoint *> joints;
bool bShiftKeyDown; bool bShiftKeyDown;
float fSnapDistance; float fSnapDistance;

19
src/Gui/Widgets/ScaleWidget.cpp

@ -1,4 +1,5 @@
#include "ScaleWidget.h" #include "ScaleWidget.h"
#include "glm/geometric.hpp"
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
@ -57,7 +58,11 @@ void ScaleWidget::draw(){
_line[1].y -= dy; _line[1].y -= dy;
// Continue // 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].x = _line[0].x + (_line[1].x - _line[0].x) * scale;
_line[1].y = _line[0].y + (_line[1].y - _line[0].y) * scale; _line[1].y = _line[0].y + (_line[1].y - _line[0].y) * scale;
@ -128,9 +133,15 @@ void ScaleWidget::onMouseDragged(ofMouseEventArgs & args){
newLine[1].x = args.x; newLine[1].x = args.x;
newLine[1].y = args.y; newLine[1].y = args.y;
_scale = _surfaceManager->getSelectedSurface()->getScale() / #if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
_line[0].distance(_line[1]) * _scale = _surfaceManager->getSelectedSurface()->getScale() /
newLine[0].distance(newLine[1]); _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; _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 // Depending on media count, decide what to load and initialize
if(numImages){ if(numImages){
// Get image names from media server // Get image names from media server
vector <string> imageNames = mediaServer->getImageNames(); std::vector<std::string> imageNames = mediaServer->getImageNames();
imageSelector->setup("Images", imageNames, mediaServer->getImagePaths()); imageSelector->setup("Images", imageNames, mediaServer->getImagePaths());
ofAddListener(imageSelector->onRadioSelected, this, &SourcesEditorWidget::handleImageSelected); ofAddListener(imageSelector->onRadioSelected, this, &SourcesEditorWidget::handleImageSelected);
} }
if(numVideos){ if(numVideos){
vector <string> videoNames = mediaServer->getVideoNames(); std::vector<std::string> videoNames = mediaServer->getVideoNames();
videoSelector->setup("Videos", videoNames, mediaServer->getVideoPaths()); videoSelector->setup("Videos", videoNames, mediaServer->getVideoPaths());
ofAddListener(videoSelector->onRadioSelected, this, &SourcesEditorWidget::handleVideoSelected); ofAddListener(videoSelector->onRadioSelected, this, &SourcesEditorWidget::handleVideoSelected);
} }
if(numFbos){ if(numFbos){
vector <string> fboNames = mediaServer->getFboSourceNames(); std::vector<std::string> fboNames = mediaServer->getFboSourceNames();
fboSelector->setup("FBOs", fboNames, fboNames); fboSelector->setup("FBOs", fboNames, fboNames);
ofAddListener(fboSelector->onRadioSelected, this, &SourcesEditorWidget::handleFboSelected); ofAddListener(fboSelector->onRadioSelected, this, &SourcesEditorWidget::handleFboSelected);
} }
@ -135,7 +135,7 @@ MediaServer * SourcesEditorWidget::getMediaServer(){
return mediaServer; return mediaServer;
} }
void SourcesEditorWidget::selectSourceRadioButton(string & sourcePath){ void SourcesEditorWidget::selectSourceRadioButton(std::string & sourcePath){
if(sourcePath == ""){ if(sourcePath == ""){
ofLogNotice("SourcesEditorWidget") << "Path is empty"; ofLogNotice("SourcesEditorWidget") << "Path is empty";
if(imageSelector->size()){ if(imageSelector->size()){
@ -210,14 +210,14 @@ void SourcesEditorWidget::removeMediaServerListeners(){
ofRemoveListener(mediaServer->onFboSourceUnloaded, this, &SourcesEditorWidget::handleFboSourceUnloaded); 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, _cmdManager->exec(new SetSourceCmd(SourceType::SOURCE_TYPE_IMAGE,
imagePath, imagePath,
surfaceManager->getSelectedSurface(), surfaceManager->getSelectedSurface(),
(SourcesEditorWidget *)this)); (SourcesEditorWidget *)this));
} }
void SourcesEditorWidget::setImageSource(string & imagePath){ void SourcesEditorWidget::setImageSource(std::string & imagePath){
// Unselect selected items // Unselect selected items
videoSelector->unselectAll(); videoSelector->unselectAll();
fboSelector->unselectAll(); fboSelector->unselectAll();
@ -240,14 +240,14 @@ void SourcesEditorWidget::setImageSource(string & imagePath){
surface->setSource(mediaServer->loadImage(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, _cmdManager->exec(new SetSourceCmd(SourceType::SOURCE_TYPE_VIDEO,
videoPath, videoPath,
surfaceManager->getSelectedSurface(), surfaceManager->getSelectedSurface(),
(SourcesEditorWidget *)this)); (SourcesEditorWidget *)this));
} }
void SourcesEditorWidget::setVideoSource(string & videoPath){ void SourcesEditorWidget::setVideoSource(std::string & videoPath){
// Unselect any selected items // Unselect any selected items
fboSelector->unselectAll(); fboSelector->unselectAll();
imageSelector->unselectAll(); imageSelector->unselectAll();
@ -270,14 +270,14 @@ void SourcesEditorWidget::setVideoSource(string & videoPath){
surface->setSource(mediaServer->loadVideo(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, _cmdManager->exec(new SetSourceCmd(SourceType::SOURCE_TYPE_FBO,
fboName, fboName,
surfaceManager->getSelectedSurface(), surfaceManager->getSelectedSurface(),
(SourcesEditorWidget *)this)); (SourcesEditorWidget *)this));
} }
void SourcesEditorWidget::setFboSource(string & fboName){ void SourcesEditorWidget::setFboSource(std::string & fboName){
videoSelector->unselectAll(); videoSelector->unselectAll();
imageSelector->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. // 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") ofLogNotice("SourcesEditorWidget::handleImageAdded")
<< "Image path: " << "Image path: "
<< path; << path;
} }
void SourcesEditorWidget::handleImageRemoved(string & path){} void SourcesEditorWidget::handleImageRemoved(std::string & path){}
void SourcesEditorWidget::handleVideoAdded(string & path){} void SourcesEditorWidget::handleVideoAdded(std::string & path){}
void SourcesEditorWidget::handleVideoRemoved(string & path){} void SourcesEditorWidget::handleVideoRemoved(std::string & path){}
void SourcesEditorWidget::handleImageLoaded(string & path){} void SourcesEditorWidget::handleImageLoaded(std::string & path){}
void SourcesEditorWidget::handleImageUnloaded(string & path){} void SourcesEditorWidget::handleImageUnloaded(std::string & path){}
void SourcesEditorWidget::handleFboSourceAdded(string & name){} void SourcesEditorWidget::handleFboSourceAdded(std::string & name){}
void SourcesEditorWidget::handleFboSourceRemoved(string & name){} void SourcesEditorWidget::handleFboSourceRemoved(std::string & name){}
void SourcesEditorWidget::handleFboSourceLoaded(string & name){} void SourcesEditorWidget::handleFboSourceLoaded(std::string & name){}
void SourcesEditorWidget::handleFboSourceUnloaded(string & name){} void SourcesEditorWidget::handleFboSourceUnloaded(std::string & name){}
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

38
src/Gui/Widgets/SourcesEditorWidget.h

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

10
src/Gui/Widgets/TextureEditorWidget.cpp

@ -44,7 +44,7 @@ void TextureEditorWidget::update(){
if(surface->getType() == SurfaceType::GRID_WARP_SURFACE){ if(surface->getType() == SurfaceType::GRID_WARP_SURFACE){
GridWarpSurface * s = (GridWarpSurface *)surface; GridWarpSurface * s = (GridWarpSurface *)surface;
vector<Vec2> texCoords = surface->getTexCoords(); std::vector<Vec2> texCoords = surface->getTexCoords();
Vec2 textureSize = Vec2( Vec2 textureSize = Vec2(
surface->getSource()->getTexture()->getWidth(), surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight()); surface->getSource()->getTexture()->getHeight());
@ -134,7 +134,7 @@ void TextureEditorWidget::createJoints(){
} }
clearJoints(); clearJoints();
vector<Vec2> texCoords = surface->getTexCoords(); std::vector<Vec2> texCoords = surface->getTexCoords();
if(surface->getSource()->getTexture()->isAllocated()){ if(surface->getSource()->getTexture()->isAllocated()){
_pollCreateJoints = false; _pollCreateJoints = false;
@ -148,7 +148,7 @@ void TextureEditorWidget::createJoints(){
surface->getSource()->getTexture()->getHeight()); surface->getSource()->getTexture()->getHeight());
// Select joints depending on the surface type // Select joints depending on the surface type
vector<Vec2> tc; std::vector<Vec2> tc;
if(surface->getType() == SurfaceType::TRIANGLE_SURFACE){ if(surface->getType() == SurfaceType::TRIANGLE_SURFACE){
tc = texCoords; tc = texCoords;
@ -282,7 +282,7 @@ void TextureEditorWidget::moveTexCoords(Vec2 by){
return; return;
} }
vector<Vec2> texCoords = surface->getTexCoords(); std::vector<Vec2> texCoords = surface->getTexCoords();
Vec2 textureSize = Vec2( Vec2 textureSize = Vec2(
surface->getSource()->getTexture()->getWidth(), surface->getSource()->getTexture()->getWidth(),
surface->getSource()->getTexture()->getHeight()); surface->getSource()->getTexture()->getHeight());
@ -407,7 +407,7 @@ CircleJoint * TextureEditorWidget::hitTestJoints(Vec2 pos){
return 0; return 0;
} }
vector <CircleJoint *> & TextureEditorWidget::getJoints(){ std::vector<CircleJoint *> & TextureEditorWidget::getJoints(){
return joints; return joints;
} }

4
src/Gui/Widgets/TextureEditorWidget.h

@ -46,11 +46,11 @@ class TextureEditorWidget : public GuiBaseWidget {
void moveSelection(Vec2 by); void moveSelection(Vec2 by);
void constrainJointsToQuad(int selectedJointIndex); void constrainJointsToQuad(int selectedJointIndex);
CircleJoint * hitTestJoints(Vec2 pos); CircleJoint * hitTestJoints(Vec2 pos);
vector <CircleJoint *> & getJoints(); std::vector<CircleJoint *> & getJoints();
private: private:
BaseSurface * surface; BaseSurface * surface;
vector <CircleJoint *> joints; std::vector<CircleJoint *> joints;
bool bShiftKeyDown; bool bShiftKeyDown;
bool _pollCreateJoints; bool _pollCreateJoints;

2
src/Gui/Widgets/TextureHighlightWidget.h

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

2
src/Info/Info.cpp

@ -51,7 +51,7 @@ void Info::toggle(){
_visible = !_visible; _visible = !_visible;
} }
void Info::setText(string text){ void Info::setText(std::string text){
_text = text; _text = text;
} }

4
src/Info/Info.h

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

13
src/MediaServer/DirectoryWatcher.cpp

@ -3,7 +3,7 @@
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
DirectoryWatcher::DirectoryWatcher(string path, int watcherMediaType){ DirectoryWatcher::DirectoryWatcher(std::string path, int watcherMediaType){
directoryPath = path; directoryPath = path;
_mediaType = watcherMediaType; _mediaType = watcherMediaType;
@ -41,11 +41,12 @@ DirectoryWatcher::DirectoryWatcher(string path, int watcherMediaType){
} }
DirectoryWatcher::~DirectoryWatcher() { DirectoryWatcher::~DirectoryWatcher() {
endWatch(); if(isThreadRunning()){
// waitForThread(false); stopThread();
}
} }
vector <string> & DirectoryWatcher::getFilePaths(){ std::vector<std::string> & DirectoryWatcher::getFilePaths(){
return _filePaths; return _filePaths;
} }
@ -58,10 +59,6 @@ void DirectoryWatcher::beginWatch(int intervalInMillis) {
startThread(); startThread();
} }
void DirectoryWatcher::endWatch() {
stopThread();
}
void DirectoryWatcher::threadedFunction() { void DirectoryWatcher::threadedFunction() {
while (isThreadRunning()) { while (isThreadRunning()) {

9
src/MediaServer/DirectoryWatcher.h

@ -8,13 +8,12 @@ namespace piMapper {
class DirectoryWatcher : public ofThread { class DirectoryWatcher : public ofThread {
public: public:
DirectoryWatcher(string path, int watcherMediaType); DirectoryWatcher(std::string path, int watcherMediaType);
virtual ~DirectoryWatcher(); virtual ~DirectoryWatcher();
vector<string> &getFilePaths(); std::vector<std::string> &getFilePaths();
int getMediaType(); int getMediaType();
void beginWatch(int intervalInMillis = 5000); void beginWatch(int intervalInMillis = 5000);
void endWatch();
void threadedFunction(); void threadedFunction();
/** /**
@ -30,7 +29,7 @@ class DirectoryWatcher : public ofThread {
private: private:
ofDirectory _directory; ofDirectory _directory;
vector<string> _filePaths; std::vector<std::string> _filePaths;
std::string directoryPath; std::string directoryPath;
int _mediaType; int _mediaType;
@ -39,4 +38,4 @@ class DirectoryWatcher : public ofThread {
}; };
} // namespace piMapper } // namespace piMapper
} // namespace ofx } // namespace ofx

90
src/MediaServer/MediaServer.cpp

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

68
src/MediaServer/MediaServer.h

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

14
src/Sources/BaseSource.cpp

@ -4,7 +4,7 @@ namespace ofx {
namespace piMapper { namespace piMapper {
BaseSource::BaseSource(){ BaseSource::BaseSource(){
//cout << "BaseSource" << endl; //std::cout << "BaseSource" << std::endl;
init(); init();
} }
@ -19,7 +19,7 @@ ofTexture * BaseSource::getTexture(){
return texture; return texture;
} }
string & BaseSource::getName(){ std::string & BaseSource::getName(){
return name; return name;
} }
@ -35,7 +35,7 @@ SourceType BaseSource::getType(){
return type; return type;
} }
string & BaseSource::getPath(){ std::string & BaseSource::getPath(){
return path; return path;
} }
@ -49,11 +49,11 @@ void BaseSource::init(){
referenceCount = 1; // We have one instance on init referenceCount = 1; // We have one instance on init
} }
void BaseSource::setNameFromPath(string & fullPath){ void BaseSource::setNameFromPath(std::string & fullPath){
vector <string> pathParts; std::vector<std::string> pathParts;
//cout << "fullPath: " << fullPath << endl; //std::cout << "fullPath: " << fullPath << std::endl;
pathParts = ofSplitString(fullPath, "/"); // Maybe on win "/" is "\", have to test 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]; 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 * newTexture); // Only one clean way of passing the texture
~BaseSource(); ~BaseSource();
ofTexture * getTexture(); ofTexture * getTexture();
string & getName(); std::string & getName();
bool isLoadable(); // Maybe the loading features shoud go to a derrived class bool isLoadable(); // Maybe the loading features shoud go to a derrived class
bool isLoaded(); // as BaseSourceLoadable bool isLoaded(); // as BaseSourceLoadable
SourceType getType(); SourceType getType();
string & getPath(); std::string & getPath();
virtual void clear(){} virtual void clear(){}
virtual void togglePause(){} virtual void togglePause(){}
@ -31,10 +31,10 @@ class BaseSource {
void init(); void init();
protected: protected:
void setNameFromPath(string & fullPath); void setNameFromPath(std::string & fullPath);
ofTexture * texture; ofTexture * texture;
string name; std::string name;
string path; // This is set only if loadable is true 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 loadable; // If the source can be loaded from disk like image and video
bool loaded; // Is the source loaded? bool loaded; // Is the source loaded?
SourceType type; SourceType type;

2
src/Sources/ImageSource.cpp

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

4
src/Sources/ImageSource.h

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

4
src/Sources/OMXPlayerCache.cpp

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

6
src/Sources/OMXPlayerCache.h

@ -14,12 +14,12 @@ class OMXPlayerCache {
public: public:
static OMXPlayerCache * instance(); static OMXPlayerCache * instance();
ofxOMXPlayer * load(string moviePath); ofxOMXPlayer * load(std::string moviePath);
void unload(string moviePath); void unload(std::string moviePath);
private: private:
static OMXPlayerCache * _instance; static OMXPlayerCache * _instance;
map <string, ofxOMXPlayer *> _players; map <std::string, ofxOMXPlayer *> _players;
}; };

8
src/Sources/SourceTypeHelper.h

@ -13,7 +13,7 @@ namespace piMapper {
class SourceTypeHelper { class SourceTypeHelper {
public: public:
static string GetSourceTypeHelperName(SourceType sourceTypeEnum){ static std::string GetSourceTypeHelperName(SourceType sourceTypeEnum){
if(sourceTypeEnum == SOURCE_TYPE_IMAGE){ if(sourceTypeEnum == SOURCE_TYPE_IMAGE){
return SOURCE_TYPE_NAME_IMAGE; return SOURCE_TYPE_NAME_IMAGE;
}else if(sourceTypeEnum == SOURCE_TYPE_VIDEO){ }else if(sourceTypeEnum == SOURCE_TYPE_VIDEO){
@ -23,14 +23,14 @@ class SourceTypeHelper {
}else if(sourceTypeEnum == SOURCE_TYPE_FBO){ }else if(sourceTypeEnum == SOURCE_TYPE_FBO){
return SOURCE_TYPE_NAME_FBO; return SOURCE_TYPE_NAME_FBO;
}else{ }else{
stringstream ss; std::stringstream ss;
ss << "Invalid source type: " << sourceTypeEnum; ss << "Invalid source type: " << sourceTypeEnum;
ofLogFatalError("SourceTypeHelper") << ss.str(); ofLogFatalError("SourceTypeHelper") << ss.str();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
static SourceType GetSourceTypeHelperEnum(string sourceTypeName){ static SourceType GetSourceTypeHelperEnum(std::string sourceTypeName){
if(sourceTypeName == SOURCE_TYPE_NAME_IMAGE){ if(sourceTypeName == SOURCE_TYPE_NAME_IMAGE){
return SOURCE_TYPE_IMAGE; return SOURCE_TYPE_IMAGE;
}else if(sourceTypeName == SOURCE_TYPE_NAME_VIDEO){ }else if(sourceTypeName == SOURCE_TYPE_NAME_VIDEO){
@ -40,7 +40,7 @@ class SourceTypeHelper {
}else if(sourceTypeName == SOURCE_TYPE_NAME_FBO){ }else if(sourceTypeName == SOURCE_TYPE_NAME_FBO){
return SOURCE_TYPE_FBO; return SOURCE_TYPE_FBO;
}else{ }else{
stringstream ss; std::stringstream ss;
ss << "Invalid source type name: " << sourceTypeName; ss << "Invalid source type name: " << sourceTypeName;
ofLogFatalError("SourceTypeHelper") << ss.str(); ofLogFatalError("SourceTypeHelper") << ss.str();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

2
src/Sources/VideoSource.cpp

@ -18,7 +18,7 @@ VideoSource::VideoSource(){
#endif #endif
} }
void VideoSource::loadVideo(string & filePath){ void VideoSource::loadVideo(std::string & filePath){
path = filePath; path = filePath;
setNameFromPath(filePath); setNameFromPath(filePath);
#ifdef TARGET_RASPBERRY_PI #ifdef TARGET_RASPBERRY_PI

4
src/Sources/VideoSource.h

@ -22,8 +22,8 @@ class VideoSource : public BaseSource {
VideoSource(); VideoSource();
string & getPath(); std::string & getPath();
void loadVideo(string & path); void loadVideo(std::string & path);
void clear(); void clear();
void togglePause(); void togglePause();

28
src/Sources/magSlideShowSource.cpp

@ -26,9 +26,10 @@ magSlideShowSource::magSlideShowSource() {
} }
} }
magSlideShowSource::~magSlideShowSource() { magSlideShowSource::~magSlideShowSource(){
directoryWatcher->endWatch(); if(directoryWatcher != 0){
delete directoryWatcher; delete directoryWatcher;
}
} }
bool magSlideShowSource::initialize(magSlideShowSource::Settings settings) { bool magSlideShowSource::initialize(magSlideShowSource::Settings settings) {
@ -168,20 +169,18 @@ bool magSlideShowSource::createFromFolderContents(std::string path) {
return false; return false;
} }
auto sortedDir = dir.getSorted(); ofDirectory sortedDir = dir.getSorted();
auto files = sortedDir.getFiles(); std::vector<ofFile> files = sortedDir.getFiles();
if (files.size() < 1) if (files.size() < 1){
{
ofLogError("magSlideShowSource::createFromFolderContents") << "Folder " << dir.getAbsolutePath() << " is empty"; ofLogError("magSlideShowSource::createFromFolderContents") << "Folder " << dir.getAbsolutePath() << " is empty";
return false; return false;
} }
ofImage tempImage; ofImage tempImage;
for (auto &file : files) for(ofFile &file : files){
{ if (tempImage.load(file.getFileName())){
if (tempImage.load(file))
{
// make a new image slide // make a new image slide
auto slide = std::make_shared<magImageSlide>(); auto slide = std::make_shared<magImageSlide>();
slide->setup(tempImage); slide->setup(tempImage);
@ -189,9 +188,7 @@ bool magSlideShowSource::createFromFolderContents(std::string path) {
slide->setTransitionDuration(static_cast<u_int64_t>(settings.transitionDuration*1000)); slide->setTransitionDuration(static_cast<u_int64_t>(settings.transitionDuration*1000));
// if (settings.transitionName == "") // if (settings.transitionName == "")
addSlide(slide); addSlide(slide);
} }else{
else
{
auto ext = ofToLower(file.getExtension()); auto ext = ofToLower(file.getExtension());
static std::vector<std::string> movieExtensions = { static std::vector<std::string> movieExtensions = {
@ -388,8 +385,7 @@ void magSlideShowSource::addSlide(std::shared_ptr<magSlide> slide) {
} }
void magSlideShowSource::play() { void magSlideShowSource::play() {
if (!isPlaying) if (!isPlaying && slides.size()){
{
runningTime = 0; runningTime = 0;
lastTime = ofGetElapsedTimeMillis(); lastTime = ofGetElapsedTimeMillis();
isPlaying = true; isPlaying = true;

7
src/Sources/magSlideShowSource.h

@ -13,7 +13,6 @@
class magSlide; class magSlide;
class magSlideShowSource : public ofx::piMapper::FboSource { class magSlideShowSource : public ofx::piMapper::FboSource {
public: public:
magSlideShowSource(); magSlideShowSource();
@ -157,9 +156,9 @@ class magSlideShowSource : public ofx::piMapper::FboSource {
int currentSlideIndex = 0; int currentSlideIndex = 0;
int direction = 1; int direction = 1;
int loopCount = 0; int loopCount = 0;
ofx::piMapper::DirectoryWatcher* directoryWatcher; ofx::piMapper::DirectoryWatcher * directoryWatcher;
void fileAddedListener(const void *sender); void fileAddedListener(const void * sender);
void fileRemovedListener(const void *sender); void fileRemovedListener(const void * sender);
bool doInit; bool doInit;
bool doPlayNextSlide = false; bool doPlayNextSlide = false;
}; };

2
src/Sources/magSlideTransition.h

@ -76,7 +76,7 @@ public:
*/ */
float getNormalizedTime(); float getNormalizedTime();
string const &getName() const std::string const &getName() const
{ {
return name; return name;
} }

2
src/Sources/magSlideTransitionFactory.h

@ -16,7 +16,7 @@ class magSlideTransitionFactory
public: public:
static magSlideTransitionFactory* instance(); static magSlideTransitionFactory* instance();
std::shared_ptr<magSlideTransition> createTransition(string transitionName, std::shared_ptr<magSlideTransition> createTransition(std::string transitionName,
std::shared_ptr<magSlide> slide, std::shared_ptr<magSlide> slide,
ofParameterGroup &group, ofParameterGroup &group,
u_int64_t duration); u_int64_t duration);

2
src/Surfaces/BaseSurface.cpp

@ -118,7 +118,7 @@ void BaseSurface::scaleTo(float scale){
_scale = scale; _scale = scale;
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }

10
src/Surfaces/BaseSurface.h

@ -20,16 +20,16 @@ class BaseSurface {
virtual void setup() = 0; virtual void setup() = 0;
virtual void draw() = 0; virtual void draw() = 0;
virtual void setVertex(int index, Vec3 p) = 0; virtual void setVertex(int index, Vec3 p) = 0;
virtual void setVertices(vector<Vec3> v) = 0; virtual void setVertices(std::vector<Vec3> v) = 0;
virtual void setTexCoord(int index, Vec2 t) = 0; virtual void setTexCoord(int index, Vec2 t) = 0;
virtual void setTexCoords(vector<Vec2> t) = 0; virtual void setTexCoords(std::vector<Vec2> t) = 0;
virtual void moveBy(Vec3 v) = 0; virtual void moveBy(Vec3 v) = 0;
virtual int getType() = 0; virtual int getType() = 0;
virtual bool hitTest(Vec2 p) = 0; virtual bool hitTest(Vec2 p) = 0;
virtual ofPolyline getHitArea() = 0; virtual ofPolyline getHitArea() = 0;
virtual ofPolyline getTextureHitArea() = 0; virtual ofPolyline getTextureHitArea() = 0;
virtual vector<Vec3> getVertices() = 0; virtual std::vector<Vec3> getVertices() = 0;
virtual vector<Vec2> getTexCoords() = 0; virtual std::vector<Vec2> getTexCoords() = 0;
virtual BaseSurface * clone() = 0; virtual BaseSurface * clone() = 0;
void drawTexture(Vec3 position); void drawTexture(Vec3 position);
@ -46,7 +46,7 @@ class BaseSurface {
ofMesh & getMesh(); ofMesh & getMesh();
ofRectangle & getBoundingBox(); ofRectangle & getBoundingBox();
ofEvent<vector<Vec3>> verticesChangedEvent; ofEvent<std::vector<Vec3>> verticesChangedEvent;
ofEvent<int> vertexChangedEvent; ofEvent<int> vertexChangedEvent;
protected: protected:

12
src/Surfaces/CircleSurface.h

@ -38,17 +38,17 @@ class CircleSurface : public QuadSurface {
bool updateMask; bool updateMask;
bool maskIsReady; bool maskIsReady;
// string glESFragmentShader; // std::string glESFragmentShader;
// string glESVertexShader; // std::string glESVertexShader;
// //
// string gl2FragmentShader; // std::string gl2FragmentShader;
// string gl2VertexShader; // std::string gl2VertexShader;
ofMesh maskMesh; ofMesh maskMesh;
// TODO: gl3 Shaders // TODO: gl3 Shaders
// string gl3VertexShader; // std::string gl3VertexShader;
// string gl3FragmentShader; // std::string gl3FragmentShader;
private: private:
std::vector<Vec2> defaultTexCoords; std::vector<Vec2> defaultTexCoords;

21
src/Surfaces/GridWarpSurface.cpp

@ -36,7 +36,7 @@ void GridWarpSurface::moveBy(Vec3 v){
} }
setMoved(true); setMoved(true);
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }
@ -80,7 +80,7 @@ bool GridWarpSurface::hitTest(Vec2 p){
pl.addVertex(mesh.getVertex(d)); pl.addVertex(mesh.getVertex(d));
pl.close(); pl.close();
if(pl.inside(p.toOf())){ if(pl.inside(p.x, p.y)){
return true; return true;
} }
} }
@ -150,7 +150,7 @@ void GridWarpSurface::setVertex(int index, Vec3 vert){
ofNotifyEvent(vertexChangedEvent, index, this); ofNotifyEvent(vertexChangedEvent, index, this);
} }
void GridWarpSurface::setVertices(vector<Vec3> v){ void GridWarpSurface::setVertices(std::vector<Vec3> v){
if(v.size() != mesh.getVertices().size()){ if(v.size() != mesh.getVertices().size()){
throw runtime_error("Wrong number of vertices"); throw runtime_error("Wrong number of vertices");
} }
@ -159,7 +159,7 @@ void GridWarpSurface::setVertices(vector<Vec3> v){
mesh.setVertex(i, v[i].toOf()); mesh.setVertex(i, v[i].toOf());
} }
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }
@ -170,7 +170,7 @@ void GridWarpSurface::setTexCoord(int index, Vec2 t){
mesh.setTexCoord(index, t.toOf()); mesh.setTexCoord(index, t.toOf());
} }
void GridWarpSurface::setTexCoords(vector<Vec2> t){ void GridWarpSurface::setTexCoords(std::vector<Vec2> t){
if(t.size() != mesh.getVertices().size()){ if(t.size() != mesh.getVertices().size()){
throw runtime_error("Wrong number of texture coordinates"); throw runtime_error("Wrong number of texture coordinates");
} }
@ -180,11 +180,11 @@ void GridWarpSurface::setTexCoords(vector<Vec2> t){
} }
vector<Vec3> GridWarpSurface::getVertices(){ std::vector<Vec3> GridWarpSurface::getVertices(){
return Vec3::fromOf(mesh.getVertices()); return Vec3::fromOf(mesh.getVertices());
} }
vector<Vec2> GridWarpSurface::getTexCoords(){ std::vector<Vec2> GridWarpSurface::getTexCoords(){
return Vec2::fromOf(mesh.getTexCoords()); return Vec2::fromOf(mesh.getTexCoords());
} }
@ -200,9 +200,10 @@ void GridWarpSurface::createGridMesh(){
// Add vertices for each col and row // Add vertices for each col and row
for(int iy = 0; iy <= _gridRows; ++iy){ for(int iy = 0; iy <= _gridRows; ++iy){
for(int ix = 0; ix <= _gridCols; ++ix){ for(int ix = 0; ix <= _gridCols; ++ix){
mesh.addVertex(Vec2( mesh.addVertex(Vec3(
margin + (vertexDistanceX * (float)ix), margin + (vertexDistanceX * (float)ix),
margin + (vertexDistanceY * (float)iy)).toOf()); margin + (vertexDistanceY * (float)iy),
0.0f).toOf());
} }
} }
@ -230,7 +231,7 @@ void GridWarpSurface::createGridMesh(){
} }
} }
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }

8
src/Surfaces/GridWarpSurface.h

@ -30,11 +30,11 @@ class GridWarpSurface : public BaseSurface {
ofPolyline getTextureHitArea(); ofPolyline getTextureHitArea();
void setVertex(int index, Vec3 p); void setVertex(int index, Vec3 p);
void setVertices(vector<Vec3> v); void setVertices(std::vector<Vec3> v);
void setTexCoord(int index, Vec2 t); void setTexCoord(int index, Vec2 t);
void setTexCoords(vector<Vec2> t); void setTexCoords(std::vector<Vec2> t);
vector<Vec3> getVertices(); std::vector<Vec3> getVertices();
vector<Vec2> getTexCoords(); std::vector<Vec2> getTexCoords();
void createGridMesh(); void createGridMesh();

26
src/Surfaces/HexagonSurface.cpp

@ -11,7 +11,7 @@ void HexagonSurface::setup(){
// Create 6 + 1 points for the hexagon surface. // Create 6 + 1 points for the hexagon surface.
vector <Vec3> verts; std::vector<Vec3> verts;
verts.resize(7); verts.resize(7);
// Start with the center. // Start with the center.
@ -26,7 +26,7 @@ void HexagonSurface::setup(){
verts[6] = Vec3(0, (float)ofGetHeight() / 2.0f, 0.0f); verts[6] = Vec3(0, (float)ofGetHeight() / 2.0f, 0.0f);
// No create the texture coordinates. // No create the texture coordinates.
vector <Vec2> coords; std::vector<Vec2> coords;
coords.resize(7); coords.resize(7);
// Start with center. // Start with center.
@ -45,8 +45,8 @@ void HexagonSurface::setup(){
} }
void HexagonSurface::setup( void HexagonSurface::setup(
vector <Vec3> & verts, std::vector<Vec3> & verts,
vector <Vec2> & coords, std::vector<Vec2> & coords,
BaseSource * newSource){ BaseSource * newSource){
// Assign texture // Assign texture
@ -105,7 +105,7 @@ void HexagonSurface::draw(){
void HexagonSurface::setVertex(int index, Vec3 p){ void HexagonSurface::setVertex(int index, Vec3 p){
if(index >= mesh.getVertices().size()){ if(index >= mesh.getVertices().size()){
ofLog() << "Vertex with this index does not exist: " << index << endl; ofLog() << "Vertex with this index does not exist: " << index << std::endl;
return; return;
} }
@ -113,7 +113,7 @@ void HexagonSurface::setVertex(int index, Vec3 p){
ofNotifyEvent(vertexChangedEvent, index, this); ofNotifyEvent(vertexChangedEvent, index, this);
} }
void HexagonSurface::setVertices(vector<Vec3> v){ void HexagonSurface::setVertices(std::vector<Vec3> v){
if(v.size() != mesh.getVertices().size()){ if(v.size() != mesh.getVertices().size()){
throw runtime_error("Wrong number of vertices"); throw runtime_error("Wrong number of vertices");
} }
@ -122,21 +122,21 @@ void HexagonSurface::setVertices(vector<Vec3> v){
mesh.setVertex(i, v[i].toOf()); mesh.setVertex(i, v[i].toOf());
} }
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }
void HexagonSurface::setTexCoord(int index, Vec2 t){ void HexagonSurface::setTexCoord(int index, Vec2 t){
if(index >= mesh.getTexCoords().size()){ if(index >= mesh.getTexCoords().size()){
ofLog() << "Texture coordinate with this index does not exist: " << index ofLog() << "Texture coordinate with this index does not exist: " << index
<< endl; << std::endl;
return; return;
} }
mesh.setTexCoord(index, t.toOf()); mesh.setTexCoord(index, t.toOf());
} }
void HexagonSurface::setTexCoords(vector<Vec2> t){ void HexagonSurface::setTexCoords(std::vector<Vec2> t){
if(t.size() != mesh.getTexCoords().size()){ if(t.size() != mesh.getTexCoords().size()){
throw runtime_error("Wrong number of texture coordinates"); throw runtime_error("Wrong number of texture coordinates");
} }
@ -152,7 +152,7 @@ void HexagonSurface::moveBy(Vec3 v){
} }
setMoved(true); setMoved(true);
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }
@ -172,7 +172,7 @@ bool HexagonSurface::hitTest(Vec2 p){
Vec3 HexagonSurface::getVertex(int index){ Vec3 HexagonSurface::getVertex(int index){
if(index > 2){ if(index > 2){
ofLog() << "Vertex with this index does not exist: " << index << endl; ofLog() << "Vertex with this index does not exist: " << index << std::endl;
throw runtime_error("Vertex index out of bounds."); throw runtime_error("Vertex index out of bounds.");
} }
@ -217,11 +217,11 @@ ofPolyline HexagonSurface::getTextureHitArea(){
return line; return line;
} }
vector<Vec3> HexagonSurface::getVertices(){ std::vector<Vec3> HexagonSurface::getVertices(){
return Vec3::fromOf(mesh.getVertices()); return Vec3::fromOf(mesh.getVertices());
} }
vector<Vec2> HexagonSurface::getTexCoords(){ std::vector<Vec2> HexagonSurface::getTexCoords(){
return Vec2::fromOf(mesh.getTexCoords()); return Vec2::fromOf(mesh.getTexCoords());
} }

12
src/Surfaces/HexagonSurface.h

@ -17,14 +17,14 @@ class HexagonSurface : public BaseSurface {
void setup(); void setup();
void setup( void setup(
vector <Vec3> & verts, std::vector<Vec3> & verts,
vector <Vec2> & coords, std::vector<Vec2> & coords,
BaseSource * newSource); BaseSource * newSource);
void draw(); void draw();
void setVertex(int index, Vec3 p); void setVertex(int index, Vec3 p);
void setVertices(vector<Vec3> v); void setVertices(std::vector<Vec3> v);
void setTexCoord(int index, Vec2 t); void setTexCoord(int index, Vec2 t);
void setTexCoords(vector<Vec2> t); void setTexCoords(std::vector<Vec2> t);
void moveBy(Vec3 v); void moveBy(Vec3 v);
int getType(); int getType();
@ -33,8 +33,8 @@ class HexagonSurface : public BaseSurface {
Vec2 getTexCoord(int index); Vec2 getTexCoord(int index);
ofPolyline getHitArea(); ofPolyline getHitArea();
ofPolyline getTextureHitArea(); ofPolyline getTextureHitArea();
vector<Vec3> getVertices(); std::vector<Vec3> getVertices();
vector<Vec2> getTexCoords(); std::vector<Vec2> getTexCoords();
BaseSurface * clone(); BaseSurface * clone();
}; };

20
src/Surfaces/QuadSurface.cpp

@ -9,7 +9,7 @@ QuadSurface::QuadSurface(){
} }
QuadSurface::~QuadSurface(){ QuadSurface::~QuadSurface(){
cout << "QuadSurface destructor." << endl; std::cout << "QuadSurface destructor." << std::endl;
} }
void QuadSurface::setup(){ void QuadSurface::setup(){
@ -112,7 +112,7 @@ void QuadSurface::draw(){
void QuadSurface::setVertex(int index, Vec3 p){ void QuadSurface::setVertex(int index, Vec3 p){
if(index > 3){ if(index > 3){
ofLog() << "Vertex with this index does not exist: " << index << endl; ofLog() << "Vertex with this index does not exist: " << index << std::endl;
return; return;
} }
@ -120,7 +120,7 @@ void QuadSurface::setVertex(int index, Vec3 p){
ofNotifyEvent(vertexChangedEvent, index, this); ofNotifyEvent(vertexChangedEvent, index, this);
} }
void QuadSurface::setVertices(vector<Vec3> v){ void QuadSurface::setVertices(std::vector<Vec3> v){
if(v.size() != 4){ if(v.size() != 4){
throw runtime_error("Wrong number of vertices"); throw runtime_error("Wrong number of vertices");
} }
@ -129,21 +129,21 @@ void QuadSurface::setVertices(vector<Vec3> v){
mesh.setVertex(i, v[i].toOf()); mesh.setVertex(i, v[i].toOf());
} }
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }
void QuadSurface::setTexCoord(int index, Vec2 t){ void QuadSurface::setTexCoord(int index, Vec2 t){
if(index > 3){ if(index > 3){
ofLog() << "Texture coordinate with this index does not exist: " << index ofLog() << "Texture coordinate with this index does not exist: " << index
<< endl; << std::endl;
return; return;
} }
mesh.setTexCoord(index, t.toOf()); mesh.setTexCoord(index, t.toOf());
} }
void QuadSurface::setTexCoords(vector<Vec2> t){ void QuadSurface::setTexCoords(std::vector<Vec2> t){
if(t.size() != 4){ if(t.size() != 4){
throw runtime_error("Wrong number of vertices"); throw runtime_error("Wrong number of vertices");
} }
@ -158,7 +158,7 @@ void QuadSurface::moveBy(Vec3 v){
} }
setMoved(true); setMoved(true);
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }
@ -178,7 +178,7 @@ bool QuadSurface::hitTest(Vec2 p){
Vec3 QuadSurface::getVertex(int index){ Vec3 QuadSurface::getVertex(int index){
if(index > 3){ if(index > 3){
ofLog() << "Vertex with this index does not exist: " << index << endl; ofLog() << "Vertex with this index does not exist: " << index << std::endl;
throw runtime_error("Vertex index out of bounds."); throw runtime_error("Vertex index out of bounds.");
} }
@ -223,11 +223,11 @@ ofPolyline QuadSurface::getTextureHitArea(){
return line; return line;
} }
vector<Vec3> QuadSurface::getVertices(){ std::vector<Vec3> QuadSurface::getVertices(){
return Vec3::fromOf(mesh.getVertices()); return Vec3::fromOf(mesh.getVertices());
} }
vector<Vec2> QuadSurface::getTexCoords(){ std::vector<Vec2> QuadSurface::getTexCoords(){
return Vec2::fromOf(mesh.getTexCoords()); return Vec2::fromOf(mesh.getTexCoords());
} }

8
src/Surfaces/QuadSurface.h

@ -22,9 +22,9 @@ class QuadSurface : public BaseSurface {
BaseSource * newSource); BaseSource * newSource);
void draw(); void draw();
void setVertex(int index, Vec3 p); void setVertex(int index, Vec3 p);
void setVertices(vector<Vec3> v); void setVertices(std::vector<Vec3> v);
void setTexCoord(int index, Vec2 t); void setTexCoord(int index, Vec2 t);
void setTexCoords(vector<Vec2> t); void setTexCoords(std::vector<Vec2> t);
void moveBy(Vec3 v); void moveBy(Vec3 v);
int getType(); int getType();
@ -33,8 +33,8 @@ class QuadSurface : public BaseSurface {
Vec2 getTexCoord(int index); Vec2 getTexCoord(int index);
ofPolyline getHitArea(); ofPolyline getHitArea();
ofPolyline getTextureHitArea(); ofPolyline getTextureHitArea();
vector<Vec3> getVertices(); std::vector<Vec3> getVertices();
vector<Vec2> getTexCoords(); std::vector<Vec2> getTexCoords();
void setPerspectiveWarping(bool b); void setPerspectiveWarping(bool b);
bool getPerspectiveWarping(); bool getPerspectiveWarping();

8
src/Surfaces/SurfaceFactory.cpp

@ -29,13 +29,13 @@ BaseSurface * SurfaceFactory::createSurface(SurfaceType type){
} }
TriangleSurface * SurfaceFactory::createTriangleSurface(){ TriangleSurface * SurfaceFactory::createTriangleSurface(){
vector <Vec3> vertices; std::vector<Vec3> vertices;
float margin = 50.0f; float margin = 50.0f;
vertices.push_back(Vec3((float)ofGetWidth() / 2.0f, margin, 0.0f)); vertices.push_back(Vec3((float)ofGetWidth() / 2.0f, margin, 0.0f));
vertices.push_back(Vec3((float)ofGetWidth() - margin, (float)ofGetHeight() - margin, 0.0f)); vertices.push_back(Vec3((float)ofGetWidth() - margin, (float)ofGetHeight() - margin, 0.0f));
vertices.push_back(Vec3(margin, (float)ofGetHeight() - margin, 0.0f)); vertices.push_back(Vec3(margin, (float)ofGetHeight() - margin, 0.0f));
vector <Vec2> texCoords; std::vector<Vec2> texCoords;
texCoords.push_back(Vec2(0.5f, 0.0f)); texCoords.push_back(Vec2(0.5f, 0.0f));
texCoords.push_back(Vec2(1.0f, 1.0f)); texCoords.push_back(Vec2(1.0f, 1.0f));
texCoords.push_back(Vec2(0.0f, 1.0f)); texCoords.push_back(Vec2(0.0f, 1.0f));
@ -51,14 +51,14 @@ TriangleSurface * SurfaceFactory::createTriangleSurface(){
} }
QuadSurface * SurfaceFactory::createQuadSurface(){ QuadSurface * SurfaceFactory::createQuadSurface(){
vector <Vec3> vertices; std::vector<Vec3> vertices;
float margin = 50.0f; float margin = 50.0f;
vertices.push_back(Vec3(margin, margin, 0.0f)); vertices.push_back(Vec3(margin, margin, 0.0f));
vertices.push_back(Vec3((float)ofGetWidth() - margin, margin, 0.0f)); vertices.push_back(Vec3((float)ofGetWidth() - margin, margin, 0.0f));
vertices.push_back(Vec3((float)ofGetWidth() - margin, (float)ofGetHeight() - margin, 0.0f)); vertices.push_back(Vec3((float)ofGetWidth() - margin, (float)ofGetHeight() - margin, 0.0f));
vertices.push_back(Vec3(margin, (float)ofGetHeight() - margin, 0.0f)); vertices.push_back(Vec3(margin, (float)ofGetHeight() - margin, 0.0f));
vector <Vec2> texCoords; std::vector<Vec2> texCoords;
texCoords.push_back(Vec2(Vec2(0.0f, 0.0f))); texCoords.push_back(Vec2(Vec2(0.0f, 0.0f)));
texCoords.push_back(Vec2(Vec2(1.0f, 0.0f))); texCoords.push_back(Vec2(Vec2(1.0f, 0.0f)));
texCoords.push_back(Vec2(Vec2(1.0f, 1.0f))); texCoords.push_back(Vec2(Vec2(1.0f, 1.0f)));

8
src/Surfaces/SurfaceManager.cpp

@ -111,7 +111,7 @@ void SurfaceManager::clearPresets(){
} }
// TODO: Do serious adjustment here. We need to save all presets. Not just the active one. // TODO: Do serious adjustment here. We need to save all presets. Not just the active one.
void SurfaceManager::saveXmlSettings(string fileName){ void SurfaceManager::saveXmlSettings(std::string fileName){
if(_presets.size() <= 0){ if(_presets.size() <= 0){
ofLogWarning( ofLogWarning(
"SurfaceManager::saveXmlSettings", "SurfaceManager::saveXmlSettings",
@ -128,7 +128,7 @@ void SurfaceManager::saveXmlSettings(string fileName){
} }
// TODO: We need to load all presets. Not just the active one. // TODO: We need to load all presets. Not just the active one.
bool SurfaceManager::loadXmlSettings(string fileName){ bool SurfaceManager::loadXmlSettings(std::string fileName){
if(mediaServer == 0){ if(mediaServer == 0){
ofLogFatalError("SurfaceManager") << "Media server not set"; ofLogFatalError("SurfaceManager") << "Media server not set";
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -292,7 +292,7 @@ void SurfaceManager::selectVertex(int i){
} }
if(i > selectedSurface->getVertices().size() - 1){ if(i > selectedSurface->getVertices().size() - 1){
ofLogError("SurfaceManager::selectVertex") << "index (" << i << ") out of bounds" << endl; ofLogError("SurfaceManager::selectVertex") << "index (" << i << ") out of bounds" << std::endl;
int prevVertIndex = _selectedVertexIndex; int prevVertIndex = _selectedVertexIndex;
ofNotifyEvent(vertexUnselectedEvent, prevVertIndex, this); ofNotifyEvent(vertexUnselectedEvent, prevVertIndex, this);
_selectedVertexIndex = -1; _selectedVertexIndex = -1;
@ -393,7 +393,7 @@ void SurfaceManager::onVertexChanged(int & i){
ofNotifyEvent(vertexChangedEvent, i, this); ofNotifyEvent(vertexChangedEvent, i, this);
} }
void SurfaceManager::onVerticesChanged(vector<Vec3> & vertices){ void SurfaceManager::onVerticesChanged(std::vector<Vec3> & vertices){
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }

10
src/Surfaces/SurfaceManager.h

@ -33,11 +33,11 @@ class SurfaceManager {
void removeSurface(int i); void removeSurface(int i);
void deleteSurface(BaseSurface * surface); void deleteSurface(BaseSurface * surface);
void deselectSurface(); void deselectSurface();
void saveXmlSettings(string fileName); void saveXmlSettings(std::string fileName);
void setMediaServer(MediaServer * newMediaServer); void setMediaServer(MediaServer * newMediaServer);
void clearPresets(); void clearPresets();
bool loadXmlSettings(string fileName); bool loadXmlSettings(std::string fileName);
BaseSurface * getSurface(int index); BaseSurface * getSurface(int index);
BaseSurface * selectSurface(int index); BaseSurface * selectSurface(int index);
@ -61,13 +61,13 @@ class SurfaceManager {
unsigned int getNumPresets(); unsigned int getNumPresets();
ofEvent <int> vertexChangedEvent; ofEvent <int> vertexChangedEvent;
ofEvent <vector<Vec3>> verticesChangedEvent; ofEvent <std::vector<Vec3>> verticesChangedEvent;
ofEvent <int> surfaceSelectedEvent; ofEvent <int> surfaceSelectedEvent;
ofEvent <int> vertexSelectedEvent; ofEvent <int> vertexSelectedEvent;
ofEvent <int> vertexUnselectedEvent; ofEvent <int> vertexUnselectedEvent;
void onVertexChanged(int & i); void onVertexChanged(int & i);
void onVerticesChanged(vector<Vec3> & vertices); void onVerticesChanged(std::vector<Vec3> & vertices);
SurfaceStack * getActivePreset(); SurfaceStack * getActivePreset();
SurfaceStack * createPreset(); SurfaceStack * createPreset();
@ -86,7 +86,7 @@ class SurfaceManager {
int _selectedVertexIndex; int _selectedVertexIndex;
int _activePresetIndex; int _activePresetIndex;
vector <SurfaceStack *> _presets; std::vector<SurfaceStack *> _presets;
}; };

2
src/Surfaces/SurfaceStack.cpp

@ -65,7 +65,7 @@ BaseSurface * SurfaceStack::back(){
return _surfaces.back(); return _surfaces.back();
} }
void SurfaceStack::onVerticesChanged(vector<Vec3> & vertices){ void SurfaceStack::onVerticesChanged(std::vector<Vec3> & vertices){
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }

8
src/Surfaces/SurfaceStack.h

@ -21,18 +21,18 @@ class SurfaceStack {
BaseSurface * at(int i); BaseSurface * at(int i);
BaseSurface * back(); BaseSurface * back();
ofEvent <vector<Vec3>> verticesChangedEvent; ofEvent <std::vector<Vec3>> verticesChangedEvent;
ofEvent <int> vertexChangedEvent; ofEvent <int> vertexChangedEvent;
void onVerticesChanged(vector<Vec3> & vertices); void onVerticesChanged(std::vector<Vec3> & vertices);
void onVertexChanged(int & i); void onVertexChanged(int & i);
vector<BaseSurface *> & getSurfaces(){ return _surfaces; }; std::vector<BaseSurface *> & getSurfaces(){ return _surfaces; };
SurfaceStack * clone(); SurfaceStack * clone();
private: private:
vector<BaseSurface *> _surfaces; std::vector<BaseSurface *> _surfaces;
}; };
} // namespace piMapper } // namespace piMapper

20
src/Surfaces/TriangleSurface.cpp

@ -64,7 +64,7 @@ void TriangleSurface::draw(){
void TriangleSurface::setVertex(int index, Vec3 p){ void TriangleSurface::setVertex(int index, Vec3 p){
if(index > 2){ if(index > 2){
ofLog() << "Vertex with this index does not exist: " << index << endl; ofLog() << "Vertex with this index does not exist: " << index << std::endl;
return; return;
} }
@ -72,7 +72,7 @@ void TriangleSurface::setVertex(int index, Vec3 p){
ofNotifyEvent(vertexChangedEvent, index, this); ofNotifyEvent(vertexChangedEvent, index, this);
} }
void TriangleSurface::setVertices(vector<Vec3> v){ void TriangleSurface::setVertices(std::vector<Vec3> v){
if(v.size() != 3){ if(v.size() != 3){
throw runtime_error("Wrong number of vertices"); throw runtime_error("Wrong number of vertices");
} }
@ -81,21 +81,21 @@ void TriangleSurface::setVertices(vector<Vec3> v){
mesh.setVertex(i, v[i].toOf()); mesh.setVertex(i, v[i].toOf());
} }
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }
void TriangleSurface::setTexCoord(int index, Vec2 t){ void TriangleSurface::setTexCoord(int index, Vec2 t){
if(index > 2){ if(index > 2){
ofLog() << "Texture coordinate with this index does not exist: " << index ofLog() << "Texture coordinate with this index does not exist: " << index
<< endl; << std::endl;
return; return;
} }
mesh.setTexCoord(index, t.toOf()); mesh.setTexCoord(index, t.toOf());
} }
void TriangleSurface::setTexCoords(vector<Vec2> t){ void TriangleSurface::setTexCoords(std::vector<Vec2> t){
if(t.size() != 3){ if(t.size() != 3){
throw runtime_error("Wrong number of texture coordinates"); throw runtime_error("Wrong number of texture coordinates");
} }
@ -111,7 +111,7 @@ void TriangleSurface::moveBy(Vec3 v){
} }
setMoved(true); setMoved(true);
vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices()); std::vector<Vec3> vertices = Vec3::fromOf(mesh.getVertices());
ofNotifyEvent(verticesChangedEvent, vertices, this); ofNotifyEvent(verticesChangedEvent, vertices, this);
} }
@ -131,7 +131,7 @@ bool TriangleSurface::hitTest(Vec2 p){
Vec2 TriangleSurface::getVertex(int index){ Vec2 TriangleSurface::getVertex(int index){
if(index > 2){ if(index > 2){
ofLog() << "Vertex with this index does not exist: " << index << endl; ofLog() << "Vertex with this index does not exist: " << index << std::endl;
throw runtime_error("Vertex index out of bounds."); throw runtime_error("Vertex index out of bounds.");
} }
@ -142,7 +142,7 @@ Vec2 TriangleSurface::getVertex(int index){
Vec2 TriangleSurface::getTexCoord(int index){ Vec2 TriangleSurface::getTexCoord(int index){
if(index > 2){ if(index > 2){
ofLog() << "Texture coordinate with this index does not exist: " << index << endl; ofLog() << "Texture coordinate with this index does not exist: " << index << std::endl;
throw runtime_error("Texture coordinate index out of bounds."); throw runtime_error("Texture coordinate index out of bounds.");
} }
@ -177,11 +177,11 @@ ofPolyline TriangleSurface::getTextureHitArea(){
return line; return line;
} }
vector<Vec3> TriangleSurface::getVertices(){ std::vector<Vec3> TriangleSurface::getVertices(){
return Vec3::fromOf(mesh.getVertices()); return Vec3::fromOf(mesh.getVertices());
} }
vector<Vec2> TriangleSurface::getTexCoords(){ std::vector<Vec2> TriangleSurface::getTexCoords(){
return Vec2::fromOf(mesh.getTexCoords()); return Vec2::fromOf(mesh.getTexCoords());
} }

8
src/Surfaces/TriangleSurface.h

@ -20,9 +20,9 @@ class TriangleSurface : public BaseSurface {
BaseSource * newSource); BaseSource * newSource);
void draw(); void draw();
void setVertex(int index, Vec3 p); void setVertex(int index, Vec3 p);
void setVertices(vector<Vec3> v); void setVertices(std::vector<Vec3> v);
void setTexCoord(int index, Vec2 t); void setTexCoord(int index, Vec2 t);
void setTexCoords(vector<Vec2> t); void setTexCoords(std::vector<Vec2> t);
void moveBy(Vec3 v); void moveBy(Vec3 v);
int getType(); int getType();
@ -31,8 +31,8 @@ class TriangleSurface : public BaseSurface {
Vec2 getTexCoord(int index); Vec2 getTexCoord(int index);
ofPolyline getHitArea(); ofPolyline getHitArea();
ofPolyline getTextureHitArea(); ofPolyline getTextureHitArea();
vector<Vec3> getVertices(); std::vector<Vec3> getVertices();
vector<Vec2> getTexCoords(); std::vector<Vec2> getTexCoords();
BaseSurface * clone(); BaseSurface * clone();
}; };

44
src/Types/Vec2.cpp

@ -1,5 +1,9 @@
#include "Vec2.h" #include "Vec2.h"
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR > 9
#include "glm/geometric.hpp"
#endif
namespace ofx { namespace ofx {
namespace piMapper { namespace piMapper {
@ -22,16 +26,16 @@ Vec2::Vec2(float ix, float iy){
return ofVec2f(x, y); return ofVec2f(x, y);
} }
vector<ofVec2f> Vec2::toOf(vector<Vec2> & src){ std::vector<ofVec2f> Vec2::toOf(std::vector<Vec2> & src){
vector<ofVec2f> retVal; std::vector<ofVec2f> retVal;
for(auto itm : src){ for(auto itm : src){
retVal.push_back(itm.toOf()); retVal.push_back(itm.toOf());
} }
return retVal; return retVal;
} }
vector<Vec2> Vec2::fromOf(vector<ofVec2f> & src){ std::vector<Vec2> Vec2::fromOf(std::vector<ofVec2f> & src){
vector<Vec2> retVal; std::vector<Vec2> retVal;
for(auto itm : src){ for(auto itm : src){
retVal.push_back(Vec2(itm)); retVal.push_back(Vec2(itm));
} }
@ -44,7 +48,37 @@ Vec2::Vec2(float ix, float iy){
return v1.distance(v2); return v1.distance(v2);
} }
#else #else
// TODO: The same for glm::vec2 Vec2::Vec2(glm::vec2 & src){
x = src.x;
y = src.y;
}
glm::vec2 Vec2::toOf(){
return glm::vec2(x, y);
}
std::vector<glm::vec2> Vec2::toOf(std::vector<Vec2> & src){
std::vector<glm::vec2> retVal;
for(auto itm : src){
retVal.push_back(itm.toOf());
}
return retVal;
}
std::vector<Vec2> Vec2::fromOf(std::vector<glm::vec2> & src){
std::vector<Vec2> retVal;
for(auto itm : src){
retVal.push_back(Vec2(itm));
}
return retVal;
}
float Vec2::distance(const Vec2 & other){
glm::vec2 v1(x, y);
glm::vec2 v2(other.x, other.y);
return glm::distance(v1, v2);
}
#endif #endif
void Vec2::operator=(const Vec2 & other){ void Vec2::operator=(const Vec2 & other){

13
src/Types/Vec2.h

@ -1,9 +1,11 @@
#pragma once #pragma once
#include <vector>
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9 #if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
#include "ofVec2f.h" #include "ofVec2f.h"
#else #else
// TODO: include glm #include "glm/vec2.hpp"
#endif #endif
namespace ofx { namespace ofx {
@ -18,10 +20,13 @@ public:
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9 #if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
Vec2(ofVec2f & src); Vec2(ofVec2f & src);
ofVec2f toOf(); ofVec2f toOf();
static vector<ofVec2f> toOf(vector<Vec2> & src); static std::vector<ofVec2f> toOf(std::vector<Vec2> & src);
static vector<Vec2> fromOf(vector<ofVec2f> & src); static std::vector<Vec2> fromOf(std::vector<ofVec2f> & src);
#else #else
// TODO: glm Vec2(glm::vec2 & src);
glm::vec2 toOf();
static std::vector<glm::vec2> toOf(std::vector<Vec2> & src);
static std::vector<Vec2> fromOf(std::vector<glm::vec2> & src);
#endif #endif
float distance(const Vec2 & other); float distance(const Vec2 & other);

34
src/Types/Vec3.cpp

@ -24,23 +24,47 @@ Vec3::Vec3(float ix, float iy, float iz){
return ofVec3f(x, y, z); return ofVec3f(x, y, z);
} }
vector<ofVec3f> Vec3::toOf(vector<Vec3> & src){ std::vector<ofVec3f> Vec3::toOf(std::vector<Vec3> & src){
vector<ofVec3f> retVal; std::vector<ofVec3f> retVal;
for(auto itm : src){ for(auto itm : src){
retVal.push_back(itm.toOf()); retVal.push_back(itm.toOf());
} }
return retVal; return retVal;
} }
vector<Vec3> Vec3::fromOf(vector<ofVec3f> & src){ std::vector<Vec3> Vec3::fromOf(std::vector<ofVec3f> & src){
vector<Vec3> retVal; std::vector<Vec3> retVal;
for(auto itm : src){ for(auto itm : src){
retVal.push_back(Vec3(itm)); retVal.push_back(Vec3(itm));
} }
return retVal; return retVal;
} }
#else #else
// TODO: Vec3::Vec3(glm::vec3 & src){...} Vec3::Vec3(glm::vec3 & src){
x = src.x;
y = src.y;
z = src.z;
}
glm::vec3 Vec3::toOf(){
return ofVec3f(x, y, z);
}
std::vector<glm::vec3> Vec3::toOf(std::vector<Vec3> & src){
std::vector<glm::vec3> retVal;
for(auto itm : src){
retVal.push_back(itm.toOf());
}
return retVal;
}
std::vector<Vec3> Vec3::fromOf(std::vector<glm::vec3> & src){
std::vector<Vec3> retVal;
for(auto itm : src){
retVal.push_back(Vec3(itm));
}
return retVal;
}
#endif #endif
void Vec3::operator=(const Vec3 & other){ void Vec3::operator=(const Vec3 & other){

13
src/Types/Vec3.h

@ -1,9 +1,11 @@
#pragma once #pragma once
#include <vector>
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9 #if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
#include "ofVec3f.h" #include "ofVec3f.h"
#else #else
// TODO: include glm #include "glm/vec3.hpp"
#endif #endif
namespace ofx { namespace ofx {
@ -18,10 +20,13 @@ public:
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9 #if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
Vec3(ofVec3f & src); Vec3(ofVec3f & src);
ofVec3f toOf(); ofVec3f toOf();
static vector<ofVec3f> toOf(vector<Vec3> & src); static std::vector<ofVec3f> toOf(std::vector<Vec3> & src);
static vector<Vec3> fromOf(vector<ofVec3f> & src); static std::vector<Vec3> fromOf(std::vector<ofVec3f> & src);
#else #else
// TODO: Vec3(glm::vec3 & src); Vec3(glm::vec3 & src);
glm::vec3 toOf();
static std::vector<glm::vec3> toOf(std::vector<Vec3> & src);
static std::vector<Vec3> fromOf(std::vector<glm::vec3> & src);
#endif #endif
void operator=(const Vec3 & other); void operator=(const Vec3 & other);

22
src/UserInterface/RadioList.cpp

@ -8,12 +8,12 @@ RadioList::RadioList(){
storedSelectedItem = 0; storedSelectedItem = 0;
} }
RadioList::RadioList(vector <string> & labels, vector <string> & values){ RadioList::RadioList(std::vector<std::string> & labels, std::vector<std::string> & values){
RadioList(); RadioList();
setup(labels, values); setup(labels, values);
} }
RadioList::RadioList(string title, vector <string> & labels, vector <string> & values){ RadioList::RadioList(std::string title, std::vector<std::string> & labels, std::vector<std::string> & values){
RadioList(); RadioList();
setup(title, labels, values); setup(title, labels, values);
} }
@ -22,7 +22,7 @@ RadioList::~RadioList(){
clear(); clear();
} }
void RadioList::setup(vector <string> & labels, vector <string> & values){ void RadioList::setup(std::vector<std::string> & labels, std::vector<std::string> & values){
// Copy incomming labels for later use // Copy incomming labels for later use
storedLabels = labels; storedLabels = labels;
@ -42,7 +42,7 @@ void RadioList::setup(vector <string> & labels, vector <string> & values){
} }
} }
void RadioList::setup(string title, vector <string> & labels, vector <string> & values){ void RadioList::setup(std::string title, std::vector<std::string> & labels, std::vector<std::string> & values){
// Store title for later use // Store title for later use
storedTitle = title; storedTitle = title;
@ -54,7 +54,7 @@ void RadioList::draw(){
guiGroup.draw(); guiGroup.draw();
} }
void RadioList::setTitle(string title){ void RadioList::setTitle(std::string title){
storedTitle = title; storedTitle = title;
guiGroup.setName(title); guiGroup.setName(title);
} }
@ -78,14 +78,14 @@ void RadioList::selectItem(int index){
toggle->removeListener(this, &RadioList::onToggleClicked); toggle->removeListener(this, &RadioList::onToggleClicked);
*toggle = true; // Select the specific radio button *toggle = true; // Select the specific radio button
toggle->addListener(this, &RadioList::onToggleClicked); toggle->addListener(this, &RadioList::onToggleClicked);
//string name = toggle->getName(); //std::string name = toggle->getName();
// Throw event with value that is image path instead of name // Throw event with value that is image path instead of name
string value = storedValues[index]; std::string value = storedValues[index];
ofNotifyEvent(onRadioSelected, value, this); ofNotifyEvent(onRadioSelected, value, this);
storedSelectedItem = index; storedSelectedItem = index;
} }
bool RadioList::selectItemByValue(string itemValue){ bool RadioList::selectItemByValue(std::string itemValue){
if(itemValue == ""){ if(itemValue == ""){
ofLogNotice("RadioList") << "Item value empty"; ofLogNotice("RadioList") << "Item value empty";
return false; return false;
@ -123,7 +123,7 @@ void RadioList::enable(){
*toggle = true; *toggle = true;
toggle->addListener(this, &RadioList::onToggleClicked); toggle->addListener(this, &RadioList::onToggleClicked);
cout << "num items after enable: " << guiGroup.getNumControls() << endl; std::cout << "num items after enable: " << guiGroup.getNumControls() << std::endl;
} }
void RadioList::disable(){ void RadioList::disable(){
@ -164,11 +164,11 @@ float RadioList::getHeight(){
return guiGroup.getHeight(); return guiGroup.getHeight();
} }
string RadioList::getTitle(){ std::string RadioList::getTitle(){
return guiGroup.getName(); return guiGroup.getName();
} }
string RadioList::getItemName(int index){ std::string RadioList::getItemName(int index){
if(index >= guiGroup.getNumControls()){ if(index >= guiGroup.getNumControls()){
return ""; return "";
} }

26
src/UserInterface/RadioList.h

@ -11,18 +11,18 @@ namespace piMapper {
class RadioList { class RadioList {
public: public:
RadioList(); RadioList();
RadioList(vector <string> & labels, vector <string> & values); RadioList(std::vector<std::string> & labels, std::vector<std::string> & values);
RadioList(string title, vector <string> & labels, vector <string> & values); RadioList(std::string title, std::vector<std::string> & labels, std::vector<std::string> & values);
~RadioList(); ~RadioList();
void setup(vector <string> & labels, vector <string> & values); void setup(std::vector<std::string> & labels, std::vector<std::string> & values);
void setup(string title, vector <string> & labels, vector <string> & values); void setup(std::string title, std::vector<std::string> & labels, std::vector<std::string> & values);
void draw(); void draw();
void setTitle(string title); void setTitle(std::string title);
void setPosition(ofPoint p); void setPosition(ofPoint p);
void setPosition(float x, float y); void setPosition(float x, float y);
void selectItem(int index); void selectItem(int index);
bool selectItemByValue(string itemValue); bool selectItemByValue(std::string itemValue);
void enable(); void enable();
void disable(); void disable();
void clear(); void clear();
@ -30,21 +30,21 @@ class RadioList {
ofPoint getPosition(); ofPoint getPosition();
float getWidth(); float getWidth();
float getHeight(); float getHeight();
string getTitle(); std::string getTitle();
string getItemName(int index); std::string getItemName(int index);
int size(); int size();
// This event notifies about a toggle being selected and passes it's name to // This event notifies about a toggle being selected and passes it's name to
// the listeners. // the listeners.
// Use ofAddListener(RadioListInstance.radioSelectedEvent, listenerClassPtr, // Use ofAddListener(RadioListInstance.radioSelectedEvent, listenerClassPtr,
// &listenerClass::listenerMethod) // &listenerClass::listenerMethod)
// to listen to this. Listner method void listenerMethod(string & radioName) // to listen to this. Listner method void listenerMethod(std::string & radioName)
ofEvent <string> onRadioSelected; ofEvent <std::string> onRadioSelected;
private: private:
vector <string> storedLabels; std::vector<std::string> storedLabels;
vector <string> storedValues; std::vector<std::string> storedValues;
string storedTitle; std::string storedTitle;
ofxGuiGroup guiGroup; ofxGuiGroup guiGroup;
int storedSelectedItem; int storedSelectedItem;

8
src/ofxPiMapper.cpp

@ -156,7 +156,7 @@ void ofxPiMapper::createSurface(ofx::piMapper::SurfaceType type){
} }
void ofxPiMapper::eraseSurface(int i){ void ofxPiMapper::eraseSurface(int i){
cout << "numSurfaces: " << getNumSurfaces() << ", i: " << i << endl; std::cout << "numSurfaces: " << getNumSurfaces() << ", i: " << i << std::endl;
if(getNumSurfaces() > 0 && i < getNumSurfaces()){ if(getNumSurfaces() > 0 && i < getNumSurfaces()){
_application.eraseSurface(i); _application.eraseSurface(i);
} }
@ -166,7 +166,7 @@ void ofxPiMapper::setNextSource(){
_application.setNextSource(); _application.setNextSource();
} }
void ofxPiMapper::setFboSource(string sourceId){ void ofxPiMapper::setFboSource(std::string sourceId){
_application.setFboSource(sourceId); _application.setFboSource(sourceId);
} }
@ -182,7 +182,7 @@ void ofxPiMapper::saveProject(){
_application.saveProject(); _application.saveProject();
} }
bool ofxPiMapper::loadProject(string filename){ bool ofxPiMapper::loadProject(std::string filename){
return _application.loadXmlSettings(filename); return _application.loadXmlSettings(filename);
} }
@ -202,7 +202,7 @@ int ofxPiMapper::getSelectedSurface(){
return _application.getSurfaceManager()->getSelectedSurfaceIndex(); return _application.getSurfaceManager()->getSelectedSurfaceIndex();
} }
void ofxPiMapper::setInfoText(string text){ void ofxPiMapper::setInfoText(std::string text){
_application.setInfoText(text); _application.setInfoText(text);
} }

6
src/ofxPiMapper.h

@ -28,7 +28,7 @@ class ofxPiMapper {
void registerFboSource(ofx::piMapper::FboSource * fboSource); void registerFboSource(ofx::piMapper::FboSource * fboSource);
// Application // Application
void setInfoText(string text); void setInfoText(std::string text);
void toggleInfo(); void toggleInfo();
void undo(); void undo();
void deselect(); void deselect();
@ -39,7 +39,7 @@ class ofxPiMapper {
// Project // Project
void saveProject(); void saveProject();
bool loadProject(string filename); bool loadProject(std::string filename);
// Presets // Presets
unsigned int getNumPresets(); unsigned int getNumPresets();
@ -74,7 +74,7 @@ class ofxPiMapper {
// Sources, selected surface // Sources, selected surface
void setNextSource(); void setNextSource();
void setFboSource(string sourceId); void setFboSource(std::string sourceId);
// System commands // System commands
void reboot(); void reboot();

Loading…
Cancel
Save