]>
git.saurik.com Git - wxWidgets.git/blob - contrib/include/wx/canvas/polygon.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Author: Klaas Holwerda
5 // Copyright: 2000 (c) Klaas Holwerda
6 // Licence: wxWindows Licence
7 /////////////////////////////////////////////////////////////////////////////
9 #ifndef __WXPOLYGON_H__
10 #define __WXPOLYGON_H__
13 #pragma interface "polygon.cpp"
20 #include "wx/matrix.h"
21 #include "wx/geometry.h"
25 enum INOUTPOLY
{OUTSIDE_POLY
,INSIDE_POLY
,ON_POLY
};
27 //----------------------------------------------------------------------------
29 //----------------------------------------------------------------------------
31 class wxCanvasPolygon
: public wxCanvasObject
34 wxCanvasPolygon( int n
, wxPoint2DDouble points
[], bool spline
= FALSE
);
36 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; }
37 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); }
40 //being the background color if filling with a monochrome bitmap
41 //or in case of gradient filling the starting colour for the fill
42 void SetColour1( const wxColour
& fg
) { m_textfg
=fg
;}
44 //being the foreground color if filling with a monochrome bitmap
45 //or in case of gradient filling the ending colour for the fill
46 void SetColour2( const wxColour
& bg
) { m_textbg
=bg
;}
47 //transparent filling when bitmapbrush is monochrome
48 void SetTransParent(bool transp
) { m_transp
=transp
;}
49 //gradient filling using lines chnging in colour from colour1 to colour2
50 void SetGradient(bool gradient
, const wxPen
& gpen
, double distance
)
51 { m_gradient
=gradient
;
56 double GetPosX() { return m_points
[0].m_x
; }
57 double GetPosY() { return m_points
[0].m_y
; }
58 void SetPosXY( double x
, double y
);
60 void TransLate( double x
, double y
);
61 void CalcBoundingBox();
63 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
64 virtual void WriteSVG( wxTextOutputStream
&stream
);
66 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
68 INOUTPOLY
PointInPolygon(const wxPoint2DDouble
& P
, double marge
);
72 bool MoveUp(double horline
, int& index
, int direction
);
73 void DetectCriticalPoints();
74 void FillPolygon(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
84 //if brush is of type bitmap with a mask fill with mask transparent
93 wxPoint2DDouble
* m_points
;
96 //----------------------------------------------------------------------------
98 //----------------------------------------------------------------------------
100 class wxCanvasPolyline
: public wxCanvasObject
103 wxCanvasPolyline(int n
, wxPoint2DDouble points
[]);
105 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); }
107 double GetPosX() { return m_points
[0].m_x
; }
108 double GetPosY() { return m_points
[0].m_y
; }
109 void SetPosXY( double x
, double y
);
111 void TransLate( double x
, double y
);
112 void CalcBoundingBox();
114 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
115 virtual void WriteSVG( wxTextOutputStream
&stream
);
117 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
119 bool PointOnPolyline(const wxPoint2DDouble
& P
, double marge
);
126 wxPoint2DDouble
* m_points
;
129 //----------------------------------------------------------------------------
131 //----------------------------------------------------------------------------
133 class wxCanvasPolygonL
: public wxCanvasObject
136 wxCanvasPolygonL(wxList
* points
, bool spline
= FALSE
);
138 void SetBrush( const wxBrush
& brush
) { m_brush
= brush
; }
139 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); }
140 void SetColour1( const wxColour
& fg
) { m_textfg
=fg
;}
141 void SetColour2( const wxColour
& bg
) { m_textbg
=bg
;}
142 void SetTransParent(bool transp
) { m_transp
=transp
;}
146 void SetPosXY( double x
, double y
);
147 void TransLate( double x
, double y
);
148 void CalcBoundingBox();
150 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
151 virtual void WriteSVG( wxTextOutputStream
&stream
);
153 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
155 INOUTPOLY
PointInPolygon(const wxPoint2DDouble
& P
, double marge
);
164 //if brush is of type bitmap with a mask fill with mask transparent
170 //----------------------------------------------------------------------------
172 //----------------------------------------------------------------------------
174 class wxCanvasPolylineL
: public wxCanvasObject
177 wxCanvasPolylineL(wxList
* points
, bool spline
);
178 ~wxCanvasPolylineL();
179 void SetPen( const wxPen
& pen
) { m_pen
= pen
; CalcBoundingBox(); }
183 void SetPosXY( double x
, double y
);
185 void TransLate( double x
, double y
);
186 void CalcBoundingBox();
188 virtual void Render(wxTransformMatrix
* cworld
, int clip_x
, int clip_y
, int clip_width
, int clip_height
);
189 virtual void WriteSVG( wxTextOutputStream
&stream
);
191 wxCanvasObject
* IsHitWorld( double x
, double y
, double margin
= 0 );
193 bool PointOnPolyline(const wxPoint2DDouble
& P
, double marge
);
206 inline void CalculateLineParameters( const wxPoint2DDouble
& p1
, const wxPoint2DDouble
& p2
);
207 inline void CalculateXs( double y
);
215 //intersection point with scanline;