From 5c37c56ecb7a5206fce3466b26944323f4a18e8d Mon Sep 17 00:00:00 2001 From: Krisjanis Rijnieks Date: Tue, 27 Sep 2016 10:33:56 +0300 Subject: [PATCH] Rename ProjectionEditor to ProjectionEditorWidget --- .../States/ProjectionMappingState.cpp | 16 +++---- src/Commands/AddGridColCmd.h | 2 +- src/Commands/AddGridRowCmd.h | 2 +- src/Commands/MvSurfaceVertCmd.h | 2 +- src/Commands/RmGridColCmd.h | 2 +- src/Commands/RmGridRowCmd.h | 2 +- .../Widgets/ProjectionEditorWidget.cpp} | 46 +++++++++---------- .../Widgets/ProjectionEditorWidget.h} | 4 +- src/Surfaces/SurfaceManagerGui.cpp | 34 +++++++------- src/Surfaces/SurfaceManagerGui.h | 6 +-- 10 files changed, 58 insertions(+), 58 deletions(-) rename src/{UserInterface/ProjectionEditor.cpp => Gui/Widgets/ProjectionEditorWidget.cpp} (74%) rename src/{UserInterface/ProjectionEditor.h => Gui/Widgets/ProjectionEditorWidget.h} (91%) diff --git a/src/Application/States/ProjectionMappingState.cpp b/src/Application/States/ProjectionMappingState.cpp index d7b2186..c0fdc37 100644 --- a/src/Application/States/ProjectionMappingState.cpp +++ b/src/Application/States/ProjectionMappingState.cpp @@ -17,7 +17,7 @@ ProjectionMappingState * ProjectionMappingState::instance(){ } void ProjectionMappingState::update(Application * app){ - app->getGui()->getProjectionEditor()->update(); + app->getGui()->getProjectionEditorWidget()->update(); Gui::instance()->getScaleWidget().update(); } @@ -28,7 +28,7 @@ void ProjectionMappingState::draw(Application * app){ ofPopStyle(); // TODO: Extract projection editor, make it a widget - app->getGui()->getProjectionEditor()->draw(); + app->getGui()->getProjectionEditorWidget()->draw(); // Draw scale widget. The size of the widget is being set on surface select. BaseSurface * selectedSurface = app->getSurfaceManager()->getSelectedSurface(); @@ -292,11 +292,11 @@ void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs int hitJointIndex = -1; BaseSurface * hitSurface = 0; - hitJoint = app->getGui()->getProjectionEditor()->hitTestJoints(ofVec2f(args.x, args.y)); + hitJoint = app->getGui()->getProjectionEditorWidget()->hitTestJoints(ofVec2f(args.x, args.y)); if(hitJoint){ - for(int i = app->getGui()->getProjectionEditor()->getJoints()->size() - 1; i >= 0 ; --i){ - if((*app->getGui()->getProjectionEditor()->getJoints())[i] == hitJoint){ + for(int i = app->getGui()->getProjectionEditorWidget()->getJoints()->size() - 1; i >= 0 ; --i){ + if((*app->getGui()->getProjectionEditorWidget()->getJoints())[i] == hitJoint){ hitJointIndex = i; break; } @@ -328,18 +328,18 @@ void ProjectionMappingState::onMousePressed(Application * app, ofMouseEventArgs void ProjectionMappingState::onMouseReleased(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseReleased(args); app->getGui()->stopDrag(); - app->getGui()->getProjectionEditor()->stopDragJoints(); + app->getGui()->getProjectionEditorWidget()->stopDragJoints(); } void ProjectionMappingState::onMouseDragged(Application * app, ofMouseEventArgs & args){ Gui::instance()->onMouseDragged(args); - app->getGui()->getProjectionEditor()->mouseDragged(args); + app->getGui()->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()->getProjectionEditor()->moveSelectedSurface(distance); + app->getGui()->getProjectionEditorWidget()->moveSelectedSurface(distance); app->getGui()->clickPosition = mousePosition; } } diff --git a/src/Commands/AddGridColCmd.h b/src/Commands/AddGridColCmd.h index 1e3c36f..24b298b 100644 --- a/src/Commands/AddGridColCmd.h +++ b/src/Commands/AddGridColCmd.h @@ -3,7 +3,7 @@ #include "SurfaceManager.h" #include "BaseCmd.h" #include "GridWarpSurface.h" -#include "ProjectionEditor.h" +#include "ProjectionEditorWidget.h" class ofxPiMapper; diff --git a/src/Commands/AddGridRowCmd.h b/src/Commands/AddGridRowCmd.h index 93c65ce..cd4b31c 100644 --- a/src/Commands/AddGridRowCmd.h +++ b/src/Commands/AddGridRowCmd.h @@ -3,7 +3,7 @@ #include "SurfaceManager.h" #include "BaseCmd.h" #include "GridWarpSurface.h" -#include "ProjectionEditor.h" +#include "ProjectionEditorWidget.h" class ofxPiMapper; diff --git a/src/Commands/MvSurfaceVertCmd.h b/src/Commands/MvSurfaceVertCmd.h index b9d958e..7695728 100644 --- a/src/Commands/MvSurfaceVertCmd.h +++ b/src/Commands/MvSurfaceVertCmd.h @@ -6,7 +6,7 @@ #include "BaseCmd.h" #include "BaseSurface.h" -#include "ProjectionEditor.h" +#include "ProjectionEditorWidget.h" #include "BaseJoint.h" namespace ofx { diff --git a/src/Commands/RmGridColCmd.h b/src/Commands/RmGridColCmd.h index 7d2a695..83b0871 100644 --- a/src/Commands/RmGridColCmd.h +++ b/src/Commands/RmGridColCmd.h @@ -3,7 +3,7 @@ #include "SurfaceManager.h" #include "BaseCmd.h" #include "GridWarpSurface.h" -#include "ProjectionEditor.h" +#include "ProjectionEditorWidget.h" class ofxPiMapper; diff --git a/src/Commands/RmGridRowCmd.h b/src/Commands/RmGridRowCmd.h index b5fc415..1abe401 100644 --- a/src/Commands/RmGridRowCmd.h +++ b/src/Commands/RmGridRowCmd.h @@ -3,7 +3,7 @@ #include "SurfaceManager.h" #include "BaseCmd.h" #include "GridWarpSurface.h" -#include "ProjectionEditor.h" +#include "ProjectionEditorWidget.h" class ofxPiMapper; diff --git a/src/UserInterface/ProjectionEditor.cpp b/src/Gui/Widgets/ProjectionEditorWidget.cpp similarity index 74% rename from src/UserInterface/ProjectionEditor.cpp rename to src/Gui/Widgets/ProjectionEditorWidget.cpp index e102c85..ed5a6b3 100644 --- a/src/UserInterface/ProjectionEditor.cpp +++ b/src/Gui/Widgets/ProjectionEditorWidget.cpp @@ -1,32 +1,32 @@ -#include "ProjectionEditor.h" +#include "ProjectionEditorWidget.h" namespace ofx { namespace piMapper { -ProjectionEditor::ProjectionEditor(){ +ProjectionEditorWidget::ProjectionEditorWidget(){ surfaceManager = 0; bShiftKeyDown = false; fSnapDistance = 10.0f; enable(); } -void ProjectionEditor::registerAppEvents(){ - ofAddListener(ofEvents().messageEvent, this, &ProjectionEditor::gotMessage); +void ProjectionEditorWidget::registerAppEvents(){ + ofAddListener(ofEvents().messageEvent, this, &ProjectionEditorWidget::gotMessage); } -void ProjectionEditor::unregisterAppEvents(){ - ofRemoveListener(ofEvents().messageEvent, this, &ProjectionEditor::gotMessage); +void ProjectionEditorWidget::unregisterAppEvents(){ + ofRemoveListener(ofEvents().messageEvent, this, &ProjectionEditorWidget::gotMessage); } -void ProjectionEditor::enable(){ +void ProjectionEditorWidget::enable(){ registerAppEvents(); } -void ProjectionEditor::disable(){ +void ProjectionEditorWidget::disable(){ unregisterAppEvents(); } -void ProjectionEditor::update(){ +void ProjectionEditorWidget::update(){ // update surface if one of the joints is being dragged for(int i = 0; i < joints.size(); i++){ if(joints[i]->isDragged() || joints[i]->isSelected()){ @@ -44,7 +44,7 @@ void ProjectionEditor::update(){ } } -void ProjectionEditor::draw(){ +void ProjectionEditorWidget::draw(){ if(surfaceManager == 0){ return; } @@ -57,7 +57,7 @@ void ProjectionEditor::draw(){ drawJoints(); } -void ProjectionEditor::mouseDragged(ofMouseEventArgs & args){ +void ProjectionEditorWidget::mouseDragged(ofMouseEventArgs & args){ // Pass args to joint mouse events for(unsigned int i = 0; i < joints.size(); ++i){ @@ -94,25 +94,25 @@ void ProjectionEditor::mouseDragged(ofMouseEventArgs & args){ } } -void ProjectionEditor::gotMessage(ofMessage & msg){ +void ProjectionEditorWidget::gotMessage(ofMessage & msg){ if(msg.message == "surfaceSelected"){ clearJoints(); createJoints(); } } -void ProjectionEditor::setSurfaceManager(SurfaceManager * newSurfaceManager){ +void ProjectionEditorWidget::setSurfaceManager(SurfaceManager * newSurfaceManager){ surfaceManager = newSurfaceManager; } -void ProjectionEditor::clearJoints(){ +void ProjectionEditorWidget::clearJoints(){ while(joints.size()){ delete joints.back(); joints.pop_back(); } } -void ProjectionEditor::createJoints(){ +void ProjectionEditorWidget::createJoints(){ if(surfaceManager == 0){ return; } @@ -132,7 +132,7 @@ void ProjectionEditor::createJoints(){ } } -void ProjectionEditor::updateJoints(){ +void ProjectionEditorWidget::updateJoints(){ if(surfaceManager->getSelectedSurface()){ vector & vertices = surfaceManager->getSelectedSurface()->getVertices(); @@ -143,13 +143,13 @@ void ProjectionEditor::updateJoints(){ } -void ProjectionEditor::unselectAllJoints(){ +void ProjectionEditorWidget::unselectAllJoints(){ for(int i = 0; i < joints.size(); i++){ joints[i]->unselect(); } } -void ProjectionEditor::moveSelectedSurface(ofVec2f by){ +void ProjectionEditorWidget::moveSelectedSurface(ofVec2f by){ if(surfaceManager == 0){ return; } @@ -160,17 +160,17 @@ void ProjectionEditor::moveSelectedSurface(ofVec2f by){ updateJoints(); } -void ProjectionEditor::stopDragJoints(){ +void ProjectionEditorWidget::stopDragJoints(){ for(int i = 0; i < joints.size(); i++){ joints[i]->stopDrag(); } } -void ProjectionEditor::setSnapDistance(float newSnapDistance){ +void ProjectionEditorWidget::setSnapDistance(float newSnapDistance){ fSnapDistance = newSnapDistance; } -CircleJoint * ProjectionEditor::hitTestJoints(ofVec2f pos){ +CircleJoint * ProjectionEditorWidget::hitTestJoints(ofVec2f pos){ for(int i = 0; i < joints.size(); i++){ if(joints[i]->hitTest(pos)){ return joints[i]; @@ -179,11 +179,11 @@ CircleJoint * ProjectionEditor::hitTestJoints(ofVec2f pos){ return 0; } -vector * ProjectionEditor::getJoints(){ +vector * ProjectionEditorWidget::getJoints(){ return &joints; } -void ProjectionEditor::drawJoints(){ +void ProjectionEditorWidget::drawJoints(){ for(int i = 0; i < joints.size(); i++){ joints[i]->draw(); } diff --git a/src/UserInterface/ProjectionEditor.h b/src/Gui/Widgets/ProjectionEditorWidget.h similarity index 91% rename from src/UserInterface/ProjectionEditor.h rename to src/Gui/Widgets/ProjectionEditorWidget.h index ecaeb93..bd77af2 100644 --- a/src/UserInterface/ProjectionEditor.h +++ b/src/Gui/Widgets/ProjectionEditorWidget.h @@ -6,10 +6,10 @@ namespace ofx { namespace piMapper { -class ProjectionEditor { +class ProjectionEditorWidget { public: - ProjectionEditor(); + ProjectionEditorWidget(); void registerAppEvents(); void unregisterAppEvents(); diff --git a/src/Surfaces/SurfaceManagerGui.cpp b/src/Surfaces/SurfaceManagerGui.cpp index a0ba49f..cc15235 100644 --- a/src/Surfaces/SurfaceManagerGui.cpp +++ b/src/Surfaces/SurfaceManagerGui.cpp @@ -28,7 +28,7 @@ void SurfaceManagerGui::setSurfaceManager(SurfaceManager * newSurfaceManager){ ofAddListener(newSurfaceManager->vertexSelectedEvent, this, &SurfaceManagerGui::onVertexSelected); ofAddListener(newSurfaceManager->vertexUnselectedEvent, this, &SurfaceManagerGui::onVertexUnselected); - projectionEditor.setSurfaceManager(surfaceManager); + projectionEditorWidget.setSurfaceManager(surfaceManager); sourcesEditor.setSurfaceManager(surfaceManager); } @@ -64,9 +64,9 @@ void SurfaceManagerGui::setMode(int newGuiMode){ } if(guiMode == GuiMode::PROJECTION_MAPPING){ - projectionEditor.enable(); + projectionEditorWidget.enable(); }else{ - projectionEditor.disable(); + projectionEditorWidget.disable(); } } @@ -82,8 +82,8 @@ void SurfaceManagerGui::stopDrag(){ bDrag = false; } -ProjectionEditor * SurfaceManagerGui::getProjectionEditor(){ - return &projectionEditor; +ProjectionEditorWidget * SurfaceManagerGui::getProjectionEditorWidget(){ + return &projectionEditorWidget; } SourcesEditor * SurfaceManagerGui::getSourcesEditor(){ @@ -91,39 +91,39 @@ SourcesEditor * SurfaceManagerGui::getSourcesEditor(){ } void SurfaceManagerGui::onVertexChanged(int & i){ - bool isDragged = projectionEditor.getJoints()->at(i)->isDragged(); - projectionEditor.createJoints(); - projectionEditor.getJoints()->at(i)->select(); + bool isDragged = projectionEditorWidget.getJoints()->at(i)->isDragged(); + projectionEditorWidget.createJoints(); + projectionEditorWidget.getJoints()->at(i)->select(); if(isDragged){ - projectionEditor.getJoints()->at(i)->startDrag(); + projectionEditorWidget.getJoints()->at(i)->startDrag(); }else{ - projectionEditor.getJoints()->at(i)->stopDrag(); + projectionEditorWidget.getJoints()->at(i)->stopDrag(); } } void SurfaceManagerGui::onVerticesChanged(vector & vertices){ - projectionEditor.createJoints(); + projectionEditorWidget.createJoints(); } void SurfaceManagerGui::onSurfaceSelected(int & surfaceIndex){ - projectionEditor.createJoints(); + projectionEditorWidget.createJoints(); } void SurfaceManagerGui::onVertexSelected(int & vertexIndex){ - if(projectionEditor.getJoints()->size() == 0){ + if(projectionEditorWidget.getJoints()->size() == 0){ return; } - projectionEditor.unselectAllJoints(); - projectionEditor.getJoints()->at(vertexIndex)->select(); + projectionEditorWidget.unselectAllJoints(); + projectionEditorWidget.getJoints()->at(vertexIndex)->select(); } void SurfaceManagerGui::onVertexUnselected(int & vertexIndex){ - if(projectionEditor.getJoints()->size() == 0){ + if(projectionEditorWidget.getJoints()->size() == 0){ return; } - projectionEditor.unselectAllJoints(); + projectionEditorWidget.unselectAllJoints(); } } // namespace piMapper diff --git a/src/Surfaces/SurfaceManagerGui.h b/src/Surfaces/SurfaceManagerGui.h index 0226ef1..302c627 100644 --- a/src/Surfaces/SurfaceManagerGui.h +++ b/src/Surfaces/SurfaceManagerGui.h @@ -6,7 +6,7 @@ #include "ofGraphics.h" #include "SurfaceManager.h" -#include "ProjectionEditor.h" +#include "ProjectionEditorWidget.h" #include "SourcesEditor.h" #include "GuiMode.h" #include "CmdManager.h" @@ -35,7 +35,7 @@ class SurfaceManagerGui { void startDrag(); void stopDrag(); - ProjectionEditor * getProjectionEditor(); + ProjectionEditorWidget * getProjectionEditorWidget(); SourcesEditor * getSourcesEditor(); void onVertexChanged(int & i); @@ -50,7 +50,7 @@ class SurfaceManagerGui { private: SurfaceManager * surfaceManager; MediaServer * mediaServer; - ProjectionEditor projectionEditor; + ProjectionEditorWidget projectionEditorWidget; SourcesEditor sourcesEditor; int guiMode;