diff --git a/example/bin/data/surfaces.xml b/example/bin/data/surfaces.xml index 9e94bfb..7a9e22f 100644 --- a/example/bin/data/surfaces.xml +++ b/example/bin/data/surfaces.xml @@ -2,16 +2,16 @@ - 300.000000000 - 0.000000000 + 250.000000000 + 34.000000000 - 0.000000000 - 500.000000000 + 374.000000000 + 201.000000000 - 600.000000000 - 500.000000000 + 535.000000000 + 35.000000000 @@ -36,30 +36,30 @@ - 24.000000000 - 33.000000000 + 162.000000000 + 23.000000000 - 566.000000000 - 35.000000000 + 219.000000000 + 183.000000000 - 207.000000000 - 310.000000000 + 22.000000000 + 196.000000000 - 0.500000000 - 0.000000000 + 0.251666665 + 0.090000004 - 0.000000000 - 1.000000000 + 0.449999988 + 0.696666658 - 1.000000000 - 1.000000000 + 0.870000005 + 0.173333332 @@ -70,16 +70,16 @@ - 74.709846497 - 448.636596680 + 75.709846497 + 450.636596680 - 564.630920410 - 201.926849365 + 214.630920410 + 282.926849365 - 23.396121979 - 257.170288086 + 24.396121979 + 259.170288086 @@ -101,4 +101,38 @@ image4.jpg + + + + 487.148498535 + 299.815002441 + + + 280.170959473 + 483.102355957 + + + 252.250427246 + 248.424682617 + + + + + 0.063067839 + 0.981202126 + + + 0.064178742 + 0.652164280 + + + 0.925386906 + 0.977848232 + + + + image + none + + diff --git a/src/ofxBaseJoint.cpp b/src/ofxBaseJoint.cpp index 75820f5..525d2c3 100644 --- a/src/ofxBaseJoint.cpp +++ b/src/ofxBaseJoint.cpp @@ -54,6 +54,16 @@ void ofxBaseJoint::stopDrag() bDrag = false; } +void ofxBaseJoint::select() +{ + selected = true; +} + +void ofxBaseJoint::unselect() +{ + selected = false; +} + bool ofxBaseJoint::isDragged() { return bDrag; diff --git a/src/ofxBaseJoint.h b/src/ofxBaseJoint.h index a75e235..85be110 100644 --- a/src/ofxBaseJoint.h +++ b/src/ofxBaseJoint.h @@ -21,6 +21,8 @@ public: void mouseDragged(ofMouseEventArgs& args); void startDrag(); void stopDrag(); + void select(); + void unselect(); bool isDragged(); virtual void update(){}; diff --git a/src/ofxProjectionEditor.cpp b/src/ofxProjectionEditor.cpp index 75d7990..6b8eb89 100644 --- a/src/ofxProjectionEditor.cpp +++ b/src/ofxProjectionEditor.cpp @@ -111,6 +111,13 @@ void ofxProjectionEditor::updateJoints() } } +void ofxProjectionEditor::unselectAllJoints() +{ + for ( int i=0; iunselect(); + } +} + void ofxProjectionEditor::moveSelectedSurface(ofVec2f by) { if ( surfaceManager == NULL ) return; diff --git a/src/ofxProjectionEditor.h b/src/ofxProjectionEditor.h index f4a806d..40dd1aa 100644 --- a/src/ofxProjectionEditor.h +++ b/src/ofxProjectionEditor.h @@ -23,6 +23,7 @@ public: void clearJoints(); void createJoints(); void updateJoints(); + void unselectAllJoints(); void moveSelectedSurface(ofVec2f by); void stopDragJoints(); void updateVertices(); diff --git a/src/ofxSurfaceManagerGui.cpp b/src/ofxSurfaceManagerGui.cpp index d8023e0..cce3909 100644 --- a/src/ofxSurfaceManagerGui.cpp +++ b/src/ofxSurfaceManagerGui.cpp @@ -88,6 +88,8 @@ void ofxSurfaceManagerGui::mousePressed(ofMouseEventArgs &args) ofxCircleJoint* hitJoint = textureEditor.hitTestJoints(ofVec2f(args.x, args.y)); if ( hitJoint != NULL ) { + textureEditor.unselectAllJoints(); + hitJoint->select(); hitJoint->startDrag(); bSurfaceSelected = true; } @@ -106,6 +108,8 @@ void ofxSurfaceManagerGui::mousePressed(ofMouseEventArgs &args) ofxCircleJoint* hitJoint = projectionEditor.hitTestJoints(ofVec2f(args.x, args.y)); if ( hitJoint != NULL ) { + projectionEditor.unselectAllJoints(); + hitJoint->select(); hitJoint->startDrag(); bSurfaceSelected = true; } diff --git a/src/ofxTextureEditor.cpp b/src/ofxTextureEditor.cpp index 33265c8..fd49cdb 100644 --- a/src/ofxTextureEditor.cpp +++ b/src/ofxTextureEditor.cpp @@ -84,6 +84,13 @@ void ofxTextureEditor::clearJoints() } } +void ofxTextureEditor::unselectAllJoints() +{ + for ( int i=0; iunselect(); + } +} + void ofxTextureEditor::moveTexCoords(ofVec2f by) { if ( surface == NULL ) return; diff --git a/src/ofxTextureEditor.h b/src/ofxTextureEditor.h index cbfdafe..a6dd85e 100644 --- a/src/ofxTextureEditor.h +++ b/src/ofxTextureEditor.h @@ -21,6 +21,7 @@ public: void clear(); void createJoints(); void clearJoints(); + void unselectAllJoints(); void moveTexCoords(ofVec2f by); void stopDragJoints(); ofxCircleJoint* hitTestJoints(ofVec2f pos);