I'm told that it's a bad idea to inherit from std::vector (because it has no virtual...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 15 Sep 2007 07:56:41 +0000 (07:56 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Sat, 15 Sep 2007 07:56:41 +0000 (07:56 +0000)
git-svn-id: http://svn.voria.com/code@673 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-core/trunk/src/synfig/gradient.cpp
synfig-core/trunk/src/synfig/gradient.h

index 21ea107..11b2295 100644 (file)
@@ -143,7 +143,7 @@ supersample_helper(const synfig::Gradient::CPoint &color1, const synfig::Gradien
 Color
 synfig::Gradient::operator()(const Real &x,float supersample)const
 {
-       if(empty())
+       if(cpoints.empty())
                return Color(0,0,0,0);
        if(supersample<0)
                supersample=-supersample;
@@ -153,11 +153,11 @@ synfig::Gradient::operator()(const Real &x,float supersample)const
        float begin_sample(x-supersample*0.5);
        float end_sample(x+supersample*0.5);
 
-       if(size()==1 || end_sample<=front().pos || isnan(x))
-               return front().color;
+       if(cpoints.size()==1 || end_sample<=cpoints.front().pos || isnan(x))
+               return cpoints.front().color;
 
-       if(begin_sample>=back().pos)
-               return back().color;
+       if(begin_sample>=cpoints.back().pos)
+               return cpoints.back().color;
 
        /*
        if(end_sample>=back().pos)
index 25a9dbf..bc4c1e8 100644 (file)
@@ -60,12 +60,17 @@ struct GradientCPoint : public UniqueID
 /*! \class Gradient
 **     \brief Color Gradient Class
 */
-class Gradient : public std::vector<GradientCPoint>
+using namespace std;
+class Gradient
 {
 public:
        typedef GradientCPoint CPoint;
+       typedef vector<GradientCPoint>::const_iterator const_iterator;
+       typedef vector<GradientCPoint>::iterator iterator;
+       typedef vector<GradientCPoint>::const_reverse_iterator const_reverse_iterator;
+       typedef vector<GradientCPoint>::reverse_iterator reverse_iterator;
 private:
-
+       vector<GradientCPoint> cpoints;
 public:
        Gradient() { }
 
@@ -81,6 +86,20 @@ public:
        //! You should call this function after changing stuff.
        void sort();
 
+       void push_back(const GradientCPoint cpoint) { cpoints.push_back(cpoint); }
+       iterator erase(iterator iter) { return cpoints.erase(iter); }
+       bool empty()const { return cpoints.empty(); }
+       size_t size()const { return cpoints.size(); }
+
+       iterator begin() { return cpoints.begin(); }
+       iterator end() { return cpoints.end(); }
+       reverse_iterator rbegin() { return cpoints.rbegin(); }
+       reverse_iterator rend() { return cpoints.rend(); }
+       const_iterator begin()const { return cpoints.begin(); }
+       const_iterator end()const { return cpoints.end(); }
+       const_reverse_iterator rbegin()const { return cpoints.rbegin(); }
+       const_reverse_iterator rend()const { return cpoints.rend(); }
+
        Color operator()(const Real &x, float supersample=0)const;
 
        //! Returns the iterator of the CPoint closest to \a x