KiCad PCB EDA Suite
gr_basic.cpp File Reference
#include <gr_basic.h>
#include <trigo.h>
#include <eda_item.h>
#include <wx/graphics.h>
#include <algorithm>

Go to the source code of this file.

Functions

static void GRSRect (wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor)
 
static void vector2IwxDrawPolygon (wxDC *aDC, const VECTOR2I *Points, int n)
 
static void winDrawLine (wxDC *DC, int x1, int y1, int x2, int y2, int width)
 
void GRResetPenAndBrush (wxDC *DC)
 
void GRSetColorPen (wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
 
void GRSetBrush (wxDC *DC, const COLOR4D &Color, bool fill)
 
void GRForceBlackPen (bool flagforce)
 
bool GetGRForceBlackPenState (void)
 
void GRLine (wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
 
void GRLine (wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, wxPenStyle aStyle)
 
void GRMoveTo (int x, int y)
 
void GRLineTo (wxDC *DC, int x, int y, int width, const COLOR4D &Color)
 
void GRCSegm (wxDC *DC, const VECTOR2I &A, const VECTOR2I &B, int width, const COLOR4D &Color)
 
void GRFilledSegment (wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void GRCircle (wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
 
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). More...
 
void GRArc (wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, 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 GRRect (wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
 
void GRFilledRect (wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
 
void GRSFilledRect (wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
 

Variables

static const bool FILLED = true
 
static const bool NOT_FILLED = false
 
GR_DRAWMODE g_XorMode = GR_NXOR
 
static int GRLastMoveToX
 
static int GRLastMoveToY
 
static bool s_ForceBlackPen
 
static COLOR4D s_DC_lastbrushcolor (0, 0, 0, 0)
 
static bool s_DC_lastbrushfill = false
 
static wxDC * s_DC_lastDC = nullptr
 

Function Documentation

◆ GetGRForceBlackPenState()

◆ GRArc()

void GRArc ( wxDC *  aDC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
const VECTOR2I aCenter,
int  aWidth,
const COLOR4D aColor 
)

Definition at line 369 of file gr_basic.cpp.

371{
372 GRSetBrush( aDC, aColor );
373 GRSetColorPen( aDC, aColor, aWidth );
374 aDC->DrawArc( aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y );
375}
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:80
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:123

References GRSetBrush(), GRSetColorPen(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_SHAPE::Print(), LIB_SHAPE::print(), and GERBER_DRAW_ITEM::Print().

◆ GRCircle()

void GRCircle ( wxDC *  aDC,
const VECTOR2I aPos,
int  aRadius,
int  aWidth,
const COLOR4D aColor 
)

Definition at line 348 of file gr_basic.cpp.

349{
350 GRSetBrush( aDC, aColor, NOT_FILLED );
351 GRSetColorPen( aDC, aColor, aWidth );
352
353 // Draw two arcs here to make a circle. Unfortunately, the printerDC doesn't handle
354 // transparent brushes when used with circles. It does work for for arcs, however
355 aDC->DrawArc(aPos.x + aRadius, aPos.y, aPos.x - aRadius, aPos.y, aPos.x, aPos.y );
356 aDC->DrawArc(aPos.x - aRadius, aPos.y, aPos.x + aRadius, aPos.y, aPos.x, aPos.y );
357}
static const bool NOT_FILLED
Definition: gr_basic.cpp:30

References GRSetBrush(), GRSetColorPen(), NOT_FILLED, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by D_CODE::DrawFlashedShape(), SCH_SHAPE::Print(), LIB_PIN::print(), LIB_SHAPE::print(), GERBER_DRAW_ITEM::Print(), and LIB_PIN::printPinSymbol().

◆ GRClosedPoly()

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.

Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around it.

Definition at line 342 of file gr_basic.cpp.

343{
344 GRSClosedPoly( DC, n, Points, Fill, 0, Color, Color );
345}
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.
Definition: gr_basic.cpp:302

References GRSClosedPoly().

Referenced by D_CODE::DrawFlashedPolygon(), GRPrintText(), GERBER_DRAW_ITEM::PrintGerberPoly(), and MARKER_BASE::PrintMarker().

◆ GRCSegm()

void GRCSegm ( wxDC *  DC,
const VECTOR2I A,
const VECTOR2I B,
int  width,
const COLOR4D Color 
)

Definition at line 192 of file gr_basic.cpp.

193{
194 GRLastMoveToX = B.x;
195 GRLastMoveToY = B.y;
196
197 if( width <= 2 ) /* single line or 2 pixels */
198 {
199 GRSetColorPen( DC, Color, width );
200 DC->DrawLine( A.x, A.y, B.x, B.y );
201 return;
202 }
203
204 GRSetBrush( DC, Color, NOT_FILLED );
205 GRSetColorPen( DC, Color, 0 );
206
207 int radius = ( width + 1 ) >> 1;
208 int dx = B.x - A.x;
209 int dy = B.y - A.y;
210 EDA_ANGLE angle( VECTOR2I( dx, dy ) );
211
212 angle = -angle;
213
214 VECTOR2I start;
215 VECTOR2I end;
216 VECTOR2I org( A.x, A.y );
217 int len = (int) hypot( dx, dy );
218
219 // We know if the DC is mirrored, to draw arcs
220 int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
221 int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
222 bool mirrored = ( slx > 0 && sly < 0 ) || ( slx < 0 && sly > 0 );
223
224 // first edge
225 start.x = 0;
226 start.y = radius;
227 end.x = len;
228 end.y = radius;
229 RotatePoint( start, angle );
230 RotatePoint( end, angle );
231
232 start += org;
233 end += org;
234
235 DC->DrawLine( (wxPoint) start, (wxPoint) end );
236
237 // first rounded end
238 end.x = 0;
239 end.y = -radius;
240 RotatePoint( end, angle );
241 end += org;
242
243 if( !mirrored )
244 DC->DrawArc( (wxPoint) end, (wxPoint) start, (wxPoint) org );
245 else
246 DC->DrawArc( (wxPoint) start, (wxPoint) end, (wxPoint) org );
247
248 // second edge
249 start.x = len;
250 start.y = -radius;
251 RotatePoint( start, angle );
252 start += org;
253
254 DC->DrawLine( (wxPoint) start, (wxPoint) end );
255
256 // second rounded end
257 end.x = len;
258 end.y = radius;
259 RotatePoint( end, angle);
260 end += org;
261
262 if( !mirrored )
263 DC->DrawArc( end.x, end.y, start.x, start.y, B.x, B.y );
264 else
265 DC->DrawArc( start.x, start.y, end.x, end.y, B.x, B.y );
266}
static int GRLastMoveToY
Definition: gr_basic.cpp:44
static int GRLastMoveToX
Definition: gr_basic.cpp:44
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References PNS::angle(), GRLastMoveToX, GRLastMoveToY, GRSetBrush(), GRSetColorPen(), NOT_FILLED, RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by D_CODE::DrawFlashedShape(), GRPrintText(), and GERBER_DRAW_ITEM::Print().

◆ GRFilledArc()

void GRFilledArc ( wxDC *  DC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
const VECTOR2I aCenter,
int  width,
const COLOR4D Color,
const COLOR4D BgColor 
)

Definition at line 378 of file gr_basic.cpp.

380{
381 GRSetBrush( DC, BgColor, FILLED );
382 GRSetColorPen( DC, Color, width );
383 DC->DrawArc( aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y );
384}
static const bool FILLED
Definition: gr_basic.cpp:29

References FILLED, GRSetBrush(), GRSetColorPen(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by LIB_SHAPE::print(), and SCH_SHAPE::PrintBackground().

◆ GRFilledCircle()

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).

Parameters
aDCthe device context into which drawing should occur.
xThe x coordinate in user space of the center of the circle.
yThe y coordinate in user space of the center of the circle.
aRadiusis the radius of the circle.
aColoris the color to draw.
See also
COLOR4D

Definition at line 360 of file gr_basic.cpp.

362{
363 GRSetBrush( aDC, aFillColor, FILLED );
364 GRSetColorPen( aDC, aStrokeColor, aWidth );
365 aDC->DrawEllipse( aPos.x - aRadius, aPos.y - aRadius, 2 * aRadius, 2 * aRadius );
366}

References FILLED, GRSetBrush(), GRSetColorPen(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by D_CODE::DrawFlashedShape(), SCH_JUNCTION::Print(), LIB_SHAPE::print(), and SCH_SHAPE::PrintBackground().

◆ GRFilledRect()

void GRFilledRect ( wxDC *  DC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aWidth,
const COLOR4D aColor,
const COLOR4D aBgColor 
)

Definition at line 394 of file gr_basic.cpp.

396{
397 GRSFilledRect( DC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aBgColor );
398}
void GRSFilledRect(wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition: gr_basic.cpp:413

References GRSFilledRect(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by D_CODE::DrawFlashedShape(), SCH_SHEET::Print(), LIB_SHAPE::print(), LIB_TEXTBOX::print(), SCH_TEXTBOX::Print(), SCH_SHAPE::PrintBackground(), and DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample().

◆ GRFilledSegment()

void GRFilledSegment ( wxDC *  aDC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aWidth,
const COLOR4D aColor 
)

Definition at line 269 of file gr_basic.cpp.

271{
272 GRSetColorPen( aDC, aColor, aWidth );
273 winDrawLine( aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
274}
static void winDrawLine(wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:64

References GRSetColorPen(), winDrawLine(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by D_CODE::DrawFlashedShape(), SCH_SYMBOL::Print(), and GERBER_DRAW_ITEM::Print().

◆ GRForceBlackPen()

void GRForceBlackPen ( bool  flagforce)
Parameters
flagforceTrue to force a black pen whenever the asked color.

Definition at line 150 of file gr_basic.cpp.

151{
152 s_ForceBlackPen = flagforce;
153}

References s_ForceBlackPen.

Referenced by SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), PLEDITOR_PRINTOUT::PrintPage(), and SCH_PRINTOUT::PrintPage().

◆ GRLine() [1/2]

void GRLine ( wxDC *  aDC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aWidth,
const COLOR4D aColor,
wxPenStyle  aStyle 
)

Definition at line 172 of file gr_basic.cpp.

174{
175 GRLine( aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
176}
void GRLine(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:162

References GRLine(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ GRLine() [2/2]

void GRLine ( wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
const COLOR4D Color,
wxPenStyle  aStyle 
)

◆ GRLineTo()

void GRLineTo ( wxDC *  DC,
int  x,
int  y,
int  width,
const COLOR4D Color 
)

Definition at line 186 of file gr_basic.cpp.

187{
188 GRLine( DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
189}

References GRLastMoveToX, GRLastMoveToY, and GRLine().

Referenced by GRSClosedPoly(), GRSPoly(), and LIB_PIN::printPinSymbol().

◆ GRMoveTo()

void GRMoveTo ( int  x,
int  y 
)

Definition at line 179 of file gr_basic.cpp.

180{
181 GRLastMoveToX = x;
182 GRLastMoveToY = y;
183}

References GRLastMoveToX, and GRLastMoveToY.

Referenced by GRSClosedPoly(), GRSPoly(), and LIB_PIN::printPinSymbol().

◆ GRPoly()

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.

Definition at line 332 of file gr_basic.cpp.

334{
335 GRSPoly( DC, n, Points, Fill, width, Color, BgColor );
336}
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.
Definition: gr_basic.cpp:279

References GRSPoly().

Referenced by SCH_SHAPE::Print(), LIB_SHAPE::print(), SCH_LABEL_BASE::Print(), SCH_SHAPE::PrintBackground(), and DS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem().

◆ GRRect()

void GRRect ( wxDC *  DC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aWidth,
const COLOR4D aColor 
)

Definition at line 387 of file gr_basic.cpp.

389{
390 GRSRect( DC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor );
391}
static void GRSRect(wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:401

References GRSRect(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by D_CODE::DrawFlashedShape(), SCH_SHAPE::Print(), SCH_SHEET::Print(), LIB_SHAPE::print(), LIB_TEXTBOX::print(), SCH_TEXTBOX::Print(), and DS_DRAW_ITEM_RECT::PrintWsItem().

◆ GRResetPenAndBrush()

void GRResetPenAndBrush ( wxDC *  DC)

◆ GRSClosedPoly()

static void GRSClosedPoly ( wxDC *  aDC,
int  aPointCount,
const VECTOR2I aPoints,
bool  aFill,
int  aWidth,
const COLOR4D aColor,
const COLOR4D aBgColor 
)
static

Draw a new closed polyline and fill it if Fill, in screen space.

Definition at line 302 of file gr_basic.cpp.

304{
305 if( aFill && ( aPointCount > 2 ) )
306 {
307 GRLastMoveToX = aPoints[aPointCount - 1].x;
308 GRLastMoveToY = aPoints[aPointCount - 1].y;
309 GRSetBrush( aDC, aBgColor, FILLED );
310 GRSetColorPen( aDC, aColor, aWidth );
311 vector2IwxDrawPolygon( aDC, aPoints, aPointCount );
312 }
313 else
314 {
315 GRMoveTo( aPoints[0].x, aPoints[0].y );
316
317 for( int i = 1; i < aPointCount; ++i )
318 GRLineTo( aDC, aPoints[i].x, aPoints[i].y, aWidth, aColor );
319
320 int lastpt = aPointCount - 1;
321
322 // Close the polygon
323 if( aPoints[lastpt] != aPoints[0] )
324 GRLineTo( aDC, aPoints[0].x, aPoints[0].y, aWidth, aColor );
325 }
326}
void GRLineTo(wxDC *DC, int x, int y, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:186
static void vector2IwxDrawPolygon(wxDC *aDC, const VECTOR2I *Points, int n)
Definition: gr_basic.cpp:52
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:179

References FILLED, GRLastMoveToX, GRLastMoveToY, GRLineTo(), GRMoveTo(), GRSetBrush(), GRSetColorPen(), vector2IwxDrawPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GRClosedPoly(), and GRSRect().

◆ GRSetBrush()

void GRSetBrush ( wxDC *  DC,
const COLOR4D Color,
bool  fill 
)

Definition at line 123 of file gr_basic.cpp.

124{
125 COLOR4D color = Color;
126
127 if( s_ForceBlackPen )
129
130 if( s_DC_lastbrushcolor != color || s_DC_lastbrushfill != fill || s_DC_lastDC != DC )
131 {
132 wxBrush brush;
133
134 brush.SetColour( color.ToColour() );
135
136 if( fill )
137 brush.SetStyle( wxBRUSHSTYLE_SOLID );
138 else
139 brush.SetStyle( wxBRUSHSTYLE_TRANSPARENT );
140
141 DC->SetBrush( brush );
142
144 s_DC_lastbrushfill = fill;
145 s_DC_lastDC = DC;
146 }
147}
int color
Definition: DXF_plotter.cpp:57
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
static bool s_DC_lastbrushfill
Definition: gr_basic.cpp:48

References BLACK, color, s_DC_lastbrushcolor, s_DC_lastbrushfill, s_DC_lastDC, and s_ForceBlackPen.

Referenced by GRArc(), GRCircle(), GRCSegm(), GRFilledArc(), GRFilledCircle(), GRResetPenAndBrush(), GRSClosedPoly(), GRSFilledRect(), and GRSPoly().

◆ GRSetColorPen()

void GRSetColorPen ( wxDC *  DC,
const COLOR4D Color,
int  width,
wxPenStyle  style 
)

Definition at line 80 of file gr_basic.cpp.

81{
82 COLOR4D color = Color;
83
84 wxDash dots[2] = { 1, 3 };
85
86 // Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
87 // nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
88 if( width <= 1 && DC->GetBrush().GetStyle() != wxBRUSHSTYLE_SOLID )
89 width = DC->DeviceToLogicalXRel( 1 );
90
91 if( s_ForceBlackPen )
93
94 const wxPen& curr_pen = DC->GetPen();
95
96 if( !curr_pen.IsOk() || curr_pen.GetColour() != color.ToColour()
97 || curr_pen.GetWidth() != width || curr_pen.GetStyle() != style )
98 {
99 wxPen pen;
100 pen.SetColour( color.ToColour() );
101
102 if( style == wxPENSTYLE_DOT )
103 {
104 style = wxPENSTYLE_USER_DASH;
105 pen.SetDashes( 2, dots );
106 }
107
108 pen.SetWidth( width );
109 pen.SetStyle( style );
110 DC->SetPen( pen );
111 }
112 else
113 {
114 // Should be not needed, but on Linux, in printing process
115 // the curr pen settings needs to be sometimes re-initialized
116 // Clearly, this is due to a bug, related to SetBrush(),
117 // but we have to live with it, at least on wxWidgets 3.0
118 DC->SetPen( curr_pen );
119 }
120}

References BLACK, color, and s_ForceBlackPen.

Referenced by GRArc(), GRCircle(), GRCSegm(), GRFilledArc(), GRFilledCircle(), GRFilledSegment(), GRLine(), GRSClosedPoly(), GRSFilledRect(), and GRSPoly().

◆ GRSFilledRect()

void GRSFilledRect ( wxDC *  aDC,
int  x1,
int  y1,
int  x2,
int  y2,
int  aWidth,
const COLOR4D aColor,
const COLOR4D aBgColor 
)

Definition at line 413 of file gr_basic.cpp.

415{
416 VECTOR2I points[5];
417 points[0] = VECTOR2I( x1, y1 );
418 points[1] = VECTOR2I( x1, y2 );
419 points[2] = VECTOR2I( x2, y2 );
420 points[3] = VECTOR2I( x2, y1 );
421 points[4] = points[0];
422
423 GRSetBrush( aDC, aBgColor, FILLED );
424 GRSetColorPen( aDC, aBgColor, aWidth );
425
426 vector2IwxDrawPolygon( aDC, points, 5 );
427}

References FILLED, GRSetBrush(), GRSetColorPen(), and vector2IwxDrawPolygon().

Referenced by GRFilledRect(), and SCH_PRINTOUT::PrintPage().

◆ GRSPoly()

static void GRSPoly ( wxDC *  DC,
int  n,
const VECTOR2I Points,
bool  Fill,
int  width,
const COLOR4D Color,
const COLOR4D BgColor 
)
static

Draw a new polyline and fill it if Fill, in screen space.

Definition at line 279 of file gr_basic.cpp.

281{
282 if( Fill && ( n > 2 ) )
283 {
284 GRSetBrush( DC, BgColor, FILLED );
285 GRSetColorPen( DC, Color, width );
286
287 vector2IwxDrawPolygon( DC, Points, n );
288 }
289 else
290 {
291 GRMoveTo( Points[0].x, Points[0].y );
292
293 for( int i = 1; i < n; ++i )
294 GRLineTo( DC, Points[i].x, Points[i].y, width, Color );
295 }
296}

References FILLED, GRLineTo(), GRMoveTo(), GRSetBrush(), GRSetColorPen(), and vector2IwxDrawPolygon().

Referenced by GRPoly().

◆ GRSRect()

void GRSRect ( wxDC *  aDC,
int  x1,
int  y1,
int  x2,
int  y2,
int  aWidth,
const COLOR4D aColor 
)
static

Definition at line 401 of file gr_basic.cpp.

402{
403 VECTOR2I points[5];
404 points[0] = VECTOR2I( x1, y1 );
405 points[1] = VECTOR2I( x1, y2 );
406 points[2] = VECTOR2I( x2, y2 );
407 points[3] = VECTOR2I( x2, y1 );
408 points[4] = points[0];
409 GRSClosedPoly( aDC, 5, points, NOT_FILLED, aWidth, aColor, aColor );
410}

References GRSClosedPoly(), and NOT_FILLED.

Referenced by GRRect().

◆ vector2IwxDrawPolygon()

static void vector2IwxDrawPolygon ( wxDC *  aDC,
const VECTOR2I Points,
int  n 
)
static

Definition at line 52 of file gr_basic.cpp.

53{
54 wxPoint* points = new wxPoint[n];
55
56 for( int i = 0; i < n; i++ )
57 points[i] = wxPoint( Points[i].x, Points[i].y );
58
59 aDC->DrawPolygon( n, points );
60 delete[] points;
61}

Referenced by GRSClosedPoly(), GRSFilledRect(), and GRSPoly().

◆ winDrawLine()

static void winDrawLine ( wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width 
)
static

Definition at line 64 of file gr_basic.cpp.

65{
66 GRLastMoveToX = x2;
67 GRLastMoveToY = y2;
68 DC->DrawLine( x1, y1, x2, y2 );
69}

References GRLastMoveToX, and GRLastMoveToY.

Referenced by GRFilledSegment(), and GRLine().

Variable Documentation

◆ FILLED

const bool FILLED = true
static

Definition at line 29 of file gr_basic.cpp.

Referenced by GRFilledArc(), GRFilledCircle(), GRSClosedPoly(), GRSFilledRect(), and GRSPoly().

◆ g_XorMode

GR_DRAWMODE g_XorMode = GR_NXOR

Definition at line 33 of file gr_basic.cpp.

◆ GRLastMoveToX

int GRLastMoveToX
static

Definition at line 44 of file gr_basic.cpp.

Referenced by GRCSegm(), GRLine(), GRLineTo(), GRMoveTo(), GRSClosedPoly(), and winDrawLine().

◆ GRLastMoveToY

int GRLastMoveToY
static

Definition at line 44 of file gr_basic.cpp.

Referenced by GRCSegm(), GRLine(), GRLineTo(), GRMoveTo(), GRSClosedPoly(), and winDrawLine().

◆ NOT_FILLED

const bool NOT_FILLED = false
static

Definition at line 30 of file gr_basic.cpp.

Referenced by GRCircle(), GRCSegm(), and GRSRect().

◆ s_DC_lastbrushcolor

COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0) ( ,
,
,
 
)
static

Referenced by GRResetPenAndBrush(), and GRSetBrush().

◆ s_DC_lastbrushfill

bool s_DC_lastbrushfill = false
static

Definition at line 48 of file gr_basic.cpp.

Referenced by GRSetBrush().

◆ s_DC_lastDC

wxDC* s_DC_lastDC = nullptr
static

Definition at line 49 of file gr_basic.cpp.

Referenced by GRResetPenAndBrush(), and GRSetBrush().

◆ s_ForceBlackPen

bool s_ForceBlackPen
static

Definition at line 45 of file gr_basic.cpp.

Referenced by GetGRForceBlackPenState(), GRForceBlackPen(), GRSetBrush(), and GRSetColorPen().