Browse Source

Refactor `SurfaceManagerGui` texture editor onMousePressed routine

master
Krisjanis Rijnieks 9 years ago
parent
commit
60488bc219
  1. 47
      src/Surfaces/SurfaceManagerGui.cpp

47
src/Surfaces/SurfaceManagerGui.cpp

@ -91,17 +91,20 @@ void SurfaceManagerGui::mousePressed(ofMouseEventArgs & args){
if(guiMode == GuiMode::NONE){ if(guiMode == GuiMode::NONE){
return; return;
}else if(guiMode == GuiMode::TEXTURE_MAPPING){ }else if(guiMode == GuiMode::TEXTURE_MAPPING){
bool bSurfaceSelected = false;
CircleJoint * hitJoint = if(surfaceManager->getSelectedSurface() == 0){
textureEditor.hitTestJoints(ofVec2f(args.x, args.y)); return;
}
CircleJoint * hitJoint = textureEditor.hitTestJoints(ofVec2f(args.x, args.y));
if(hitJoint != 0){ if(hitJoint != 0){
textureEditor.unselectAllJoints();
textureEditor.unselectAllJoints();
hitJoint->select(); hitJoint->select();
hitJoint->startDrag(); hitJoint->startDrag();
bSurfaceSelected = true; int jointIndex;
int jointIndex = -1;
for(int i = 0; i < textureEditor.getJoints().size(); i++){ for(int i = 0; i < textureEditor.getJoints().size(); i++){
if(textureEditor.getJoints()[i] == hitJoint){ if(textureEditor.getJoints()[i] == hitJoint){
jointIndex = i; jointIndex = i;
@ -109,31 +112,21 @@ void SurfaceManagerGui::mousePressed(ofMouseEventArgs & args){
} }
} }
if(jointIndex != -1){ _cmdManager->exec(new MvTexCoordCmd(jointIndex, &textureEditor));
// TODO: emit event through the GUI singleton }else if(surfaceManager->getSelectedSurface()->getTextureHitArea().inside(args.x, args.y)){
_cmdManager->exec(new MvTexCoordCmd(jointIndex, &textureEditor));
}
}else{ clickPosition = ofVec2f(args.x, args.y);
textureEditor.unselectAllJoints(); startDrag();
}
if(surfaceManager->getSelectedSurface() != 0 && !bSurfaceSelected){
// hittest texture area to see if we are hitting the texture surface
if(surfaceManager->getSelectedSurface()->getTextureHitArea().inside(
args.x, args.y)){
// TODO: move these to a separate routine
clickPosition = ofVec2f(args.x, args.y);
startDrag();
// TODO: emit event through the gui singleton // TODO: emit event through the gui singleton
_cmdManager->exec(new MvAllTexCoordsCmd( _cmdManager->exec(new MvAllTexCoordsCmd(
surfaceManager->getSelectedSurface(), surfaceManager->getSelectedSurface(),
&textureEditor)); &textureEditor));
} }else{
// TODO: Create command for this
textureEditor.unselectAllJoints();
} }
}else if(guiMode == GuiMode::PROJECTION_MAPPING){ }else if(guiMode == GuiMode::PROJECTION_MAPPING){

Loading…
Cancel
Save