wxArt2D
vpath.h
Go to the documentation of this file.
1 /*! \file wx/canvas/vpath.h
2  \brief vector path a2dVectorPath derived from a2dCanvasObject
3 
4  a2dVectorPath holds internal a plain a2dVpath, which no can be styled and placed
5  inside a document.
6 
7  \author Klaas Holwerda
8 
9  Copyright: 2000-2004 (c) Klaas Holwerda
10 
11  Licence: wxWidgets Licence
12 
13  RCS-ID: $Id: vpath.h,v 1.17 2009/04/04 15:04:56 titato Exp $
14 */
15 
16 /*!
17  \defgroup vpath vector path a2dCanvasObject plus segment classes
18 
19  \ingroup canvasobject
20 */
21 
22 #ifndef __WXVPATH_H__
23 #define __WXVPATH_H__
24 
25 #ifndef WX_PRECOMP
26 #include "wx/wx.h"
27 #endif
28 
29 #include "wx/artbase/drawer2d.h"
30 #include "wx/canvas/canobj.h"
31 
32 //----------------------------------------------------------------------------
33 // a2dVectorPath
34 //----------------------------------------------------------------------------
35 
36 
37 //!a2dCanvasObject for a Vector Path
38 /*!
39  This class is mainly a wrapper around a2dVpath,
40  a2dVpath is a wxArray like structure.
41  So see wxArray for more documentation.
42 
43 
44  \sa a2dVpath
45  \sa a2dVpathqBCurveSegment
46  \sa a2dVpathCBCurveSegment
47  \sa a2dVpathArcSegment
48 
49  \sa wxArray
50 
51  \remark do use Shrink() after filling a a2dVectorPath, to reduce memory usage
52 
53  \ingroup canvasobject vpath
54 */
55 class A2DCANVASDLLEXP a2dVectorPath: public a2dCanvasObject
56 {
57 public:
58 
59  //! construct with empty array of segments
60  a2dVectorPath();
61 
62  //! initialize using a vector path array
63  a2dVectorPath( a2dVpath* path );
64 
65  //! construct with a pointer to another a2dVectorPath
66  a2dVectorPath( const a2dVectorPath& other, CloneOptions options, a2dRefMap* refs );
67 
68  ~a2dVectorPath();
69 
70  //! calculate Length
71  double Length() { return m_segments->Length(); }
72 
73  //! reduce matrix to identity without replacing object
74  bool EliminateMatrix();
75 
76  //! Convert complex segments to line segments.
77  void ConvertToLines();
78 
79  //! convert to a list of a2dPolygonL and a2dPolylineL
80  /*!
81  For vectorpaths can be split into closed sections ( polygon filled areas),
82  non closed sections ( polyline ). Those two type can be stroked or not.
83  If m_contourwidth is set the two type above are contoured and a distance of
84  m_contourwidth/2.0 and those parts are stroked.
85  Effectively this brings only pure polygons as output.
86  */
88 
89  a2dCanvasObjectList* GetAsCanvasVpaths( bool transform = true ) const;
90 
91  virtual bool RestrictToObject( a2dIterC& ic, const a2dPoint2D& pointToSnapTo, a2dPoint2D& bestPointSofar, a2dSnapToWhatMask snapToWhat, double thresHoldWorld );
92 
93  //!modify point at index to x,y
94  /*!
95  Set the coordinates of the point at index to x,y.
96  \param index the index of the point to change
97  \param x new x for the point
98  \param y new y for the point
99  \param afterinversion if true the input x,y or first inverted with the local matrix of the object.
100  The inverted values are used to set the point.
101 
102  \remark afterinversion = true should be used if you have x,y relative to the polygon object,
103  while afterinversion = false should be used when x,y are relative to the point in the polygon.
104  */
105  //void SetPosXYSegment(int index, double x, double y, bool afterinversion = true );
106 
107  //! get point x and y at index
108  /*!
109  \param index the index of the point to change
110  \param x new x for the point
111  \param y new y for the point
112  \param transform if true return x y transformed with local matrix
113  */
114  //void GetPosXYSegment(int index, double& x, double& y, bool transform = true );
115 
116  //! use this to get to other function in underlying wxArray
117  a2dVpath* GetSegments() { return m_segments; }
118 
119  //!Return the number of segments.
120  size_t GetCount() { return m_segments->size(); }
121 
122  //!Append a new segment, which is owned by this class now
123  void Add( a2dVpathSegment* item ) { m_segments->push_back( item ); }
124 
125  //!Preallocates memory for a given number of array elements.
126  /*!
127  It is worth calling when the number of items which are going to be added to the array
128  is known in advance because it will save unneeded memory reallocation.
129  If the array already has enough memory for the given number of items, nothing happens.
130  */
131  void Alloc( size_t count ) { m_segments->reserve( count ); }
132 
133  //!This function does the same as Empty() and additionally frees the memory allocated to the array.
134  void Clear() { m_segments->clear(); }
135 
136  //!Returns true if the array is empty, false otherwise.
137  bool IsEmpty() const { return m_segments->empty(); }
138 
139  //! get i'th segment
140  a2dVpathSegmentPtr operator[]( size_t index ) const { return m_segments->operator[]( index ); }
141 
142  //!Returns a reference to the segment at the given position in the array.
143  //!If index is out of bounds, an assert failure is raised in
144  //!the debug builds but nothing special is done in the release build.
145  a2dVpathSegmentPtr Item( size_t index ) const { return m_segments->operator[]( index ); }
146 
147  //!Returns a reference to the last segment in de array, i.e. is the same as
148  //!Item(GetCount() - 1). An assert failure is raised in the debug mode if the array is empty.
149  a2dVpathSegmentPtr Last() const { return m_segments->back(); }
150 
151  //!Removes a segment from the array by index. When a segment is removed
152  //!it is deleted - use Detach() if you don't want this to happen.
153  //void RemoveAt(size_t index) { m_segments->erase( index ); }
154 
155  void SetContourWidth( double width ) { m_contourwidth = width; SetPending( true ); }
156 
157  //!get the Contour width of the shape
158  double GetContourWidth() const { return m_contourwidth; }
159 
160  //! GDSII compatible to sub identify this object.
161  /*! you can use it as a special tagged object */
162  void SetDataType( int type ) { m_datatype = type; }
163 
164  //! GDSII compatible to sub identify this object.
165  /*! you can use it as a special tagged object */
166  int GetDataType() { return m_datatype; }
167 
168  //! Set when m_contourwidth != 0 what is the end of the lines should be.
169  void SetPathType( a2dPATH_END_TYPE pathtype ) { m_pathtype = pathtype; }
170 
171  //! get when m_contourwidth != 0 what is the end of the lines looks like.
172  a2dPATH_END_TYPE GetPathType() { return m_pathtype; }
173 
174  void DoRender( a2dIterC& ic, OVERLAP clipparent );
175 
176  DECLARE_DYNAMIC_CLASS( a2dVectorPath )
177 
178 protected:
179 
180  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
181  bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
182 
183  a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
184 
185  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
186 
187 #if wxART2D_USE_CVGIO
188  void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
189  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
190 #endif //wxART2D_USE_CVGIO
191 
192  a2dVpath* m_segments;
193 
194  //! if != 0 the continues path parts are contoured at distance m_contourwidth/2
196 
197  //! GDSII compatible to sub identify this object
199 
200  //! when m_contourwidth != 0 what is the end of the line looking like.
202 
203 private:
204  //!this is a not implemented copy constructor that avoids automatic creation of one
205  a2dVectorPath( const a2dVectorPath& other );
206 };
207 
208 #endif
209 
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
a2dPATH_END_TYPE
defines the way a polyline with a contour width is ended.
Definition: polyver.h:31
bool IsEmpty() const
Returns true if the array is empty, false otherwise.
Definition: vpath.h:137
void Clear()
This function does the same as Empty() and additionally frees the memory allocated to the array...
Definition: vpath.h:134
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
double GetContourWidth() const
get the Contour width of the shape
Definition: vpath.h:158
Ref Counted base object.
Definition: gen.h:1045
size_t GetCount()
Return the number of segments.
Definition: vpath.h:120
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
int GetDataType()
GDSII compatible to sub identify this object.
Definition: vpath.h:166
The base class for all drawable objects in a a2dCanvasDocument.
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
a2dPATH_END_TYPE GetPathType()
get when m_contourwidth != 0 what is the end of the lines looks like.
Definition: vpath.h:172
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
Definition: canobj.cpp:4695
virtual bool RestrictToObject(a2dIterC &ic, const a2dPoint2D &pointToSnapTo, a2dPoint2D &bestPointSofar, a2dSnapToWhatMask snapToWhat, double thresHoldWorld)
called from an a2dRestrictionEngine, to restrict vertexes, lines, object to this object.
Definition: canobj.cpp:4209
virtual a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canobj.cpp:1505
Normal straight line segment in a2dVpath.
Definition: polyver.h:878
a2dPATH_END_TYPE m_pathtype
when m_contourwidth != 0 what is the end of the line looking like.
Definition: vpath.h:201
void SetContourWidth(double width)
Definition: vpath.h:155
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
double Length()
calculate Length
Definition: vpath.h:71
int m_datatype
GDSII compatible to sub identify this object.
Definition: vpath.h:198
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
void SetPathType(a2dPATH_END_TYPE pathtype)
Set when m_contourwidth != 0 what is the end of the lines should be.
Definition: vpath.h:169
wxUint32 a2dSnapToWhatMask
mask for a2dSnapToWhat flags
Definition: restrict.h:26
a2dVpathSegmentPtr Last() const
Definition: vpath.h:149
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
Contains graphical drawing context specific classes. a2dDrawer2D and derived classes are used for dra...
void Alloc(size_t count)
Preallocates memory for a given number of array elements.
Definition: vpath.h:131
virtual bool EliminateMatrix()
reduce matrix to identity
Definition: canobj.cpp:6191
double m_contourwidth
if != 0 the continues path parts are contoured at distance m_contourwidth/2
Definition: vpath.h:195
void Add(a2dVpathSegment *item)
Append a new segment, which is owned by this class now.
Definition: vpath.h:123
void SetDataType(int type)
GDSII compatible to sub identify this object.
Definition: vpath.h:162
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
a2dVpath * GetSegments()
modify point at index to x,y
Definition: vpath.h:117
a2dCanvasObject for a Vector Path
Definition: vpath.h:55
virtual a2dCanvasObjectList * GetAsPolygons(bool transform=true) const
convert to a list of polygons.
Definition: canobj.cpp:1510
a2dVpathSegmentPtr Item(size_t index) const
Definition: vpath.h:145
Vector Path.
Definition: polyver.h:1211
list of a2dObject's
Definition: gen.h:3157
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
Definition: a2dlist.h:20
CloneOptions
options for cloning
Definition: gen.h:1200
a2dVpathSegmentPtr operator[](size_t index) const
get i'th segment
Definition: vpath.h:140
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
vpath.h Source File -- Sun Oct 12 2014 17:04:26 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation