polyline.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PAPYRUSPOLYLINE_H
00021 #define PAPYRUSPOLYLINE_H
00022
00023 #include <vector>
00024
00025 #include <papyrus/shape.h>
00026 #include <papyrus/marker.h>
00027
00056 namespace Papyrus
00057 {
00058
00059 class Vertex
00060 {
00061 public:
00062 Vertex ( double vx=0.0, double vy=0.0, bool vrelative=false ) :
00063 x ( vx ), y ( vy ), relative ( vrelative )
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 {
00088 protected:
00089
00090 Polyline ( const Glib::ustring& id, const Vertices& vertices, Fill::pointer fill, Stroke::pointer stroke );
00091
00092 public:
00093 typedef PapyrusPointer<Polyline> pointer;
00094
00096 static pointer create ( const Vertices& vertices = Vertices(), Stroke::pointer stroke = Stroke::pointer() );
00097
00098 static pointer create ( const Vertices& vertices, Fill::pointer fill, Stroke::pointer stroke = Stroke::pointer() );
00099
00100 static pointer create ( const Glib::ustring& id, Vertices vertices = Vertices(), Stroke::pointer stroke = Stroke::pointer() );
00101
00102 static pointer create ( const Glib::ustring& id, Vertices vertices, Fill::pointer fill, Stroke::pointer stroke = Stroke::pointer() );
00103
00104 virtual ~Polyline();
00105
00106 Polyline& operator= ( const Polyline& other );
00107
00108 Vertex vertex ( unsigned n ) const;
00109
00110 const Vertices& vertices() const;
00111
00112 void add_vertex ( Vertex v );
00113
00114 void add_vertex ( double x, double y );
00115
00116 void set_vertex ( unsigned n, Vertex v );
00117
00118 void set_vertex ( unsigned n, double x, double y );
00119
00120 void set_vertices ( const Vertices& vertices );
00121
00122 virtual Marker::pointer marker(MarkerPosition position);
00123
00129 virtual bool set_marker ( MarkerPosition position, Marker::pointer marker );
00130
00131 virtual void draw ( Cairo::RefPtr<Cairo::Context> cairo ) const;
00132
00134 virtual void draw_shape ( Cairo::RefPtr<Cairo::Context> cairo ) const;
00135
00136 sigc::signal<void, unsigned> signal_vertex();
00137 sigc::signal<void> signal_vertices();
00138
00139 PAPYRUS_CLASS_NAME ( "Polyline" );
00140
00141 PAPYRUS_CLONE_METHOD ( Polyline );
00142
00143 protected:
00144 Vertices m_vertices;
00145 Marker::pointer m_markers[3];
00146
00147 sigc::signal<void, unsigned> m_signal_vertex;
00148 sigc::signal<void> m_signal_vertices;
00149
00150 virtual void on_vertex_changed ( int n );
00151
00152 virtual void on_vertices_changed();
00153
00154 void update_marker_position( MarkerPosition n );
00155
00160 virtual Region calculate_pre_viewbox_extents(const Matrix& m = Matrix::Identity) const;
00161
00162 mutable sigc::connection m_marker_changed_connections[3];
00163
00164 void on_marker_changed(MarkerPosition which);
00165
00166 };
00167
00168 }
00169
00170 #endif