Module: synfig
Branch: genete_width_points
Commit: 3dce7865676ddcdc4bcb7d3dbda084d1b2e9a66b
URL:    
http://synfig.git.sourceforge.net/git/gitweb.cgi?p=synfig;a=commit;h=3dce7865676ddcdc4bcb7d3dbda084d1b2e9a66b

Author: Carlos Lopez <car...@pcnuevo.(none)>
Date:   Wed Jul 29 00:43:07 2009 +0200

More WIP

---

 synfig-core/trunk/src/synfig/valuenode_wline.cpp |   71 ++++++++++++++++++++-
 synfig-core/trunk/src/synfig/valuenode_wline.h   |    6 ++
 synfig-core/trunk/src/synfig/wlinepoint.h        |    7 ++
 3 files changed, 80 insertions(+), 4 deletions(-)

diff --git a/synfig-core/trunk/src/synfig/valuenode_wline.cpp 
b/synfig-core/trunk/src/synfig/valuenode_wline.cpp
index 8a95bcd..4902e4e 100644
--- a/synfig-core/trunk/src/synfig/valuenode_wline.cpp
+++ b/synfig-core/trunk/src/synfig/valuenode_wline.cpp
@@ -681,16 +681,79 @@ ValueNode_WLine::check_type(ValueBase::Type type)
 }
 
 int
-ValueNode_WLine::find_next_valid_wlinepoint(int index, Time time)const
+ValueNode_WLine::find_next_wlinepoint(int index, Time t)const
 {
-
+       float big_value=10000000;
+       int reti=index;
+       int mini=index;
+       float cpos,ipos;
+       float dist=big_value;
+       float min=0;
+       cpos=(*list[index].value_node)(t).get_pos();
+       for (int i = 0; i < link_count(); i++)
+       {
+               ipos=(*list[i].value_node)(t).get_pos();
+               if (ipos>=cpos && (ipos-cpos)<dist)
+               {
+                       dist=ipos-cpos;
+                       reti=i;
+               }
+               if (ipos<cpos && (cpos-ipos)>min)
+               {
+                       min=cpos-ipos;
+                       mini=i;
+               }
+       }
+       if (reti==index) // we didn't find a bigger position
+       {
+               if (mini==index)
+               {
+                       synfig::info("Not Found: 
ValueNode_WLine::find_next_wlinepoint(%i,%s)", index, t.c_str());
+               }
+               reti=mini;
+       }
+       return reti;
 }
 
 int
-ValueNode_WLine::find_prev_valid_wlinepoint(int orig_index, Time t)const
+ValueNode_WLine::find_prev_wlinepoint(int index, Time t)const
 {
-       list status_at_time(t)
+       float big_value=10000000;
+       int reti=index;
+       int maxi=index;
+       float cpos,ipos;
+       float dist=big_value;
+       float max=0;
+       cpos=(*list[index].value_node)(t).get_pos();
+       for (int i = 0; i < link_count(); i++)
+       {
+               ipos=(*list[i].value_node)(t).get_pos();
+               if (ipos<=cpos && (cpos-ipos)<dist)
+               {
+                       dist=cpos-ipos;
+                       reti=i;
+               }
+               if (ipos>cpos && (ipos-cpos)>max)
+               {
+                       max=ipos-cpos;
+                       maxi=i;
+               }
+       }
+       if (reti==index) // we didn't find a smaller position
+       {
+               if (maxi==index)
+               {
+                       synfig::info("Not Found: 
ValueNode_WLine::find_prev_wlinepoint(%i,%s)", index, t.c_str());
+               }
+               reti=maxi;
+       }
+       return reti;
+}
 
+
+int
+ValueNode_WLine::find_next_valid_wlinepoint(int orig_index, Time t)const
+{
        // Grabs the position of the WLinePoint at orig_index at time t
        float index_pos((*list[orig_index].value_node)(t).get_pos());
        // This is a very long position to compare to
diff --git a/synfig-core/trunk/src/synfig/valuenode_wline.h 
b/synfig-core/trunk/src/synfig/valuenode_wline.h
index eeee3e6..370a901 100644
--- a/synfig-core/trunk/src/synfig/valuenode_wline.h
+++ b/synfig-core/trunk/src/synfig/valuenode_wline.h
@@ -84,10 +84,16 @@ public:
        //! index parameter and the previous valid one.
        //! @param index: The index where the Insert item action was performed
        //! @param time: The time to insert the item
+       //! @param origin: the relative position between previous and next 
WLinePoints
+       //! in terms of previous and next position parameter.
        virtual ListEntry create_list_entry(int index, Time time=0, Real 
origin=0.5);
+
        int find_next_valid_wlinepoint(int index, Time time)const;
        int find_prev_valid_wlinepoint(int index, Time time)const;
 
+       int find_next_wlinepoint(int index, Time time)const;
+       int find_prev_wlinepoint(int index, Time time)const;
+
 protected:
 
        LinkableValueNode* create_new()const;
diff --git a/synfig-core/trunk/src/synfig/wlinepoint.h 
b/synfig-core/trunk/src/synfig/wlinepoint.h
index c9c52ef..e18a10a 100644
--- a/synfig-core/trunk/src/synfig/wlinepoint.h
+++ b/synfig-core/trunk/src/synfig/wlinepoint.h
@@ -68,6 +68,13 @@ public:
        float get_origin()const;
        void set_origin(float x);
 
+       //Operators
+       bool operator<(const WLinePoint& rhs)const { return pos_<rhs.pos_; }
+       bool operator>(const WLinePoint& rhs)const { return pos_>rhs.pos_; }
+       bool operator<=(const WLinePoint& rhs)const { return pos_<=rhs.pos_; }
+       bool operator>=(const WLinePoint& rhs)const { return pos_>=rhs.pos_; }
+       bool operator==(const WLinePoint& rhs)const { return pos_==rhs.pos_; }
+       bool operator!=(const WLinePoint& rhs)const { return pos_!=rhs.pos_; }
 
 }; // END of class WLinePoint
 


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Synfig-devl mailing list
Synfig-devl@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to