25#include <wx/graphics.h>
41static void GRSRect( wxDC* aDC,
int x1,
int y1,
int x2,
int y2,
int aWidth,
const COLOR4D& aColor );
55 wxPoint* points =
new wxPoint[n];
57 for(
int i = 0; i < n; i++ )
58 points[i] = wxPoint( Points[i].x, Points[i].y );
60 aDC->DrawPolygon( n, points );
65static void winDrawLine( wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int width )
69 DC->DrawLine( x1, y1, x2, y2 );
85 wxDash dots[2] = { 1, 3 };
89 if( width <= 1 && DC->GetBrush().GetStyle() != wxBRUSHSTYLE_SOLID )
90 width = DC->DeviceToLogicalXRel( 1 );
100 style = wxPENSTYLE_TRANSPARENT;
103 const wxPen& curr_pen = DC->GetPen();
105 if( !curr_pen.IsOk() || curr_pen.GetColour() !=
color.ToColour()
106 || curr_pen.GetWidth() != width || curr_pen.GetStyle() != style )
109 pen.SetColour(
color.ToColour() );
111 if( style == wxPENSTYLE_DOT )
113 style = wxPENSTYLE_USER_DASH;
114 pen.SetDashes( 2, dots );
117 pen.SetWidth( width );
118 pen.SetStyle( style );
127 DC->SetPen( curr_pen );
143 brush.SetColour(
color.ToColour() );
146 brush.SetStyle( wxBRUSHSTYLE_SOLID );
148 brush.SetStyle( wxBRUSHSTYLE_TRANSPARENT );
150 DC->SetBrush( brush );
171void GRLine( wxDC* DC,
int x1,
int y1,
int x2,
int y2,
int width,
const COLOR4D& Color,
182 const COLOR4D& aColor, wxPenStyle aStyle )
184 GRLine( aDC, aStart.
x, aStart.
y, aEnd.
x, aEnd.
y, aWidth, aColor, aStyle );
209 DC->DrawLine(
A.x,
A.y,
B.x,
B.y );
216 int radius = ( width + 1 ) >> 1;
226 int len = (int) hypot( dx, dy );
229 int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
230 int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
231 bool mirrored = ( slx > 0 && sly < 0 ) || ( slx < 0 && sly > 0 );
272 DC->DrawArc( end.
x, end.
y, start.
x, start.
y,
B.x,
B.y );
274 DC->DrawArc( start.
x, start.
y, end.
x, end.
y,
B.x,
B.y );
291 if( Fill && ( n > 2 ) )
300 GRMoveTo( Points[0].x, Points[0].y );
302 for(
int i = 1; i < n; ++i )
303 GRLineTo( DC, Points[i].x, Points[i].y, width, Color );
314 if( aFill && ( aPointCount > 2 ) )
324 GRMoveTo( aPoints[0].x, aPoints[0].y );
326 for(
int i = 1; i < aPointCount; ++i )
327 GRLineTo( aDC, aPoints[i].x, aPoints[i].y, aWidth, aColor );
329 int lastpt = aPointCount - 1;
332 if( aPoints[lastpt] != aPoints[0] )
333 GRLineTo( aDC, aPoints[0].x, aPoints[0].y, aWidth, aColor );
344 GRSPoly( DC, n, Points, Fill, width, Color, BgColor );
364 aDC->DrawArc(aPos.
x + aRadius, aPos.
y, aPos.
x - aRadius, aPos.
y, aPos.
x, aPos.
y );
365 aDC->DrawArc(aPos.
x - aRadius, aPos.
y, aPos.
x + aRadius, aPos.
y, aPos.
x, aPos.
y );
374 aDC->DrawEllipse( aPos.
x - aRadius, aPos.
y - aRadius, 2 * aRadius, 2 * aRadius );
379 int aWidth,
const COLOR4D& aColor )
383 aDC->DrawArc( aStart.
x, aStart.
y, aEnd.
x, aEnd.
y, aCenter.
x, aCenter.
y );
392 DC->DrawArc( aStart.
x, aStart.
y, aEnd.
x, aEnd.
y, aCenter.
x, aCenter.
y );
399 GRSRect( DC, aStart.
x, aStart.
y, aEnd.
x, aEnd.
y, aWidth, aColor );
406 GRSFilledRect( DC, aStart.
x, aStart.
y, aEnd.
x, aEnd.
y, aWidth, aColor, aBgColor );
410void GRSRect( wxDC* aDC,
int x1,
int y1,
int x2,
int y2,
int aWidth,
const COLOR4D& aColor )
417 points[4] = points[0];
430 points[4] = points[0];
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
static const COLOR4D BLACK
void GRForceBlackPen(bool flagforce)
void GRResetPenAndBrush(wxDC *DC)
void GRLineTo(wxDC *DC, int x, int y, int width, const COLOR4D &Color)
static void GRSRect(wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor)
void GRRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
void GRCSegm(wxDC *DC, const VECTOR2I &A, const VECTOR2I &B, int width, const COLOR4D &Color)
static void winDrawLine(wxDC *DC, int x1, int y1, int x2, int y2, int width)
static bool s_ForceBlackPen
static void vector2IwxDrawPolygon(wxDC *aDC, const VECTOR2I *Points, int n)
static const bool NOT_FILLED
static bool s_DC_lastbrushfill
void GRCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
void GRFilledSegment(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
void GRFilledArc(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int width, const COLOR4D &Color, const COLOR4D &BgColor)
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
static void GRSPoly(wxDC *DC, int n, const VECTOR2I *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a new polyline and fill it if Fill, in screen space.
void GRMoveTo(int x, int y)
static void GRSClosedPoly(wxDC *aDC, int aPointCount, const VECTOR2I *aPoints, bool aFill, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Draw a new closed polyline and fill it if Fill, in screen space.
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
void GRSFilledRect(wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
void GRClosedPoly(wxDC *DC, int n, const VECTOR2I *Points, bool Fill, const COLOR4D &Color)
Draw a closed polyline and fill it if Fill, in object space.
static wxDC * s_DC_lastDC
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
void GRArc(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int aWidth, const COLOR4D &aColor)
void GRPoly(wxDC *DC, int n, const VECTOR2I *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a new polyline and fill it if Fill, in drawing space.
bool GetGRForceBlackPenState(void)
void GRFilledCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aStrokeColor, const COLOR4D &aFillColor)
Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
VECTOR2< int32_t > VECTOR2I
wxPoint ToWxPoint(const VECTOR2I &aSize)