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

Author: Carlos Lopez <car...@pcnuevo.(none)>
Date:   Fri Jul 31 19:27:57 2009 +0200

Modify the sort operation and add unsort operation to the valuenode_wline

---

 synfig-core/trunk/src/synfig/valuenode_wline.cpp |   17 ++++++++++++++++-
 synfig-core/trunk/src/synfig/valuenode_wline.h   |    5 +++++
 synfig-core/trunk/src/synfig/wlinepoint.cpp      |   17 +++++++++++++++++
 synfig-core/trunk/src/synfig/wlinepoint.h        |    8 ++++++++
 4 files changed, 46 insertions(+), 1 deletions(-)

diff --git a/synfig-core/trunk/src/synfig/valuenode_wline.cpp 
b/synfig-core/trunk/src/synfig/valuenode_wline.cpp
index 3f324e5..5331c3c 100644
--- a/synfig-core/trunk/src/synfig/valuenode_wline.cpp
+++ b/synfig-core/trunk/src/synfig/valuenode_wline.cpp
@@ -497,6 +497,21 @@ ValueNode_WLine::check_type(ValueBase::Type type)
 void
 ValueNode_WLine::list_sort()
 {
-       // sort in ascending order
+       // First store the current list order on each wlinepoint
+       int index(0);
+       std::vector<ListEntry>::const_iterator iter;
+       for (iter=list.begin(), iter!=list.end();++iter, index++)
+       {
+               iter->set_list_index(index);
+       }
+
+       // Then sort in ascending order
        sort(list.begin(),list.end());
 }
+
+void
+ValueNode_WLine::list_unsort()
+{
+       // Restore the original order based on stored index
+       sort(list.begin(),list.end(), icmp);
+}
diff --git a/synfig-core/trunk/src/synfig/valuenode_wline.h 
b/synfig-core/trunk/src/synfig/valuenode_wline.h
index da84591..e7c1b44 100644
--- a/synfig-core/trunk/src/synfig/valuenode_wline.h
+++ b/synfig-core/trunk/src/synfig/valuenode_wline.h
@@ -90,8 +90,13 @@ public:
        //! Sorts the List of WLinePoints based on its position parameter
        //! This is needed to perform the operations of insert and interpolate
        //! the width at a given amount of the bline.
+       //! Also it stores the index of the list in the wlinepoint to unsort 
later
        void list_sort();
 
+       //! Restores the original list sorted by the index not by the origin
+       //! of each wlinepoint hold.
+       void list_unsort();
+
 protected:
 
        LinkableValueNode* create_new()const;
diff --git a/synfig-core/trunk/src/synfig/wlinepoint.cpp 
b/synfig-core/trunk/src/synfig/wlinepoint.cpp
index 4fff9b4..56f0741 100644
--- a/synfig-core/trunk/src/synfig/wlinepoint.cpp
+++ b/synfig-core/trunk/src/synfig/wlinepoint.cpp
@@ -45,6 +45,11 @@ using namespace synfig;
 
 /* === P R O C E D U R E S ================================================= */
 
+bool icmp(WLinepoint a, WLinePoin b)
+{
+       return (a.get_list_index() < b.get_list_index());
+}
+
 /* === M E T H O D S ======================================================= */
 
 WLinePoint::WLinePoint():
@@ -88,3 +93,15 @@ WLinePoint::set_origin(Real x)
 {
        origin_=x;
 }
+
+const int
+WLinePoint::get_list_index()const
+{
+        return list_index_;
+}
+
+void
+WLinePoint::set_list_index(int x)
+{
+        list_index_=x;
+}
diff --git a/synfig-core/trunk/src/synfig/wlinepoint.h 
b/synfig-core/trunk/src/synfig/wlinepoint.h
index 8f460ac..2f39f46 100644
--- a/synfig-core/trunk/src/synfig/wlinepoint.h
+++ b/synfig-core/trunk/src/synfig/wlinepoint.h
@@ -56,6 +56,10 @@ private:
        //! big position. 0.5 means averaged.
        Real    origin_;
 
+private:
+       //!The index from the List. Used to track the order in the list
+       int list_index_;
+
 public:
 
        WLinePoint();
@@ -76,6 +80,10 @@ public:
        bool operator==(const WLinePoint& rhs)const { return 
position_==rhs.position_; }
        bool operator!=(const WLinePoint& rhs)const { return 
position_!=rhs.position_; }
 
+       public:
+       const int get_list_index() const;
+       void set_list_index(int x);
+
 }; // END of class WLinePoint
 
 }; // END of namespace synfig


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