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)
 

Variables

GR_DRAWMODE g_XorMode
 

Macro Definition Documentation

#define GR_M_DCLICK   0x80000000

Definition at line 81 of file gr_basic.h.

Referenced by EDA_DRAW_PANEL::OnMouseEvent().

#define GR_M_LEFT_DOWN   0x10000000

Definition at line 78 of file gr_basic.h.

Referenced by EDA_DRAW_PANEL::OnMouseEvent().

#define GR_M_MIDDLE_DOWN   0x40000000

Definition at line 80 of file gr_basic.h.

Referenced by EDA_DRAW_PANEL::OnMouseEvent().

#define GR_M_RIGHT_DOWN   0x20000000

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

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

Definition at line 86 of file gr_basic.h.

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

Function Documentation

void DrawModeAddHighlight ( GR_DRAWMODE mode)
inline

Definition at line 53 of file gr_basic.h.

References GR_HIGHLIGHT.

Referenced by GBR_LAYOUT::Draw().

54 {
55  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_HIGHLIGHT );
56 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
void DrawModeAllowHighContrast ( GR_DRAWMODE mode)
inline

Definition at line 58 of file gr_basic.h.

References GR_ALLOW_HIGHCONTRAST.

59 {
60  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_ALLOW_HIGHCONTRAST );
61 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
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 287 of file gr_basic.cpp.

References s_ForceBlackPen.

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

288 {
289  return s_ForceBlackPen;
290 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:68
void GRArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
COLOR4D  Color 
)

Definition at line 981 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().

983 {
984  int x1, y1, x2, y2;
985 
986  /* Clip arcs off screen */
987  if( ClipBox )
988  {
989  int radius = r + 1;
990  int x0, y0, xm, ym, x, y;
991  x0 = ClipBox->GetX();
992  y0 = ClipBox->GetY();
993  xm = ClipBox->GetRight();
994  ym = ClipBox->GetBottom();
995  x = xc;
996  y = yc;
997 
998  if( x < ( x0 - radius ) )
999  return;
1000  if( y < ( y0 - radius ) )
1001  return;
1002  if( x > ( xm + radius ) )
1003  return;
1004  if( y > ( ym + radius ) )
1005  return;
1006  }
1007 
1008  x1 = r;
1009  y1 = 0;
1010  RotatePoint( &x1, &y1, EndAngle );
1011 
1012  x2 = r;
1013  y2 = 0;
1014  RotatePoint( &x2, &y2, StAngle );
1015 
1016  GRSetBrush( DC, Color, NOT_FILLED );
1017  GRSetColorPen( DC, Color );
1018  DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
1019 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
static const bool NOT_FILLED
Definition: gr_basic.cpp:21
int GetBottom() const
int GetRight() const
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:246
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:209
int GetX() const
int GetY() const
void GRArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
int  width,
COLOR4D  Color 
)

Definition at line 1025 of file gr_basic.cpp.

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

1034 {
1035  int x1, y1, x2, y2;
1036 
1037  /* Clip arcs off screen. */
1038  if( ClipBox )
1039  {
1040  int x0, y0, xm, ym;
1041  x0 = ClipBox->GetX();
1042  y0 = ClipBox->GetY();
1043  xm = ClipBox->GetRight();
1044  ym = ClipBox->GetBottom();
1045 
1046  if( x < ( x0 - r - width ) )
1047  return;
1048 
1049  if( y < ( y0 - r - width ) )
1050  return;
1051 
1052  if( x > ( r + xm + width ) )
1053  return;
1054 
1055  if( y > ( r + ym + width ) )
1056  return;
1057  }
1058 
1059  x1 = r;
1060  y1 = 0;
1061  RotatePoint( &x1, &y1, EndAngle );
1062 
1063  x2 = r;
1064  y2 = 0;
1065  RotatePoint( &x2, &y2, StAngle );
1066 
1067  GRSetBrush( DC, Color );
1068  GRSetColorPen( DC, Color, width );
1069  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
1070 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
int GetBottom() const
int GetRight() const
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:246
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:209
int GetX() const
int GetY() const
void GRArc1 ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  xc,
int  yc,
COLOR4D  Color 
)

Definition at line 872 of file gr_basic.cpp.

References GRArc1().

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

874 {
875  GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
876 }
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:872
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 882 of file gr_basic.cpp.

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

884 {
885  /* Clip arcs off screen. */
886  if( ClipBox )
887  {
888  int x0, y0, xm, ym, r;
889  x0 = ClipBox->GetX();
890  y0 = ClipBox->GetY();
891  xm = ClipBox->GetRight();
892  ym = ClipBox->GetBottom();
893  r = KiROUND( Distance( x1, y1, xc, yc ) );
894  if( xc < ( x0 - r ) )
895  return;
896  if( yc < ( y0 - r ) )
897  return;
898  if( xc > ( r + xm ) )
899  return;
900  if( yc > ( r + ym ) )
901  return;
902  }
903 
904  GRSetBrush( DC, Color );
905  GRSetColorPen( DC, Color, width );
906  DC->DrawArc( x1, y1, x2, y2, xc, yc );
907 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
int GetBottom() const
int GetRight() const
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:246
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:209
int GetX() const
int GetY() const
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 910 of file gr_basic.cpp.

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

912 {
913  GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
914  aWidth, aColor );
915 }
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:872
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 1224 of file gr_basic.cpp.

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

1234 {
1235  std::vector<wxPoint> points;
1236 
1237  BEZIER_POLY converter( x1, y1, x2, y2, x3, y3 );
1238  converter.GetPoly( points );
1239 
1240  GRPoly( ClipBox, DC, points.size(), &points[0], false, width, Color, Color );
1241 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:774
Bezier curves to polygon converter.
Definition: bezier_curves.h:34
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 1244 of file gr_basic.cpp.

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

1256 {
1257  std::vector<wxPoint> points;
1258 
1259  BEZIER_POLY converter( x1, y1, x2, y2, x3, y3, x4, y4 );
1260  converter.GetPoly( points );
1261 
1262  GRPoly( ClipBox, DC, points.size(), &points[0], false, width, Color, Color );
1263 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:774
Bezier curves to polygon converter.
Definition: bezier_curves.h:34
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 839 of file gr_basic.cpp.

References GRCircle().

840 {
841  GRCircle( ClipBox, DC, x, y, r, 0, Color );
842 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:828
void GRCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  r,
int  width,
COLOR4D  Color 
)

Definition at line 828 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(), EDA_DRAW_PANEL::DrawAuxiliaryAxis(), D_CODE::DrawFlashedShape(), LIB_CIRCLE::drawGraphic(), EDA_DRAW_PANEL::DrawGridAxis(), LIB_PIN::DrawPinSymbol(), D_PAD::DrawShape(), DrawViaCirclesWhenEditingNewTrack(), GRCircle(), and DIALOG_PAD_PROPERTIES::OnPaintShowPanel().

829 {
830  if( clipCircle( ClipBox, xc, yc, r, width ) )
831  return;
832 
833  GRSetBrush( DC, Color, NOT_FILLED );
834  GRSetColorPen( DC, Color, width );
835  DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
836 }
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:798
static const bool NOT_FILLED
Definition: gr_basic.cpp:21
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:246
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:209
void GRCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aPos,
int  aRadius,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 845 of file gr_basic.cpp.

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

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

References GRClosedPoly().

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

786 {
787  GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
788 }
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:784
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 791 of file gr_basic.cpp.

References GRSClosedPoly().

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

Definition at line 574 of file gr_basic.cpp.

References GRCSegm().

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

Definition at line 488 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(), DRAWSEGMENT::Draw(), DIMENSION::Draw(), GERBER_DRAW_ITEM::Draw(), SEGZONE::Draw(), ZONE_CONTAINER::DrawFilledArea(), D_CODE::DrawFlashedShape(), BASIC_GAL::DrawLine(), BASIC_GAL::DrawPolyline(), D_PAD::DrawShape(), and GRCSegm().

490 {
491  GRLastMoveToX = x2;
492  GRLastMoveToY = y2;
493 
494  if( ClipBox )
495  {
496  EDA_RECT clipbox(*ClipBox);
497  clipbox.Inflate(width/2);
498 
499  if( clipLine( &clipbox, x1, y1, x2, y2 ) )
500  return;
501  }
502 
503 
504  if( width <= 2 ) /* single line or 2 pixels */
505  {
506  GRSetColorPen( DC, Color, width );
507  DC->DrawLine( x1, y1, x2, y2 );
508  return;
509  }
510 
511  GRSetBrush( DC, Color, NOT_FILLED );
512  GRSetColorPen( DC, Color, aPenSize );
513 
514  int radius = (width + 1) >> 1;
515  int dx = x2 - x1;
516  int dy = y2 - y1;
517  double angle = -ArcTangente( dy, dx );
518  wxPoint start;
519  wxPoint end;
520  wxPoint org( x1, y1);
521  int len = (int) hypot( dx, dy );
522 
523  // We know if the DC is mirrored, to draw arcs
524  int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
525  int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
526  bool mirrored = (slx > 0 && sly < 0) || (slx < 0 && sly > 0);
527 
528  // first edge
529  start.x = 0;
530  start.y = radius;
531  end.x = len;
532  end.y = radius;
533  RotatePoint( &start, angle);
534  RotatePoint( &end, angle);
535 
536  start += org;
537  end += org;
538 
539  DC->DrawLine( start, end );
540 
541  // first rounded end
542  end.x = 0;
543  end.y = -radius;
544  RotatePoint( &end, angle);
545  end += org;
546 
547  if( !mirrored )
548  DC->DrawArc( end, start, org );
549  else
550  DC->DrawArc( start, end, org );
551 
552 
553  // second edge
554  start.x = len;
555  start.y = -radius;
556  RotatePoint( &start, angle);
557  start += org;
558 
559  DC->DrawLine( start, end );
560 
561  // second rounded end
562  end.x = len;
563  end.y = radius;
564  RotatePoint( &end, angle);
565  end += org;
566 
567  if( !mirrored )
568  DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
569  else
570  DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
571 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
static int GRLastMoveToX
Definition: gr_basic.cpp:67
static const bool NOT_FILLED
Definition: gr_basic.cpp:21
static int GRLastMoveToY
Definition: gr_basic.cpp:67
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:271
static 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.
Definition: gr_basic.cpp:114
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:246
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:209
Class EDA_RECT handles the component boundary box.
void GRCSegm ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 581 of file gr_basic.cpp.

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

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

Definition at line 381 of file gr_basic.cpp.

References GRLine().

Referenced by LIB_ARC::drawEditGraphics().

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

Definition at line 389 of file gr_basic.cpp.

References GRLine().

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

Definition at line 1266 of file gr_basic.cpp.

References GRLine().

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

1268 {
1269  int anchor_size = aDC->DeviceToLogicalXRel( aSize );
1270 
1271  GRLine( aClipBox, aDC,
1272  x - anchor_size, y,
1273  x + anchor_size, y, 0, aColor );
1274  GRLine( aClipBox, aDC,
1275  x, y - anchor_size,
1276  x, y + anchor_size, 0, aColor );
1277 }
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:358
void GRFillCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 591 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().

593 {
594  GRSetColorPen( DC, Color, width );
595  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
596 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:176
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:209
void GRFilledArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 970 of file gr_basic.cpp.

References GRFilledArc().

973 {
974  GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
975 }
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:921
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 921 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().

931 {
932  int x1, y1, x2, y2;
933 
934  /* Clip arcs off screen */
935  if( ClipBox )
936  {
937  int x0, y0, xm, ym;
938  x0 = ClipBox->GetX();
939  y0 = ClipBox->GetY();
940  xm = ClipBox->GetRight();
941  ym = ClipBox->GetBottom();
942 
943  if( x < ( x0 - r - 1 ) )
944  return;
945 
946  if( y < ( y0 - r - 1 ) )
947  return;
948 
949  if( x > ( r + xm + 1 ) )
950  return;
951 
952  if( y > ( r + ym + 1 ) )
953  return;
954  }
955 
956  x1 = r;
957  y1 = 0;
958  RotatePoint( &x1, &y1, EndAngle );
959 
960  x2 = r;
961  y2 = 0;
962  RotatePoint( &x2, &y2, StAngle );
963 
964  GRSetBrush( DC, BgColor, FILLED );
965  GRSetColorPen( DC, Color, width );
966  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
967 }
static const bool FILLED
Definition: gr_basic.cpp:20
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
int GetBottom() const
int GetRight() const
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:246
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:209
int GetX() const
int GetY() const
void GRFilledCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  r,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 851 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(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), and PCB_EDIT_FRAME::PrintPage().

853 {
854  if( clipCircle( ClipBox, x, y, r, width ) )
855  return;
856 
857  GRSetBrush( DC, BgColor, FILLED );
858  GRSetColorPen( DC, Color, width );
859  DC->DrawEllipse( x - r, y - r, r + r, r + r );
860 }
static const bool FILLED
Definition: gr_basic.cpp:20
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:798
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:246
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:209
void GRFilledCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aPos,
int  aRadius,
COLOR4D  aColor 
)

Definition at line 863 of file gr_basic.cpp.

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

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

Definition at line 1116 of file gr_basic.cpp.

References GRSFilledRect().

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

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

Definition at line 1126 of file gr_basic.cpp.

References GRSFilledRect().

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

Definition at line 599 of file gr_basic.cpp.

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

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

601 {
602  GRSetColorPen( aDC, aColor, aWidth );
603  WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
604 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:176
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:209
void GRForceBlackPen ( bool  flagforce)

Function GRForceBlackPen.

Parameters
flagforceTrue to force a black pen whenever the asked color

Definition at line 277 of file gr_basic.cpp.

References s_ForceBlackPen.

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

278 {
279  s_ForceBlackPen = flagforce;
280 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:68
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 375 of file gr_basic.cpp.

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

376 {
377  GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
378 }
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:358
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 358 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(), EDGE_MODULE::Draw(), SCH_LINE::Draw(), BLOCK_SELECTOR::Draw(), SCH_FIELD::Draw(), TRACK::Draw(), DIMENSION::Draw(), GERBER_DRAW_ITEM::Draw(), SEGZONE::Draw(), VIA::Draw(), LIB_PART::Draw(), EDA_DRAW_PANEL::DrawAuxiliaryAxis(), EDA_DRAW_PANEL::DrawBackGround(), EDA_DRAW_PANEL::DrawCrossHair(), LIB_ARC::drawEditGraphics(), PCB_BASE_FRAME::DrawGeneralRatsnest(), EDA_DRAW_PANEL::DrawGridAxis(), BASIC_GAL::DrawLine(), LIB_PIN::DrawPinSymbol(), D_PAD::DrawShape(), TEXTE_MODULE::DrawUmbilical(), ZONE_CONTAINER::DrawWhileCreateOutline(), WS_DRAW_ITEM_LINE::DrawWsItem(), GRDashedLine(), GRDottedLine(), GRDrawAnchor(), GRLine(), GRLineTo(), GRMixedLine(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), PCB_EDIT_FRAME::Solve(), PCB_BASE_FRAME::TraceAirWiresToTargets(), and PCB_BASE_FRAME::TraceModuleRatsNest().

367 {
368  GRSetColorPen( DC, Color, width, aStyle );
369  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
370  GRLastMoveToX = x2;
371  GRLastMoveToY = y2;
372 }
static int GRLastMoveToX
Definition: gr_basic.cpp:67
static int GRLastMoveToY
Definition: gr_basic.cpp:67
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:176
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:209
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 434 of file gr_basic.cpp.

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

Referenced by ZONE_CONTAINER::Draw().

436 {
437  if( aLines.empty() )
438  return;
439 
440  GRSetColorPen( aDC, aColor, aWidth );
441 
442  if( aClipBox )
443  aClipBox->Inflate( aWidth / 2 );
444 
445 #if defined( __WXMAC__ ) && defined( USE_WX_GRAPHICS_CONTEXT )
446  wxGCDC *gcdc = wxDynamicCast( aDC, wxGCDC );
447  if( gcdc )
448  {
449  wxGraphicsContext *gc = gcdc->GetGraphicsContext();
450 
451  // create path
452  wxGraphicsPath path = gc->CreatePath();
453  for( unsigned i = 0; i < aLines.size(); i += 2 )
454  {
455  int x1 = aLines[i].x;
456  int y1 = aLines[i].y;
457  int x2 = aLines[i+1].x;
458  int y2 = aLines[i+1].y;
459  if( ( aClipBox == NULL ) || !clipLine( aClipBox, x1, y1, x2, y2 ) )
460  {
461  path.MoveToPoint( x1, y1 );
462  path.AddLineToPoint( x2, y2 );
463  }
464  }
465  // draw path
466  gc->StrokePath( path );
467  }
468  else
469 #endif
470  {
471  for( unsigned i = 0; i < aLines.size(); i += 2 )
472  {
473  int x1 = aLines[i].x;
474  int y1 = aLines[i].y;
475  int x2 = aLines[i+1].x;
476  int y2 = aLines[i+1].y;
477  if( ( aClipBox == NULL ) || !clipLine( aClipBox, x1, y1, x2, y2 ) )
478  aDC->DrawLine( x1, y1, x2, y2 );
479  }
480  }
481  GRMoveTo( aLines[aLines.size() - 1].x, aLines[aLines.size() - 1].y );
482 
483  if( aClipBox )
484  aClipBox->Inflate(-aWidth/2);
485 }
static 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.
Definition: gr_basic.cpp:114
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:400
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:209
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 410 of file gr_basic.cpp.

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

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

Definition at line 416 of file gr_basic.cpp.

References GRLine().

418 {
419  GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_DOT_DASH );
420 }
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:358
void GRMoveTo ( int  x,
int  y 
)

Definition at line 400 of file gr_basic.cpp.

References GRLastMoveToX, and GRLastMoveToY.

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

401 {
402  GRLastMoveToX = x;
403  GRLastMoveToY = y;
404 }
static int GRLastMoveToX
Definition: gr_basic.cpp:67
static int GRLastMoveToY
Definition: gr_basic.cpp:67
void GRPoly ( EDA_RECT ClipBox,
wxDC *  DC,
int  n,
wxPoint  Points[],
bool  Fill,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 774 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().

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

Definition at line 345 of file gr_basic.cpp.

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

Referenced by DisplayRoutingMatrix(), and drawPlacementRoutingMatrix().

346 {
347  if( ClipBox && !ClipBox->Contains( x, y ) )
348  return;
349 
350  GRSetColorPen( DC, Color );
351  DC->DrawPoint( x, y );
352 }
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:209
void GRRect ( EDA_RECT ClipBox,
wxDC *  DC,
const EDA_RECT aRect,
int  aWidth,
COLOR4D  Color 
)

Definition at line 1102 of file gr_basic.cpp.

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

1103 {
1104  int x1 = aRect.GetX();
1105  int y1 = aRect.GetY();
1106  int x2 = aRect.GetRight();
1107  int y2 = aRect.GetBottom();
1108 
1109  GRSRect( aClipBox, aDC, x1, y1, x2, y2, aWidth, aColor );
1110 }
int GetBottom() const
int GetRight() const
int GetX() const
int GetY() const
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:1137
void GRRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 1096 of file gr_basic.cpp.

References GRSRect().

1097 {
1098  GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
1099 }
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:1137
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 196 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(), BOARD_PRINTOUT_CONTROLLER::DrawPage(), DrawPageOnClipboard(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), EDA_DRAW_PANEL::ReDraw(), DIALOG_CHOOSE_COMPONENT::RenderPreview(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

197 {
198  GRSetBrush( DC, BLACK ); // Force no fill
199  s_DC_lastbrushcolor = COLOR4D::UNSPECIFIED;
200  s_DC_lastcolor = COLOR4D::UNSPECIFIED;
201  s_DC_lastDC = NULL;
202 }
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:78
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:246
Definition: colors.h:45
void GRSetBrush ( wxDC *  DC,
COLOR4D  Color,
bool  fill = false 
)

Definition at line 246 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().

247 {
248  if( s_ForceBlackPen )
249  Color = COLOR4D::BLACK;
250 
251  if( s_DC_lastbrushcolor != Color
252  || s_DC_lastbrushfill != fill
253  || s_DC_lastDC != DC )
254  {
255  wxBrush brush;
256 
257  brush.SetColour( Color.ToColour() );
258 
259  if( fill )
260  brush.SetStyle( wxBRUSHSTYLE_SOLID );
261  else
262  brush.SetStyle( wxBRUSHSTYLE_TRANSPARENT );
263 
264  DC->SetBrush( brush );
265 
266  s_DC_lastbrushcolor = Color;
267  s_DC_lastbrushfill = fill;
268  s_DC_lastDC = DC;
269  }
270 }
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:78
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
Definition: colors.h:45
static bool s_DC_lastbrushfill
Definition: gr_basic.cpp:77
static bool s_ForceBlackPen
Definition: gr_basic.cpp:68
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 209 of file gr_basic.cpp.

References BLACK, and s_ForceBlackPen.

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

210 {
211  wxDash dots[2] = { 1, 3 };
212  // Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
213  // nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
214  if( width <= 1 )
215  width = DC->DeviceToLogicalXRel( 1 );
216 
217  if( s_ForceBlackPen )
218  Color = COLOR4D::BLACK;
219 
220  const wxPen& curr_pen = DC->GetPen();
221 
222  if( !curr_pen.IsOk() || curr_pen.GetColour() != Color.ToColour()
223  || curr_pen.GetWidth() != width
224  || curr_pen.GetStyle() != style )
225  {
226  wxPen pen;
227  pen.SetColour( Color.ToColour() );
228  if( style == wxPENSTYLE_DOT )
229  {
230  style = wxPENSTYLE_USER_DASH;
231  pen.SetDashes( 2, dots );
232  }
233  pen.SetWidth( width );
234  pen.SetStyle( style );
235  DC->SetPen( pen );
236  }
237  else
238  // Should be not needed, but on Linux, in printing process
239  // the curr pen settings needs to be sometimes re-initialized
240  // Clearly, this is due to a bug, related to SetBrush(),
241  // but we have to live with it, at least on wxWidgets 3.0
242  DC->SetPen( curr_pen );
243 }
Definition: colors.h:45
static bool s_ForceBlackPen
Definition: gr_basic.cpp:68
void GRSetDefaultPalette ( )
void GRSetDrawMode ( wxDC *  DC,
GR_DRAWMODE  mode 
)

Definition at line 296 of file gr_basic.cpp.

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

Referenced by Autoroute_One_Track(), DisplayRoutingMatrix(), SCH_NO_CONNECT::Draw(), SCH_JUNCTION::Draw(), PCB_TARGET::Draw(), SCH_BUS_ENTRY_BASE::Draw(), SCH_BITMAP::Draw(), EDGE_MODULE::Draw(), ZONE_CONTAINER::Draw(), SCH_LINE::Draw(), GBR_LAYOUT::Draw(), BLOCK_SELECTOR::Draw(), SCH_TEXT::Draw(), SCH_FIELD::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DRAWSEGMENT::Draw(), DIMENSION::Draw(), LIB_ITEM::Draw(), GERBER_DRAW_ITEM::Draw(), SCH_GLOBALLABEL::Draw(), SCH_HIERLABEL::Draw(), SEGZONE::Draw(), VIA::Draw(), SCH_SHEET::Draw(), LIB_PART::Draw(), MODULE::DrawAncre(), EDA_DRAW_PANEL::DrawAuxiliaryAxis(), EDA_DRAW_PANEL::DrawBackGround(), EDA_DRAW_PANEL::DrawCrossHair(), ZONE_CONTAINER::DrawFilledArea(), LIB_CIRCLE::drawGraphic(), LIB_POLYLINE::drawGraphic(), LIB_RECTANGLE::drawGraphic(), LIB_BEZIER::drawGraphic(), LIB_TEXT::drawGraphic(), LIB_ARC::drawGraphic(), LIB_FIELD::drawGraphic(), EDA_DRAW_PANEL::DrawGridAxis(), GBR_LAYOUT::DrawItemsDCodeID(), MARKER_BASE::DrawMarker(), DrawMovingBlockOutlines(), EDA_TEXT::drawOneLineOfText(), LIB_PIN::DrawPinElectricalTypeName(), LIB_PIN::DrawPinSymbol(), LIB_PIN::DrawPinTexts(), drawPlacementRoutingMatrix(), 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(), EDA_DRAW_PANEL::EraseScreen(), FOOTPRINT_EDIT_FRAME::RedrawActiveWindow(), PCB_EDIT_FRAME::RedrawActiveWindow(), ShowBoundingBoxMicroWaveInductor(), and PCB_BASE_FRAME::TraceAirWiresToTargets().

297 {
298  if( draw_mode & GR_OR )
299 #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
300 
301  DC->SetLogicalFunction( wxCOPY );
302 #elif defined( USE_WX_GRAPHICS_CONTEXT )
303 
304  DC->SetLogicalFunction( wxCOPY );
305 #else
306 
307  DC->SetLogicalFunction( wxOR );
308 #endif
309  else if( draw_mode & GR_XOR )
310 #if defined( USE_WX_GRAPHICS_CONTEXT )
311 
312  DC->SetLogicalFunction( wxCOPY );
313 #else
314 
315  DC->SetLogicalFunction( wxXOR );
316 #endif
317  else if( draw_mode & GR_NXOR )
318 #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
319 
320  DC->SetLogicalFunction( wxXOR );
321 #elif defined( USE_WX_GRAPHICS_CONTEXT )
322 
323  DC->SetLogicalFunction( wxCOPY );
324 #else
325 
326  DC->SetLogicalFunction( wxEQUIV );
327 #endif
328  else if( draw_mode & GR_INVERT )
329 #if defined( USE_WX_GRAPHICS_CONTEXT )
330 
331  DC->SetLogicalFunction( wxCOPY );
332 #else
333 
334  DC->SetLogicalFunction( wxINVERT );
335 #endif
336  else if( draw_mode & GR_COPY )
337  DC->SetLogicalFunction( wxCOPY );
338 
339 #ifdef USE_WX_OVERLAY
340  DC->SetLogicalFunction( wxCOPY );
341 #endif
342 }
Definition: gr_basic.h:42
void GRSFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 1151 of file gr_basic.cpp.

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

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

1153 {
1154  wxPoint points[5];
1155  points[0] = wxPoint(x1, y1);
1156  points[1] = wxPoint(x1, y2);
1157  points[2] = wxPoint(x2, y2);
1158  points[3] = wxPoint(x2, y1);
1159  points[4] = points[0];
1160 
1161  GRSetBrush( aDC, aBgColor, FILLED );
1162  GRSetColorPen( aDC, aBgColor, aWidth );
1163 
1164  if( aClipBox && (aWidth > 0) )
1165  {
1166  EDA_RECT clipbox(*aClipBox);
1167  clipbox.Inflate(aWidth);
1168  ClipAndDrawPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
1169  }
1170  else
1171  ClipAndDrawPoly(aClipBox, aDC, points, 5 );
1172 }
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:1189
static const bool FILLED
Definition: gr_basic.cpp:20
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:246
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:209
Class EDA_RECT handles the component boundary box.
GR_DRAWMODE operator& ( const GR_DRAWMODE a,
const GR_DRAWMODE b 
)
inline

Definition at line 73 of file gr_basic.h.

74 {
75  return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
76 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
GR_DRAWMODE operator| ( const GR_DRAWMODE a,
const GR_DRAWMODE b 
)
inline

Definition at line 68 of file gr_basic.h.

69 {
70  return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
71 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
GR_DRAWMODE operator~ ( const GR_DRAWMODE a)
inline

Definition at line 63 of file gr_basic.h.

64 {
65  return static_cast<GR_DRAWMODE>( ~int( a ) );
66 }
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41

Variable Documentation