Browse Source

Optimize `SurfaceManagerGui`

Replace the initiation of `StartDragSurfaceCmd` with an emited event that is being handled elsewhere
master
Krisjanis Rijnieks 9 years ago
parent
commit
7430c64655
  1. 63
      src/Surfaces/SurfaceManagerGui.cpp
  2. 1
      src/Surfaces/SurfaceManagerGui.h

63
src/Surfaces/SurfaceManagerGui.cpp

@ -137,57 +137,38 @@ void SurfaceManagerGui::mousePressed(ofMouseEventArgs & args){
}
}else if(guiMode == GuiMode::PROJECTION_MAPPING){
bool bSurfaceSelected = false;
CircleJoint * hitJoint =
projectionEditor.hitTestJoints(ofVec2f(args.x, args.y));
if(hitJoint != 0){
projectionEditor.unselectAllJoints();
hitJoint->select();
hitJoint->startDrag();
int jointVertIndex = 0;
for(int i = 0; i < projectionEditor.getJoints()->size(); i++){
CircleJoint * hitJoint = 0;
int hitJointIndex = -1;
BaseSurface * hitSurface = 0;
hitJoint = projectionEditor.hitTestJoints(ofVec2f(args.x, args.y));
if(hitJoint){
for(int i = projectionEditor.getJoints()->size() - 1; i >= 0 ; --i){
if((*projectionEditor.getJoints())[i] == hitJoint){
jointVertIndex = i;
hitJointIndex = i;
break;
}
}
Gui::instance()->notifyJointPressed(args, jointVertIndex);
bSurfaceSelected = true;
}
// attempt to select surface, loop from end to beginning
if(!bSurfaceSelected){
for(int i = surfaceManager->size() - 1; i >= 0; i--){
}else{
for(int i = surfaceManager->size() - 1; i >= 0; --i){
if(surfaceManager->getSurface(i)->hitTest(ofVec2f(args.x, args.y))){
Gui::instance()->notifySurfacePressed(args, surfaceManager->getSurface(i));
bSurfaceSelected = true;
hitSurface = surfaceManager->getSurface(i);
break;
}
}
}
if(bSurfaceSelected && hitJoint == 0){
// if not hitting the joints, start drag only if
// we have a selected surface
if(hitJoint){
hitJoint->select();
hitJoint->startDrag();
Gui::instance()->notifyJointPressed(args, hitJointIndex);
}else if(hitSurface){
clickPosition = ofVec2f(args.x, args.y);
startDrag();
// TODO: emit event through the gui singleton
_cmdManager->exec(
new MvSurfaceCmd(
surfaceManager->getSelectedSurface(),
&projectionEditor));
}
if(!bSurfaceSelected){
// unselect if no surface selected
projectionEditor.clearJoints();
// TODO: emit event though the gui singleton
startDrag(); // TODO: Should be something like `hitSurface->startDrag()`
Gui::instance()->notifySurfacePressed(args, hitSurface);
}else{
//projectionEditor.clearJoints();
_cmdManager->exec(new DeselectSurfaceCmd(surfaceManager));
}
}else if(guiMode == GuiMode::SOURCE_SELECTION){}

1
src/Surfaces/SurfaceManagerGui.h

@ -11,7 +11,6 @@
#include "SourcesEditor.h"
#include "GuiMode.h"
#include "CmdManager.h"
#include "MvSurfaceCmd.h"
#include "SelSurfaceCmd.h"
#include "MvSurfaceVertCmd.h"
#include "MvAllTexCoordsCmd.h"

Loading…
Cancel
Save