Browse Source

Add select joints on click

master
Krisjanis Rijnieks 11 years ago
parent
commit
db50dc6404
  1. 82
      example/bin/data/surfaces.xml
  2. 10
      src/ofxBaseJoint.cpp
  3. 2
      src/ofxBaseJoint.h
  4. 7
      src/ofxProjectionEditor.cpp
  5. 1
      src/ofxProjectionEditor.h
  6. 4
      src/ofxSurfaceManagerGui.cpp
  7. 7
      src/ofxTextureEditor.cpp
  8. 1
      src/ofxTextureEditor.h

82
example/bin/data/surfaces.xml

@ -2,16 +2,16 @@
<surface>
<vertices>
<vertex>
<x>300.000000000</x>
<y>0.000000000</y>
<x>250.000000000</x>
<y>34.000000000</y>
</vertex>
<vertex>
<x>0.000000000</x>
<y>500.000000000</y>
<x>374.000000000</x>
<y>201.000000000</y>
</vertex>
<vertex>
<x>600.000000000</x>
<y>500.000000000</y>
<x>535.000000000</x>
<y>35.000000000</y>
</vertex>
</vertices>
<texCoords>
@ -36,30 +36,30 @@
<surface>
<vertices>
<vertex>
<x>24.000000000</x>
<y>33.000000000</y>
<x>162.000000000</x>
<y>23.000000000</y>
</vertex>
<vertex>
<x>566.000000000</x>
<y>35.000000000</y>
<x>219.000000000</x>
<y>183.000000000</y>
</vertex>
<vertex>
<x>207.000000000</x>
<y>310.000000000</y>
<x>22.000000000</x>
<y>196.000000000</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.500000000</x>
<y>0.000000000</y>
<x>0.251666665</x>
<y>0.090000004</y>
</texCoord>
<texCoord>
<x>0.000000000</x>
<y>1.000000000</y>
<x>0.449999988</x>
<y>0.696666658</y>
</texCoord>
<texCoord>
<x>1.000000000</x>
<y>1.000000000</y>
<x>0.870000005</x>
<y>0.173333332</y>
</texCoord>
</texCoords>
<source>
@ -70,16 +70,16 @@
<surface>
<vertices>
<vertex>
<x>74.709846497</x>
<y>448.636596680</y>
<x>75.709846497</x>
<y>450.636596680</y>
</vertex>
<vertex>
<x>564.630920410</x>
<y>201.926849365</y>
<x>214.630920410</x>
<y>282.926849365</y>
</vertex>
<vertex>
<x>23.396121979</x>
<y>257.170288086</y>
<x>24.396121979</x>
<y>259.170288086</y>
</vertex>
</vertices>
<texCoords>
@ -101,4 +101,38 @@
<source-name>image4.jpg</source-name>
</source>
</surface>
<surface>
<vertices>
<vertex>
<x>487.148498535</x>
<y>299.815002441</y>
</vertex>
<vertex>
<x>280.170959473</x>
<y>483.102355957</y>
</vertex>
<vertex>
<x>252.250427246</x>
<y>248.424682617</y>
</vertex>
</vertices>
<texCoords>
<texCoord>
<x>0.063067839</x>
<y>0.981202126</y>
</texCoord>
<texCoord>
<x>0.064178742</x>
<y>0.652164280</y>
</texCoord>
<texCoord>
<x>0.925386906</x>
<y>0.977848232</y>
</texCoord>
</texCoords>
<source>
<source-type>image</source-type>
<source-name>none</source-name>
</source>
</surface>
</surfaces>

10
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;

2
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(){};

7
src/ofxProjectionEditor.cpp

@ -111,6 +111,13 @@ void ofxProjectionEditor::updateJoints()
}
}
void ofxProjectionEditor::unselectAllJoints()
{
for ( int i=0; i<joints.size(); i++ ) {
joints[i]->unselect();
}
}
void ofxProjectionEditor::moveSelectedSurface(ofVec2f by)
{
if ( surfaceManager == NULL ) return;

1
src/ofxProjectionEditor.h

@ -23,6 +23,7 @@ public:
void clearJoints();
void createJoints();
void updateJoints();
void unselectAllJoints();
void moveSelectedSurface(ofVec2f by);
void stopDragJoints();
void updateVertices();

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

7
src/ofxTextureEditor.cpp

@ -84,6 +84,13 @@ void ofxTextureEditor::clearJoints()
}
}
void ofxTextureEditor::unselectAllJoints()
{
for ( int i=0; i<joints.size(); i++ ) {
joints[i]->unselect();
}
}
void ofxTextureEditor::moveTexCoords(ofVec2f by)
{
if ( surface == NULL ) return;

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

Loading…
Cancel
Save