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

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 GRSetDrawMode (wxDC *DC, GR_DRAWMODE mode)
 
GR_DRAWMODE GRGetDrawMode (wxDC *DC)
 
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 GRMixedLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRDashedLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRDottedLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
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

#define GR_M_DCLICK   0x80000000

Definition at line 77 of file gr_basic.h.

Referenced by SCH_DRAW_PANEL::OnMouseEvent(), and EDA_DRAW_PANEL::OnMouseEvent().

#define GR_M_LEFT_DOWN   0x10000000

Definition at line 74 of file gr_basic.h.

Referenced by SCH_DRAW_PANEL::OnMouseEvent(), and EDA_DRAW_PANEL::OnMouseEvent().

#define GR_M_MIDDLE_DOWN   0x40000000

Definition at line 76 of file gr_basic.h.

Referenced by SCH_DRAW_PANEL::OnMouseEvent(), and EDA_DRAW_PANEL::OnMouseEvent().

#define GR_M_RIGHT_DOWN   0x20000000

Definition at line 75 of file gr_basic.h.

Enumeration Type Documentation

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

void DrawModeAddHighlight ( GR_DRAWMODE mode)
inline

Definition at line 49 of file gr_basic.h.

References GR_HIGHLIGHT.

Referenced by GBR_LAYOUT::Draw().

50 {
51  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_HIGHLIGHT );
52 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
void DrawModeAllowHighContrast ( GR_DRAWMODE mode)
inline

Definition at line 54 of file gr_basic.h.

References GR_ALLOW_HIGHCONTRAST.

55 {
56  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_ALLOW_HIGHCONTRAST );
57 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
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 214 of file gr_basic.cpp.

References s_ForceBlackPen.

Referenced by VIA::Draw(), LIB_PART::Draw(), and D_PAD::DrawShape().

215 {
216  return s_ForceBlackPen;
217 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:91
void GRArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
COLOR4D  Color 
)

Definition at line 908 of file gr_basic.cpp.

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

Referenced by EDGE_MODULE::Draw(), DRAWSEGMENT::Draw(), and LIB_ARC::drawGraphic().

910 {
911  int x1, y1, x2, y2;
912 
913  /* Clip arcs off screen */
914  if( ClipBox )
915  {
916  int radius = r + 1;
917  int x0, y0, xm, ym, x, y;
918  x0 = ClipBox->GetX();
919  y0 = ClipBox->GetY();
920  xm = ClipBox->GetRight();
921  ym = ClipBox->GetBottom();
922  x = xc;
923  y = yc;
924 
925  if( x < ( x0 - radius ) )
926  return;
927  if( y < ( y0 - radius ) )
928  return;
929  if( x > ( xm + radius ) )
930  return;
931  if( y > ( ym + radius ) )
932  return;
933  }
934 
935  x1 = r;
936  y1 = 0;
937  RotatePoint( &x1, &y1, EndAngle );
938 
939  x2 = r;
940  y2 = 0;
941  RotatePoint( &x2, &y2, StAngle );
942 
943  GRSetBrush( DC, Color, NOT_FILLED );
944  GRSetColorPen( DC, Color );
945  DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
946 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
static const bool NOT_FILLED
Definition: gr_basic.cpp:44
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:173
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:136
int GetX() const
Definition: eda_rect.h:109
int GetY() const
Definition: eda_rect.h:110
void GRArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
int  width,
COLOR4D  Color 
)

Definition at line 952 of file gr_basic.cpp.

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

961 {
962  int x1, y1, x2, y2;
963 
964  /* Clip arcs off screen. */
965  if( ClipBox )
966  {
967  int x0, y0, xm, ym;
968  x0 = ClipBox->GetX();
969  y0 = ClipBox->GetY();
970  xm = ClipBox->GetRight();
971  ym = ClipBox->GetBottom();
972 
973  if( x < ( x0 - r - width ) )
974  return;
975 
976  if( y < ( y0 - r - width ) )
977  return;
978 
979  if( x > ( r + xm + width ) )
980  return;
981 
982  if( y > ( r + ym + width ) )
983  return;
984  }
985 
986  x1 = r;
987  y1 = 0;
988  RotatePoint( &x1, &y1, EndAngle );
989 
990  x2 = r;
991  y2 = 0;
992  RotatePoint( &x2, &y2, StAngle );
993 
994  GRSetBrush( DC, Color );
995  GRSetColorPen( DC, Color, width );
996  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
997 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
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:173
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:136
int GetX() const
Definition: eda_rect.h:109
int GetY() const
Definition: eda_rect.h:110
void GRArc1 ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  xc,
int  yc,
COLOR4D  Color 
)

Definition at line 799 of file gr_basic.cpp.

References GRArc1().

Referenced by GERBER_DRAW_ITEM::Draw(), LIB_ARC::drawGraphic(), GRArc1(), and DIALOG_PAD_PROPERTIES::OnPaintShowPanel().

801 {
802  GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
803 }
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:799
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 809 of file gr_basic.cpp.

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

811 {
812  /* Clip arcs off screen. */
813  if( ClipBox )
814  {
815  int x0, y0, xm, ym, r;
816  x0 = ClipBox->GetX();
817  y0 = ClipBox->GetY();
818  xm = ClipBox->GetRight();
819  ym = ClipBox->GetBottom();
820  r = KiROUND( Distance( x1, y1, xc, yc ) );
821  if( xc < ( x0 - r ) )
822  return;
823  if( yc < ( y0 - r ) )
824  return;
825  if( xc > ( r + xm ) )
826  return;
827  if( yc > ( r + ym ) )
828  return;
829  }
830 
831  GRSetBrush( DC, Color );
832  GRSetColorPen( DC, Color, width );
833  DC->DrawArc( x1, y1, x2, y2, xc, yc );
834 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
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:173
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:136
int GetX() const
Definition: eda_rect.h:109
int GetY() const
Definition: eda_rect.h:110
double Distance(double x1, double y1, double x2, double y2)
void GRArc1 ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
wxPoint  aCenter,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 837 of file gr_basic.cpp.

References GRArc1(), wxPoint::x, and wxPoint::y.

839 {
840  GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
841  aWidth, aColor );
842 }
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:799
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 1151 of file gr_basic.cpp.

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

1161 {
1162  std::vector<wxPoint> points;
1163 
1164  BEZIER_POLY converter( x1, y1, x2, y2, x3, y3 );
1165  converter.GetPoly( points );
1166 
1167  GRPoly( ClipBox, DC, points.size(), &points[0], false, width, Color, Color );
1168 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:701
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
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 1171 of file gr_basic.cpp.

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

1183 {
1184  std::vector<wxPoint> points;
1185 
1186  BEZIER_POLY converter( x1, y1, x2, y2, x3, y3, x4, y4 );
1187  converter.GetPoly( points );
1188 
1189  GRPoly( ClipBox, DC, points.size(), &points[0], false, width, Color, Color );
1190 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:701
Bezier curves to polygon converter.
Definition: bezier_curves.h:35
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 766 of file gr_basic.cpp.

References GRCircle().

767 {
768  GRCircle( ClipBox, DC, x, y, r, 0, Color );
769 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:755
void GRCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  r,
int  width,
COLOR4D  Color 
)

Definition at line 755 of file gr_basic.cpp.

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

Referenced by PCB_TARGET::Draw(), SCH_BUS_ENTRY_BASE::Draw(), EDGE_MODULE::Draw(), DRAWSEGMENT::Draw(), GERBER_DRAW_ITEM::Draw(), VIA::Draw(), D_CODE::DrawFlashedShape(), LIB_CIRCLE::drawGraphic(), LIB_PIN::DrawPinSymbol(), D_PAD::DrawShape(), DrawViaCirclesWhenEditingNewTrack(), GRCircle(), and DIALOG_PAD_PROPERTIES::OnPaintShowPanel().

756 {
757  if( clipCircle( ClipBox, xc, yc, r, width ) || r <= 0 )
758  return;
759 
760  GRSetBrush( DC, Color, NOT_FILLED );
761  GRSetColorPen( DC, Color, width );
762  DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
763 }
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:725
static const bool NOT_FILLED
Definition: gr_basic.cpp:44
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
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:136
void GRCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aPos,
int  aRadius,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 772 of file gr_basic.cpp.

References GRCircle(), wxPoint::x, and wxPoint::y.

773 {
774  GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
775 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:755
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 711 of file gr_basic.cpp.

References GRClosedPoly().

Referenced by DRAWSEGMENT::Draw(), APERTURE_MACRO::DrawApertureMacroShape(), D_CODE::DrawFlashedPolygon(), GERBER_DRAW_ITEM::DrawGbrPoly(), D_PAD::DrawShape(), GRClosedPoly(), and DIALOG_PAD_PROPERTIES::OnPaintShowPanel().

713 {
714  GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
715 }
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:711
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 718 of file gr_basic.cpp.

References GRSClosedPoly().

720 {
721  GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
722 }
static void GRSClosedPoly(EDA_RECT *aClipBox, wxDC *aDC, int aPointCount, wxPoint aPoints[], bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:634
void GRCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 501 of file gr_basic.cpp.

References GRCSegm().

503 {
504  GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
505 }
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:415
void GRCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
int  aPenSize,
COLOR4D  Color 
)

Definition at line 415 of file gr_basic.cpp.

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

Referenced by PCB_TARGET::Draw(), EDGE_MODULE::Draw(), TRACK::Draw(), DIMENSION::Draw(), DRAWSEGMENT::Draw(), GERBER_DRAW_ITEM::Draw(), SEGZONE::Draw(), ZONE_CONTAINER::DrawFilledArea(), D_CODE::DrawFlashedShape(), BASIC_GAL::DrawLine(), BASIC_GAL::DrawPolyline(), D_PAD::DrawShape(), GRCSegm(), and DIALOG_PAD_PROPERTIES::OnPaintShowPanel().

417 {
418  GRLastMoveToX = x2;
419  GRLastMoveToY = y2;
420 
421  if( ClipBox )
422  {
423  EDA_RECT clipbox(*ClipBox);
424  clipbox.Inflate(width/2);
425 
426  if( ClipLine( &clipbox, x1, y1, x2, y2 ) )
427  return;
428  }
429 
430 
431  if( width <= 2 ) /* single line or 2 pixels */
432  {
433  GRSetColorPen( DC, Color, width );
434  DC->DrawLine( x1, y1, x2, y2 );
435  return;
436  }
437 
438  GRSetBrush( DC, Color, NOT_FILLED );
439  GRSetColorPen( DC, Color, aPenSize );
440 
441  int radius = (width + 1) >> 1;
442  int dx = x2 - x1;
443  int dy = y2 - y1;
444  double angle = -ArcTangente( dy, dx );
445  wxPoint start;
446  wxPoint end;
447  wxPoint org( x1, y1);
448  int len = (int) hypot( dx, dy );
449 
450  // We know if the DC is mirrored, to draw arcs
451  int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
452  int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
453  bool mirrored = (slx > 0 && sly < 0) || (slx < 0 && sly > 0);
454 
455  // first edge
456  start.x = 0;
457  start.y = radius;
458  end.x = len;
459  end.y = radius;
460  RotatePoint( &start, angle);
461  RotatePoint( &end, angle);
462 
463  start += org;
464  end += org;
465 
466  DC->DrawLine( start, end );
467 
468  // first rounded end
469  end.x = 0;
470  end.y = -radius;
471  RotatePoint( &end, angle);
472  end += org;
473 
474  if( !mirrored )
475  DC->DrawArc( end, start, org );
476  else
477  DC->DrawArc( start, end, org );
478 
479 
480  // second edge
481  start.x = len;
482  start.y = -radius;
483  RotatePoint( &start, angle);
484  start += org;
485 
486  DC->DrawLine( start, end );
487 
488  // second rounded end
489  end.x = len;
490  end.y = radius;
491  RotatePoint( &end, angle);
492  end += org;
493 
494  if( !mirrored )
495  DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
496  else
497  DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
498 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
static int GRLastMoveToX
Definition: gr_basic.cpp:90
static const bool NOT_FILLED
Definition: gr_basic.cpp:44
static int GRLastMoveToY
Definition: gr_basic.cpp:90
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:170
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
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:136
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void GRCSegm ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 508 of file gr_basic.cpp.

References GRCSegm(), wxPoint::x, and wxPoint::y.

510 {
511  GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
512 }
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:415
void GRDashedLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 308 of file gr_basic.cpp.

References GRLine().

Referenced by LIB_ARC::drawEditGraphics().

311 {
312  GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_SHORT_DASH );
313 }
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:285
void GRDottedLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 316 of file gr_basic.cpp.

References GRLine().

319 {
320  GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_DOT );
321 }
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:285
void GRDrawAnchor ( EDA_RECT aClipBox,
wxDC *  aDC,
int  x,
int  y,
int  aSize,
COLOR4D  aColor 
)

Definition at line 1193 of file gr_basic.cpp.

References GRLine().

Referenced by TEXTE_MODULE::Draw(), EDA_TEXT::Draw(), and MODULE::DrawAncre().

1195 {
1196  int anchor_size = aDC->DeviceToLogicalXRel( aSize );
1197 
1198  GRLine( aClipBox, aDC,
1199  x - anchor_size, y,
1200  x + anchor_size, y, 0, aColor );
1201  GRLine( aClipBox, aDC,
1202  x, y - anchor_size,
1203  x, y + anchor_size, 0, aColor );
1204 }
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:285
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 1207 of file gr_basic.cpp.

1208 {
1209  wxStringTokenizer tokenizer( aText, " " );
1210  wxSize const dc_size = aDC.GetSize();
1211  wxSize const margin = aDC.GetTextExtent( " " );
1212  std::vector<wxString> lines;
1213  wxString line_accumulator;
1214  int total_height = 0;
1215 
1216  while( tokenizer.HasMoreTokens() )
1217  {
1218  wxString word = tokenizer.GetNextToken();
1219  wxSize linesize = aDC.GetTextExtent( line_accumulator + " " + word );
1220 
1221  if( linesize.x >= dc_size.x - margin.x && !line_accumulator.IsEmpty() )
1222  {
1223  lines.push_back( line_accumulator );
1224  line_accumulator = word;
1225  }
1226  else
1227  {
1228  line_accumulator += " ";
1229  line_accumulator += word;
1230  }
1231  }
1232 
1233  if( !line_accumulator.IsEmpty() )
1234  {
1235  lines.push_back( line_accumulator );
1236  }
1237 
1238  for( auto const& line: lines )
1239  {
1240  wxSize linesize = aDC.GetTextExtent( line );
1241  total_height += linesize.y;
1242  }
1243 
1244  int top = ( dc_size.y - total_height ) / 2;
1245  int pos = top;
1246 
1247  for( auto const& line: lines )
1248  {
1249  wxSize linesize = aDC.GetTextExtent( line );
1250  aDC.DrawText( line, ( dc_size.x - linesize.x ) / 2, pos );
1251  pos += linesize.y;
1252  }
1253 }
void GRFillCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 518 of file gr_basic.cpp.

References GRSetColorPen(), and WinClipAndDrawLine().

Referenced by TRACK::Draw(), DRAWSEGMENT::Draw(), SEGZONE::Draw(), ZONE_CONTAINER::DrawFilledArea(), D_CODE::DrawFlashedShape(), and D_PAD::DrawShape().

520 {
521  GRSetColorPen( DC, Color, width );
522  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
523 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:103
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:136
void GRFilledArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 897 of file gr_basic.cpp.

References GRFilledArc().

900 {
901  GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
902 }
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:848
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 848 of file gr_basic.cpp.

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

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

858 {
859  int x1, y1, x2, y2;
860 
861  /* Clip arcs off screen */
862  if( ClipBox )
863  {
864  int x0, y0, xm, ym;
865  x0 = ClipBox->GetX();
866  y0 = ClipBox->GetY();
867  xm = ClipBox->GetRight();
868  ym = ClipBox->GetBottom();
869 
870  if( x < ( x0 - r - 1 ) )
871  return;
872 
873  if( y < ( y0 - r - 1 ) )
874  return;
875 
876  if( x > ( r + xm + 1 ) )
877  return;
878 
879  if( y > ( r + ym + 1 ) )
880  return;
881  }
882 
883  x1 = r;
884  y1 = 0;
885  RotatePoint( &x1, &y1, EndAngle );
886 
887  x2 = r;
888  y2 = 0;
889  RotatePoint( &x2, &y2, StAngle );
890 
891  GRSetBrush( DC, BgColor, FILLED );
892  GRSetColorPen( DC, Color, width );
893  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
894 }
static const bool FILLED
Definition: gr_basic.cpp:43
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
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:173
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:136
int GetX() const
Definition: eda_rect.h:109
int GetY() const
Definition: eda_rect.h:110
void GRFilledCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  r,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 778 of file gr_basic.cpp.

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

Referenced by SCH_JUNCTION::Draw(), VIA::Draw(), SCH_SHEET::Draw(), D_CODE::DrawFlashedShape(), LIB_CIRCLE::drawGraphic(), drawMarker(), D_PAD::DrawShape(), GRFilledCircle(), and DIALOG_PAD_PROPERTIES::OnPaintShowPanel().

780 {
781  if( clipCircle( ClipBox, x, y, r, width ) || r <= 0 )
782  return;
783 
784  GRSetBrush( DC, BgColor, FILLED );
785  GRSetColorPen( DC, Color, width );
786  DC->DrawEllipse( x - r, y - r, r + r, r + r );
787 }
static const bool FILLED
Definition: gr_basic.cpp:43
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:725
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
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:136
void GRFilledCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aPos,
int  aRadius,
COLOR4D  aColor 
)

Definition at line 790 of file gr_basic.cpp.

References GRFilledCircle(), wxPoint::x, and wxPoint::y.

791 {
792  GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor );
793 }
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:778
void GRFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 1043 of file gr_basic.cpp.

References GRSFilledRect().

Referenced by GBR_LAYOUT::Draw(), D_CODE::DrawFlashedShape(), LIB_RECTANGLE::drawGraphic(), and drawMarker().

1045 {
1046  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
1047 }
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:1078
void GRFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 1053 of file gr_basic.cpp.

References GRSFilledRect().

1055 {
1056  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
1057 }
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:1078
void GRFilledSegment ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 526 of file gr_basic.cpp.

References GRSetColorPen(), WinClipAndDrawLine(), wxPoint::x, and wxPoint::y.

Referenced by EDGE_MODULE::Draw(), DRAWSEGMENT::Draw(), GERBER_DRAW_ITEM::Draw(), D_PAD::DrawShape(), and DIALOG_PAD_PROPERTIES::OnPaintShowPanel().

528 {
529  GRSetColorPen( aDC, aColor, aWidth );
530  WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
531 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:103
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:136
void GRForceBlackPen ( bool  flagforce)

Function GRForceBlackPen.

Parameters
flagforceTrue to force a black pen whenever the asked color

Definition at line 204 of file gr_basic.cpp.

References s_ForceBlackPen.

Referenced by VIA::Draw(), PLEDITOR_PRINTOUT::DrawPage(), SCH_PRINTOUT::DrawPage(), DrawPageOnClipboard(), and D_PAD::DrawShape().

205 {
206  s_ForceBlackPen = flagforce;
207 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:91
COLOR4D GRGetColor ( )
GR_DRAWMODE GRGetDrawMode ( wxDC *  DC)
void GRLine ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor,
wxPenStyle  aStyle = wxPENSTYLE_SOLID 
)

Definition at line 302 of file gr_basic.cpp.

References GRLine(), wxPoint::x, and wxPoint::y.

303 {
304  GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
305 }
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:285
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 285 of file gr_basic.cpp.

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

Referenced by Autoroute_One_Track(), SCH_NO_CONNECT::Draw(), PCB_TARGET::Draw(), SCH_BUS_ENTRY_BASE::Draw(), SCH_LINE::Draw(), EDGE_MODULE::Draw(), BLOCK_SELECTOR::Draw(), SCH_FIELD::Draw(), TRACK::Draw(), DIMENSION::Draw(), GERBER_DRAW_ITEM::Draw(), SEGZONE::Draw(), VIA::Draw(), LIB_PART::Draw(), LIB_ARC::drawEditGraphics(), PCB_BASE_FRAME::DrawGeneralRatsnest(), BASIC_GAL::DrawLine(), LIB_PIN::DrawPinSymbol(), D_PAD::DrawShape(), TEXTE_MODULE::DrawUmbilical(), ZONE_CONTAINER::DrawWhileCreateOutline(), WS_DRAW_ITEM_LINE::DrawWsItem(), EDA_DRAW_PANEL::GetScreen(), GRDashedLine(), GRDottedLine(), GRDrawAnchor(), GRLine(), GRLineTo(), GRMixedLine(), EDA_DRAW_PANEL::OnPaint(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), PCB_BASE_FRAME::TraceAirWiresToTargets(), and PCB_BASE_FRAME::TraceModuleRatsNest().

294 {
295  GRSetColorPen( DC, Color, width, aStyle );
296  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
297  GRLastMoveToX = x2;
298  GRLastMoveToY = y2;
299 }
static int GRLastMoveToX
Definition: gr_basic.cpp:90
static int GRLastMoveToY
Definition: gr_basic.cpp:90
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:103
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:136
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 361 of file gr_basic.cpp.

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

Referenced by ZONE_CONTAINER::Draw().

363 {
364  if( aLines.empty() )
365  return;
366 
367  GRSetColorPen( aDC, aColor, aWidth );
368 
369  if( aClipBox )
370  aClipBox->Inflate( aWidth / 2 );
371 
372 #if defined( __WXMAC__ ) && defined( USE_WX_GRAPHICS_CONTEXT )
373  wxGCDC *gcdc = wxDynamicCast( aDC, wxGCDC );
374  if( gcdc )
375  {
376  wxGraphicsContext *gc = gcdc->GetGraphicsContext();
377 
378  // create path
379  wxGraphicsPath path = gc->CreatePath();
380  for( unsigned i = 0; i < aLines.size(); i += 2 )
381  {
382  int x1 = aLines[i].x;
383  int y1 = aLines[i].y;
384  int x2 = aLines[i+1].x;
385  int y2 = aLines[i+1].y;
386  if( ( aClipBox == NULL ) || !ClipLine( aClipBox, x1, y1, x2, y2 ) )
387  {
388  path.MoveToPoint( x1, y1 );
389  path.AddLineToPoint( x2, y2 );
390  }
391  }
392  // draw path
393  gc->StrokePath( path );
394  }
395  else
396 #endif
397  {
398  for( unsigned i = 0; i < aLines.size(); i += 2 )
399  {
400  int x1 = aLines[i].x;
401  int y1 = aLines[i].y;
402  int x2 = aLines[i+1].x;
403  int y2 = aLines[i+1].y;
404  if( ( aClipBox == NULL ) || !ClipLine( aClipBox, x1, y1, x2, y2 ) )
405  aDC->DrawLine( x1, y1, x2, y2 );
406  }
407  }
408  GRMoveTo( aLines[aLines.size() - 1].x, aLines[aLines.size() - 1].y );
409 
410  if( aClipBox )
411  aClipBox->Inflate(-aWidth/2);
412 }
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:327
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:136
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
void GRLineTo ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  width,
COLOR4D  Color 
)

Definition at line 337 of file gr_basic.cpp.

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

338 {
339  GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
340 }
static int GRLastMoveToX
Definition: gr_basic.cpp:90
static int GRLastMoveToY
Definition: gr_basic.cpp:90
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:285
void GRMixedLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 343 of file gr_basic.cpp.

References GRLine().

345 {
346  GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_DOT_DASH );
347 }
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:285
void GRMoveTo ( int  x,
int  y 
)

Definition at line 327 of file gr_basic.cpp.

References GRLastMoveToX, and GRLastMoveToY.

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

328 {
329  GRLastMoveToX = x;
330  GRLastMoveToY = y;
331 }
static int GRLastMoveToX
Definition: gr_basic.cpp:90
static int GRLastMoveToY
Definition: gr_basic.cpp:90
void GRPoly ( EDA_RECT ClipBox,
wxDC *  DC,
int  n,
wxPoint  Points[],
bool  Fill,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 701 of file gr_basic.cpp.

References GRSPoly().

Referenced by EDGE_MODULE::Draw(), SCH_GLOBALLABEL::Draw(), SCH_HIERLABEL::Draw(), ZONE_CONTAINER::DrawFilledArea(), LIB_POLYLINE::drawGraphic(), LIB_BEZIER::drawGraphic(), BASIC_GAL::DrawPolyline(), WS_DRAW_ITEM_POLYGON::DrawWsItem(), GRBezier(), and ShowBoundingBoxMicroWaveInductor().

703 {
704  GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
705 }
static void GRSPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:576
void GRPutPixel ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
COLOR4D  color 
)

Definition at line 272 of file gr_basic.cpp.

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

Referenced by DisplayRoutingMatrix().

273 {
274  if( ClipBox && !ClipBox->Contains( x, y ) )
275  return;
276 
277  GRSetColorPen( DC, Color );
278  DC->DrawPoint( x, y );
279 }
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:136
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 
)

Definition at line 1029 of file gr_basic.cpp.

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

1030 {
1031  int x1 = aRect.GetX();
1032  int y1 = aRect.GetY();
1033  int x2 = aRect.GetRight();
1034  int y2 = aRect.GetBottom();
1035 
1036  GRSRect( aClipBox, aDC, x1, y1, x2, y2, aWidth, aColor );
1037 }
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
int GetX() const
Definition: eda_rect.h:109
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:1064
void GRRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 1023 of file gr_basic.cpp.

References GRSRect().

1024 {
1025  GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
1026 }
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:1064
void GRRectPs ( EDA_RECT aClipBox,
wxDC *  aDC,
const EDA_RECT aRect,
int  aWidth,
COLOR4D  aColor,
wxPenStyle  aStyle = wxPENSTYLE_SOLID 
)
void GRResetPenAndBrush ( wxDC *  DC)

Definition at line 123 of file gr_basic.cpp.

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

Referenced by EDA_DRAW_PANEL::DoPrepareDC(), PLEDITOR_PRINTOUT::DrawPage(), SCH_PRINTOUT::DrawPage(), DrawPageOnClipboard(), EDA_DRAW_PANEL::OnPaint(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

124 {
125  GRSetBrush( DC, BLACK ); // Force no fill
126  s_DC_lastbrushcolor = COLOR4D::UNSPECIFIED;
127  s_DC_lastcolor = COLOR4D::UNSPECIFIED;
128  s_DC_lastDC = NULL;
129 }
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:101
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
static COLOR4D s_DC_lastcolor(0, 0, 0, 0)
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
Definition: colors.h:45
void GRSetBrush ( wxDC *  DC,
COLOR4D  Color,
bool  fill = false 
)

Definition at line 173 of file gr_basic.cpp.

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

174 {
175  if( s_ForceBlackPen )
176  Color = COLOR4D::BLACK;
177 
178  if( s_DC_lastbrushcolor != Color
179  || s_DC_lastbrushfill != fill
180  || s_DC_lastDC != DC )
181  {
182  wxBrush brush;
183 
184  brush.SetColour( Color.ToColour() );
185 
186  if( fill )
187  brush.SetStyle( wxBRUSHSTYLE_SOLID );
188  else
189  brush.SetStyle( wxBRUSHSTYLE_TRANSPARENT );
190 
191  DC->SetBrush( brush );
192 
193  s_DC_lastbrushcolor = Color;
194  s_DC_lastbrushfill = fill;
195  s_DC_lastDC = DC;
196  }
197 }
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:101
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
Definition: colors.h:45
static bool s_DC_lastbrushfill
Definition: gr_basic.cpp:100
static bool s_ForceBlackPen
Definition: gr_basic.cpp:91
void GRSetColor ( COLOR4D  Color)
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 136 of file gr_basic.cpp.

References BLACK, and s_ForceBlackPen.

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

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

Definition at line 223 of file gr_basic.cpp.

References GR_COPY, GR_INVERT, GR_NXOR, GR_OR, and GR_XOR.

Referenced by Autoroute_One_Track(), PCB_EDIT_FRAME::Delete_net(), PCB_EDIT_FRAME::Delete_Segment(), DisplayRoutingMatrix(), SCH_NO_CONNECT::Draw(), SCH_JUNCTION::Draw(), PCB_TARGET::Draw(), SCH_BUS_ENTRY_BASE::Draw(), SCH_BITMAP::Draw(), GBR_LAYOUT::Draw(), SCH_LINE::Draw(), EDGE_MODULE::Draw(), ZONE_CONTAINER::Draw(), SCH_TEXT::Draw(), BLOCK_SELECTOR::Draw(), SCH_FIELD::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DIMENSION::Draw(), LIB_ITEM::Draw(), DRAWSEGMENT::Draw(), GERBER_DRAW_ITEM::Draw(), SCH_GLOBALLABEL::Draw(), SCH_HIERLABEL::Draw(), SEGZONE::Draw(), VIA::Draw(), SCH_SHEET::Draw(), LIB_PART::Draw(), MODULE::DrawAncre(), ZONE_CONTAINER::DrawFilledArea(), LIB_CIRCLE::drawGraphic(), LIB_POLYLINE::drawGraphic(), LIB_RECTANGLE::drawGraphic(), LIB_BEZIER::drawGraphic(), LIB_TEXT::drawGraphic(), LIB_ARC::drawGraphic(), LIB_FIELD::drawGraphic(), GBR_LAYOUT::DrawItemsDCodeID(), DrawMovingBlockOutlines(), EDA_TEXT::drawOneLineOfText(), DrawPageLayout(), LIB_PIN::DrawPinElectricalTypeName(), LIB_PIN::DrawPinSymbol(), LIB_PIN::DrawPinTexts(), D_PAD::DrawShape(), TRACK::DrawShortNetname(), TEXTE_MODULE::DrawUmbilical(), ZONE_CONTAINER::DrawWhileCreateOutline(), EDA_DRAW_FRAME::DrawWorkSheet(), WS_DRAW_ITEM_LINE::DrawWsItem(), WS_DRAW_ITEM_POLYGON::DrawWsItem(), WS_DRAW_ITEM_RECT::DrawWsItem(), WS_DRAW_ITEM_BITMAP::DrawWsItem(), PCB_EDIT_FRAME::End_Route(), EDA_DRAW_PANEL::GetScreen(), EDA_DRAW_PANEL::OnPaint(), EDA_DRAW_PANEL::OnScroll(), FOOTPRINT_EDIT_FRAME::RedrawActiveWindow(), PCB_EDIT_FRAME::RedrawActiveWindow(), PCB_EDIT_FRAME::Remove_One_Track(), ShowBoundingBoxMicroWaveInductor(), and PCB_BASE_FRAME::TraceAirWiresToTargets().

224 {
225  if( draw_mode & GR_OR )
226 #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
227 
228  DC->SetLogicalFunction( wxCOPY );
229 #elif defined( USE_WX_GRAPHICS_CONTEXT )
230 
231  DC->SetLogicalFunction( wxCOPY );
232 #else
233 
234  DC->SetLogicalFunction( wxOR );
235 #endif
236  else if( draw_mode & GR_XOR )
237 #if defined( USE_WX_GRAPHICS_CONTEXT )
238 
239  DC->SetLogicalFunction( wxCOPY );
240 #else
241 
242  DC->SetLogicalFunction( wxXOR );
243 #endif
244  else if( draw_mode & GR_NXOR )
245 #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
246 
247  DC->SetLogicalFunction( wxXOR );
248 #elif defined( USE_WX_GRAPHICS_CONTEXT )
249 
250  DC->SetLogicalFunction( wxCOPY );
251 #else
252 
253  DC->SetLogicalFunction( wxEQUIV );
254 #endif
255  else if( draw_mode & GR_INVERT )
256 #if defined( USE_WX_GRAPHICS_CONTEXT )
257 
258  DC->SetLogicalFunction( wxCOPY );
259 #else
260 
261  DC->SetLogicalFunction( wxINVERT );
262 #endif
263  else if( draw_mode & GR_COPY )
264  DC->SetLogicalFunction( wxCOPY );
265 
266 #ifdef USE_WX_OVERLAY
267  DC->SetLogicalFunction( wxCOPY );
268 #endif
269 }
Definition: gr_basic.h:38
void GRSFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 1078 of file gr_basic.cpp.

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

Referenced by GRFilledRect(), and EDA_DRAW_PANEL::OnScroll().

1080 {
1081  wxPoint points[5];
1082  points[0] = wxPoint(x1, y1);
1083  points[1] = wxPoint(x1, y2);
1084  points[2] = wxPoint(x2, y2);
1085  points[3] = wxPoint(x2, y1);
1086  points[4] = points[0];
1087 
1088  GRSetBrush( aDC, aBgColor, FILLED );
1089  GRSetColorPen( aDC, aBgColor, aWidth );
1090 
1091  if( aClipBox && (aWidth > 0) )
1092  {
1093  EDA_RECT clipbox(*aClipBox);
1094  clipbox.Inflate(aWidth);
1095  ClipAndDrawPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
1096  }
1097  else
1098  ClipAndDrawPoly(aClipBox, aDC, points, 5 );
1099 }
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:1116
static const bool FILLED
Definition: gr_basic.cpp:43
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
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:136
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
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 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
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 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
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 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37

Variable Documentation