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)
 
void GRLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
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 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 281 of file gr_basic.cpp.

References s_ForceBlackPen.

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

282 {
283  return s_ForceBlackPen;
284 }
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 982 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().

984 {
985  int x1, y1, x2, y2;
986 
987  /* Clip arcs off screen */
988  if( ClipBox )
989  {
990  int radius = r + 1;
991  int x0, y0, xm, ym, x, y;
992  x0 = ClipBox->GetX();
993  y0 = ClipBox->GetY();
994  xm = ClipBox->GetRight();
995  ym = ClipBox->GetBottom();
996  x = xc;
997  y = yc;
998 
999  if( x < ( x0 - radius ) )
1000  return;
1001  if( y < ( y0 - radius ) )
1002  return;
1003  if( x > ( xm + radius ) )
1004  return;
1005  if( y > ( ym + radius ) )
1006  return;
1007  }
1008 
1009  x1 = r;
1010  y1 = 0;
1011  RotatePoint( &x1, &y1, EndAngle );
1012 
1013  x2 = r;
1014  y2 = 0;
1015  RotatePoint( &x2, &y2, StAngle );
1016 
1017  GRSetBrush( DC, Color, NOT_FILLED );
1018  GRSetColorPen( DC, Color );
1019  DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
1020 }
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:240
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 1026 of file gr_basic.cpp.

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

1035 {
1036  int x1, y1, x2, y2;
1037 
1038  /* Clip arcs off screen. */
1039  if( ClipBox )
1040  {
1041  int x0, y0, xm, ym;
1042  x0 = ClipBox->GetX();
1043  y0 = ClipBox->GetY();
1044  xm = ClipBox->GetRight();
1045  ym = ClipBox->GetBottom();
1046 
1047  if( x < ( x0 - r - width ) )
1048  return;
1049 
1050  if( y < ( y0 - r - width ) )
1051  return;
1052 
1053  if( x > ( r + xm + width ) )
1054  return;
1055 
1056  if( y > ( r + ym + width ) )
1057  return;
1058  }
1059 
1060  x1 = r;
1061  y1 = 0;
1062  RotatePoint( &x1, &y1, EndAngle );
1063 
1064  x2 = r;
1065  y2 = 0;
1066  RotatePoint( &x2, &y2, StAngle );
1067 
1068  GRSetBrush( DC, Color );
1069  GRSetColorPen( DC, Color, width );
1070  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
1071 }
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:240
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 873 of file gr_basic.cpp.

References GRArc1().

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

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

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

885 {
886  /* Clip arcs off screen. */
887  if( ClipBox )
888  {
889  int x0, y0, xm, ym, r;
890  x0 = ClipBox->GetX();
891  y0 = ClipBox->GetY();
892  xm = ClipBox->GetRight();
893  ym = ClipBox->GetBottom();
894  r = KiROUND( Distance( x1, y1, xc, yc ) );
895  if( xc < ( x0 - r ) )
896  return;
897  if( yc < ( y0 - r ) )
898  return;
899  if( xc > ( r + xm ) )
900  return;
901  if( yc > ( r + ym ) )
902  return;
903  }
904 
905  GRSetBrush( DC, Color );
906  GRSetColorPen( DC, Color, width );
907  DC->DrawArc( x1, y1, x2, y2, xc, yc );
908 }
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:240
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 911 of file gr_basic.cpp.

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

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

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

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

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

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

References GRCircle().

822 {
823  GRCircle( ClipBox, DC, x, y, r, 0, Color );
824 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:791
void GRCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  r,
int  width,
COLOR4D  Color 
)

Definition at line 791 of file gr_basic.cpp.

References EDA_RECT::GetBottom(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), 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().

792 {
793  /* Clip circles off screen. */
794  if( ClipBox )
795  {
796  int x0, y0, xm, ym;
797  x0 = ClipBox->GetX();
798  y0 = ClipBox->GetY();
799  xm = ClipBox->GetRight();
800  ym = ClipBox->GetBottom();
801 
802  if( xc < ( x0 - r - width ) )
803  return;
804 
805  if( yc < ( y0 - r - width ) )
806  return;
807 
808  if( xc > ( r + xm + width ) )
809  return;
810 
811  if( yc > ( r + ym + width ) )
812  return;
813  }
814 
815  GRSetBrush( DC, Color, NOT_FILLED );
816  GRSetColorPen( DC, Color, width );
817  DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
818 }
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:240
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 GRCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aPos,
int  aRadius,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 827 of file gr_basic.cpp.

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

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

References GRClosedPoly().

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

779 {
780  GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
781 }
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:777
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 784 of file gr_basic.cpp.

References GRSClosedPoly().

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

Definition at line 567 of file gr_basic.cpp.

References GRCSegm().

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

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

483 {
484  GRLastMoveToX = x2;
485  GRLastMoveToY = y2;
486 
487  if( ClipBox )
488  {
489  EDA_RECT clipbox(*ClipBox);
490  clipbox.Inflate(width/2);
491 
492  if( clipLine( &clipbox, x1, y1, x2, y2 ) )
493  return;
494  }
495 
496 
497  if( width <= 2 ) /* single line or 2 pixels */
498  {
499  GRSetColorPen( DC, Color, width );
500  DC->DrawLine( x1, y1, x2, y2 );
501  return;
502  }
503 
504  GRSetBrush( DC, Color, NOT_FILLED );
505  GRSetColorPen( DC, Color, aPenSize );
506 
507  int radius = (width + 1) >> 1;
508  int dx = x2 - x1;
509  int dy = y2 - y1;
510  double angle = -ArcTangente( dy, dx );
511  wxPoint start;
512  wxPoint end;
513  wxPoint org( x1, y1);
514  int len = (int) hypot( dx, dy );
515 
516  // We know if the DC is mirrored, to draw arcs
517  int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
518  int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
519  bool mirrored = (slx > 0 && sly < 0) || (slx < 0 && sly > 0);
520 
521  // first edge
522  start.x = 0;
523  start.y = radius;
524  end.x = len;
525  end.y = radius;
526  RotatePoint( &start, angle);
527  RotatePoint( &end, angle);
528 
529  start += org;
530  end += org;
531 
532  DC->DrawLine( start, end );
533 
534  // first rounded end
535  end.x = 0;
536  end.y = -radius;
537  RotatePoint( &end, angle);
538  end += org;
539 
540  if( !mirrored )
541  DC->DrawArc( end, start, org );
542  else
543  DC->DrawArc( start, end, org );
544 
545 
546  // second edge
547  start.x = len;
548  start.y = -radius;
549  RotatePoint( &start, angle);
550  start += org;
551 
552  DC->DrawLine( start, end );
553 
554  // second rounded end
555  end.x = len;
556  end.y = radius;
557  RotatePoint( &end, angle);
558  end += org;
559 
560  if( !mirrored )
561  DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
562  else
563  DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
564 }
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:240
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 574 of file gr_basic.cpp.

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

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

Definition at line 374 of file gr_basic.cpp.

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

Referenced by SCH_LINE::Draw(), and LIB_ARC::drawEditGraphics().

377 {
378  GRLastMoveToX = x2;
379  GRLastMoveToY = y2;
380  s_DC_lastcolor = COLOR4D::UNSPECIFIED;
381  GRSetColorPen( DC, Color, width, wxPENSTYLE_SHORT_DASH );
382  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
383  s_DC_lastcolor = COLOR4D::UNSPECIFIED;
384  GRSetColorPen( DC, Color, width );
385 }
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
static COLOR4D s_DC_lastcolor(0, 0, 0, 0)
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 GRDrawAnchor ( EDA_RECT aClipBox,
wxDC *  aDC,
int  x,
int  y,
int  aSize,
COLOR4D  aColor 
)

Definition at line 1267 of file gr_basic.cpp.

References GRLine().

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

1269 {
1270  int anchor_size = aDC->DeviceToLogicalXRel( aSize );
1271 
1272  GRLine( aClipBox, aDC,
1273  x - anchor_size, y,
1274  x + anchor_size, y, 0, aColor );
1275  GRLine( aClipBox, aDC,
1276  x, y - anchor_size,
1277  x, y + anchor_size, 0, aColor );
1278 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
void GRFillCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

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

586 {
587  GRSetColorPen( DC, Color, width );
588  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
589 }
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 971 of file gr_basic.cpp.

References GRFilledArc().

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

932 {
933  int x1, y1, x2, y2;
934 
935  /* Clip arcs off screen */
936  if( ClipBox )
937  {
938  int x0, y0, xm, ym;
939  x0 = ClipBox->GetX();
940  y0 = ClipBox->GetY();
941  xm = ClipBox->GetRight();
942  ym = ClipBox->GetBottom();
943 
944  if( x < ( x0 - r - 1 ) )
945  return;
946 
947  if( y < ( y0 - r - 1 ) )
948  return;
949 
950  if( x > ( r + xm + 1 ) )
951  return;
952 
953  if( y > ( r + ym + 1 ) )
954  return;
955  }
956 
957  x1 = r;
958  y1 = 0;
959  RotatePoint( &x1, &y1, EndAngle );
960 
961  x2 = r;
962  y2 = 0;
963  RotatePoint( &x2, &y2, StAngle );
964 
965  GRSetBrush( DC, BgColor, FILLED );
966  GRSetColorPen( DC, Color, width );
967  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
968 }
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:240
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 833 of file gr_basic.cpp.

References FILLED, EDA_RECT::GetBottom(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), 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().

835 {
836  /* Clip circles off screen. */
837  if( ClipBox )
838  {
839  int x0, y0, xm, ym;
840  x0 = ClipBox->GetX();
841  y0 = ClipBox->GetY();
842  xm = ClipBox->GetRight();
843  ym = ClipBox->GetBottom();
844 
845  if( x < ( x0 - r ) )
846  return;
847 
848  if( y < ( y0 - r ) )
849  return;
850 
851  if( x > ( r + xm ) )
852  return;
853 
854  if( y > ( r + ym ) )
855  return;
856  }
857 
858  GRSetBrush( DC, BgColor, FILLED );
859  GRSetColorPen( DC, Color, width );
860  DC->DrawEllipse( x - r, y - r, r + r, r + r );
861 }
static const bool FILLED
Definition: gr_basic.cpp:20
int GetBottom() const
int GetRight() const
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:240
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 aClipBox,
wxDC *  aDC,
wxPoint  aPos,
int  aRadius,
COLOR4D  aColor 
)

Definition at line 864 of file gr_basic.cpp.

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

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

Definition at line 1117 of file gr_basic.cpp.

References GRSFilledRect().

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

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

Definition at line 1127 of file gr_basic.cpp.

References GRSFilledRect().

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

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

594 {
595  GRSetColorPen( aDC, aColor, aWidth );
596  WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
597 }
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 271 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().

272 {
273  s_ForceBlackPen = flagforce;
274 }
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 
)

Definition at line 368 of file gr_basic.cpp.

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

369 {
370  GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor );
371 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
void GRLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

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

360 {
361  GRSetColorPen( DC, Color, width );
362  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
363  GRLastMoveToX = x2;
364  GRLastMoveToY = y2;
365 }
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 427 of file gr_basic.cpp.

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

Referenced by ZONE_CONTAINER::Draw().

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

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

402 {
403  GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
404 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
static int GRLastMoveToX
Definition: gr_basic.cpp:67
static int GRLastMoveToY
Definition: gr_basic.cpp:67
void GRMixedLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 407 of file gr_basic.cpp.

References GRLine(), and GRSetColorPen().

409 {
410  GRSetColorPen( DC, Color, width, wxPENSTYLE_DOT_DASH );
411  GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color );
412  GRSetColorPen( DC, Color, width );
413 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
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 GRMoveTo ( int  x,
int  y 
)

Definition at line 391 of file gr_basic.cpp.

References GRLastMoveToX, and GRLastMoveToY.

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

392 {
393  GRLastMoveToX = x;
394  GRLastMoveToY = y;
395 }
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 767 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().

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

Definition at line 339 of file gr_basic.cpp.

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

Referenced by DisplayRoutingMatrix(), and drawPlacementRoutingMatrix().

340 {
341  if( ClipBox && !ClipBox->Contains( x, y ) )
342  return;
343 
344  GRSetColorPen( DC, Color );
345  DC->DrawPoint( x, y );
346 }
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 1103 of file gr_basic.cpp.

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

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

Definition at line 1097 of file gr_basic.cpp.

References GRSRect().

1098 {
1099  GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
1100 }
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:1138
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:240
Definition: colors.h:45
void GRSetBrush ( wxDC *  DC,
COLOR4D  Color,
bool  fill = false 
)

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

241 {
242  if( s_ForceBlackPen )
243  Color = COLOR4D::BLACK;
244 
245  if( s_DC_lastbrushcolor != Color
246  || s_DC_lastbrushfill != fill
247  || s_DC_lastDC != DC )
248  {
249  wxBrush brush;
250 
251  brush.SetColour( Color.ToColour() );
252 
253  if( fill )
254  brush.SetStyle( wxBRUSHSTYLE_SOLID );
255  else
256  brush.SetStyle( wxBRUSHSTYLE_TRANSPARENT );
257 
258  DC->SetBrush( brush );
259 
260  s_DC_lastbrushcolor = Color;
261  s_DC_lastbrushfill = fill;
262  s_DC_lastDC = DC;
263  }
264 }
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(), GRDashedLine(), GRFillCSegm(), GRFilledArc(), GRFilledCircle(), GRFilledSegment(), GRLine(), GRLineArray(), GRMixedLine(), GRPutPixel(), GRSClosedPoly(), GRSFilledRect(), and GRSPoly().

210 {
211  // Under OSX and while printing when wxPen is set to 0, renderer follows the request drawing
212  // nothing & in the bitmap world the minimum is enough to light a pixel, in vectorial one not
213  if( width <= 1 )
214  width = DC->DeviceToLogicalXRel( 1 );
215 
216  if( s_ForceBlackPen )
217  Color = COLOR4D::BLACK;
218 
219  const wxPen& curr_pen = DC->GetPen();
220 
221  if( !curr_pen.IsOk() || curr_pen.GetColour() != Color.ToColour()
222  || curr_pen.GetWidth() != width
223  || curr_pen.GetStyle() != style )
224  {
225  wxPen pen;
226  pen.SetColour( Color.ToColour() );
227  pen.SetWidth( width );
228  pen.SetStyle( style );
229  DC->SetPen( pen );
230  }
231  else
232  // Should be not needed, but on Linux, in printing process
233  // the curr pen settings needs to be sometimes re-initialized
234  // Clearly, this is due to a bug, related to SetBrush(),
235  // but we have to live with it, at least on wxWidgets 3.0
236  DC->SetPen( curr_pen );
237 }
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 290 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_LINE::Draw(), SCH_BITMAP::Draw(), EDGE_MODULE::Draw(), GBR_LAYOUT::Draw(), BLOCK_SELECTOR::Draw(), SCH_TEXT::Draw(), ZONE_CONTAINER::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().

291 {
292  if( draw_mode & GR_OR )
293 #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
294 
295  DC->SetLogicalFunction( wxCOPY );
296 #elif defined( USE_WX_GRAPHICS_CONTEXT )
297 
298  DC->SetLogicalFunction( wxCOPY );
299 #else
300 
301  DC->SetLogicalFunction( wxOR );
302 #endif
303  else if( draw_mode & GR_XOR )
304 #if defined( USE_WX_GRAPHICS_CONTEXT )
305 
306  DC->SetLogicalFunction( wxCOPY );
307 #else
308 
309  DC->SetLogicalFunction( wxXOR );
310 #endif
311  else if( draw_mode & GR_NXOR )
312 #if defined(__WXMAC__) && (wxMAC_USE_CORE_GRAPHICS || wxCHECK_VERSION( 2, 9, 0 ) )
313 
314  DC->SetLogicalFunction( wxXOR );
315 #elif defined( USE_WX_GRAPHICS_CONTEXT )
316 
317  DC->SetLogicalFunction( wxCOPY );
318 #else
319 
320  DC->SetLogicalFunction( wxEQUIV );
321 #endif
322  else if( draw_mode & GR_INVERT )
323 #if defined( USE_WX_GRAPHICS_CONTEXT )
324 
325  DC->SetLogicalFunction( wxCOPY );
326 #else
327 
328  DC->SetLogicalFunction( wxINVERT );
329 #endif
330  else if( draw_mode & GR_COPY )
331  DC->SetLogicalFunction( wxCOPY );
332 
333 #ifdef USE_WX_OVERLAY
334  DC->SetLogicalFunction( wxCOPY );
335 #endif
336 }
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 1152 of file gr_basic.cpp.

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

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

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