34 m_pathtype = a2dPATH_END_SQAURE;
47 a2dVectorPath::~a2dVectorPath()
56 *m_segments = *other.m_segments;
77 canpathlist->push_back( copy );
88 for ( i = 0; i < m_segments->size(); i++ )
91 switch ( seg->GetType() )
125 bool nostrokeparts =
false;
131 for ( i = 0; i < m_segments->size(); i++ )
159 ret->push_back( poly );
167 for ( i = 0; i < m_segments->size(); i++ )
170 switch ( seg->GetType() )
202 for ( i = 0; i < m_segments->size(); i++ )
205 switch ( seg->GetType() )
222 nostrokeparts =
true;
231 nostrokeparts =
true;
236 double xwl = m_segments->Item( i ? i - 1 : 0 )->m_x1;
237 double ywl = m_segments->Item( i ? i - 1 : 0 )->m_y1;
244 xw = xwl * pow( 1 - t, 3 ) + cseg->
m_x2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_x3 * ( 1 - t ) * t * t * 3 + cseg->
m_x1 * pow( t, 3 );
245 yw = ywl * pow( 1 - t, 3 ) + cseg->
m_y2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_y3 * ( 1 - t ) * t * t * 3 + cseg->
m_y1 * pow( t, 3 );
255 nostrokeparts =
true;
260 double xwl = m_segments->Item( i ? i - 1 : 0 )->m_x1;
261 double ywl = m_segments->Item( i ? i - 1 : 0 )->m_y1;
268 xw = xwl * pow( 1 - t, 2 ) + cseg->
m_x2 * ( 1 - t ) * t * 2 + cseg->
m_x1 * pow( t, 2 );
269 yw = ywl * pow( 1 - t, 2 ) + cseg->
m_y2 * ( 1 - t ) * t * 2 + cseg->
m_y1 * pow( t, 2 );
279 nostrokeparts =
true;
284 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
286 if ( cseg->
CalcR( m_segments->Item( i ? i - 1 : 0 ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
289 unsigned int segments;
292 double theta = beginrad;
296 for ( step = 0; step < segments + 1; step++ )
301 theta = theta + dphi;
320 ret->push_back( polyl );
331 ret->push_back( poly );
332 nostrokeparts =
true;
338 ret->push_back( poly );
345 else if ( i == m_segments->size() - 1 )
350 ret->push_back( polyl );
360 nostrokeparts =
false;
362 double lastmovex = 0;
363 double lastmovey = 0;
365 for ( i = 0; i < m_segments->size(); i++ )
368 switch ( seg->GetType() )
405 nostrokeparts =
true;
413 double xwl = m_segments->Item( i ? i - 1 : 0 )->m_x1;
414 double ywl = m_segments->Item( i ? i - 1 : 0 )->m_y1;
421 xw = xwl * pow( 1 - t, 3 ) + cseg->
m_x2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_x3 * ( 1 - t ) * t * t * 3 + cseg->
m_x1 * pow( t, 3 );
422 yw = ywl * pow( 1 - t, 3 ) + cseg->
m_y2 * pow( 1 - t, 2 ) * t * 3 + cseg->
m_y3 * ( 1 - t ) * t * t * 3 + cseg->
m_y1 * pow( t, 3 );
435 double xwl = m_segments->Item( i ? i - 1 : 0 )->m_x1;
436 double ywl = m_segments->Item( i ? i - 1 : 0 )->m_y1;
443 xw = xwl * pow( 1 - t, 2 ) + cseg->
m_x2 * ( 1 - t ) * t * 2 + cseg->
m_x1 * pow( t, 2 );
444 yw = ywl * pow( 1 - t, 2 ) + cseg->
m_y2 * ( 1 - t ) * t * 2 + cseg->
m_y1 * pow( t, 2 );
457 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
459 if ( cseg->
CalcR( m_segments->Item( i ? i - 1 : 0 ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
462 unsigned int segments;
465 double theta = beginrad;
469 for ( step = 0; step < segments + 1; step++ )
474 theta = theta + dphi;
488 if ( move || nostrokeparts )
493 ret->push_back( polyl );
495 nostrokeparts =
false;
509 ret->push_back( polyl );
510 nostrokeparts =
false;
515 else if ( i == m_segments->size() )
520 ret->push_back( polyl );
538 for ( i = 0; i < m_segments->size() ; i++ )
541 m_segments->Item( i )->m_x1, m_segments->Item( i )->m_y1 );
552 for ( i = 0; i < m_segments->size(); i++ )
555 switch ( seg->GetType() )
579 double radius, center_x, center_y, beginrad, midrad, endrad, phit;
582 if ( cseg->
CalcR( m_segments->Item( i ? i - 1 : 0 ), radius, center_x, center_y, beginrad, midrad, endrad, phit ) )
584 bbox.
Expand( center_x + radius , center_y + radius );
585 bbox.
Expand( center_x + radius , center_y - radius );
586 bbox.
Expand( center_x - radius , center_y + radius );
587 bbox.
Expand( center_x - radius , center_y - radius );
597 bbox.
Expand( m_segments->Item( i )->m_x1, m_segments->Item( i )->m_y1 );
632 *segments = *m_segments;
641 #if wxART2D_USE_CVGIO
646 if ( xmlparts == a2dXmlSer_attrib )
648 out.WriteAttribute( wxT(
"segments" ), m_segments->size() );
654 for ( i = 0; i < m_segments->size(); i++ )
661 switch ( seg->m_type )
665 out.WriteAttribute( wxT(
"type" ), wxT(
"moveto" ) );
666 out.WriteAttribute( wxT(
"x1" ), seg->m_x1 );
667 out.WriteAttribute( wxT(
"y1" ), seg->m_y1 );
672 out.WriteAttribute( wxT(
"type" ), wxT(
"lineto" ) );
673 out.WriteAttribute( wxT(
"x1" ), seg->m_x1 );
674 out.WriteAttribute( wxT(
"y1" ), seg->m_y1 );
679 out.WriteAttribute( wxT(
"type" ), wxT(
"lineto_nostroke" ) );
680 out.WriteAttribute( wxT(
"x1" ), seg->m_x1 );
681 out.WriteAttribute( wxT(
"y1" ), seg->m_y1 );
687 out.WriteAttribute( wxT(
"type" ), wxT(
"cb_curveto" ) );
688 out.WriteAttribute( wxT(
"x1" ), seg->m_x1 );
689 out.WriteAttribute( wxT(
"y1" ), seg->m_y1 );
691 out.WriteAttribute( wxT(
"x2" ), cseg->
m_x2 );
692 out.WriteAttribute( wxT(
"y2" ), cseg->
m_y2 );
693 out.WriteAttribute( wxT(
"x3" ), cseg->
m_x3 );
694 out.WriteAttribute( wxT(
"y3" ), cseg->
m_y3 );
699 out.WriteAttribute( wxT(
"type" ), wxT(
"cb_curveto_nostroke" ) );
700 out.WriteAttribute( wxT(
"x1" ), seg->m_x1 );
701 out.WriteAttribute( wxT(
"y1" ), seg->m_y1 );
703 out.WriteAttribute( wxT(
"x2" ), cseg->
m_x2 );
704 out.WriteAttribute( wxT(
"y2" ), cseg->
m_y2 );
705 out.WriteAttribute( wxT(
"x3" ), cseg->
m_x3 );
706 out.WriteAttribute( wxT(
"y3" ), cseg->
m_y3 );
712 out.WriteAttribute( wxT(
"type" ), wxT(
"qb_curveto" ) );
713 out.WriteAttribute( wxT(
"x1" ), seg->m_x1 );
714 out.WriteAttribute( wxT(
"y1" ), seg->m_y1 );
716 out.WriteAttribute( wxT(
"x2" ), cseg->
m_x2 );
717 out.WriteAttribute( wxT(
"y2" ), cseg->
m_y2 );
722 out.WriteAttribute( wxT(
"type" ), wxT(
"qb_curveto_nostroke" ) );
723 out.WriteAttribute( wxT(
"x1" ), seg->m_x1 );
724 out.WriteAttribute( wxT(
"y1" ), seg->m_y1 );
726 out.WriteAttribute( wxT(
"x2" ), cseg->
m_x2 );
727 out.WriteAttribute( wxT(
"y2" ), cseg->
m_y2 );
733 out.WriteAttribute( wxT(
"type" ), wxT(
"arcto" ) );
734 out.WriteAttribute( wxT(
"x1" ), seg->m_x1 );
735 out.WriteAttribute( wxT(
"y1" ), seg->m_y1 );
737 out.WriteAttribute( wxT(
"x2" ), cseg->
m_x2 );
738 out.WriteAttribute( wxT(
"y2" ), cseg->
m_y2 );
743 out.WriteAttribute( wxT(
"type" ), wxT(
"arcto_nostroke" ) );
744 out.WriteAttribute( wxT(
"x1" ), seg->m_x1 );
745 out.WriteAttribute( wxT(
"y1" ), seg->m_y1 );
747 out.WriteAttribute( wxT(
"x2" ), cseg->
m_x2 );
748 out.WriteAttribute( wxT(
"y2" ), cseg->
m_y2 );
755 switch ( seg->m_close )
759 out.WriteAttribute( wxT(
"end" ), wxT(
"open" ) );
764 out.WriteAttribute( wxT(
"end" ), wxT(
"closed" ) );
769 out.WriteAttribute( wxT(
"end" ), wxT(
"closed_nostroke" ) );
781 if ( xmlparts == a2dXmlSer_attrib )
801 if ( send == wxT(
"open" ) )
803 else if ( send == wxT(
"closed" ) )
805 else if ( send == wxT(
"closed_nostroke" ) )
810 if ( type == wxT(
"moveto" ) )
814 else if ( type == wxT(
"lineto" ) )
818 else if ( type == wxT(
"lineto_nostroke" ) )
823 else if ( type == wxT(
"cb_curveto" ) )
827 else if ( type == wxT(
"cb_curveto_nostroke" ) )
832 else if ( type == wxT(
"qb_curveto" ) )
836 else if ( type == wxT(
"qb_curveto_nostroke" ) )
841 else if ( type == wxT(
"arcto" ) )
845 else if ( type == wxT(
"arcto_nostroke" ) )
850 m_segments->push_back( seg );
858 #endif //wxART2D_USE_CVGIO
a2dHit m_how
return in which way the object was hit (stroke, fill, ...)
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
double m_relx
(world coordinates) hit point x relative to the canvas object its parent object(s) ...
bool IsPolygon(bool allowArc=true)
test if closed polygon ( a2dPATHSEG_MOVETO, a2dPATHSEG_LINETO, a2dPATHSEG_ARCTO ) ...
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.
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
void DoRender(a2dIterC &ic, OVERLAP clipparent)
render derived object
void ConvertToLines()
Convert complex segments to line segments.
XMLeventType Next()
Walks to next element and returns event type.
class to map references to objects stored in XML, in order to make the connection later on...
const int SPLINE_STEP
number of steps when converting a spline to lines.
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
void Transform(const a2dAffineMatrix &world)
transform all segments with given matrix
void WriteStartElementAttributes(const wxString &name, bool newLine=true)
Writes start tag which has attributes.
polygon defined with list of points.
virtual void DrawVpath(const a2dVpath *path)
Draw vector path in world coordinates.
bool EliminateMatrix()
reduce matrix to identity without replacing object
a2dCanvasObjectList * GetAsPolygons()
convert to a list of a2dPolygonL and a2dPolylineL
void Enlarge(const double Marge)
enlarge with the given amount
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
bool IsHit() const
true if this is a hit
double m_y3
control point 2
bool IsIdentity(void) const
Is the matrix the identity matrix?
double m_x3
control point 2
Input and output handler for the XmlSer format.
bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
UpdateMode
Various mode flags for Update.
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
a2dGlobal * a2dGlobals
global a2dCanvasGlobal to have easy access to global settings
Arc Segment in a2dVertexList.
a2dVectorPath()
construct with empty array of segments
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
a2dCanvasObject is the base class for Canvas Objects.
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
double m_y2
control point 1
a2dPATHSEG_END GetClose() const
is this segment the closing a part since the last move
bool SetPointIfCloser(const a2dPoint2D &pointToSnapTo, const a2dPoint2D &pointToSnap, a2dPoint2D &bestPointSofar, double thresHoldWorld)
vertex list of line and arc segments.
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
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.
void SetContourWidth(double width)
set the Contour width of the shape
vector path a2dVectorPath derived from a2dCanvasObject
a2dAffineMatrix m_lworld
used for positioning the object (x,y,ang,scale etc.)
snap to other objects its vertexes, which are decided in a2dCanvasObject::RestrictToObject() ...
void WriteNewLine()
Writes a new line and takes care of indentation.
void SetPathType(a2dPATH_END_TYPE pathtype)
Set when m_contourwidth != 0 what is the end of the line should be.
double m_y2
second control point
bool GetValid() const
returns true if boundingbox is calculated properly and therefore its valid flag is set...
void Expand(const a2dPoint2D &, const a2dPoint2D &)
expand boundingbox width two points
bool IsTranslate(void) const
Is the matrix only a translation?
a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
In derived object this should be overriden to calculate the boundingbox of the object without its chi...
polyline defined with list of points.
a2dDrawer2D * GetDrawer2D() const
get current a2dDrawer2D
Normal straight line segment in a2dVpath.
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
a2dPATH_END_TYPE m_pathtype
when m_contourwidth != 0 what is the end of the line looking like.
Normal straight line segment in a2dVertexList and a2dVertexArray.
bool CalcR(a2dVpathSegmentPtr prev, double &radius, double ¢er_x, double ¢er_y, double &beginrad, double &midrad, double &endrad, double &phit)
Calculation of center for the Arc.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
int m_datatype
GDSII compatible to sub identify this object.
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Input and output handler for the XmlSer format.
wxUint32 a2dSnapToWhatMask
mask for a2dSnapToWhat flags
void WriteEndAttributes(bool close=false)
"Closes" the start tag after writing all attributes (writes the ">" or "/>" bracket).
double m_x2
control point 1
A 2x3 affine matrix class for 2D transformations.
double GetAttributeValueDouble(const wxString &attrib, double defaultv=0)
Returns the double value of an attribute.
void Aberration(double angle, double radius, double &dphi, unsigned int &segments)
based on angle and radius and m_displayaberration calculate a proper delta phi and number of segments...
while iterating a a2dCanvasDocument, this holds the context.
void MapBbox(const a2dAffineMatrix &matrix)
a2dPATHSEG GetType() const
easy way to test type of segment
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
double m_y1
y endpoint of line
void Require(const XMLeventType &type, wxString name)
Forces a special tag.
wxString GetTagName()
Returns name of the current XML tag.
virtual bool EliminateMatrix()
reduce matrix to identity
double m_contourwidth
if != 0 the continues path parts are contoured at distance m_contourwidth/2
bool IsPolyline(bool allowArc=true)
test if polyline ( a2dPATHSEG_MOVETO, a2dPATHSEG_LINETO, a2dPATHSEG_ARCTO )
a2dPATHSEG_END
end of a segment type
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
void Contour(double distance, a2dPATH_END_TYPE pathtype)
create an offset contour at distance
static a2dHit stock_fill
Stock object for a fill hit.
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
double m_x1
x endpoint of line
a2dCanvasObject for a Vector Path
a2dVpathSegmentPtr Item(size_t index) const
a2dBoundingBox m_bbox
boundingbox in world coordinates
double m_rely
(world coordinates) hit point y relative to the canvas object its parent object(s) ...
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
CloneOptions
options for cloning
double m_x2
second control point
structure to give as parameter to member functions of a2dCanvasObject
void ConvertToLines()
Convert complex segments to line segments.