From f3ef6e81345bd1f34ac033cca85e6b57f6d2a1e9 Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 27 Sep 2016 12:08:09 +0300 Subject: [PATCH] Clean up after ProjectionEditorWidget move --- src/Application/Application.cpp | 1 - .../States/ProjectionMappingState.cpp | 9 --- src/Surfaces/SurfaceManagerGui.cpp | 74 ------------------- src/Surfaces/SurfaceManagerGui.h | 12 +-- 4 files changed, 1 insertion(+), 95 deletions(-) diff --git a/src/Application/Application.cpp b/src/Application/Application.cpp index 578ad7e..ccec62f 100644 --- a/src/Application/Application.cpp +++ b/src/Application/Application.cpp @@ -10,7 +10,6 @@ Application::Application(){ _surfaceManager.setMediaServer(&_mediaServer); _gui.setMediaServer(&_mediaServer); _gui.setCmdManager(&_cmdManager); - _gui.setSurfaceManager(&_surfaceManager); setState(PresentationState::instance()); ofAddListener(ofEvents().keyPressed, this, &Application::onKeyPressed); diff --git a/src/Application/States/ProjectionMappingState.cpp b/src/Application/States/ProjectionMappingState.cpp index 4c1381e..a81ec2f 100644 --- a/src/Application/States/ProjectionMappingState.cpp +++ b/src/Application/States/ProjectionMappingState.cpp @@ -23,7 +23,6 @@ void ProjectionMappingState::setup(Application *app){ } void ProjectionMappingState::update(Application * app){ - //app->getGui()->getProjectionEditorWidget()->update(); Gui::instance()->getProjectionEditorWidget().update(); Gui::instance()->getScaleWidget().update(); } @@ -34,8 +33,6 @@ void ProjectionMappingState::draw(Application * app){ app->getSurfaceManager()->draw(); ofPopStyle(); - // TODO: Extract projection editor, make it a widget - //app->getGui()->getProjectionEditorWidget()->draw(); Gui::instance()->getProjectionEditorWidget().draw(); // Draw scale widget. The size of the widget is being set on surface select. @@ -297,13 +294,10 @@ void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs int hitJointIndex = -1; BaseSurface * hitSurface = 0; - //hitJoint = app->getGui()->getProjectionEditorWidget()->hitTestJoints(ofVec2f(args.x, args.y)); hitJoint = Gui::instance()->getProjectionEditorWidget().hitTestJoints(ofVec2f(args.x, args.y)); if(hitJoint){ - //for(int i = app->getGui()->getProjectionEditorWidget()->getJoints()->size() - 1; i >= 0 ; --i){ for(int i = Gui::instance()->getProjectionEditorWidget().getJoints()->size() - 1; i >= 0 ; --i){ - //if((*app->getGui()->getProjectionEditorWidget()->getJoints())[i] == hitJoint){ if((*Gui::instance()->getProjectionEditorWidget().getJoints())[i] == hitJoint){ hitJointIndex = i; break; @@ -336,20 +330,17 @@ void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs void ProjectionMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseReleased(args); app->getGui()->stopDrag(); // TODO: handle this locally - //app->getGui()->getProjectionEditorWidget()->stopDragJoints(); Gui::instance()->getProjectionEditorWidget().stopDragJoints(); } void ProjectionMappingState::onMouseDragged(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseDragged(args); - //app->getGui()->getProjectionEditorWidget()->mouseDragged(args); Gui::instance()->getProjectionEditorWidget().mouseDragged(args); // TODO: Handle app->getGui()->clickPosition and app->getGui()->bDrag locally. if(app->getGui()->bDrag){ ofVec2f mousePosition = ofVec2f(args.x, args.y); ofVec2f distance = mousePosition - app->getGui()->clickPosition; - //app->getGui()->getProjectionEditorWidget()->moveSelectedSurface(distance); Gui::instance()->getProjectionEditorWidget().moveSelectedSurface(distance); app->getGui()->clickPosition = mousePosition; } diff --git a/src/Surfaces/SurfaceManagerGui.cpp b/src/Surfaces/SurfaceManagerGui.cpp index 0079155..ff354a8 100644 --- a/src/Surfaces/SurfaceManagerGui.cpp +++ b/src/Surfaces/SurfaceManagerGui.cpp @@ -4,34 +4,12 @@ namespace ofx { namespace piMapper { SurfaceManagerGui::SurfaceManagerGui(){ - surfaceManager = 0; guiMode = GuiMode::NONE; bDrag = false; ofHideCursor(); _cmdManager = 0; } -void SurfaceManagerGui::setSurfaceManager(SurfaceManager * newSurfaceManager){ - if(surfaceManager == 0){ - ofRemoveListener(newSurfaceManager->vertexChangedEvent, this, &SurfaceManagerGui::onVertexChanged); - ofRemoveListener(newSurfaceManager->verticesChangedEvent, this, &SurfaceManagerGui::onVerticesChanged); - ofRemoveListener(newSurfaceManager->surfaceSelectedEvent, this, &SurfaceManagerGui::onSurfaceSelected); - ofRemoveListener(newSurfaceManager->vertexSelectedEvent, this, &SurfaceManagerGui::onVertexSelected); - ofRemoveListener(newSurfaceManager->vertexUnselectedEvent, this, &SurfaceManagerGui::onVertexUnselected); - } - - surfaceManager = newSurfaceManager; - - ofAddListener(newSurfaceManager->vertexChangedEvent, this, &SurfaceManagerGui::onVertexChanged); - ofAddListener(newSurfaceManager->verticesChangedEvent, this, &SurfaceManagerGui::onVerticesChanged); - ofAddListener(newSurfaceManager->surfaceSelectedEvent, this, &SurfaceManagerGui::onSurfaceSelected); - ofAddListener(newSurfaceManager->vertexSelectedEvent, this, &SurfaceManagerGui::onVertexSelected); - ofAddListener(newSurfaceManager->vertexUnselectedEvent, this, &SurfaceManagerGui::onVertexUnselected); - -// projectionEditorWidget.setSurfaceManager(surfaceManager); - sourcesEditor.setSurfaceManager(surfaceManager); -} - void SurfaceManagerGui::setMediaServer(MediaServer * newMediaServer){ mediaServer = newMediaServer; sourcesEditor.setMediaServer(mediaServer); @@ -62,14 +40,6 @@ void SurfaceManagerGui::setMode(int newGuiMode){ }else{ sourcesEditor.disable(); } - -/* - if(guiMode == GuiMode::PROJECTION_MAPPING){ - projectionEditorWidget.enable(); - }else{ - projectionEditorWidget.disable(); - } -*/ } int SurfaceManagerGui::getMode(){ @@ -84,53 +54,9 @@ void SurfaceManagerGui::stopDrag(){ bDrag = false; } -//ProjectionEditorWidget * SurfaceManagerGui::getProjectionEditorWidget(){ -// return &projectionEditorWidget; -//} - SourcesEditor * SurfaceManagerGui::getSourcesEditor(){ return &sourcesEditor; } -void SurfaceManagerGui::onVertexChanged(int & i){ - //bool isDragged = projectionEditorWidget.getJoints()->at(i)->isDragged(); - //projectionEditorWidget.createJoints(); - //projectionEditorWidget.getJoints()->at(i)->select(); - //if(isDragged){ - // projectionEditorWidget.getJoints()->at(i)->startDrag(); - //}else{ - // projectionEditorWidget.getJoints()->at(i)->stopDrag(); - //} -} - -void SurfaceManagerGui::onVerticesChanged(vector & vertices){ - //projectionEditorWidget.createJoints(); -} - -void SurfaceManagerGui::onSurfaceSelected(int & surfaceIndex){ - //projectionEditorWidget.createJoints(); -} - -void SurfaceManagerGui::onVertexSelected(int & vertexIndex){ - /* - if(projectionEditorWidget.getJoints()->size() == 0){ - return; - } - - projectionEditorWidget.unselectAllJoints(); - projectionEditorWidget.getJoints()->at(vertexIndex)->select(); - */ -} - -void SurfaceManagerGui::onVertexUnselected(int & vertexIndex){ - /* - if(projectionEditorWidget.getJoints()->size() == 0){ - return; - } - - projectionEditorWidget.unselectAllJoints(); - */ -} - } // namespace piMapper } // namespace ofx \ No newline at end of file diff --git a/src/Surfaces/SurfaceManagerGui.h b/src/Surfaces/SurfaceManagerGui.h index c1ca8e6..230b810 100644 --- a/src/Surfaces/SurfaceManagerGui.h +++ b/src/Surfaces/SurfaceManagerGui.h @@ -6,7 +6,6 @@ #include "ofGraphics.h" #include "SurfaceManager.h" -//#include "ProjectionEditorWidget.h" #include "SourcesEditor.h" #include "GuiMode.h" #include "CmdManager.h" @@ -25,8 +24,7 @@ class SurfaceManagerGui { public: SurfaceManagerGui(); - - void setSurfaceManager(SurfaceManager * newSurfaceManager); + void setMediaServer(MediaServer * newMediaServer); void setCmdManager(CmdManager * cmdManager); @@ -35,22 +33,14 @@ class SurfaceManagerGui { void startDrag(); void stopDrag(); - //ProjectionEditorWidget * getProjectionEditorWidget(); SourcesEditor * getSourcesEditor(); - void onVertexChanged(int & i); - void onVerticesChanged(vector & vertices); - void onSurfaceSelected(int & surfaceIndex); - void onVertexSelected(int & vertexIndex); - void onVertexUnselected(int & vertexIndex); - ofVec2f clickPosition; bool bDrag; private: SurfaceManager * surfaceManager; MediaServer * mediaServer; - //ProjectionEditorWidget projectionEditorWidget; SourcesEditor sourcesEditor; int guiMode;