KiCad PCB EDA Suite
gr_basic.h File Reference
#include <gal/color4d.h>
#include <vector>
#include <eda_rect.h>
#include <wx/pen.h>
#include <wx/dc.h>

Go to the source code of this file.

Enumerations

enum  GR_DRAWMODE {
  GR_OR = 0x01000000, GR_XOR = 0x02000000, GR_AND = 0x04000000, GR_NXOR = 0x08000000,
  GR_INVERT = 0x10000000, GR_ALLOW_HIGHCONTRAST = 0x20000000, GR_COPY = 0x40000000, GR_HIGHLIGHT = 0x80000000,
  UNSPECIFIED_DRAWMODE = -1
}
 Drawmode. Compositing mode plus a flag or two. More...
 
enum  GRLineStypeType { GR_SOLID_LINE = 0, GR_DOTTED_LINE = 1, GR_DASHED_LINE = 3 }
 

Functions

GR_DRAWMODE operator~ (const GR_DRAWMODE &a)
 
GR_DRAWMODE operator| (const GR_DRAWMODE &a, const GR_DRAWMODE &b)
 
GR_DRAWMODE operator & (const GR_DRAWMODE &a, const GR_DRAWMODE &b)
 
void GRResetPenAndBrush (wxDC *DC)
 
void GRSetColorPen (wxDC *DC, const COLOR4D &Color, int width=1, wxPenStyle stype=wxPENSTYLE_SOLID)
 
void GRSetBrush (wxDC *DC, const COLOR4D &Color, bool fill=false)
 
void GRForceBlackPen (bool flagforce)
 
bool GetGRForceBlackPenState (void)
 
void GRLine (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, const COLOR4D &aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
 
void GRLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle=wxPENSTYLE_SOLID)
 
void GRMoveTo (int x, int y)
 
void GRLineTo (EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, const COLOR4D &Color)
 
void GRPoly (EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *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 (EDA_RECT *ClipBox, wxDC *aDC, int aPointCount, const wxPoint *aPoints, bool doFill, const COLOR4D &aPenColor, const COLOR4D &aFillColor)
 Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around it. More...
 
void GRClosedPoly (EDA_RECT *ClipBox, wxDC *aDC, int aPointCount, const wxPoint *aPoints, bool doFill, int aPenWidth, const COLOR4D &aPenColor, const COLOR4D &aFillColor)
 Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around it. More...
 
void GRCircle (EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, const COLOR4D &Color)
 Draw a circle onto the drawing context aDC centered at the user coordinates (x,y). More...
 
void GRFilledCircle (EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, const COLOR4D &Color, const COLOR4D &BgColor)
 
void GRFilledCircle (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, int aRadius, const COLOR4D &aColor)
 
void GRCircle (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
 
void GRArc (EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, const COLOR4D &Color)
 
void GRArc (EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, int width, const COLOR4D &Color)
 
void GRArc1 (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, int width, const COLOR4D &Color)
 
void GRArc1 (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aStart, const wxPoint &aEnd, const wxPoint &aCenter, int aWidth, const COLOR4D &aColor)
 
void GRFilledArc1 (EDA_RECT *ClipBox, wxDC *DC, const wxPoint &aStart, const wxPoint &aEnd, const wxPoint &aCenter, int width, const COLOR4D &Color, const COLOR4D &BgColor)
 
void GRCSegm (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color)
 
void GRFillCSegm (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color)
 
void GRFilledSegment (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, const COLOR4D &aColor)
 
void GRCSegm (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, const COLOR4D &Color)
 
void GRCSegm (EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, const COLOR4D &aColor)
 
void GRFilledRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, const COLOR4D &Color, const COLOR4D &BgColor)
 
void GRFilledRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, const COLOR4D &BgColor)
 
void GRRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color)
 
void GRSFilledRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, const COLOR4D &BgColor)
 

Variables

GR_DRAWMODE g_XorMode
 

Enumeration Type Documentation

◆ GR_DRAWMODE

Drawmode. Compositing mode plus a flag or two.

Enumerator
GR_OR 
GR_XOR 
GR_AND 
GR_NXOR 
GR_INVERT 
GR_ALLOW_HIGHCONTRAST 
GR_COPY 
GR_HIGHLIGHT 
UNSPECIFIED_DRAWMODE 

Definition at line 39 of file gr_basic.h.

39  {
40  GR_OR = 0x01000000,
41  GR_XOR = 0x02000000,
42  GR_AND = 0x04000000,
43  GR_NXOR = 0x08000000,
44  GR_INVERT = 0x10000000,
45  GR_ALLOW_HIGHCONTRAST = 0x20000000,
46  GR_COPY = 0x40000000,
47  GR_HIGHLIGHT = 0x80000000,
49 };
Definition: gr_basic.h:40

◆ GRLineStypeType

Enumerator
GR_SOLID_LINE 
GR_DOTTED_LINE 
GR_DASHED_LINE 

Definition at line 68 of file gr_basic.h.

68  {
69  /* Line styles for Get/SetLineStyle. */
70  GR_SOLID_LINE = 0,
71  GR_DOTTED_LINE = 1,
72  GR_DASHED_LINE = 3
GRLineStypeType
Definition: gr_basic.h:68

Function Documentation

◆ GetGRForceBlackPenState()

bool GetGRForceBlackPenState ( void  )
Returns
True if a black pen was forced or false if not forced.

Definition at line 191 of file gr_basic.cpp.

192 {
193  return s_ForceBlackPen;
194 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:78

References s_ForceBlackPen.

Referenced by BITMAP_BASE::DrawBitmap(), SCH_SHEET::Print(), and LIB_SYMBOL::Print().

◆ GRArc() [1/2]

void GRArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
const COLOR4D Color 
)

Definition at line 616 of file gr_basic.cpp.

618 {
619  int x1, y1, x2, y2;
620 
621  /* Clip arcs off screen */
622  if( ClipBox )
623  {
624  int radius = r + 1;
625  int x0, y0, xm, ym, x, y;
626  x0 = ClipBox->GetX();
627  y0 = ClipBox->GetY();
628  xm = ClipBox->GetRight();
629  ym = ClipBox->GetBottom();
630  x = xc;
631  y = yc;
632 
633  if( x < ( x0 - radius ) )
634  return;
635 
636  if( y < ( y0 - radius ) )
637  return;
638 
639  if( x > ( xm + radius ) )
640  return;
641 
642  if( y > ( ym + radius ) )
643  return;
644  }
645 
646  x1 = r;
647  y1 = 0;
648  RotatePoint( &x1, &y1, EndAngle );
649 
650  x2 = r;
651  y2 = 0;
652  RotatePoint( &x2, &y2, StAngle );
653 
654  GRSetBrush( DC, Color, NOT_FILLED );
655  GRSetColorPen( DC, Color );
656  DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
657 }
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
int GetX() const
Definition: eda_rect.h:98
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
int GetBottom() const
Definition: eda_rect.h:114
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:158
static const bool NOT_FILLED
Definition: gr_basic.cpp:33
int GetRight() const
Definition: eda_rect.h:111
E_SERIE r
Definition: eserie.cpp:41
int GetY() const
Definition: eda_rect.h:99

References EDA_RECT::GetBottom(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), GRSetBrush(), GRSetColorPen(), NOT_FILLED, r, and RotatePoint().

◆ GRArc() [2/2]

void GRArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
int  width,
const COLOR4D Color 
)

Definition at line 660 of file gr_basic.cpp.

662 {
663  int x1, y1, x2, y2;
664 
665  /* Clip arcs off screen. */
666  if( ClipBox )
667  {
668  int x0, y0, xm, ym;
669  x0 = ClipBox->GetX();
670  y0 = ClipBox->GetY();
671  xm = ClipBox->GetRight();
672  ym = ClipBox->GetBottom();
673 
674  if( x < ( x0 - r - width ) )
675  return;
676 
677  if( y < ( y0 - r - width ) )
678  return;
679 
680  if( x > ( r + xm + width ) )
681  return;
682 
683  if( y > ( r + ym + width ) )
684  return;
685  }
686 
687  x1 = r;
688  y1 = 0;
689  RotatePoint( &x1, &y1, EndAngle );
690 
691  x2 = r;
692  y2 = 0;
693  RotatePoint( &x2, &y2, StAngle );
694 
695  GRSetBrush( DC, Color );
696  GRSetColorPen( DC, Color, width );
697  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
698 }
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
int GetX() const
Definition: eda_rect.h:98
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
int GetBottom() const
Definition: eda_rect.h:114
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:158
int GetRight() const
Definition: eda_rect.h:111
E_SERIE r
Definition: eserie.cpp:41
int GetY() const
Definition: eda_rect.h:99

References EDA_RECT::GetBottom(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), GRSetBrush(), GRSetColorPen(), r, and RotatePoint().

◆ GRArc1() [1/2]

void GRArc1 ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  xc,
int  yc,
int  width,
const COLOR4D Color 
)

Definition at line 544 of file gr_basic.cpp.

546 {
547  /* Clip arcs off screen. */
548  if( ClipBox )
549  {
550  int x0, y0, xm, ym, r;
551  x0 = ClipBox->GetX();
552  y0 = ClipBox->GetY();
553  xm = ClipBox->GetRight();
554  ym = ClipBox->GetBottom();
555  r = KiROUND( Distance( x1, y1, xc, yc ) );
556 
557  if( xc < ( x0 - r ) )
558  return;
559 
560  if( yc < ( y0 - r ) )
561  return;
562 
563  if( xc > ( r + xm ) )
564  return;
565 
566  if( yc > ( r + ym ) )
567  return;
568  }
569 
570  GRSetBrush( DC, Color );
571  GRSetColorPen( DC, Color, width );
572  DC->DrawArc( x1, y1, x2, y2, xc, yc );
573 }
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
int GetX() const
Definition: eda_rect.h:98
int GetBottom() const
Definition: eda_rect.h:114
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:158
int GetRight() const
Definition: eda_rect.h:111
E_SERIE r
Definition: eserie.cpp:41
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
int GetY() const
Definition: eda_rect.h:99

References EDA_RECT::GetBottom(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), GRSetBrush(), GRSetColorPen(), KiROUND(), and r.

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

◆ GRArc1() [2/2]

void GRArc1 ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint &  aStart,
const wxPoint &  aEnd,
const wxPoint &  aCenter,
int  aWidth,
const COLOR4D aColor 
)

Definition at line 576 of file gr_basic.cpp.

578 {
579  GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
580  aWidth, aColor );
581 }
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:544

References GRArc1().

◆ GRCircle() [1/2]

void GRCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  r,
int  width,
const COLOR4D Color 
)

Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).

Parameters
ClipBoxdefines a rectangular boundary outside of which no drawing will occur.
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 507 of file gr_basic.cpp.

508 {
509  if( clipCircle( ClipBox, xc, yc, r, width ) || r <= 0 )
510  return;
511 
512  GRSetBrush( DC, Color, NOT_FILLED );
513  GRSetColorPen( DC, Color, width );
514  DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
515 }
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:477
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:158
static const bool NOT_FILLED
Definition: gr_basic.cpp:33
E_SERIE r
Definition: eserie.cpp:41

References clipCircle(), GRSetBrush(), GRSetColorPen(), NOT_FILLED, and r.

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

◆ GRCircle() [2/2]

void GRCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint &  aPos,
int  aRadius,
int  aWidth,
const COLOR4D aColor 
)

Definition at line 518 of file gr_basic.cpp.

520 {
521  GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
522 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, const COLOR4D &Color)
Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
Definition: gr_basic.cpp:507

References GRCircle().

◆ GRClosedPoly() [1/2]

void GRClosedPoly ( EDA_RECT ClipBox,
wxDC *  DC,
int  n,
const wxPoint *  Points,
bool  Fill,
const COLOR4D Color,
const COLOR4D BgColor 
)

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

Parameters
ClipBoxdefines a rectangular boundary outside of which no drawing will occur.
aDCthe device context into which drawing should occur.
aPointCountthe number of points in the array aPoints.
aPointsThe points to draw.
doFilltrue if polygon is to be filled, else false and only the boundary is drawn.
aPenColorthe color of the border.
aFillColorthe fill color of the polygon's interior.

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

Definition at line 463 of file gr_basic.cpp.

465 {
466  GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
467 }
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a closed polyline and fill it if Fill, in object space.
Definition: gr_basic.cpp:463

References GRClosedPoly().

Referenced by APERTURE_MACRO::DrawApertureMacroShape(), D_CODE::DrawFlashedPolygon(), GRClosedPoly(), GERBER_DRAW_ITEM::PrintGerberPoly(), and MARKER_BASE::PrintMarker().

◆ GRClosedPoly() [2/2]

void GRClosedPoly ( EDA_RECT ClipBox,
wxDC *  aDC,
int  aPointCount,
const wxPoint *  aPoints,
bool  doFill,
int  aPenWidth,
const COLOR4D aPenColor,
const COLOR4D aFillColor 
)

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

Parameters
ClipBoxdefines a rectangular boundary outside of which no drawing will occur.
aDCthe device context into which drawing should occur.
aPointCountthe number of points in the array aPointArray.
aPointsthe points to draw.
doFilltrue if polygon is to be filled, else false and only the boundary is drawn.
aPenWidthis the width of the pen to use on the perimeter, can be zero.
aPenColorthe color of the border.
aFillColorthe fill color of the polygon's interior.

Definition at line 470 of file gr_basic.cpp.

472 {
473  GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
474 }
static void GRSClosedPoly(EDA_RECT *aClipBox, wxDC *aDC, int aPointCount, const wxPoint *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:415

References GRSClosedPoly().

◆ GRCSegm() [1/3]

void GRCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
const COLOR4D Color 
)

Definition at line 311 of file gr_basic.cpp.

313 {
314  GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
315 }
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, const COLOR4D &Color)
Definition: gr_basic.cpp:227

References GRCSegm().

◆ GRCSegm() [2/3]

void GRCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
int  aPenSize,
const COLOR4D Color 
)

Definition at line 227 of file gr_basic.cpp.

229 {
230  GRLastMoveToX = x2;
231  GRLastMoveToY = y2;
232 
233  if( ClipBox )
234  {
235  EDA_RECT clipbox( *ClipBox );
236  clipbox.Inflate( width / 2 );
237 
238  if( ClipLine( &clipbox, x1, y1, x2, y2 ) )
239  return;
240  }
241 
242  if( width <= 2 ) /* single line or 2 pixels */
243  {
244  GRSetColorPen( DC, Color, width );
245  DC->DrawLine( x1, y1, x2, y2 );
246  return;
247  }
248 
249  GRSetBrush( DC, Color, NOT_FILLED );
250  GRSetColorPen( DC, Color, aPenSize );
251 
252  int radius = ( width + 1 ) >> 1;
253  int dx = x2 - x1;
254  int dy = y2 - y1;
255  double angle = -ArcTangente( dy, dx );
256  wxPoint start;
257  wxPoint end;
258  wxPoint org( x1, y1 );
259  int len = (int) hypot( dx, dy );
260 
261  // We know if the DC is mirrored, to draw arcs
262  int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
263  int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
264  bool mirrored = ( slx > 0 && sly < 0 ) || ( slx < 0 && sly > 0 );
265 
266  // first edge
267  start.x = 0;
268  start.y = radius;
269  end.x = len;
270  end.y = radius;
271  RotatePoint( &start, angle );
272  RotatePoint( &end, angle );
273 
274  start += org;
275  end += org;
276 
277  DC->DrawLine( start, end );
278 
279  // first rounded end
280  end.x = 0;
281  end.y = -radius;
282  RotatePoint( &end, angle );
283  end += org;
284 
285  if( !mirrored )
286  DC->DrawArc( end, start, org );
287  else
288  DC->DrawArc( start, end, org );
289 
290  // second edge
291  start.x = len;
292  start.y = -radius;
293  RotatePoint( &start, angle );
294  start += org;
295 
296  DC->DrawLine( start, end );
297 
298  // second rounded end
299  end.x = len;
300  end.y = radius;
301  RotatePoint( &end, angle);
302  end += org;
303 
304  if( !mirrored )
305  DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
306  else
307  DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
308 }
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
static int GRLastMoveToX
Definition: gr_basic.cpp:77
bool ClipLine(const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:158
static const bool NOT_FILLED
Definition: gr_basic.cpp:33
static int GRLastMoveToY
Definition: gr_basic.cpp:77
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
Handle the component boundary box.
Definition: eda_rect.h:42
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183

References PNS::angle(), ArcTangente(), ClipLine(), GRLastMoveToX, GRLastMoveToY, GRSetBrush(), GRSetColorPen(), EDA_RECT::Inflate(), NOT_FILLED, and RotatePoint().

Referenced by BASIC_GAL::doDrawPolyline(), D_CODE::DrawFlashedShape(), BASIC_GAL::DrawLine(), GRCSegm(), and GERBER_DRAW_ITEM::Print().

◆ GRCSegm() [3/3]

void GRCSegm ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint &  aStart,
const wxPoint &  aEnd,
int  aWidth,
const COLOR4D aColor 
)

Definition at line 318 of file gr_basic.cpp.

320 {
321  GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
322 }
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, const COLOR4D &Color)
Definition: gr_basic.cpp:227

References GRCSegm().

◆ GRFillCSegm()

void GRFillCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
const COLOR4D Color 
)

Definition at line 325 of file gr_basic.cpp.

327 {
328  GRSetColorPen( DC, Color, width );
329  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
330 }
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:89

References GRSetColorPen(), and WinClipAndDrawLine().

Referenced by D_CODE::DrawFlashedShape().

◆ GRFilledArc1()

void GRFilledArc1 ( EDA_RECT ClipBox,
wxDC *  DC,
const wxPoint &  aStart,
const wxPoint &  aEnd,
const wxPoint &  aCenter,
int  width,
const COLOR4D Color,
const COLOR4D BgColor 
)

Definition at line 584 of file gr_basic.cpp.

586 {
587  /* Clip arcs off screen. */
588  if( ClipBox )
589  {
590  int x0, y0, xm, ym, r;
591  x0 = ClipBox->GetX();
592  y0 = ClipBox->GetY();
593  xm = ClipBox->GetRight();
594  ym = ClipBox->GetBottom();
595  r = KiROUND( Distance( aStart.x, aStart.y, aCenter.x, aCenter.y ) );
596 
597  if( aCenter.x < ( x0 - r ) )
598  return;
599 
600  if( aCenter.y < ( y0 - r ) )
601  return;
602 
603  if( aCenter.x > ( r + xm ) )
604  return;
605 
606  if( aCenter.y > ( r + ym ) )
607  return;
608  }
609 
610  GRSetBrush( DC, BgColor, FILLED );
611  GRSetColorPen( DC, Color, width );
612  DC->DrawArc( aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y );
613 }
static const bool FILLED
Definition: gr_basic.cpp:32
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
int GetX() const
Definition: eda_rect.h:98
int GetBottom() const
Definition: eda_rect.h:114
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:158
int GetRight() const
Definition: eda_rect.h:111
E_SERIE r
Definition: eserie.cpp:41
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
int GetY() const
Definition: eda_rect.h:99

References FILLED, EDA_RECT::GetBottom(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), GRSetBrush(), GRSetColorPen(), KiROUND(), and r.

Referenced by LIB_SHAPE::print().

◆ GRFilledCircle() [1/2]

void GRFilledCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  r,
int  width,
const COLOR4D Color,
const COLOR4D BgColor 
)

Definition at line 525 of file gr_basic.cpp.

527 {
528  if( clipCircle( ClipBox, x, y, r, width ) || r <= 0 )
529  return;
530 
531  GRSetBrush( DC, BgColor, FILLED );
532  GRSetColorPen( DC, Color, width );
533  DC->DrawEllipse( x - r, y - r, r + r, r + r );
534 }
static const bool FILLED
Definition: gr_basic.cpp:32
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:477
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:158
E_SERIE r
Definition: eserie.cpp:41

References clipCircle(), FILLED, GRSetBrush(), GRSetColorPen(), and r.

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

◆ GRFilledCircle() [2/2]

void GRFilledCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint &  aPos,
int  aRadius,
const COLOR4D aColor 
)

Definition at line 537 of file gr_basic.cpp.

539 {
540  GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor );
541 }
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:525

References GRFilledCircle().

◆ GRFilledRect() [1/2]

void GRFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
const COLOR4D Color,
const COLOR4D BgColor 
)

Definition at line 708 of file gr_basic.cpp.

710 {
711  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
712 }
void GRSFilledRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition: gr_basic.cpp:735

References GRSFilledRect().

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

◆ GRFilledRect() [2/2]

void GRFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
const COLOR4D Color,
const COLOR4D BgColor 
)

Definition at line 715 of file gr_basic.cpp.

717 {
718  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
719 }
void GRSFilledRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition: gr_basic.cpp:735

References GRSFilledRect().

◆ GRFilledSegment()

void GRFilledSegment ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint &  aStart,
const wxPoint &  aEnd,
int  aWidth,
const COLOR4D aColor 
)

Definition at line 333 of file gr_basic.cpp.

335 {
336  GRSetColorPen( aDC, aColor, aWidth );
337  WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
338 }
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:89

References GRSetColorPen(), and WinClipAndDrawLine().

Referenced by GERBER_DRAW_ITEM::Print().

◆ GRForceBlackPen()

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

Definition at line 185 of file gr_basic.cpp.

186 {
187  s_ForceBlackPen = flagforce;
188 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:78

References s_ForceBlackPen.

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

◆ GRLine() [1/2]

void GRLine ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint &  aStart,
const wxPoint &  aEnd,
int  aWidth,
const COLOR4D aColor,
wxPenStyle  aStyle = wxPENSTYLE_SOLID 
)

Definition at line 207 of file gr_basic.cpp.

209 {
210  GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
211 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:197

References GRLine().

◆ GRLine() [2/2]

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

Definition at line 197 of file gr_basic.cpp.

199 {
200  GRSetColorPen( DC, Color, width, aStyle );
201  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
202  GRLastMoveToX = x2;
203  GRLastMoveToY = y2;
204 }
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
static int GRLastMoveToX
Definition: gr_basic.cpp:77
static int GRLastMoveToY
Definition: gr_basic.cpp:77
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:89

References GRLastMoveToX, GRLastMoveToY, GRSetColorPen(), and WinClipAndDrawLine().

Referenced by BASIC_GAL::DrawLine(), GRLine(), GRLineTo(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), SCH_NO_CONNECT::Print(), SCH_BUS_ENTRY_BASE::Print(), SCH_LINE::Print(), LIB_PIN::printPinSymbol(), and DS_DRAW_ITEM_LINE::PrintWsItem().

◆ GRLineTo()

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

Definition at line 221 of file gr_basic.cpp.

222 {
223  GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
224 }
static int GRLastMoveToX
Definition: gr_basic.cpp:77
static int GRLastMoveToY
Definition: gr_basic.cpp:77
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:197

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

◆ GRMoveTo()

void GRMoveTo ( int  x,
int  y 
)

Definition at line 214 of file gr_basic.cpp.

215 {
216  GRLastMoveToX = x;
217  GRLastMoveToY = y;
218 }
static int GRLastMoveToX
Definition: gr_basic.cpp:77
static int GRLastMoveToY
Definition: gr_basic.cpp:77

References GRLastMoveToX, and GRLastMoveToY.

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

◆ GRPoly()

void GRPoly ( EDA_RECT ClipBox,
wxDC *  DC,
int  n,
const wxPoint *  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 453 of file gr_basic.cpp.

455 {
456  GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
457 }
static void GRSPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *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:382

References GRSPoly().

Referenced by BASIC_GAL::doDrawPolyline(), LIB_SHAPE::print(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), and DS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem().

◆ GRRect()

void GRRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
const COLOR4D Color 
)

Definition at line 701 of file gr_basic.cpp.

703 {
704  GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
705 }
static void GRSRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:722

References GRSRect().

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

◆ GRResetPenAndBrush()

void GRResetPenAndBrush ( wxDC *  DC)

Definition at line 107 of file gr_basic.cpp.

108 {
109  GRSetBrush( DC, BLACK ); // Force no fill
110  s_DC_lastbrushcolor = COLOR4D::UNSPECIFIED;
111  s_DC_lastDC = nullptr;
112 }
Definition: color4d.h:44
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:158
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:87
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)

References BLACK, GRSetBrush(), s_DC_lastbrushcolor, and s_DC_lastDC.

Referenced by SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), DIALOG_PIN_PROPERTIES::OnPaintShowPanel(), PLEDITOR_PRINTOUT::PrintPage(), SCH_PRINTOUT::PrintPage(), and DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample().

◆ GRSetBrush()

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

Definition at line 158 of file gr_basic.cpp.

159 {
160  COLOR4D color = Color;
161 
162  if( s_ForceBlackPen )
164 
165  if( s_DC_lastbrushcolor != color || s_DC_lastbrushfill != fill || s_DC_lastDC != DC )
166  {
167  wxBrush brush;
168 
169  brush.SetColour( color.ToColour() );
170 
171  if( fill )
172  brush.SetStyle( wxBRUSHSTYLE_SOLID );
173  else
174  brush.SetStyle( wxBRUSHSTYLE_TRANSPARENT );
175 
176  DC->SetBrush( brush );
177 
179  s_DC_lastbrushfill = fill;
180  s_DC_lastDC = DC;
181  }
182 }
int color
Definition: DXF_plotter.cpp:57
Definition: color4d.h:44
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:87
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
static bool s_DC_lastbrushfill
Definition: gr_basic.cpp:86
static bool s_ForceBlackPen
Definition: gr_basic.cpp:78
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

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

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

◆ GRSetColorPen()

void GRSetColorPen ( wxDC *  DC,
const COLOR4D Color,
int  width = 1,
wxPenStyle  stype = wxPENSTYLE_SOLID 
)

Definition at line 115 of file gr_basic.cpp.

116 {
117  COLOR4D color = Color;
118 
119  wxDash dots[2] = { 1, 3 };
120 
121  // Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
122  // nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
123  if( width <= 1 )
124  width = DC->DeviceToLogicalXRel( 1 );
125 
126  if( s_ForceBlackPen )
128 
129  const wxPen& curr_pen = DC->GetPen();
130 
131  if( !curr_pen.IsOk() || curr_pen.GetColour() != color.ToColour()
132  || curr_pen.GetWidth() != width || curr_pen.GetStyle() != style )
133  {
134  wxPen pen;
135  pen.SetColour( color.ToColour() );
136 
137  if( style == wxPENSTYLE_DOT )
138  {
139  style = wxPENSTYLE_USER_DASH;
140  pen.SetDashes( 2, dots );
141  }
142 
143  pen.SetWidth( width );
144  pen.SetStyle( style );
145  DC->SetPen( pen );
146  }
147  else
148  {
149  // Should be not needed, but on Linux, in printing process
150  // the curr pen settings needs to be sometimes re-initialized
151  // Clearly, this is due to a bug, related to SetBrush(),
152  // but we have to live with it, at least on wxWidgets 3.0
153  DC->SetPen( curr_pen );
154  }
155 }
int color
Definition: DXF_plotter.cpp:57
Definition: color4d.h:44
static bool s_ForceBlackPen
Definition: gr_basic.cpp:78
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103

References BLACK, color, and s_ForceBlackPen.

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

◆ GRSFilledRect()

void GRSFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
const COLOR4D Color,
const COLOR4D BgColor 
)

Definition at line 735 of file gr_basic.cpp.

737 {
738  wxPoint points[5];
739  points[0] = wxPoint( x1, y1 );
740  points[1] = wxPoint( x1, y2 );
741  points[2] = wxPoint( x2, y2 );
742  points[3] = wxPoint( x2, y1 );
743  points[4] = points[0];
744 
745  GRSetBrush( aDC, aBgColor, FILLED );
746  GRSetColorPen( aDC, aBgColor, aWidth );
747 
748  if( aClipBox && ( aWidth > 0 ) )
749  {
750  EDA_RECT clipbox( *aClipBox );
751  clipbox.Inflate( aWidth );
752  ClipAndDrawPoly( &clipbox, aDC, points, 5 ); // polygon approach is more accurate
753  }
754  else
755  {
756  ClipAndDrawPoly(aClipBox, aDC, points, 5 );
757  }
758 }
static const bool FILLED
Definition: gr_basic.cpp:32
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
Definition: gr_basic.cpp:115
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill)
Definition: gr_basic.cpp:158
static void ClipAndDrawPoly(EDA_RECT *ClipBox, wxDC *DC, const wxPoint *Points, int n)
Used to clip a polygon and draw it as Filled Polygon.
Definition: gr_basic.cpp:771
Handle the component boundary box.
Definition: eda_rect.h:42

References ClipAndDrawPoly(), FILLED, GRSetBrush(), GRSetColorPen(), and EDA_RECT::Inflate().

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

◆ operator &()

GR_DRAWMODE operator & ( const GR_DRAWMODE a,
const GR_DRAWMODE b 
)
inline

Definition at line 61 of file gr_basic.h.

62 {
63  return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
64 }

◆ operator|()

GR_DRAWMODE operator| ( const GR_DRAWMODE a,
const GR_DRAWMODE b 
)
inline

Definition at line 56 of file gr_basic.h.

57 {
58  return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
59 }

◆ operator~()

GR_DRAWMODE operator~ ( const GR_DRAWMODE a)
inline

Definition at line 51 of file gr_basic.h.

52 {
53  return static_cast<GR_DRAWMODE>( ~int( a ) );
54 }

Variable Documentation

◆ g_XorMode

GR_DRAWMODE g_XorMode

Definition at line 63 of file gr_basic.cpp.