papyrus logo

bezierline.h

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

Generated on Fri Apr 16 12:40:10 2010 for papyrus by doxygen 1.6.1