Browse Source

Clean up after ProjectionEditorWidget move

master
Krisjanis Rijnieks 9 years ago
parent
commit
f3ef6e8134
  1. 1
      src/Application/Application.cpp
  2. 9
      src/Application/States/ProjectionMappingState.cpp
  3. 74
      src/Surfaces/SurfaceManagerGui.cpp
  4. 10
      src/Surfaces/SurfaceManagerGui.h

1
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);

9
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;
}

74
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<ofVec3f> & 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

10
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"
@ -26,7 +25,6 @@ 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<ofVec3f> & 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;

Loading…
Cancel
Save