Module: synfig
Branch: nikitakit_ducks
Commit: 1b0547169603e911e37bf1f3d56ceb023b87cc91
URL:    
http://synfig.git.sourceforge.net/git/gitweb.cgi?p=synfig;a=commit;h=1b0547169603e911e37bf1f3d56ceb023b87cc91

Author: Nikita Kitaev <nikita...@gmail.com>
Date:   Wed Dec  9 21:30:42 2009 -0800

Better functionality for ducks linked to BLine

Still not ideal, but should be as good as it was originally.

---

 synfig-studio/src/gtkmm/duck.cpp                   |    3 +-
 synfig-studio/src/gtkmm/duckmatic.cpp              |   21 +++++-
 .../src/gtkmm/mod_mirror/state_mirror.cpp          |    4 +-
 synfig-studio/src/gtkmm/state_normal.cpp           |   36 ++++++++---
 synfig-studio/src/gtkmm/state_smoothmove.cpp       |   67 +++++++++++++++++++-
 5 files changed, 114 insertions(+), 17 deletions(-)

diff --git a/synfig-studio/src/gtkmm/duck.cpp b/synfig-studio/src/gtkmm/duck.cpp
index 362ac0a..da32897 100644
--- a/synfig-studio/src/gtkmm/duck.cpp
+++ b/synfig-studio/src/gtkmm/duck.cpp
@@ -255,7 +255,7 @@ Duck::set_sub_trans_point(const synfig::Point &x, const 
synfig::Time &time)
 void
 Duck::update(const synfig::Time &time)
 {
-       if((get_type() == Duck::TYPE_TANGENT || get_type() == Duck::TYPE_WIDTH) 
&& origin_duck)
+       if((get_type() == Duck::TYPE_TANGENT || get_type() == Duck::TYPE_WIDTH 
|| get_type() == Duck::TYPE_ANGLE) && origin_duck)
        {
                ValueNode_BLineCalcVertex::Handle bline_vertex;
                ValueNode_Composite::Handle composite;
@@ -280,6 +280,7 @@ Duck::update(const synfig::Time &time)
                                {
                                        Angle angle((*bline_tangent)(time, 
amount).get(Angle()));
                                        
set_point(Point(Angle::cos(angle).get(), Angle::sin(angle).get()));
+                                       rotations=synfig::Angle::deg(0); 
//hack: rotations are a relative value
                                        break;
                                }
                                case ValueBase::TYPE_REAL:
diff --git a/synfig-studio/src/gtkmm/duckmatic.cpp 
b/synfig-studio/src/gtkmm/duckmatic.cpp
index 6c5510e..c1813e7 100644
--- a/synfig-studio/src/gtkmm/duckmatic.cpp
+++ b/synfig-studio/src/gtkmm/duckmatic.cpp
@@ -562,11 +562,26 @@ DuckDrag_Translate::duck_drag(Duckmatic* duckmatic, const 
synfig::Vector& vector
 
        // then patch up the tangents for the vertices we've moved
        DuckList duck_list(duckmatic->get_duck_list());
-       for (iter=duck_list.begin(); iter!=duck_list.end(); ++iter)
+       for (iter=selected_ducks.begin(); iter!=selected_ducks.end(); ++iter)
        {
-               if ((*iter)->get_type() == Duck::TYPE_TANGENT || 
(*iter)->get_type() == Duck::TYPE_WIDTH)
+               etl::handle<Duck> duck(*iter);
+               if (duck->get_type() == Duck::TYPE_VERTEX || duck->get_type() 
== Duck::TYPE_POSITION)
                {
-                       (*iter)->update(time);
+                       ValueNode_Composite::Handle composite;
+
+                       if 
((ValueNode_BLineCalcVertex::Handle::cast_dynamic(duck->get_value_desc().get_value_node()))
 ||
+                               ((composite = 
ValueNode_Composite::Handle::cast_dynamic(duck->get_value_desc().get_value_node()))
 &&
+                                composite->get_type() == 
ValueBase::TYPE_BLINEPOINT &&
+                                
(ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point")))))
+                       {
+                               //! \todo update() will call dynamic cast 
again, see if we can avoid that
+                               DuckList::iterator iter;
+                               for (iter=duck_list.begin(); 
iter!=duck_list.end(); iter++)
+                                       if ((*iter)->get_origin_duck()==duck 
+                                               && 
std::find(selected_ducks.begin(), 
+                                                                        
selected_ducks.end(), *iter) == selected_ducks.end() )
+                                               (*iter)->update(time);
+                       }
                }
        }
 
diff --git a/synfig-studio/src/gtkmm/mod_mirror/state_mirror.cpp 
b/synfig-studio/src/gtkmm/mod_mirror/state_mirror.cpp
index 35cac16..5843a6a 100644
--- a/synfig-studio/src/gtkmm/mod_mirror/state_mirror.cpp
+++ b/synfig-studio/src/gtkmm/mod_mirror/state_mirror.cpp
@@ -292,7 +292,7 @@ DuckDrag_Mirror::duck_drag(Duckmatic* duckmatic, const 
synfig::Vector& vector)
                        if              (axis==AXIS_X) p[0] = -(p[0]-center[0]) 
+ center[0];
                        else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + 
center[1];
 
-                       (*iter)->set_trans_point(p, time);
+                       (*iter)->set_trans_point(p);
                }
 
        // then do the other ducks
@@ -309,7 +309,7 @@ DuckDrag_Mirror::duck_drag(Duckmatic* duckmatic, const 
synfig::Vector& vector)
                        if              (axis==AXIS_X) p[0] = -(p[0]-center[0]) 
+ center[0];
                        else if (axis==AXIS_Y) p[1] = -(p[1]-center[1]) + 
center[1];
 
-                       (*iter)->set_trans_point(p, time);
+                       (*iter)->set_trans_point(p);
                }
 }
 
diff --git a/synfig-studio/src/gtkmm/state_normal.cpp 
b/synfig-studio/src/gtkmm/state_normal.cpp
index 68f1750..6cca469 100644
--- a/synfig-studio/src/gtkmm/state_normal.cpp
+++ b/synfig-studio/src/gtkmm/state_normal.cpp
@@ -35,6 +35,7 @@
 #include <gtkmm/entry.h>
 
 #include <synfig/valuenode_animated.h>
+#include <synfig/valuenode_blinecalcvertex.h>
 #include <synfig/valuenode_composite.h>
 #include <synfig/valuenode_const.h>
 #include <synfig/valuenode_dynamiclist.h>
@@ -411,15 +412,6 @@ DuckDrag_Combo::duck_drag(Duckmatic* duckmatic, const 
synfig::Vector& vector)
                        
if((*iter)->get_type()!=Duck::TYPE_VERTEX&&(*iter)->get_type()!=Duck::TYPE_POSITION)
                                (*iter)->set_trans_point(positions[i]+vect, 
time);
                }
-               DuckList duck_list(duckmatic->get_duck_list());
-               for (iter=duck_list.begin(); iter!=duck_list.end(); ++iter)
-               {
-                       if ((*iter)->get_type() == Duck::TYPE_TANGENT || 
(*iter)->get_type() == Duck::TYPE_WIDTH)
-                       {
-                               (*iter)->update(time);
-                       }
-               }
-               return;
        }
 
        if (rotate)
@@ -507,6 +499,32 @@ DuckDrag_Combo::duck_drag(Duckmatic* duckmatic, const 
synfig::Vector& vector)
                        (*iter)->set_trans_point(p, time);
                }
        }
+
+       // then patch up the tangents for the vertices we've moved
+       DuckList duck_list(duckmatic->get_duck_list());
+       for (iter=selected_ducks.begin(); iter!=selected_ducks.end(); ++iter)
+       {
+               etl::handle<Duck> duck(*iter);
+               if (duck->get_type() == Duck::TYPE_VERTEX || duck->get_type() 
== Duck::TYPE_POSITION)
+               {
+                       ValueNode_Composite::Handle composite;
+
+                       if 
((ValueNode_BLineCalcVertex::Handle::cast_dynamic(duck->get_value_desc().get_value_node()))
 ||
+                               ((composite = 
ValueNode_Composite::Handle::cast_dynamic(duck->get_value_desc().get_value_node()))
 &&
+                                composite->get_type() == 
ValueBase::TYPE_BLINEPOINT &&
+                                
(ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point")))))
+                       {
+                               //! \todo update() will call dynamic cast 
again, see if we can avoid that
+                               DuckList::iterator iter;
+                               for (iter=duck_list.begin(); 
iter!=duck_list.end(); iter++)
+                                       if ((*iter)->get_origin_duck()==duck 
+                                               && 
std::find(selected_ducks.begin(), 
+                                                                        
selected_ducks.end(), *iter) == selected_ducks.end())
+                                               (*iter)->update(time);
+                       }
+               }
+       }
+
        last_move=vect;
 }
 
diff --git a/synfig-studio/src/gtkmm/state_smoothmove.cpp 
b/synfig-studio/src/gtkmm/state_smoothmove.cpp
index 78f617b..6f96f57 100644
--- a/synfig-studio/src/gtkmm/state_smoothmove.cpp
+++ b/synfig-studio/src/gtkmm/state_smoothmove.cpp
@@ -34,6 +34,8 @@
 #include <gtkmm/dialog.h>
 #include <gtkmm/entry.h>
 
+#include <synfig/valuenode_blinecalcvertex.h>
+#include <synfig/valuenode_composite.h>
 #include <synfig/valuenode_dynamiclist.h>
 #include <synfigapp/action_system.h>
 
@@ -299,6 +301,31 @@ DuckDrag_SmoothMove::duck_drag(Duckmatic* duckmatic, const 
synfig::Vector& vecto
                (*iter)->set_trans_point(p+last_[i], time);
        }
 
+       // then patch up the tangents for the vertices we've moved
+       DuckList duck_list(duckmatic->get_duck_list());
+       for (iter=selected_ducks.begin(); iter!=selected_ducks.end(); ++iter)
+       {
+               etl::handle<Duck> duck(*iter);
+               if (duck->get_type() == Duck::TYPE_VERTEX || duck->get_type() 
== Duck::TYPE_POSITION)
+               {
+                       ValueNode_Composite::Handle composite;
+
+                       if 
((ValueNode_BLineCalcVertex::Handle::cast_dynamic(duck->get_value_desc().get_value_node()))
 ||
+                               ((composite = 
ValueNode_Composite::Handle::cast_dynamic(duck->get_value_desc().get_value_node()))
 &&
+                                composite->get_type() == 
ValueBase::TYPE_BLINEPOINT &&
+                                
(ValueNode_BLineCalcVertex::Handle::cast_dynamic(composite->get_link("point")))))
+                       {
+                               //! \todo update() will call dynamic cast 
again, see if we can avoid that
+                               DuckList::iterator iter;
+                               for (iter=duck_list.begin(); 
iter!=duck_list.end(); iter++)
+                                       if ((*iter)->get_origin_duck()==duck 
+                                               && 
std::find(selected_ducks.begin(), 
+                                                                        
selected_ducks.end(), *iter) == selected_ducks.end() )
+                                               (*iter)->update(time);
+                       }
+               }
+       }
+
        last_translate_=vect;
        //snap=Vector(0,0);
 }
@@ -319,9 +346,45 @@ DuckDrag_SmoothMove::end_duck_drag(Duckmatic* duckmatic)
                
for(i=0,iter=selected_ducks.begin();iter!=selected_ducks.end();++iter,i++)
                {
                        if(last_[i].mag()>0.0001)
-                               
if(!(*iter)->signal_edited()((*iter)->get_point()))
                                {
-                                       throw String("Bad Move");
+                               if ((*iter)->get_type() == Duck::TYPE_ANGLE)
+                                       {
+                                               
if(!(*iter)->signal_edited_angle()((*iter)->get_rotations()))
+                                               {
+                                                       throw String("Bad 
edit");
+                                               }
+                                       }
+                                       else if (App::restrict_radius_ducks &&
+                                                        (*iter)->is_radius())
+                                       {
+                                               Point 
point((*iter)->get_point());
+                                               bool changed = false;
+
+                                               if (point[0] < 0)
+                                               {
+                                                       point[0] = 0;
+                                                       changed = true;
+                                               }
+                                               if (point[1] < 0)
+                                               {
+                                                       point[1] = 0;
+                                                       changed = true;
+                                               }
+
+                                               if (changed) 
(*iter)->set_point(point);
+
+                                               
if(!(*iter)->signal_edited()(point))
+                                               {
+                                                       throw String("Bad 
edit");
+                                               }
+                                       }
+                                       else
+                                       {
+                                               
if(!(*iter)->signal_edited()((*iter)->get_point()))
+                                               {
+                                                       throw String("Bad 
edit");
+                                               }
+                                       }
                                }
                }
                //duckmatic->get_selected_ducks()=new_set;


------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
Synfig-devl mailing list
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to