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, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
 
void GRBezier (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int x3, int y3, int width, COLOR4D Color)
 
void GRBezier (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int width, COLOR4D Color)
 
void GRClosedPoly (EDA_RECT *ClipBox, wxDC *aDC, int aPointCount, 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, 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 211 of file gr_basic.cpp.

212 {
213  return s_ForceBlackPen;
214 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:88

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

755 {
756  int x1, y1, x2, y2;
757 
758  /* Clip arcs off screen */
759  if( ClipBox )
760  {
761  int radius = r + 1;
762  int x0, y0, xm, ym, x, y;
763  x0 = ClipBox->GetX();
764  y0 = ClipBox->GetY();
765  xm = ClipBox->GetRight();
766  ym = ClipBox->GetBottom();
767  x = xc;
768  y = yc;
769 
770  if( x < ( x0 - radius ) )
771  return;
772  if( y < ( y0 - radius ) )
773  return;
774  if( x > ( xm + radius ) )
775  return;
776  if( y > ( ym + radius ) )
777  return;
778  }
779 
780  x1 = r;
781  y1 = 0;
782  RotatePoint( &x1, &y1, EndAngle );
783 
784  x2 = r;
785  y2 = 0;
786  RotatePoint( &x2, &y2, StAngle );
787 
788  GRSetBrush( DC, Color, NOT_FILLED );
789  GRSetColorPen( DC, Color );
790  DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
791 }
int GetX() const
Definition: eda_rect.h:109
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
int GetBottom() const
Definition: eda_rect.h:122
static const bool NOT_FILLED
Definition: gr_basic.cpp:41
int GetRight() const
Definition: eda_rect.h:119
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
int GetY() const
Definition: eda_rect.h:110

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

806 {
807  int x1, y1, x2, y2;
808 
809  /* Clip arcs off screen. */
810  if( ClipBox )
811  {
812  int x0, y0, xm, ym;
813  x0 = ClipBox->GetX();
814  y0 = ClipBox->GetY();
815  xm = ClipBox->GetRight();
816  ym = ClipBox->GetBottom();
817 
818  if( x < ( x0 - r - width ) )
819  return;
820 
821  if( y < ( y0 - r - width ) )
822  return;
823 
824  if( x > ( r + xm + width ) )
825  return;
826 
827  if( y > ( r + ym + width ) )
828  return;
829  }
830 
831  x1 = r;
832  y1 = 0;
833  RotatePoint( &x1, &y1, EndAngle );
834 
835  x2 = r;
836  y2 = 0;
837  RotatePoint( &x2, &y2, StAngle );
838 
839  GRSetBrush( DC, Color );
840  GRSetColorPen( DC, Color, width );
841  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
842 }
int GetX() const
Definition: eda_rect.h:109
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
int GetY() const
Definition: eda_rect.h:110

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

646 {
647  GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
648 }
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:644

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

656 {
657  /* Clip arcs off screen. */
658  if( ClipBox )
659  {
660  int x0, y0, xm, ym, r;
661  x0 = ClipBox->GetX();
662  y0 = ClipBox->GetY();
663  xm = ClipBox->GetRight();
664  ym = ClipBox->GetBottom();
665  r = KiROUND( Distance( x1, y1, xc, yc ) );
666  if( xc < ( x0 - r ) )
667  return;
668  if( yc < ( y0 - r ) )
669  return;
670  if( xc > ( r + xm ) )
671  return;
672  if( yc > ( r + ym ) )
673  return;
674  }
675 
676  GRSetBrush( DC, Color );
677  GRSetColorPen( DC, Color, width );
678  DC->DrawArc( x1, y1, x2, y2, xc, yc );
679 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
int GetX() const
Definition: eda_rect.h:109
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
int GetY() const
Definition: eda_rect.h:110
double Distance(double x1, double y1, double x2, double y2)

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

684 {
685  GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
686  aWidth, aColor );
687 }
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:644

References GRArc1().

◆ GRBezier() [1/2]

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

Definition at line 996 of file gr_basic.cpp.

1006 {
1007  std::vector<wxPoint> points;
1008 
1009  BEZIER_POLY converter( x1, y1, x2, y2, x3, y3 );
1010  converter.GetPoly( points );
1011 
1012  GRPoly( ClipBox, DC, points.size(), &points[0], false, width, Color, Color );
1013 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:546
Bezier curves to polygon converter.
Definition: bezier_curves.h:35

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

◆ GRBezier() [2/2]

void GRBezier ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
int  x4,
int  y4,
int  width,
COLOR4D  Color 
)

Definition at line 1016 of file gr_basic.cpp.

1028 {
1029  std::vector<wxPoint> points;
1030 
1031  BEZIER_POLY converter( x1, y1, x2, y2, x3, y3, x4, y4 );
1032  converter.GetPoly( points );
1033 
1034  GRPoly( ClipBox, DC, points.size(), &points[0], false, width, Color, Color );
1035 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:546
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 611 of file gr_basic.cpp.

612 {
613  GRCircle( ClipBox, DC, x, y, r, 0, Color );
614 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:600

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

601 {
602  if( clipCircle( ClipBox, xc, yc, r, width ) || r <= 0 )
603  return;
604 
605  GRSetBrush( DC, Color, NOT_FILLED );
606  GRSetColorPen( DC, Color, width );
607  DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
608 }
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:570
static const bool NOT_FILLED
Definition: gr_basic.cpp:41
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133

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

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

References GRCircle().

◆ GRClosedPoly() [1/2]

void GRClosedPoly ( EDA_RECT ClipBox,
wxDC *  aDC,
int  aPointCount,
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 556 of file gr_basic.cpp.

558 {
559  GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
560 }
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, 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:556

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

565 {
566  GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
567 }
static void GRSClosedPoly(EDA_RECT *aClipBox, wxDC *aDC, int aPointCount, wxPoint aPoints[], bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:506

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

400 {
401  GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
402 }
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:312

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

314 {
315  GRLastMoveToX = x2;
316  GRLastMoveToY = y2;
317 
318  if( ClipBox )
319  {
320  EDA_RECT clipbox(*ClipBox);
321  clipbox.Inflate(width/2);
322 
323  if( ClipLine( &clipbox, x1, y1, x2, y2 ) )
324  return;
325  }
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 
377  // second edge
378  start.x = len;
379  start.y = -radius;
380  RotatePoint( &start, angle);
381  start += org;
382 
383  DC->DrawLine( start, end );
384 
385  // second rounded end
386  end.x = len;
387  end.y = radius;
388  RotatePoint( &end, angle);
389  end += org;
390 
391  if( !mirrored )
392  DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
393  else
394  DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
395 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
static int GRLastMoveToX
Definition: gr_basic.cpp:87
static const bool NOT_FILLED
Definition: gr_basic.cpp:41
static int GRLastMoveToY
Definition: gr_basic.cpp:87
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
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 405 of file gr_basic.cpp.

407 {
408  GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
409 }
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:312

References GRCSegm().

◆ GRDrawAnchor()

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

Definition at line 1038 of file gr_basic.cpp.

1040 {
1041  int anchor_size = aDC->DeviceToLogicalXRel( aSize );
1042 
1043  GRLine( aClipBox, aDC,
1044  x - anchor_size, y,
1045  x + anchor_size, y, 0, aColor );
1046  GRLine( aClipBox, aDC,
1047  x, y - anchor_size,
1048  x, y + anchor_size, 0, aColor );
1049 }
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:230

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

1053 {
1054  wxStringTokenizer tokenizer( aText, " " );
1055  wxSize const dc_size = aDC.GetSize();
1056  wxSize const margin = aDC.GetTextExtent( " " );
1057  std::vector<wxString> lines;
1058  wxString line_accumulator;
1059  int total_height = 0;
1060 
1061  while( tokenizer.HasMoreTokens() )
1062  {
1063  wxString word = tokenizer.GetNextToken();
1064  wxSize linesize = aDC.GetTextExtent( line_accumulator + " " + word );
1065 
1066  if( linesize.x >= dc_size.x - margin.x && !line_accumulator.IsEmpty() )
1067  {
1068  lines.push_back( line_accumulator );
1069  line_accumulator = word;
1070  }
1071  else
1072  {
1073  line_accumulator += " ";
1074  line_accumulator += word;
1075  }
1076  }
1077 
1078  if( !line_accumulator.IsEmpty() )
1079  {
1080  lines.push_back( line_accumulator );
1081  }
1082 
1083  for( auto const& line: lines )
1084  {
1085  wxSize linesize = aDC.GetTextExtent( line );
1086  total_height += linesize.y;
1087  }
1088 
1089  int top = ( dc_size.y - total_height ) / 2;
1090  int pos = top;
1091 
1092  for( auto const& line: lines )
1093  {
1094  wxSize linesize = aDC.GetTextExtent( line );
1095  aDC.DrawText( line, ( dc_size.x - linesize.x ) / 2, pos );
1096  pos += linesize.y;
1097  }
1098 }

◆ GRFillCSegm()

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

Definition at line 415 of file gr_basic.cpp.

417 {
418  GRSetColorPen( DC, Color, width );
419  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
420 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:100
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:133

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

745 {
746  GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
747 }
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:693

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

703 {
704  int x1, y1, x2, y2;
705 
706  /* Clip arcs off screen */
707  if( ClipBox )
708  {
709  int x0, y0, xm, ym;
710  x0 = ClipBox->GetX();
711  y0 = ClipBox->GetY();
712  xm = ClipBox->GetRight();
713  ym = ClipBox->GetBottom();
714 
715  if( x < ( x0 - r - 1 ) )
716  return;
717 
718  if( y < ( y0 - r - 1 ) )
719  return;
720 
721  if( x > ( r + xm + 1 ) )
722  return;
723 
724  if( y > ( r + ym + 1 ) )
725  return;
726  }
727 
728  x1 = r;
729  y1 = 0;
730  RotatePoint( &x1, &y1, EndAngle );
731 
732  x2 = r;
733  y2 = 0;
734  RotatePoint( &x2, &y2, StAngle );
735 
736  GRSetBrush( DC, BgColor, FILLED );
737  GRSetColorPen( DC, Color, width );
738  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
739 }
static const bool FILLED
Definition: gr_basic.cpp:40
int GetX() const
Definition: eda_rect.h:109
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
int GetY() const
Definition: eda_rect.h:110

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

625 {
626  if( clipCircle( ClipBox, x, y, r, width ) || r <= 0 )
627  return;
628 
629  GRSetBrush( DC, BgColor, FILLED );
630  GRSetColorPen( DC, Color, width );
631  DC->DrawEllipse( x - r, y - r, r + r, r + r );
632 }
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:570
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133

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

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

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

890 {
891  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
892 }
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(), 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 898 of file gr_basic.cpp.

900 {
901  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
902 }
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 423 of file gr_basic.cpp.

425 {
426  GRSetColorPen( aDC, aColor, aWidth );
427  WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
428 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:100
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:133

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

202 {
203  s_ForceBlackPen = flagforce;
204 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:88

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

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

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

239 {
240  GRSetColorPen( DC, Color, width, aStyle );
241  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
242  GRLastMoveToX = x2;
243  GRLastMoveToY = y2;
244 }
static int GRLastMoveToX
Definition: gr_basic.cpp:87
static int GRLastMoveToY
Definition: gr_basic.cpp:87
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:100
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:133

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 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 == NULL ) || !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:256
size_t i
Definition: json11.cpp:597
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:133
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 266 of file gr_basic.cpp.

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

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

◆ GRMoveTo()

void GRMoveTo ( int  x,
int  y 
)

Definition at line 256 of file gr_basic.cpp.

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

References GRLastMoveToX, and GRLastMoveToY.

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

◆ GRPoly()

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

Definition at line 546 of file gr_basic.cpp.

548 {
549  GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
550 }
static void GRSPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:473

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

218 {
219  if( ClipBox && !ClipBox->Contains( x, y ) )
220  return;
221 
222  GRSetColorPen( DC, Color );
223  DC->DrawPoint( x, y );
224 }
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:133

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

849 {
850  GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor );
851 }
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:909

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

875 {
876  int x1 = aRect.GetX();
877  int y1 = aRect.GetY();
878  int x2 = aRect.GetRight();
879  int y2 = aRect.GetBottom();
880 
881  GRSRect( aClipBox, aDC, x1, y1, x2, y2, aWidth, aColor );
882 }
int GetX() const
Definition: eda_rect.h:109
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
int GetY() const
Definition: eda_rect.h:110
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:909

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

869 {
870  GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
871 }
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:909

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

121 {
122  GRSetBrush( DC, BLACK ); // Force no fill
123  s_DC_lastbrushcolor = COLOR4D::UNSPECIFIED;
124  s_DC_lastcolor = COLOR4D::UNSPECIFIED;
125  s_DC_lastDC = NULL;
126 }
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:98
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:170
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 170 of file gr_basic.cpp.

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

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

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

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  ClipAndDrawPoly(aClipBox, aDC, points, 5 );
944 }
static void ClipAndDrawPoly(EDA_RECT *ClipBox, wxDC *DC, 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:961
static const bool FILLED
Definition: gr_basic.cpp:40
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
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.