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

Author: Carlos Lopez <[email protected]>
Date:   Sat Jan  8 11:48:01 2011 +0100

Code find next and previous valid entries by position ValueNode_WPList members.

---

 synfig-core/src/synfig/valuenode_wplist.cpp |   47 +++++++++++++++++++++++++--
 synfig-core/src/synfig/valuenode_wplist.h   |    4 ++
 2 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/synfig-core/src/synfig/valuenode_wplist.cpp 
b/synfig-core/src/synfig/valuenode_wplist.cpp
index fc7642c..afa1a24 100644
--- a/synfig-core/src/synfig/valuenode_wplist.cpp
+++ b/synfig-core/src/synfig/valuenode_wplist.cpp
@@ -55,7 +55,7 @@ using namespace synfig;
 
 //! Converts a ValueNode_BLine into a WidthPoint list
 ValueBase
-synfig::convert_bline_to_wpoint_list(const ValueBase& bline)
+synfig::convert_bline_to_wplist(const ValueBase& bline)
 {
        // returns if the parameter is not a list or if it is a list, it is 
empty
        if(bline.empty())
@@ -135,7 +135,7 @@ ValueNode_WPList::create(const ValueBase &value)
                case ValueBase::TYPE_BLINEPOINT:
                {
                        // this will create a standard list of width points
-                       std::vector<WidthPoint> 
wplist(convert_bline_to_width_list(value));
+                       std::vector<WidthPoint> 
wplist(convert_bline_to_wplist(value));
                        // and then let's call again the create method to 
convert the
                        // standard list of widthpoints to a ValueNode_WPList
                        return create(wplist);
@@ -207,7 +207,7 @@ ValueNode_WPList::operator()(Time t)const
 
        std::vector<WidthPoint> ret_list;
 
-       std::vector<ListEntry>::const_iterator iter,first_iter;
+       std::vector<ListEntry>::const_iterator iter;
        bool rising;
 
        WidthPoint curr;
@@ -305,3 +305,44 @@ ValueNode_WPList::check_type(ValueBase::Type type)
 {
        return type==ValueBase::TYPE_LIST;
 }
+
+synfig::WidthPoint
+ValueNode_WPList::find_next_valid_entry_by_postion(Real position, Time 
time=0)const
+{
+       std::vector<ListEntry>::const_iterator iter;
+       Real next_pos(10000.0);
+       synfig::WidthPoint curr, next_ret(next_pos, 0.0);
+       for(iter=list.begin();iter!=list.end();++iter)
+       {
+               curr=(*iter->value_node)(t).get(curr)
+               Real curr_pos(curr.get_position());
+               bool status(iter->status_at_time(time);
+               if((curr_pos => position && curr_pos <=next_pos) && status)
+               {
+                       next_pos=curr_pos;
+                       next_ret=curr;
+               }
+       }
+       return next_ret;
+}
+
+synfig::WidthPoint
+ValueNode_WPList::find_prev_valid_entry_by_postion(Real position, Time 
time=0)const
+{
+       std::vector<ListEntry>::const_iterator iter;
+       Real prev_pos(-10000.0);
+       synfig::WidthPoint curr, prev_ret(prev_pos, 0.0);
+       for(iter=list.begin();iter!=list.end();++iter)
+       {
+               curr=(*iter->value_node)(t).get(curr)
+               Real curr_pos(curr.get_position());
+               bool status(iter->status_at_time(time);
+               if((curr_pos <= position && curr_pos >=prev_pos) && status)
+               {
+                       prev_pos=curr_pos;
+                       prev_ret=curr;
+               }
+       }
+       return prev_ret;
+}
+
diff --git a/synfig-core/src/synfig/valuenode_wplist.h 
b/synfig-core/src/synfig/valuenode_wplist.h
index 076a973..d8ac9dd 100644
--- a/synfig-core/src/synfig/valuenode_wplist.h
+++ b/synfig-core/src/synfig/valuenode_wplist.h
@@ -70,6 +70,10 @@ public:
        //! \param time the time when inserted in animation mode
        //! \return the new List Entry
        virtual ListEntry create_list_entry(Real position, Time time=0);
+       //! Finds a fully on width point at given time and after the given 
position
+       synfig::WidthPoint find_next_valid_entry_by_postion(Real position, Time 
time=0)const;
+       //! Finds a fully on width point at given time and before the given 
position
+       synfig::WidthPoint find_prev_valid_entry_by_postion(Real position, Time 
time=0)const;
 
 protected:
 


------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl

Reply via email to