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 draw();
vector <ofRectangle> rects;
vector <float> rectSpeeds;
std::vector<ofRectangle> rects;
std::vector<float> rectSpeeds;
};

2
example/src/main.cpp

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

3
example/src/ofApp.h

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

2
example_camera/src/CameraSource.cpp

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

2
example_camera/src/main.cpp

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

2
example_gamepad/src/InputHandler.h

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

2
example_gamepad/src/main.cpp

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

2
example_shortcuts/src/ofApp.cpp

@ -73,7 +73,7 @@ void ofApp::keyPressed(int key){
}else if(key == '\\'){
mapper.togglePause();
}else if(key == 'n'){
string multilineInfoText =
std::string multilineInfoText =
"Custom ofxPiMapper shortcuts\n\n"
"Good day user.\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 draw();
vector <ofRectangle> rects;
vector <float> rectSpeeds;
std::vector<ofRectangle> rects;
std::vector<float> rectSpeeds;
};

2
example_simpler/src/main.cpp

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

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

10
src/Application/Application.h

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

42
src/Application/SettingsLoader.cpp

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

10
src/Application/SettingsLoader.h

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

4
src/Commands/AddGridColCmd.h

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

4
src/Commands/AddGridRowCmd.h

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

2
src/Commands/ClearSurfacesCmd.h

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

4
src/Commands/CmdManager.h

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

2
src/Commands/DeselectTexCoordCmd.cpp

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

2
src/Commands/MvAllTexCoordsCmd.h

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

4
src/Commands/RmGridColCmd.h

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

4
src/Commands/RmGridRowCmd.h

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

2
src/Commands/SetNextSourceCmd.cpp

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

4
src/Commands/SetNextSourceCmd.h

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

2
src/Commands/SetSourceCmd.cpp

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

6
src/Commands/SetSourceCmd.h

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

2
src/Commands/StartDragSurfaceCmd.h

@ -16,7 +16,7 @@ class StartDragSurfaceCmd : public BaseUndoCmd {
private:
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 layerIconY = offsetTop + ((layerIconHeight + verticalSpacing) * (numSurfaces - i - 1));
string label = "Layers";
std::string label = "Layers";
ofDrawBitmapString(label, ofGetWidth() - 66, 30);
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);
// Collect all vertices of the projection surfaces
vector<Vec3> allVertices;
std::vector<Vec3> allVertices;
for(int i = 0; i < surfaceManager->size(); i++){
BaseSurface * surface = surfaceManager->getSurface(i);
@ -137,7 +137,7 @@ void ProjectionEditorWidget::createJoints(){
return;
}
vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices();
std::vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices();
for(int i = 0; i < vertices.size(); i++){
joints.push_back(new CircleJoint());
@ -147,7 +147,7 @@ void ProjectionEditorWidget::createJoints(){
void ProjectionEditorWidget::updateJoints(){
if(surfaceManager->getSelectedSurface()){
vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices();
std::vector<Vec3> vertices = surfaceManager->getSelectedSurface()->getVertices();
for(int i = 0; i < vertices.size(); i++){
joints[i]->position = Vec2(vertices[i].x, vertices[i].y);
@ -197,7 +197,7 @@ CircleJoint * ProjectionEditorWidget::hitTestJoints(Vec2 pos){
return 0;
}
vector <CircleJoint *> * ProjectionEditorWidget::getJoints(){
std::vector<CircleJoint *> * ProjectionEditorWidget::getJoints(){
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();
}

6
src/Gui/Widgets/ProjectionEditorWidget.h

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

19
src/Gui/Widgets/ScaleWidget.cpp

@ -1,4 +1,5 @@
#include "ScaleWidget.h"
#include "glm/geometric.hpp"
namespace ofx {
namespace piMapper {
@ -57,7 +58,11 @@ void ScaleWidget::draw(){
_line[1].y -= dy;
// Continue
float scale = lineLength / _line[0].distance(_line[1]);
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
float scale = lineLength / _line[0].distance(_line[1]);
#else
float scale = lineLength / glm::distance(_line[0], _line[1]);
#endif
_line[1].x = _line[0].x + (_line[1].x - _line[0].x) * scale;
_line[1].y = _line[0].y + (_line[1].y - _line[0].y) * scale;
@ -128,9 +133,15 @@ void ScaleWidget::onMouseDragged(ofMouseEventArgs & args){
newLine[1].x = args.x;
newLine[1].y = args.y;
_scale = _surfaceManager->getSelectedSurface()->getScale() /
_line[0].distance(_line[1]) *
newLine[0].distance(newLine[1]);
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
_scale = _surfaceManager->getSelectedSurface()->getScale() /
_line[0].distance(_line[1]) *
newLine[0].distance(newLine[1]);
#else
_scale = _surfaceManager->getSelectedSurface()->getScale() /
glm::distance(_line[0], _line[1]) *
glm::distance(newLine[0], newLine[1]);
#endif
_line = newLine;

40
src/Gui/Widgets/SourcesEditorWidget.cpp

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

38
src/Gui/Widgets/SourcesEditorWidget.h

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

10
src/Gui/Widgets/TextureEditorWidget.cpp

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

4
src/Gui/Widgets/TextureEditorWidget.h

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

2
src/Gui/Widgets/TextureHighlightWidget.h

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

2
src/Info/Info.cpp

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

4
src/Info/Info.h

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

13
src/MediaServer/DirectoryWatcher.cpp

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

9
src/MediaServer/DirectoryWatcher.h

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

90
src/MediaServer/MediaServer.cpp

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

68
src/MediaServer/MediaServer.h

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

14
src/Sources/BaseSource.cpp

@ -4,7 +4,7 @@ namespace ofx {
namespace piMapper {
BaseSource::BaseSource(){
//cout << "BaseSource" << endl;
//std::cout << "BaseSource" << std::endl;
init();
}
@ -19,7 +19,7 @@ ofTexture * BaseSource::getTexture(){
return texture;
}
string & BaseSource::getName(){
std::string & BaseSource::getName(){
return name;
}
@ -35,7 +35,7 @@ SourceType BaseSource::getType(){
return type;
}
string & BaseSource::getPath(){
std::string & BaseSource::getPath(){
return path;
}
@ -49,11 +49,11 @@ void BaseSource::init(){
referenceCount = 1; // We have one instance on init
}
void BaseSource::setNameFromPath(string & fullPath){
vector <string> pathParts;
//cout << "fullPath: " << fullPath << endl;
void BaseSource::setNameFromPath(std::string & fullPath){
std::vector<std::string> pathParts;
//std::cout << "fullPath: " << fullPath << std::endl;
pathParts = ofSplitString(fullPath, "/"); // Maybe on win "/" is "\", have to test
//cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << endl;
//std::cout << "lastPathPart: " << pathParts[pathParts.size() - 1] << std::endl;
name = pathParts[pathParts.size() - 1];
}

10
src/Sources/BaseSource.h

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

2
src/Sources/ImageSource.cpp

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

4
src/Sources/ImageSource.h

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

4
src/Sources/OMXPlayerCache.cpp

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

6
src/Sources/OMXPlayerCache.h

@ -14,12 +14,12 @@ class OMXPlayerCache {
public:
static OMXPlayerCache * instance();
ofxOMXPlayer * load(string moviePath);
void unload(string moviePath);
ofxOMXPlayer * load(std::string moviePath);
void unload(std::string moviePath);
private:
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 {
public:
static string GetSourceTypeHelperName(SourceType sourceTypeEnum){
static std::string GetSourceTypeHelperName(SourceType sourceTypeEnum){
if(sourceTypeEnum == SOURCE_TYPE_IMAGE){
return SOURCE_TYPE_NAME_IMAGE;
}else if(sourceTypeEnum == SOURCE_TYPE_VIDEO){
@ -23,14 +23,14 @@ class SourceTypeHelper {
}else if(sourceTypeEnum == SOURCE_TYPE_FBO){
return SOURCE_TYPE_NAME_FBO;
}else{
stringstream ss;
std::stringstream ss;
ss << "Invalid source type: " << sourceTypeEnum;
ofLogFatalError("SourceTypeHelper") << ss.str();
exit(EXIT_FAILURE);
}
}
static SourceType GetSourceTypeHelperEnum(string sourceTypeName){
static SourceType GetSourceTypeHelperEnum(std::string sourceTypeName){
if(sourceTypeName == SOURCE_TYPE_NAME_IMAGE){
return SOURCE_TYPE_IMAGE;
}else if(sourceTypeName == SOURCE_TYPE_NAME_VIDEO){
@ -40,7 +40,7 @@ class SourceTypeHelper {
}else if(sourceTypeName == SOURCE_TYPE_NAME_FBO){
return SOURCE_TYPE_FBO;
}else{
stringstream ss;
std::stringstream ss;
ss << "Invalid source type name: " << sourceTypeName;
ofLogFatalError("SourceTypeHelper") << ss.str();
exit(EXIT_FAILURE);

2
src/Sources/VideoSource.cpp

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

4
src/Sources/VideoSource.h

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

28
src/Sources/magSlideShowSource.cpp

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

7
src/Sources/magSlideShowSource.h

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

2
src/Sources/magSlideTransition.h

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

2
src/Sources/magSlideTransitionFactory.h

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

2
src/Surfaces/BaseSurface.cpp

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

10
src/Surfaces/BaseSurface.h

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

12
src/Surfaces/CircleSurface.h

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

21
src/Surfaces/GridWarpSurface.cpp

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

8
src/Surfaces/GridWarpSurface.h

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

26
src/Surfaces/HexagonSurface.cpp

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

12
src/Surfaces/HexagonSurface.h

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

20
src/Surfaces/QuadSurface.cpp

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

8
src/Surfaces/QuadSurface.h

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

8
src/Surfaces/SurfaceFactory.cpp

@ -29,13 +29,13 @@ BaseSurface * SurfaceFactory::createSurface(SurfaceType type){
}
TriangleSurface * SurfaceFactory::createTriangleSurface(){
vector <Vec3> vertices;
std::vector<Vec3> vertices;
float margin = 50.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(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(1.0f, 1.0f));
texCoords.push_back(Vec2(0.0f, 1.0f));
@ -51,14 +51,14 @@ TriangleSurface * SurfaceFactory::createTriangleSurface(){
}
QuadSurface * SurfaceFactory::createQuadSurface(){
vector <Vec3> vertices;
std::vector<Vec3> vertices;
float margin = 50.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, (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(1.0f, 0.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.
void SurfaceManager::saveXmlSettings(string fileName){
void SurfaceManager::saveXmlSettings(std::string fileName){
if(_presets.size() <= 0){
ofLogWarning(
"SurfaceManager::saveXmlSettings",
@ -128,7 +128,7 @@ void SurfaceManager::saveXmlSettings(string fileName){
}
// 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){
ofLogFatalError("SurfaceManager") << "Media server not set";
exit(EXIT_FAILURE);
@ -292,7 +292,7 @@ void SurfaceManager::selectVertex(int i){
}
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;
ofNotifyEvent(vertexUnselectedEvent, prevVertIndex, this);
_selectedVertexIndex = -1;
@ -393,7 +393,7 @@ void SurfaceManager::onVertexChanged(int & i){
ofNotifyEvent(vertexChangedEvent, i, this);
}
void SurfaceManager::onVerticesChanged(vector<Vec3> & vertices){
void SurfaceManager::onVerticesChanged(std::vector<Vec3> & vertices){
ofNotifyEvent(verticesChangedEvent, vertices, this);
}

10
src/Surfaces/SurfaceManager.h

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

2
src/Surfaces/SurfaceStack.cpp

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

8
src/Surfaces/SurfaceStack.h

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

20
src/Surfaces/TriangleSurface.cpp

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

8
src/Surfaces/TriangleSurface.h

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

44
src/Types/Vec2.cpp

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

13
src/Types/Vec2.h

@ -1,9 +1,11 @@
#pragma once
#include <vector>
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
#include "ofVec2f.h"
#else
// TODO: include glm
#include "glm/vec2.hpp"
#endif
namespace ofx {
@ -18,10 +20,13 @@ public:
#if OF_VERSION_MAJOR == 0 && OF_VERSION_MINOR <= 9
Vec2(ofVec2f & src);
ofVec2f toOf();
static vector<ofVec2f> toOf(vector<Vec2> & src);
static vector<Vec2> fromOf(vector<ofVec2f> & src);
static std::vector<ofVec2f> toOf(std::vector<Vec2> & src);
static std::vector<Vec2> fromOf(std::vector<ofVec2f> & src);
#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
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);
}
vector<ofVec3f> Vec3::toOf(vector<Vec3> & src){
vector<ofVec3f> retVal;
std::vector<ofVec3f> Vec3::toOf(std::vector<Vec3> & src){
std::vector<ofVec3f> retVal;
for(auto itm : src){
retVal.push_back(itm.toOf());
}
return retVal;
}
vector<Vec3> Vec3::fromOf(vector<ofVec3f> & src){
vector<Vec3> retVal;
std::vector<Vec3> Vec3::fromOf(std::vector<ofVec3f> & src){
std::vector<Vec3> retVal;
for(auto itm : src){
retVal.push_back(Vec3(itm));
}
return retVal;
}
#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
void Vec3::operator=(const Vec3 & other){

13
src/Types/Vec3.h

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

22
src/UserInterface/RadioList.cpp

@ -8,12 +8,12 @@ RadioList::RadioList(){
storedSelectedItem = 0;
}
RadioList::RadioList(vector <string> & labels, vector <string> & values){
RadioList::RadioList(std::vector<std::string> & labels, std::vector<std::string> & values){
RadioList();
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();
setup(title, labels, values);
}
@ -22,7 +22,7 @@ RadioList::~RadioList(){
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
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
storedTitle = title;
@ -54,7 +54,7 @@ void RadioList::draw(){
guiGroup.draw();
}
void RadioList::setTitle(string title){
void RadioList::setTitle(std::string title){
storedTitle = title;
guiGroup.setName(title);
}
@ -78,14 +78,14 @@ void RadioList::selectItem(int index){
toggle->removeListener(this, &RadioList::onToggleClicked);
*toggle = true; // Select the specific radio button
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
string value = storedValues[index];
std::string value = storedValues[index];
ofNotifyEvent(onRadioSelected, value, this);
storedSelectedItem = index;
}
bool RadioList::selectItemByValue(string itemValue){
bool RadioList::selectItemByValue(std::string itemValue){
if(itemValue == ""){
ofLogNotice("RadioList") << "Item value empty";
return false;
@ -123,7 +123,7 @@ void RadioList::enable(){
*toggle = true;
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(){
@ -164,11 +164,11 @@ float RadioList::getHeight(){
return guiGroup.getHeight();
}
string RadioList::getTitle(){
std::string RadioList::getTitle(){
return guiGroup.getName();
}
string RadioList::getItemName(int index){
std::string RadioList::getItemName(int index){
if(index >= guiGroup.getNumControls()){
return "";
}

26
src/UserInterface/RadioList.h

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

8
src/ofxPiMapper.cpp

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

6
src/ofxPiMapper.h

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

Loading…
Cancel
Save