KiCad PCB EDA Suite
gr_basic.h File Reference
#include <gal/color4d.h>
#include <vector>
#include <eda_rect.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)
 Function GRSetColorPen sets 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)
 Function GRForceBlackPen. More...
 
bool GetGRForceBlackPenState (void)
 Function GetGRForceBlackPenState. More...
 
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)
 Function GRClosedPoly draws 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)
 Function GRClosedPoly draws 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)
 Function GRCircle draws 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)
 Function GRLineArray draws 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 77 of file gr_basic.h.

◆ GR_M_LEFT_DOWN

#define GR_M_LEFT_DOWN   0x10000000

Definition at line 74 of file gr_basic.h.

◆ GR_M_MIDDLE_DOWN

#define GR_M_MIDDLE_DOWN   0x40000000

Definition at line 76 of file gr_basic.h.

◆ GR_M_RIGHT_DOWN

#define GR_M_RIGHT_DOWN   0x20000000

Definition at line 75 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 37 of file gr_basic.h.

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

◆ GRLineStypeType

Enumerator
GR_SOLID_LINE 
GR_DOTTED_LINE 
GR_DASHED_LINE 

Definition at line 82 of file gr_basic.h.

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

Function Documentation

◆ DrawModeAddHighlight()

void DrawModeAddHighlight ( GR_DRAWMODE mode)
inline

Definition at line 49 of file gr_basic.h.

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

References GR_HIGHLIGHT.

◆ DrawModeAllowHighContrast()

void DrawModeAllowHighContrast ( GR_DRAWMODE mode)
inline

Definition at line 54 of file gr_basic.h.

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

References GR_ALLOW_HIGHCONTRAST.

◆ GetGRForceBlackPenState()

bool GetGRForceBlackPenState ( void  )

Function GetGRForceBlackPenState.

Returns
ForceBlackPen (True if a black pen was forced)
s_ForceBlackPen (True if a black pen was forced)

Definition at line 210 of file gr_basic.cpp.

211 {
212  return s_ForceBlackPen;
213 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:87

References s_ForceBlackPen.

Referenced by VIA::Print(), LIB_PART::Print(), and D_PAD::PrintShape().

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

750 {
751  int x1, y1, x2, y2;
752 
753  /* Clip arcs off screen */
754  if( ClipBox )
755  {
756  int radius = r + 1;
757  int x0, y0, xm, ym, x, y;
758  x0 = ClipBox->GetX();
759  y0 = ClipBox->GetY();
760  xm = ClipBox->GetRight();
761  ym = ClipBox->GetBottom();
762  x = xc;
763  y = yc;
764 
765  if( x < ( x0 - radius ) )
766  return;
767  if( y < ( y0 - radius ) )
768  return;
769  if( x > ( xm + radius ) )
770  return;
771  if( y > ( ym + radius ) )
772  return;
773  }
774 
775  x1 = r;
776  y1 = 0;
777  RotatePoint( &x1, &y1, EndAngle );
778 
779  x2 = r;
780  y2 = 0;
781  RotatePoint( &x2, &y2, StAngle );
782 
783  GRSetBrush( DC, Color, NOT_FILLED );
784  GRSetColorPen( DC, Color );
785  DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
786 }
int GetX() const
Definition: eda_rect.h:111
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:206
int GetBottom() const
Definition: eda_rect.h:124
static const bool NOT_FILLED
Definition: gr_basic.cpp:41
int GetRight() const
Definition: eda_rect.h:121
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:169
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:132
int GetY() const
Definition: eda_rect.h:112

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

Referenced by EDGE_MODULE::Print(), and DRAWSEGMENT::Print().

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

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

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

641 {
642  GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
643 }
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:639

References GRArc1().

Referenced by GRArc1(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), 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 649 of file gr_basic.cpp.

651 {
652  /* Clip arcs off screen. */
653  if( ClipBox )
654  {
655  int x0, y0, xm, ym, r;
656  x0 = ClipBox->GetX();
657  y0 = ClipBox->GetY();
658  xm = ClipBox->GetRight();
659  ym = ClipBox->GetBottom();
660  r = KiROUND( Distance( x1, y1, xc, yc ) );
661  if( xc < ( x0 - r ) )
662  return;
663  if( yc < ( y0 - r ) )
664  return;
665  if( xc > ( r + xm ) )
666  return;
667  if( yc > ( r + ym ) )
668  return;
669  }
670 
671  GRSetBrush( DC, Color );
672  GRSetColorPen( DC, Color, width );
673  DC->DrawArc( x1, y1, x2, y2, xc, yc );
674 }
int GetX() const
Definition: eda_rect.h:111
int GetBottom() const
Definition: eda_rect.h:124
int GetRight() const
Definition: eda_rect.h:121
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:169
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:132
int GetY() const
Definition: eda_rect.h:112
double Distance(double x1, double y1, double x2, double y2)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114

References Distance(), 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 677 of file gr_basic.cpp.

679 {
680  GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
681  aWidth, aColor );
682 }
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:639

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

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

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

◆ GRCircle() [1/3]

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

Function GRCircle draws 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 606 of file gr_basic.cpp.

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

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

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

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

Referenced by D_CODE::DrawFlashedShape(), GRCircle(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), LIB_CIRCLE::print(), PCB_TARGET::Print(), EDGE_MODULE::Print(), DRAWSEGMENT::Print(), GERBER_DRAW_ITEM::Print(), VIA::Print(), LIB_PIN::PrintPinSymbol(), and D_PAD::PrintShape().

◆ GRCircle() [3/3]

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

Definition at line 612 of file gr_basic.cpp.

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

References GRCircle().

◆ GRClosedPoly() [1/2]

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

Function GRClosedPoly draws 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 551 of file gr_basic.cpp.

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

References GRClosedPoly().

Referenced by APERTURE_MACRO::DrawApertureMacroShape(), D_CODE::DrawFlashedPolygon(), GRClosedPoly(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), DRAWSEGMENT::Print(), GERBER_DRAW_ITEM::PrintGerberPoly(), MARKER_BASE::PrintMarker(), and D_PAD::PrintShape().

◆ GRClosedPoly() [2/2]

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

Function GRClosedPoly draws 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 558 of file gr_basic.cpp.

560 {
561  GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
562 }
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:504

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:311

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

313 {
314  GRLastMoveToX = x2;
315  GRLastMoveToY = y2;
316 
317  if( ClipBox )
318  {
319  EDA_RECT clipbox(*ClipBox);
320  clipbox.Inflate(width/2);
321 
322  if( ClipLine( &clipbox, x1, y1, x2, y2 ) )
323  return;
324  }
325 
326 
327  if( width <= 2 ) /* single line or 2 pixels */
328  {
329  GRSetColorPen( DC, Color, width );
330  DC->DrawLine( x1, y1, x2, y2 );
331  return;
332  }
333 
334  GRSetBrush( DC, Color, NOT_FILLED );
335  GRSetColorPen( DC, Color, aPenSize );
336 
337  int radius = (width + 1) >> 1;
338  int dx = x2 - x1;
339  int dy = y2 - y1;
340  double angle = -ArcTangente( dy, dx );
341  wxPoint start;
342  wxPoint end;
343  wxPoint org( x1, y1);
344  int len = (int) hypot( dx, dy );
345 
346  // We know if the DC is mirrored, to draw arcs
347  int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
348  int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
349  bool mirrored = (slx > 0 && sly < 0) || (slx < 0 && sly > 0);
350 
351  // first edge
352  start.x = 0;
353  start.y = radius;
354  end.x = len;
355  end.y = radius;
356  RotatePoint( &start, angle);
357  RotatePoint( &end, angle);
358 
359  start += org;
360  end += org;
361 
362  DC->DrawLine( start, end );
363 
364  // first rounded end
365  end.x = 0;
366  end.y = -radius;
367  RotatePoint( &end, angle);
368  end += org;
369 
370  if( !mirrored )
371  DC->DrawArc( end, start, org );
372  else
373  DC->DrawArc( start, end, org );
374 
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:206
static int GRLastMoveToX
Definition: gr_basic.cpp:86
static const bool NOT_FILLED
Definition: gr_basic.cpp:41
static int GRLastMoveToY
Definition: gr_basic.cpp:86
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:160
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:169
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 DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:132
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44

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

Referenced by D_CODE::DrawFlashedShape(), BASIC_GAL::DrawLine(), BASIC_GAL::DrawPolyline(), GRCSegm(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), PCB_TARGET::Print(), EDGE_MODULE::Print(), TRACK::Print(), DIMENSION::Print(), DRAWSEGMENT::Print(), GERBER_DRAW_ITEM::Print(), ZONE_CONTAINER::PrintFilledArea(), and D_PAD::PrintShape().

◆ 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:311

References GRCSegm().

◆ GRDrawAnchor()

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

Definition at line 1004 of file gr_basic.cpp.

1006 {
1007  int anchor_size = aDC->DeviceToLogicalXRel( aSize );
1008 
1009  GRLine( aClipBox, aDC,
1010  x - anchor_size, y,
1011  x + anchor_size, y, 0, aColor );
1012  GRLine( aClipBox, aDC,
1013  x, y - anchor_size,
1014  x, y + anchor_size, 0, aColor );
1015 }
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:229

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

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

◆ 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:99
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:132

References GRSetColorPen(), and WinClipAndDrawLine().

Referenced by D_CODE::DrawFlashedShape(), TRACK::Print(), DRAWSEGMENT::Print(), and D_PAD::PrintShape().

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

740 {
741  GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
742 }
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:688

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

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

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

620 {
621  if( clipCircle( ClipBox, x, y, r, width ) || r <= 0 )
622  return;
623 
624  GRSetBrush( DC, BgColor, FILLED );
625  GRSetColorPen( DC, Color, width );
626  DC->DrawEllipse( x - r, y - r, r + r, r + r );
627 }
static const bool FILLED
Definition: gr_basic.cpp:40
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:565
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:169
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:132

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

Referenced by D_CODE::DrawFlashedShape(), GRFilledCircle(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), LIB_CIRCLE::print(), SCH_JUNCTION::Print(), VIA::Print(), and D_PAD::PrintShape().

◆ GRFilledCircle() [2/2]

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

Definition at line 630 of file gr_basic.cpp.

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

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

885 {
886  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
887 }
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:918

References GRSFilledRect().

Referenced by D_CODE::DrawFlashedShape(), LIB_RECTANGLE::print(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

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

895 {
896  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
897 }
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:918

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:99
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:132

References GRSetColorPen(), and WinClipAndDrawLine().

Referenced by DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), EDGE_MODULE::Print(), DRAWSEGMENT::Print(), GERBER_DRAW_ITEM::Print(), ZONE_CONTAINER::PrintFilledArea(), and D_PAD::PrintShape().

◆ GRForceBlackPen()

void GRForceBlackPen ( bool  flagforce)

Function GRForceBlackPen.

Parameters
flagforceTrue to force a black pen whenever the asked color

Definition at line 200 of file gr_basic.cpp.

201 {
202  s_ForceBlackPen = flagforce;
203 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:87

References s_ForceBlackPen.

Referenced by SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), VIA::Print(), PLEDITOR_PRINTOUT::PrintPage(), SCH_PRINTOUT::PrintPage(), and D_PAD::PrintShape().

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

247 {
248  GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
249 }
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:229

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

238 {
239  GRSetColorPen( DC, Color, width, aStyle );
240  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
241  GRLastMoveToX = x2;
242  GRLastMoveToY = y2;
243 }
static int GRLastMoveToX
Definition: gr_basic.cpp:86
static int GRLastMoveToY
Definition: gr_basic.cpp:86
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:99
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:132

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

Referenced by BASIC_GAL::DrawLine(), GRDrawAnchor(), GRLine(), GRLineTo(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), SCH_NO_CONNECT::Print(), PCB_TARGET::Print(), SCH_BUS_ENTRY_BASE::Print(), EDGE_MODULE::Print(), SCH_LINE::Print(), TRACK::Print(), DIMENSION::Print(), VIA::Print(), LIB_PIN::PrintPinSymbol(), D_PAD::PrintShape(), and WS_DRAW_ITEM_LINE::PrintWsItem().

◆ GRLineArray()

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

Function GRLineArray draws an array of lines (not a polygon).

Parameters
aClipBox= the clip box
aDC= the device context into which drawing should occur.
aLines= a list of pair of coordinate in user space: a pair for each line.
aWidth= the width of each line.
aColor= the color of the lines
See also
COLOR4D
Parameters
aClipBox= the clip box
aDC= the device context into which drawing should occur.
aLines= a list of pair of coordinate in user space: a pair for each line.
aWidth= the width of each line.
aColor= color to draw the lines
See also
COLOR4D

Definition at line 283 of file gr_basic.cpp.

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

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

Referenced by ZONE_CONTAINER::Print().

◆ GRLineTo()

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

Definition at line 265 of file gr_basic.cpp.

266 {
267  GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
268 }
static int GRLastMoveToX
Definition: gr_basic.cpp:86
static int GRLastMoveToY
Definition: gr_basic.cpp:86
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:229

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

◆ GRMoveTo()

void GRMoveTo ( int  x,
int  y 
)

Definition at line 255 of file gr_basic.cpp.

256 {
257  GRLastMoveToX = x;
258  GRLastMoveToY = y;
259 }
static int GRLastMoveToX
Definition: gr_basic.cpp:86
static int GRLastMoveToY
Definition: gr_basic.cpp:86

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

543 {
544  GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
545 }
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::DrawPolyline(), GRBezier(), LIB_POLYLINE::print(), LIB_BEZIER::print(), EDGE_MODULE::Print(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), ZONE_CONTAINER::PrintFilledArea(), and WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem().

◆ GRPutPixel()

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

Definition at line 216 of file gr_basic.cpp.

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

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

844 {
845  GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor );
846 }
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:904

References GRSRect().

Referenced by D_CODE::DrawFlashedShape(), LIB_RECTANGLE::print(), SCH_SHEET::Print(), and WS_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 869 of file gr_basic.cpp.

870 {
871  int x1 = aRect.GetX();
872  int y1 = aRect.GetY();
873  int x2 = aRect.GetRight();
874  int y2 = aRect.GetBottom();
875 
876  GRSRect( aClipBox, aDC, x1, y1, x2, y2, aWidth, aColor );
877 }
int GetX() const
Definition: eda_rect.h:111
int GetBottom() const
Definition: eda_rect.h:124
int GetRight() const
Definition: eda_rect.h:121
int GetY() const
Definition: eda_rect.h:112
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:904

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

864 {
865  GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
866 }
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:904

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 = NULL;
125 }
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:97
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:169
Definition: colors.h:45

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_LIB_EDIT_PIN::OnPaintShowPanel(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), PLEDITOR_PRINTOUT::PrintPage(), SCH_PRINTOUT::PrintPage(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

◆ GRSetBrush()

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

Definition at line 169 of file gr_basic.cpp.

170 {
171  if( s_ForceBlackPen )
172  Color = COLOR4D::BLACK;
173 
174  if( s_DC_lastbrushcolor != Color
175  || s_DC_lastbrushfill != fill
176  || s_DC_lastDC != DC )
177  {
178  wxBrush brush;
179 
180  brush.SetColour( Color.ToColour() );
181 
182  if( fill )
183  brush.SetStyle( wxBRUSHSTYLE_SOLID );
184  else
185  brush.SetStyle( wxBRUSHSTYLE_TRANSPARENT );
186 
187  DC->SetBrush( brush );
188 
189  s_DC_lastbrushcolor = Color;
190  s_DC_lastbrushfill = fill;
191  s_DC_lastDC = DC;
192  }
193 }
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:97
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
Definition: colors.h:45
static bool s_DC_lastbrushfill
Definition: gr_basic.cpp:96
static bool s_ForceBlackPen
Definition: gr_basic.cpp:87

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 
)

Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.

Definition at line 132 of file gr_basic.cpp.

133 {
134  wxDash dots[2] = { 1, 3 };
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  if( style == wxPENSTYLE_DOT )
152  {
153  style = wxPENSTYLE_USER_DASH;
154  pen.SetDashes( 2, dots );
155  }
156  pen.SetWidth( width );
157  pen.SetStyle( style );
158  DC->SetPen( pen );
159  }
160  else
161  // Should be not needed, but on Linux, in printing process
162  // the curr pen settings needs to be sometimes re-initialized
163  // Clearly, this is due to a bug, related to SetBrush(),
164  // but we have to live with it, at least on wxWidgets 3.0
165  DC->SetPen( curr_pen );
166 }
Definition: colors.h:45
static bool s_ForceBlackPen
Definition: gr_basic.cpp:87

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

920 {
921  wxPoint points[5];
922  points[0] = wxPoint(x1, y1);
923  points[1] = wxPoint(x1, y2);
924  points[2] = wxPoint(x2, y2);
925  points[3] = wxPoint(x2, y1);
926  points[4] = points[0];
927 
928  GRSetBrush( aDC, aBgColor, FILLED );
929  GRSetColorPen( aDC, aBgColor, aWidth );
930 
931  if( aClipBox && (aWidth > 0) )
932  {
933  EDA_RECT clipbox(*aClipBox);
934  clipbox.Inflate(aWidth);
935  ClipAndDrawPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
936  }
937  else
938  ClipAndDrawPoly(aClipBox, aDC, points, 5 );
939 }
static const bool FILLED
Definition: gr_basic.cpp:40
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:169
static void ClipAndDrawPoly(EDA_RECT *ClipBox, wxDC *DC, const wxPoint *Points, int n)
Function ClipAndDrawPoly Used to clip a polygon and draw it as Filled Polygon uses the Sutherland and...
Definition: gr_basic.cpp:956
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:132
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44

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

70 {
71  return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
72 }

◆ operator ~()

GR_DRAWMODE operator ~ ( const GR_DRAWMODE a)
inline

Definition at line 59 of file gr_basic.h.

60 {
61  return static_cast<GR_DRAWMODE>( ~int( a ) );
62 }

◆ operator|()

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

Definition at line 64 of file gr_basic.h.

65 {
66  return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
67 }

Variable Documentation

◆ g_XorMode

GR_DRAWMODE g_XorMode

Definition at line 71 of file gr_basic.cpp.