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.

Macros

#define GR_M_LEFT_DOWN   0x10000000
 
#define GR_M_RIGHT_DOWN   0x20000000
 
#define GR_M_MIDDLE_DOWN   0x40000000
 
#define GR_M_DCLICK   0x80000000
 

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

void DrawModeAddHighlight (GR_DRAWMODE *mode)
 
void DrawModeAllowHighContrast (GR_DRAWMODE *mode)
 
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, COLOR4D Color, int width=1, wxPenStyle stype=wxPENSTYLE_SOLID)
 Set a pen style, width, color, and alpha into the given device context. More...
 
void GRSetBrush (wxDC *DC, COLOR4D Color, bool fill=false)
 
void GRForceBlackPen (bool flagforce)
 
bool GetGRForceBlackPenState (void)
 
void GRLine (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
 
void GRLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, 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, COLOR4D Color)
 
void GRPoly (EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
 
void GRBezier (EDA_RECT *aClipBox, wxDC *aDC, std::vector< wxPoint > &aPoints, int aWidth, COLOR4D aColor)
 Draw cubic (4 points: start control1, control2, end) bezier curve. More...
 
void GRClosedPoly (EDA_RECT *ClipBox, wxDC *aDC, int aPointCount, const wxPoint *aPoints, bool doFill, COLOR4D aPenColor, 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, COLOR4D aPenColor, 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 *aDC, int x, int y, int aRadius, COLOR4D aColor)
 Draw a circle onto the drawing context aDC centered at the user coordinates (x,y). More...
 
void GRCircle (EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color)
 
void GRFilledCircle (EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
 
void GRFilledCircle (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aPos, int aRadius, COLOR4D aColor)
 
void GRCircle (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor)
 
void GRArc (EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, COLOR4D Color)
 
void GRArc (EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, int width, COLOR4D Color)
 
void GRArc1 (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, COLOR4D Color)
 
void GRArc1 (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, int width, COLOR4D Color)
 
void GRArc1 (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, wxPoint aCenter, int aWidth, COLOR4D aColor)
 
void GRFilledArc (EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor)
 
void GRFilledArc (EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor)
 
void GRCSegm (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRFillCSegm (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRFilledSegment (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
 
void GRCSegm (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
 
void GRCSegm (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
 
void GRSetColor (COLOR4D Color)
 
void GRSetDefaultPalette ()
 
COLOR4D GRGetColor ()
 
void GRPutPixel (EDA_RECT *ClipBox, wxDC *DC, int x, int y, COLOR4D color)
 
void GRFilledRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
 
void GRFilledRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor)
 
void GRRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color)
 
void GRRect (EDA_RECT *ClipBox, wxDC *DC, const EDA_RECT &aRect, int aWidth, COLOR4D Color)
 
void GRRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRRectPs (EDA_RECT *aClipBox, wxDC *aDC, const EDA_RECT &aRect, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
 
void GRSFilledRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor)
 
void GRLineArray (EDA_RECT *aClipBox, wxDC *aDC, std::vector< wxPoint > &aLines, int aWidth, COLOR4D aColor)
 Draw an array of lines (not a polygon). More...
 
void GRDrawAnchor (EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor)
 
void GRDrawWrappedText (wxDC &aDC, wxString const &aText)
 Draw text centered on a wxDC with wrapping. More...
 

Variables

GR_DRAWMODE g_XorMode
 

Macro Definition Documentation

◆ GR_M_DCLICK

#define GR_M_DCLICK   0x80000000

Definition at line 79 of file gr_basic.h.

◆ GR_M_LEFT_DOWN

#define GR_M_LEFT_DOWN   0x10000000

Definition at line 76 of file gr_basic.h.

◆ GR_M_MIDDLE_DOWN

#define GR_M_MIDDLE_DOWN   0x40000000

Definition at line 78 of file gr_basic.h.

◆ GR_M_RIGHT_DOWN

#define GR_M_RIGHT_DOWN   0x20000000

Definition at line 77 of file gr_basic.h.

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 84 of file gr_basic.h.

84  {
85  /* Line styles for Get/SetLineStyle. */
86  GR_SOLID_LINE = 0,
87  GR_DOTTED_LINE = 1,
88  GR_DASHED_LINE = 3
GRLineStypeType
Definition: gr_basic.h:84

Function Documentation

◆ DrawModeAddHighlight()

void DrawModeAddHighlight ( GR_DRAWMODE mode)
inline

Definition at line 51 of file gr_basic.h.

52 {
53  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_HIGHLIGHT );
54 }

References GR_HIGHLIGHT.

◆ DrawModeAllowHighContrast()

void DrawModeAllowHighContrast ( GR_DRAWMODE mode)
inline

Definition at line 56 of file gr_basic.h.

57 {
58  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_ALLOW_HIGHCONTRAST );
59 }

References GR_ALLOW_HIGHCONTRAST.

◆ GetGRForceBlackPenState()

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

Definition at line 212 of file gr_basic.cpp.

213 {
214  return s_ForceBlackPen;
215 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:86

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,
COLOR4D  Color 
)

Definition at line 751 of file gr_basic.cpp.

753 {
754  int x1, y1, x2, y2;
755 
756  /* Clip arcs off screen */
757  if( ClipBox )
758  {
759  int radius = r + 1;
760  int x0, y0, xm, ym, x, y;
761  x0 = ClipBox->GetX();
762  y0 = ClipBox->GetY();
763  xm = ClipBox->GetRight();
764  ym = ClipBox->GetBottom();
765  x = xc;
766  y = yc;
767 
768  if( x < ( x0 - radius ) )
769  return;
770 
771  if( y < ( y0 - radius ) )
772  return;
773 
774  if( x > ( xm + radius ) )
775  return;
776 
777  if( y > ( ym + radius ) )
778  return;
779  }
780 
781  x1 = r;
782  y1 = 0;
783  RotatePoint( &x1, &y1, EndAngle );
784 
785  x2 = r;
786  y2 = 0;
787  RotatePoint( &x2, &y2, StAngle );
788 
789  GRSetBrush( DC, Color, NOT_FILLED );
790  GRSetColorPen( DC, Color );
791  DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
792 }
int GetX() const
Definition: eda_rect.h:98
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
int GetBottom() const
Definition: eda_rect.h:114
static const bool NOT_FILLED
Definition: gr_basic.cpp:40
int GetRight() const
Definition: eda_rect.h:111
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131
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, and RotatePoint().

◆ GRArc() [2/2]

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

Definition at line 798 of file gr_basic.cpp.

807 {
808  int x1, y1, x2, y2;
809 
810  /* Clip arcs off screen. */
811  if( ClipBox )
812  {
813  int x0, y0, xm, ym;
814  x0 = ClipBox->GetX();
815  y0 = ClipBox->GetY();
816  xm = ClipBox->GetRight();
817  ym = ClipBox->GetBottom();
818 
819  if( x < ( x0 - r - width ) )
820  return;
821 
822  if( y < ( y0 - r - width ) )
823  return;
824 
825  if( x > ( r + xm + width ) )
826  return;
827 
828  if( y > ( r + ym + width ) )
829  return;
830  }
831 
832  x1 = r;
833  y1 = 0;
834  RotatePoint( &x1, &y1, EndAngle );
835 
836  x2 = r;
837  y2 = 0;
838  RotatePoint( &x2, &y2, StAngle );
839 
840  GRSetBrush( DC, Color );
841  GRSetColorPen( DC, Color, width );
842  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
843 }
int GetX() const
Definition: eda_rect.h:98
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
int GetBottom() const
Definition: eda_rect.h:114
int GetRight() const
Definition: eda_rect.h:111
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131
int GetY() const
Definition: eda_rect.h:99

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

◆ GRArc1() [1/3]

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

Definition at line 642 of file gr_basic.cpp.

644 {
645  GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
646 }
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, COLOR4D Color)
Definition: gr_basic.cpp:642

References GRArc1().

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

◆ GRArc1() [2/3]

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

Definition at line 652 of file gr_basic.cpp.

654 {
655  /* Clip arcs off screen. */
656  if( ClipBox )
657  {
658  int x0, y0, xm, ym, r;
659  x0 = ClipBox->GetX();
660  y0 = ClipBox->GetY();
661  xm = ClipBox->GetRight();
662  ym = ClipBox->GetBottom();
663  r = KiROUND( Distance( x1, y1, xc, yc ) );
664  if( xc < ( x0 - r ) )
665  return;
666  if( yc < ( y0 - r ) )
667  return;
668  if( xc > ( r + xm ) )
669  return;
670  if( yc > ( r + ym ) )
671  return;
672  }
673 
674  GRSetBrush( DC, Color );
675  GRSetColorPen( DC, Color, width );
676  DC->DrawArc( x1, y1, x2, y2, xc, yc );
677 }
int GetX() const
Definition: eda_rect.h:98
int GetBottom() const
Definition: eda_rect.h:114
int GetRight() const
Definition: eda_rect.h:111
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131
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(), and KiROUND().

◆ GRArc1() [3/3]

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

Definition at line 680 of file gr_basic.cpp.

682 {
683  GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
684  aWidth, aColor );
685 }
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, COLOR4D Color)
Definition: gr_basic.cpp:642

References GRArc1().

◆ GRBezier()

void GRBezier ( EDA_RECT aClipBox,
wxDC *  aDC,
std::vector< wxPoint > &  aPoints,
int  aWidth,
COLOR4D  aColor 
)

Draw cubic (4 points: start control1, control2, end) bezier curve.

Definition at line 994 of file gr_basic.cpp.

996 {
997  std::vector<wxPoint> output;
998 
999  BEZIER_POLY converter( aPoint );
1000  converter.GetPoly( output, aWidth );
1001 
1002  GRPoly( aClipBox, aDC, output.size(), &output[0], false, aWidth, aColor, aColor );
1003 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:543
Bezier curves to polygon converter.
Definition: bezier_curves.h:36

References BEZIER_POLY::GetPoly(), and GRPoly().

◆ GRCircle() [1/3]

void GRCircle ( EDA_RECT ClipBox,
wxDC *  aDC,
int  x,
int  y,
int  aRadius,
COLOR4D  aColor 
)

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 608 of file gr_basic.cpp.

609 {
610  GRCircle( ClipBox, DC, x, y, r, 0, Color );
611 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:597

References GRCircle().

◆ GRCircle() [2/3]

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

Definition at line 597 of file gr_basic.cpp.

598 {
599  if( clipCircle( ClipBox, xc, yc, r, width ) || r <= 0 )
600  return;
601 
602  GRSetBrush( DC, Color, NOT_FILLED );
603  GRSetColorPen( DC, Color, width );
604  DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
605 }
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:567
static const bool NOT_FILLED
Definition: gr_basic.cpp:40
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131

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

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

◆ GRCircle() [3/3]

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

Definition at line 614 of file gr_basic.cpp.

616 {
617  GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
618 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:597

References GRCircle().

◆ GRClosedPoly() [1/2]

void GRClosedPoly ( EDA_RECT ClipBox,
wxDC *  aDC,
int  aPointCount,
const wxPoint *  aPoints,
bool  doFill,
COLOR4D  aPenColor,
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 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.

Definition at line 553 of file gr_basic.cpp.

555 {
556  GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
557 }
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, COLOR4D Color, COLOR4D BgColor)
Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around ...
Definition: gr_basic.cpp:553

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,
COLOR4D  aPenColor,
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 560 of file gr_basic.cpp.

562 {
563  GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
564 }
static void GRSClosedPoly(EDA_RECT *aClipBox, wxDC *aDC, int aPointCount, const wxPoint *aPoints, bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:505

References GRSClosedPoly().

◆ GRCSegm() [1/3]

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

Definition at line 397 of file gr_basic.cpp.

399 {
400  GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
401 }
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
Definition: gr_basic.cpp:313

References GRCSegm().

◆ GRCSegm() [2/3]

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

Definition at line 313 of file gr_basic.cpp.

315 {
316  GRLastMoveToX = x2;
317  GRLastMoveToY = y2;
318 
319  if( ClipBox )
320  {
321  EDA_RECT clipbox(*ClipBox);
322  clipbox.Inflate(width/2);
323 
324  if( ClipLine( &clipbox, x1, y1, x2, y2 ) )
325  return;
326  }
327 
328  if( width <= 2 ) /* single line or 2 pixels */
329  {
330  GRSetColorPen( DC, Color, width );
331  DC->DrawLine( x1, y1, x2, y2 );
332  return;
333  }
334 
335  GRSetBrush( DC, Color, NOT_FILLED );
336  GRSetColorPen( DC, Color, aPenSize );
337 
338  int radius = (width + 1) >> 1;
339  int dx = x2 - x1;
340  int dy = y2 - y1;
341  double angle = -ArcTangente( dy, dx );
342  wxPoint start;
343  wxPoint end;
344  wxPoint org( x1, y1);
345  int len = (int) hypot( dx, dy );
346 
347  // We know if the DC is mirrored, to draw arcs
348  int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
349  int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
350  bool mirrored = (slx > 0 && sly < 0) || (slx < 0 && sly > 0);
351 
352  // first edge
353  start.x = 0;
354  start.y = radius;
355  end.x = len;
356  end.y = radius;
357  RotatePoint( &start, angle);
358  RotatePoint( &end, angle);
359 
360  start += org;
361  end += org;
362 
363  DC->DrawLine( start, end );
364 
365  // first rounded end
366  end.x = 0;
367  end.y = -radius;
368  RotatePoint( &end, angle);
369  end += org;
370 
371  if( !mirrored )
372  DC->DrawArc( end, start, org );
373  else
374  DC->DrawArc( start, end, org );
375 
376  // second edge
377  start.x = len;
378  start.y = -radius;
379  RotatePoint( &start, angle);
380  start += org;
381 
382  DC->DrawLine( start, end );
383 
384  // second rounded end
385  end.x = len;
386  end.y = radius;
387  RotatePoint( &end, angle);
388  end += org;
389 
390  if( !mirrored )
391  DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
392  else
393  DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
394 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
static int GRLastMoveToX
Definition: gr_basic.cpp:85
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.
static const bool NOT_FILLED
Definition: gr_basic.cpp:40
static int GRLastMoveToY
Definition: gr_basic.cpp:85
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131
Handle the component boundary box.
Definition: eda_rect.h:42
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:182

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,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 404 of file gr_basic.cpp.

406 {
407  GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
408 }
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
Definition: gr_basic.cpp:313

References GRCSegm().

◆ GRDrawAnchor()

void GRDrawAnchor ( EDA_RECT aClipBox,
wxDC *  aDC,
int  x,
int  y,
int  aSize,
COLOR4D  aColor 
)

Definition at line 1006 of file gr_basic.cpp.

1007 {
1008  int anchor_size = aDC->DeviceToLogicalXRel( aSize );
1009 
1010  GRLine( aClipBox, aDC, x - anchor_size, y, x + anchor_size, y, 0, aColor );
1011  GRLine( aClipBox, aDC, x, y - anchor_size, x, y + anchor_size, 0, aColor );
1012 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:231

References GRLine().

◆ GRDrawWrappedText()

void GRDrawWrappedText ( wxDC &  aDC,
wxString const &  aText 
)

Draw text centered on a wxDC with wrapping.

Parameters
aDCwxDC instance onto which the text will be drawn.
aTextthe text to draw.

Definition at line 1015 of file gr_basic.cpp.

1016 {
1017  wxStringTokenizer tokenizer( aText, " " );
1018  wxSize const dc_size = aDC.GetSize();
1019  wxSize const margin = aDC.GetTextExtent( " " );
1020  std::vector<wxString> lines;
1021  wxString line_accumulator;
1022  int total_height = 0;
1023 
1024  while( tokenizer.HasMoreTokens() )
1025  {
1026  wxString word = tokenizer.GetNextToken();
1027  wxSize linesize = aDC.GetTextExtent( line_accumulator + " " + word );
1028 
1029  if( linesize.x >= dc_size.x - margin.x && !line_accumulator.IsEmpty() )
1030  {
1031  lines.push_back( line_accumulator );
1032  line_accumulator = word;
1033  }
1034  else
1035  {
1036  line_accumulator += " ";
1037  line_accumulator += word;
1038  }
1039  }
1040 
1041  if( !line_accumulator.IsEmpty() )
1042  {
1043  lines.push_back( line_accumulator );
1044  }
1045 
1046  for( auto const& line: lines )
1047  {
1048  wxSize linesize = aDC.GetTextExtent( line );
1049  total_height += linesize.y;
1050  }
1051 
1052  int top = ( dc_size.y - total_height ) / 2;
1053  int pos = top;
1054 
1055  for( auto const& line: lines )
1056  {
1057  wxSize linesize = aDC.GetTextExtent( line );
1058  aDC.DrawText( line, ( dc_size.x - linesize.x ) / 2, pos );
1059  pos += linesize.y;
1060  }
1061 }

◆ GRFillCSegm()

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

Definition at line 414 of file gr_basic.cpp.

416 {
417  GRSetColorPen( DC, Color, width );
418  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
419 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:98
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131

References GRSetColorPen(), and WinClipAndDrawLine().

Referenced by D_CODE::DrawFlashedShape().

◆ GRFilledArc() [1/2]

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

Definition at line 740 of file gr_basic.cpp.

743 {
744  GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
745 }
void GRFilledArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:691

References GRFilledArc().

◆ GRFilledArc() [2/2]

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

Definition at line 691 of file gr_basic.cpp.

701 {
702  int x1, y1, x2, y2;
703 
704  /* Clip arcs off screen */
705  if( ClipBox )
706  {
707  int x0, y0, xm, ym;
708  x0 = ClipBox->GetX();
709  y0 = ClipBox->GetY();
710  xm = ClipBox->GetRight();
711  ym = ClipBox->GetBottom();
712 
713  if( x < ( x0 - r - 1 ) )
714  return;
715 
716  if( y < ( y0 - r - 1 ) )
717  return;
718 
719  if( x > ( r + xm + 1 ) )
720  return;
721 
722  if( y > ( r + ym + 1 ) )
723  return;
724  }
725 
726  x1 = r;
727  y1 = 0;
728  RotatePoint( &x1, &y1, EndAngle );
729 
730  x2 = r;
731  y2 = 0;
732  RotatePoint( &x2, &y2, StAngle );
733 
734  GRSetBrush( DC, BgColor, FILLED );
735  GRSetColorPen( DC, Color, width );
736  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
737 }
static const bool FILLED
Definition: gr_basic.cpp:39
int GetX() const
Definition: eda_rect.h:98
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:228
int GetBottom() const
Definition: eda_rect.h:114
int GetRight() const
Definition: eda_rect.h:111
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131
int GetY() const
Definition: eda_rect.h:99

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

Referenced by GRFilledArc(), and LIB_ARC::print().

◆ GRFilledCircle() [1/2]

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

Definition at line 621 of file gr_basic.cpp.

623 {
624  if( clipCircle( ClipBox, x, y, r, width ) || r <= 0 )
625  return;
626 
627  GRSetBrush( DC, BgColor, FILLED );
628  GRSetColorPen( DC, Color, width );
629  DC->DrawEllipse( x - r, y - r, r + r, r + r );
630 }
static const bool FILLED
Definition: gr_basic.cpp:39
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:567
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131

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

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

◆ GRFilledCircle() [2/2]

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

Definition at line 633 of file gr_basic.cpp.

634 {
635  GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor );
636 }
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:621

References GRFilledCircle().

◆ GRFilledRect() [1/2]

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

Definition at line 890 of file gr_basic.cpp.

892 {
893  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
894 }
void GRSFilledRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:923

References GRSFilledRect().

Referenced by D_CODE::DrawFlashedShape(), LIB_RECTANGLE::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,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 900 of file gr_basic.cpp.

902 {
903  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
904 }
void GRSFilledRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:923

References GRSFilledRect().

◆ GRFilledSegment()

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

Definition at line 422 of file gr_basic.cpp.

424 {
425  GRSetColorPen( aDC, aColor, aWidth );
426  WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
427 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:98
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131

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 203 of file gr_basic.cpp.

204 {
205  s_ForceBlackPen = flagforce;
206 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:86

References s_ForceBlackPen.

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

◆ GRGetColor()

COLOR4D GRGetColor ( )

◆ GRLine() [1/2]

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

Definition at line 248 of file gr_basic.cpp.

250 {
251  GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
252 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:231

References GRLine().

◆ GRLine() [2/2]

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

Definition at line 231 of file gr_basic.cpp.

240 {
241  GRSetColorPen( DC, Color, width, aStyle );
242  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
243  GRLastMoveToX = x2;
244  GRLastMoveToY = y2;
245 }
static int GRLastMoveToX
Definition: gr_basic.cpp:85
static int GRLastMoveToY
Definition: gr_basic.cpp:85
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:98
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131

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

Referenced by BASIC_GAL::DrawLine(), GRDrawAnchor(), 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().

◆ GRLineArray()

void GRLineArray ( EDA_RECT aClipBox,
wxDC *  aDC,
std::vector< wxPoint > &  aLines,
int  aWidth,
COLOR4D  aColor 
)

Draw an array of lines (not a polygon).

Parameters
aClipBoxthe clip box.
aDCthe device context into which drawing should occur.
aLinesa list of pair of coordinate in user space: a pair for each line.
aWidththe width of each line.
aColorthe color of the lines.
See also
COLOR4D
Parameters
aClipBoxis the clip box.
aDCis the device context into which drawing should occur.
aLinesis a list of pair of coordinate in user space: a pair for each line.
aWidthis the width of each line.
aColoris the color to draw the lines.
See also
COLOR4D

Definition at line 284 of file gr_basic.cpp.

286 {
287  if( aLines.empty() )
288  return;
289 
290  GRSetColorPen( aDC, aColor, aWidth );
291 
292  if( aClipBox )
293  aClipBox->Inflate( aWidth / 2 );
294 
295  for( unsigned i = 0; i < aLines.size(); i += 2 )
296  {
297  int x1 = aLines[i].x;
298  int y1 = aLines[i].y;
299  int x2 = aLines[i + 1].x;
300  int y2 = aLines[i + 1].y;
301  if( ( aClipBox == nullptr ) || !ClipLine( aClipBox, x1, y1, x2, y2 ) )
302  aDC->DrawLine( x1, y1, x2, y2 );
303  }
304 
305  GRMoveTo( aLines[aLines.size() - 1].x, aLines[aLines.size() - 1].y );
306 
307  if( aClipBox )
308  aClipBox->Inflate(-aWidth/2);
309 }
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 GRMoveTo(int x, int y)
Definition: gr_basic.cpp:258
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References ClipLine(), GRMoveTo(), GRSetColorPen(), and EDA_RECT::Inflate().

◆ GRLineTo()

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

Definition at line 268 of file gr_basic.cpp.

269 {
270  GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
271 }
static int GRLastMoveToX
Definition: gr_basic.cpp:85
static int GRLastMoveToY
Definition: gr_basic.cpp:85
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:231

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

◆ GRMoveTo()

void GRMoveTo ( int  x,
int  y 
)

Definition at line 258 of file gr_basic.cpp.

259 {
260  GRLastMoveToX = x;
261  GRLastMoveToY = y;
262 }
static int GRLastMoveToX
Definition: gr_basic.cpp:85
static int GRLastMoveToY
Definition: gr_basic.cpp:85

References GRLastMoveToX, and GRLastMoveToY.

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

◆ GRPoly()

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

Definition at line 543 of file gr_basic.cpp.

545 {
546  GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
547 }
static void GRSPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:472

References GRSPoly().

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

◆ GRPutPixel()

void GRPutPixel ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
COLOR4D  color 
)

Definition at line 218 of file gr_basic.cpp.

219 {
220  if( ClipBox && !ClipBox->Contains( x, y ) )
221  return;
222 
223  GRSetColorPen( DC, Color );
224  DC->DrawPoint( x, y );
225 }
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131

References EDA_RECT::Contains(), and GRSetColorPen().

◆ GRRect() [1/3]

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

Definition at line 849 of file gr_basic.cpp.

850 {
851  GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor );
852 }
static void GRSRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:910

References GRSRect().

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

◆ GRRect() [2/3]

void GRRect ( EDA_RECT ClipBox,
wxDC *  DC,
const EDA_RECT aRect,
int  aWidth,
COLOR4D  Color 
)

Definition at line 876 of file gr_basic.cpp.

877 {
878  int x1 = aRect.GetX();
879  int y1 = aRect.GetY();
880  int x2 = aRect.GetRight();
881  int y2 = aRect.GetBottom();
882 
883  GRSRect( aClipBox, aDC, x1, y1, x2, y2, aWidth, aColor );
884 }
int GetX() const
Definition: eda_rect.h:98
int GetBottom() const
Definition: eda_rect.h:114
int GetRight() const
Definition: eda_rect.h:111
int GetY() const
Definition: eda_rect.h:99
static void GRSRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:910

References EDA_RECT::GetBottom(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), and GRSRect().

◆ GRRect() [3/3]

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

Definition at line 870 of file gr_basic.cpp.

871 {
872  GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
873 }
static void GRSRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:910

References GRSRect().

◆ GRRectPs()

void GRRectPs ( EDA_RECT aClipBox,
wxDC *  aDC,
const EDA_RECT aRect,
int  aWidth,
COLOR4D  aColor,
wxPenStyle  aStyle = wxPENSTYLE_SOLID 
)

◆ GRResetPenAndBrush()

void GRResetPenAndBrush ( wxDC *  DC)

Definition at line 119 of file gr_basic.cpp.

120 {
121  GRSetBrush( DC, BLACK ); // Force no fill
122  s_DC_lastbrushcolor = COLOR4D::UNSPECIFIED;
123  s_DC_lastcolor = COLOR4D::UNSPECIFIED;
124  s_DC_lastDC = nullptr;
125 }
Definition: color4d.h:44
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:96
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
static COLOR4D s_DC_lastcolor(0, 0, 0, 0)
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173

References BLACK, GRSetBrush(), s_DC_lastbrushcolor, s_DC_lastcolor, 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,
COLOR4D  Color,
bool  fill = false 
)

Definition at line 173 of file gr_basic.cpp.

174 {
175  if( s_ForceBlackPen )
176  Color = COLOR4D::BLACK;
177 
178  if( s_DC_lastbrushcolor != Color
179  || s_DC_lastbrushfill != fill
180  || s_DC_lastDC != DC )
181  {
182  wxBrush brush;
183 
184  brush.SetColour( Color.ToColour() );
185 
186  if( fill )
187  brush.SetStyle( wxBRUSHSTYLE_SOLID );
188  else
189  brush.SetStyle( wxBRUSHSTYLE_TRANSPARENT );
190 
191  DC->SetBrush( brush );
192 
193  s_DC_lastbrushcolor = Color;
194  s_DC_lastbrushfill = fill;
195  s_DC_lastDC = DC;
196  }
197 }
Definition: color4d.h:44
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:96
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
static bool s_DC_lastbrushfill
Definition: gr_basic.cpp:95
static bool s_ForceBlackPen
Definition: gr_basic.cpp:86

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

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

◆ GRSetColor()

void GRSetColor ( COLOR4D  Color)

◆ GRSetColorPen()

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

Set a pen style, width, color, and alpha into the given device context.

Definition at line 131 of file gr_basic.cpp.

132 {
133  wxDash dots[2] = { 1, 3 };
134 
135  // Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
136  // nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
137  if( width <= 1 )
138  width = DC->DeviceToLogicalXRel( 1 );
139 
140  if( s_ForceBlackPen )
141  Color = COLOR4D::BLACK;
142 
143  const wxPen& curr_pen = DC->GetPen();
144 
145  if( !curr_pen.IsOk() || curr_pen.GetColour() != Color.ToColour()
146  || curr_pen.GetWidth() != width
147  || curr_pen.GetStyle() != style )
148  {
149  wxPen pen;
150  pen.SetColour( Color.ToColour() );
151 
152  if( style == wxPENSTYLE_DOT )
153  {
154  style = wxPENSTYLE_USER_DASH;
155  pen.SetDashes( 2, dots );
156  }
157 
158  pen.SetWidth( width );
159  pen.SetStyle( style );
160  DC->SetPen( pen );
161  }
162  else
163  {
164  // Should be not needed, but on Linux, in printing process
165  // the curr pen settings needs to be sometimes re-initialized
166  // Clearly, this is due to a bug, related to SetBrush(),
167  // but we have to live with it, at least on wxWidgets 3.0
168  DC->SetPen( curr_pen );
169  }
170 }
Definition: color4d.h:44
static bool s_ForceBlackPen
Definition: gr_basic.cpp:86

References BLACK, and s_ForceBlackPen.

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

◆ GRSetDefaultPalette()

void GRSetDefaultPalette ( )

◆ GRSFilledRect()

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

Definition at line 923 of file gr_basic.cpp.

925 {
926  wxPoint points[5];
927  points[0] = wxPoint( x1, y1 );
928  points[1] = wxPoint( x1, y2 );
929  points[2] = wxPoint( x2, y2 );
930  points[3] = wxPoint( x2, y1 );
931  points[4] = points[0];
932 
933  GRSetBrush( aDC, aBgColor, FILLED );
934  GRSetColorPen( aDC, aBgColor, aWidth );
935 
936  if( aClipBox && ( aWidth > 0 ) )
937  {
938  EDA_RECT clipbox( *aClipBox );
939  clipbox.Inflate( aWidth );
940  ClipAndDrawPoly( &clipbox, aDC, points, 5 ); // polygon approach is more accurate
941  }
942  else
943  {
944  ClipAndDrawPoly(aClipBox, aDC, points, 5 );
945  }
946 }
static const bool FILLED
Definition: gr_basic.cpp:39
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
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:959
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Set a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:131
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 71 of file gr_basic.h.

72 {
73  return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
74 }

◆ operator|()

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

Definition at line 66 of file gr_basic.h.

67 {
68  return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
69 }

◆ operator~()

GR_DRAWMODE operator~ ( const GR_DRAWMODE a)
inline

Definition at line 61 of file gr_basic.h.

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

Variable Documentation

◆ g_XorMode

GR_DRAWMODE g_XorMode

Definition at line 70 of file gr_basic.cpp.