bezierline.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation version 2.1.                *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this library; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018  ***************************************************************************/
00019 #ifndef PAPYRUSBEZIERLINE_H
00020 #define PAPYRUSBEZIERLINE_H
00021 
00022 #include <vector>
00023 
00024 #include <papyrus/shape.h>
00025 #include <papyrus/marker.h>
00026 #include <papyrus/polyline.h>
00027 
00071 namespace Papyrus
00072 {
00073 
00074   class BezierVertex : public Vertex
00075   {
00076     public:
00077       BezierVertex( double vx = 0.0, double vy = 0.0, double vc1x = 0.0, double vc1y = 0.0, double vc2x = 0.0, double vc2y = 0.0, bool vrelative = false ) :
00078           Vertex( vx, vy, vrelative ), c1x( vc1x ), c1y( vc1y ), c2x( vc2x ), c2y( vc2y )
00079       {}
00080 
00081       virtual ~BezierVertex()
00082       { }
00083 
00084       double c1x, c1y, c2x, c2y;
00085   };
00086 
00087   typedef std::vector<BezierVertex> BezierVertices;
00088 
00094   class Bezierline : public Shape
00095   {
00096     public:
00097       typedef PapyrusSmartPointer<Bezierline> pointer;
00098 
00099       Bezierline( BezierVertices vertices = BezierVertices() );
00100 
00102       static Bezierline::pointer create( BezierVertices vertices = BezierVertices() );
00103 
00104       ~Bezierline();
00105 
00106       Bezierline& operator=( const Bezierline& other );
00107 
00108       LineStyle& line_style();
00109 
00110       BezierVertex get_vertex( unsigned n );
00111 
00112       const BezierVertices& get_vertices();
00113 
00114       void add_vertex( BezierVertex v );
00115 
00116       void add_vertex( double x, double y, double c1x, double c1y, double c2x, double c2y );
00117 
00118       void set_vertex( unsigned n, BezierVertex v );
00119 
00120       void set_vertex( unsigned n, double x, double y, double c1x, double c1y, double c2x, double c2y );
00121 
00122       void set_vertices( BezierVertices vertices );
00123 
00124       virtual void set_line_style( const LineStyle& style );
00125 
00126       virtual Drawable::pointer start_marker();
00127 
00128       virtual void set_start_marker( Drawable::pointer );
00129 
00130       virtual Drawable::pointer end_marker();
00131 
00132       virtual void set_end_marker( Drawable::pointer );
00133 
00134       virtual Drawable::pointer vertex_marker();
00135 
00136       virtual void set_vertex_marker( Drawable::pointer );
00137 
00138       virtual void draw( Cairo::RefPtr<Cairo::Context> cairo );
00139 
00141       virtual void draw_shape( Cairo::RefPtr<Cairo::Context> cairo );
00142 
00143       sigc::signal<void, unsigned>& signal_vertex();
00144       sigc::signal<void>& signal_vertices();
00145       sigc::signal<void> signal_start_marker();
00146       sigc::signal<void> signal_end_marker();
00147       sigc::signal<void> signal_vertex_marker();
00148 
00149       PAPYRUS_CLASS_NAME("Bezierline");
00150 
00151       PAPYRUS_CLONE_METHOD( Bezierline );
00152 
00153     protected:
00154       BezierVertices m_vertices;
00155       Drawable::pointer m_start_marker, m_end_marker, m_vertex_marker;
00156       Region m_vertex_extents;
00157 
00158       sigc::signal<void, unsigned> m_signal_vertex;
00159       sigc::signal<void> m_signal_vertices;
00160       sigc::signal<void> m_signal_start_marker;
00161       sigc::signal<void> m_signal_end_marker;
00162       sigc::signal<void> m_signal_vertex_marker;
00163 
00164       virtual void on_vertex_changed( int n );
00165 
00166       virtual void on_vertices_changed();
00167 
00171       virtual void set_extents( const Region& extents );
00172 
00173   };
00174 
00175 }
00176 
00177 #endif

Generated on Sun Mar 11 10:01:27 2007 by  doxygen 1.5.1