polyline.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 PAPYRUSPOLYLINE_H
00020 #define PAPYRUSPOLYLINE_H
00021 
00022 #include <vector>
00023 
00024 #include <papyrus/shape.h>
00025 #include <papyrus/marker.h>
00026 
00057 namespace Papyrus {
00058 
00059 class Vertex {
00060         public:
00061                 Vertex(double vx=0.0, double vy=0.0, bool vrelative=false):
00062       x(vx), y(vy), relative(vrelative)
00063     {
00064                 }
00065 
00066                 virtual ~Vertex() { }
00067 
00068                 double x, y;
00069     bool relative;
00070 };
00071 
00072 typedef std::vector<Vertex> Vertices;
00073 
00086   class Polyline : public Shape {
00087     public:
00088       typedef PapyrusSmartPointer<Polyline> pointer;
00089 
00090       Polyline( Vertices vertices = Vertices() );
00091 
00093       static Polyline::pointer create( Vertices vertices = Vertices() );
00094 
00095       ~Polyline();
00096 
00097       Polyline& operator=(const Polyline& other);
00098 
00099       LineStyle& line_style();
00100 
00101                         Vertex get_vertex(unsigned n);
00102 
00103                         const Vertices& get_vertices();
00104 
00105                         void add_vertex(Vertex v);
00106 
00107                         void add_vertex(double x, double y);
00108 
00109                         void set_vertex(unsigned n, Vertex v);
00110 
00111                         void set_vertex(unsigned n, double x, double y);
00112 
00113                         void set_vertices(Vertices vertices);
00114 
00115       virtual void set_line_style( const LineStyle& style );
00116 
00117       virtual Drawable::pointer start_marker();
00118 
00119       virtual void set_start_marker(Drawable::pointer);
00120 
00121       virtual Drawable::pointer end_marker();
00122 
00123       virtual void set_end_marker(Drawable::pointer);
00124 
00125       virtual Drawable::pointer vertex_marker();
00126 
00127       virtual void set_vertex_marker(Drawable::pointer);
00128 
00129       virtual void draw(Cairo::RefPtr<Cairo::Context> cairo);
00130 
00132       virtual void draw_shape( Cairo::RefPtr<Cairo::Context> cairo );
00133 
00134       sigc::signal<void, unsigned>& signal_vertex();
00135       sigc::signal<void>& signal_vertices();
00136       sigc::signal<void> signal_start_marker();
00137       sigc::signal<void> signal_end_marker();
00138       sigc::signal<void> signal_vertex_marker();
00139 
00140       PAPYRUS_CLASS_NAME("Polyline");
00141 
00142       PAPYRUS_CLONE_METHOD( Polyline );
00143 
00144     protected:
00145                         Vertices m_vertices;
00146       Drawable::pointer m_start_marker, m_end_marker, m_vertex_marker;
00147                         Region m_vertex_extents;
00148 
00149                         sigc::signal<void, unsigned> m_signal_vertex;
00150                         sigc::signal<void> m_signal_vertices;
00151       sigc::signal<void> m_signal_start_marker;
00152       sigc::signal<void> m_signal_end_marker;
00153       sigc::signal<void> m_signal_vertex_marker;
00154 
00155                         virtual void on_vertex_changed(int n);
00156 
00157                         virtual void on_vertices_changed();
00158 
00162                         virtual void set_extents(const Region& extents);
00163 
00164   };
00165 
00166 }
00167 
00168 #endif

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