|
|
@ -179,30 +179,39 @@ void TextureMappingMode::onMousePressed(Application * app, ofMouseEventArgs & ar |
|
|
|
Gui::instance()->getTextureEditorWidget().hitTestJoints(ofVec2f(args.x, args.y)); |
|
|
|
|
|
|
|
if(hitJoint != 0){ |
|
|
|
|
|
|
|
hitJoint->mousePressed(args); |
|
|
|
//Gui::instance()->getTextureEditorWidget().unselectAllJoints();
|
|
|
|
|
|
|
|
Gui::instance()->getTextureEditorWidget().unselectAllJoints(); |
|
|
|
hitJoint->select(); |
|
|
|
hitJoint->startDrag(); |
|
|
|
int jointIndex; |
|
|
|
//hitJoint->select();
|
|
|
|
|
|
|
|
for(int i = 0; i < Gui::instance()->getTextureEditorWidget().getJoints().size(); i++){ |
|
|
|
if(Gui::instance()->getTextureEditorWidget().getJoints()[i] == hitJoint){ |
|
|
|
jointIndex = i; |
|
|
|
int selectedTexCoord = -1; |
|
|
|
for(int i = 0; i < Gui::instance()->getTextureEditorWidget().getJoints().size(); ++i){ |
|
|
|
if(hitJoint == Gui::instance()->getTextureEditorWidget().getJoints()[i]){ |
|
|
|
selectedTexCoord = i; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
app->getCmdManager()->exec( |
|
|
|
new MvTexCoordCmd(jointIndex, &Gui::instance()->getTextureEditorWidget())); |
|
|
|
|
|
|
|
if(!hitJoint->isSelected()){ |
|
|
|
app->getCmdManager()->exec( |
|
|
|
new SelTexCoordCmd( |
|
|
|
&Gui::instance()->getTextureEditorWidget(), |
|
|
|
selectedTexCoord)); |
|
|
|
} |
|
|
|
|
|
|
|
hitJoint->startDrag(); |
|
|
|
// TODO: Make the following better, more direct.
|
|
|
|
// Move this to mouseReleased part as we nee to save the previous location only
|
|
|
|
// if the move has happened.
|
|
|
|
ofVec2f tex = app->getSurfaceManager()->getSelectedSurface()->getTexCoords()[selectedTexCoord]; |
|
|
|
app->getCmdManager()->exec(new SaveTexCoordPosCmd(selectedTexCoord, tex)); |
|
|
|
}else if(app->getSurfaceManager()->getSelectedSurface()->getTextureHitArea().inside(args.x, args.y)){ |
|
|
|
|
|
|
|
_clickPosition = ofPoint(args.x, args.y); |
|
|
|
_bCropAreaDrag = true; |
|
|
|
|
|
|
|
// TODO: emit event through the gui singleton
|
|
|
|
// TODO: emit event through the gui singleton.
|
|
|
|
// TODO: create command only on mouse release.
|
|
|
|
app->getCmdManager()->exec(new MvAllTexCoordsCmd( |
|
|
|
app->getSurfaceManager()->getSelectedSurface(), |
|
|
|
&Gui::instance()->getTextureEditorWidget())); |
|
|
@ -224,6 +233,20 @@ void TextureMappingMode::onMouseReleased(Application * app, ofMouseEventArgs & a |
|
|
|
_canvasTranslate)); |
|
|
|
} |
|
|
|
|
|
|
|
// If selected joint is being dragged and the mouse position has been changed
|
|
|
|
// create an undoable move tex coord command.
|
|
|
|
int selectedTexCoord = Gui::instance()->getTextureEditorWidget().getSelectedTexCoord(); |
|
|
|
if(selectedTexCoord >= 0){ |
|
|
|
ofPoint mouseReleasePosition = ofPoint(args.x, args.y); |
|
|
|
if(_clickPosition != mouseReleasePosition){ |
|
|
|
ofVec2f moveBy = ofVec2f( |
|
|
|
mouseReleasePosition.x - _clickPosition.x, |
|
|
|
mouseReleasePosition.y - _clickPosition.y); |
|
|
|
//app->getCmdManager()->exec(
|
|
|
|
// new MvTexCoordCmd(selectedTexCoord, moveBy));
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
_clickCanvasTranslate = _canvasTranslate; |
|
|
|
|
|
|
|
args.x -= _canvasTranslate.x; |
|
|
@ -270,18 +293,18 @@ void TextureMappingMode::drawTexture(Application * app){ |
|
|
|
void TextureMappingMode::moveSelection(Application * app, ofVec2f by){ |
|
|
|
int selectedTexCoord = Gui::instance()->getTextureEditorWidget().getSelectedTexCoord(); |
|
|
|
|
|
|
|
// TODO: Do the moving only through commands not like now.
|
|
|
|
|
|
|
|
if(selectedTexCoord >= 0){ |
|
|
|
app->getCmdManager()->exec( |
|
|
|
new MvTexCoordCmd( |
|
|
|
selectedTexCoord, |
|
|
|
&Gui::instance()->getTextureEditorWidget())); |
|
|
|
new MvTexCoordCmd(selectedTexCoord, by)); |
|
|
|
}else{ |
|
|
|
app->getCmdManager()->exec(new MvAllTexCoordsCmd( |
|
|
|
app->getSurfaceManager()->getSelectedSurface(), |
|
|
|
&Gui::instance()->getTextureEditorWidget())); |
|
|
|
|
|
|
|
Gui::instance()->getTextureEditorWidget().moveSelection(by); |
|
|
|
} |
|
|
|
|
|
|
|
Gui::instance()->getTextureEditorWidget().moveSelection(by); |
|
|
|
} |
|
|
|
|
|
|
|
ofPoint TextureMappingMode::getTranslation(){ |
|
|
|