KiCad PCB EDA Suite
gr_basic.cpp File Reference
#include <fctsys.h>
#include <gr_basic.h>
#include <common.h>
#include <trigo.h>
#include <macros.h>
#include <base_struct.h>
#include <class_base_screen.h>
#include <bezier_curves.h>
#include <math_for_graphics.h>
#include <wx/graphics.h>
#include <SutherlandHodgmanClipPoly.h>

Go to the source code of this file.

Macros

#define DEBUG_DUMP_CLIP_ERROR_COORDS   0
 
#define DEBUG_DUMP_CLIP_COORDS   0
 

Functions

static void ClipAndDrawPoly (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aPoints[], int n)
 Function ClipAndDrawPoly Used to clip a polygon and draw it as Filled Polygon uses the Sutherland and Hodgman algo to clip the given poly against a rectangle. More...
 
static void GRSRect (EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
 
static int clipOutCode (const EDA_RECT *aClipBox, int x, int y)
 
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. More...
 
static void WinClipAndDrawLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
 
void GRResetPenAndBrush (wxDC *DC)
 
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. More...
 
void GRSetBrush (wxDC *DC, COLOR4D Color, bool fill)
 
void GRForceBlackPen (bool flagforce)
 Function GRForceBlackPen. More...
 
bool GetGRForceBlackPenState (void)
 Function GetGRForceBlackPenState. More...
 
void GRSetDrawMode (wxDC *DC, GR_DRAWMODE draw_mode)
 
void GRPutPixel (EDA_RECT *ClipBox, wxDC *DC, int x, int y, COLOR4D Color)
 
void GRLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRLine (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
 
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 GRMixedLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
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 GRCSegm (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
 
void GRCSegm (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRCSegm (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
 
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)
 
static bool IsGRSPolyDrawable (EDA_RECT *ClipBox, int n, wxPoint Points[])
 
static void GRSPoly (EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
 
static void GRSClosedPoly (EDA_RECT *aClipBox, wxDC *aDC, int aPointCount, wxPoint aPoints[], bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
 
void GRPoly (EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
 
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 draws a border around it. More...
 
void GRClosedPoly (EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
 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 *DC, int xc, int yc, int r, int width, COLOR4D Color)
 
void GRCircle (EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, COLOR4D Color)
 Function GRCircle draws a circle onto the drawing context aDC centered at the user coordinates (x,y) More...
 
void GRCircle (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor)
 
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 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, int width, COLOR4D Color, COLOR4D BgColor)
 
void GRFilledArc (EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor)
 
void GRArc (EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, 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 GRRect (EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
 
void GRRectPs (EDA_RECT *aClipBox, wxDC *aDC, const EDA_RECT &aRect, COLOR4D aColor, wxPenStyle aStyle)
 
void GRRect (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRRect (EDA_RECT *aClipBox, wxDC *aDC, const EDA_RECT &aRect, int aWidth, COLOR4D aColor)
 
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 GRSFilledRect (EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
 
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 GRDrawAnchor (EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor)
 

Variables

static const bool FILLED = true
 
static const bool NOT_FILLED = false
 
GR_DRAWMODE g_XorMode = GR_NXOR
 
static int GRLastMoveToX
 
static int GRLastMoveToY
 
static bool s_ForceBlackPen
 
static int xcliplo = 0
 
static int ycliplo = 0
 
static int xcliphi = 2000
 
static int ycliphi = 2000
 
static COLOR4D s_DC_lastcolor (0, 0, 0, 0)
 
static COLOR4D s_DC_lastbrushcolor (0, 0, 0, 0)
 
static bool s_DC_lastbrushfill = false
 
static wxDC * s_DC_lastDC = NULL
 

Macro Definition Documentation

#define DEBUG_DUMP_CLIP_COORDS   0

Definition at line 47 of file gr_basic.cpp.

#define DEBUG_DUMP_CLIP_ERROR_COORDS   0

Definition at line 46 of file gr_basic.cpp.

Function Documentation

void ClipAndDrawPoly ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aPoints[],
int  n 
)
static

Function ClipAndDrawPoly Used to clip a polygon and draw it as Filled Polygon uses the Sutherland and Hodgman algo to clip the given poly against a rectangle.

This rectangle is the drawing area this is useful under Linux (2009) because filled polygons are incorrectly drawn if they have too large coordinates (seems due to integer overflows in calculations) Could be removed in some years, if become unnecessary.

Definition at line 1190 of file gr_basic.cpp.

References EDA_RECT::GetHeight(), EDA_RECT::GetWidth(), EDA_RECT::GetX(), EDA_RECT::GetY(), and KiROUND().

Referenced by GRSClosedPoly(), GRSFilledRect(), and GRSPoly().

1191 {
1192  if( aClipBox == NULL )
1193  {
1194  aDC->DrawPolygon( n, aPoints );
1195  return;
1196  }
1197 
1198  // A clip box exists: clip and draw the polygon.
1199  static std::vector<wxPoint> clippedPolygon;
1200  static pointVector inputPolygon, outputPolygon;
1201 
1202  inputPolygon.clear();
1203  outputPolygon.clear();
1204  clippedPolygon.clear();
1205 
1206  for( int ii = 0; ii < n; ii++ )
1207  inputPolygon.push_back( PointF( (REAL) aPoints[ii].x, (REAL) aPoints[ii].y ) );
1208 
1209  RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(),
1210  (REAL) aClipBox->GetWidth(), (REAL) aClipBox->GetHeight() );
1211 
1212  SutherlandHodgman sh( window );
1213  sh.Clip( inputPolygon, outputPolygon );
1214 
1215  for( cpointIterator cit = outputPolygon.begin(); cit != outputPolygon.end(); ++cit )
1216  {
1217  clippedPolygon.push_back( wxPoint( KiROUND( cit->X ), KiROUND( cit->Y ) ) );
1218  }
1219 
1220  if( clippedPolygon.size() )
1221  aDC->DrawPolygon( clippedPolygon.size(), &clippedPolygon[0] );
1222 }
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
std::vector< PointF > pointVector
double REAL
int GetHeight() const
std::vector< PointF >::const_iterator cpointIterator
int GetX() const
int GetWidth() const
int GetY() const
static bool clipLine ( const EDA_RECT aClipBox,
int &  x1,
int &  y1,
int &  x2,
int &  y2 
)
static

Test if any part of a line falls within the bounds of a rectangle.

Please note that this is only accurate for lines that are one pixel wide.

Parameters
aClipBox- The rectangle to test.
x1- X coordinate of one end of a line.
y1- Y coordinate of one end of a line.
x2- X coordinate of the other end of a line.
y2- Y coordinate of the other end of a line.
Returns
- False if any part of the line lies within the rectangle.

Definition at line 114 of file gr_basic.cpp.

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

Referenced by GRCSegm(), GRLineArray(), and WinClipAndDrawLine().

115 {
116  // Stock Cohen-Sutherland algorithm; check *any* CG book for details
117  int outcode1 = clipOutCode( aClipBox, x1, y1 );
118  int outcode2 = clipOutCode( aClipBox, x2, y2 );
119 
120  while( outcode1 || outcode2 )
121  {
122  // Fast reject
123  if( outcode1 & outcode2 )
124  return true;
125 
126  // Choose a side to clip
127  int thisoutcode, x, y;
128  if( outcode1 )
129  thisoutcode = outcode1;
130  else
131  thisoutcode = outcode2;
132 
133  /* One clip round
134  * Since we use the full range of 32 bit ints, the proportion
135  * computation has to be done in 64 bits to avoid horrible
136  * results */
137  if( thisoutcode & 1 ) // Clip the bottom
138  {
139  y = aClipBox->GetBottom();
140  x = x1 + (x2 - x1) * int64_t(y - y1) / (y2 - y1);
141  }
142  else if( thisoutcode & 2 ) // Clip the top
143  {
144  y = aClipBox->GetY();
145  x = x1 + (x2 - x1) * int64_t(y - y1) / (y2 - y1);
146  }
147  else if( thisoutcode & 8 ) // Clip the right
148  {
149  x = aClipBox->GetRight();
150  y = y1 + (y2 - y1) * int64_t(x - x1) / (x2 - x1);
151  }
152  else // if( thisoutcode & 4), obviously, clip the left
153  {
154  x = aClipBox->GetX();
155  y = y1 + (y2 - y1) * int64_t(x - x1) / (x2 - x1);
156  }
157 
158  // Put the result back and update the boundary code
159  // No ambiguity, otherwise it would have been a fast reject
160  if( thisoutcode == outcode1 )
161  {
162  x1 = x;
163  y1 = y;
164  outcode1 = clipOutCode( aClipBox, x1, y1 );
165  }
166  else
167  {
168  x2 = x;
169  y2 = y;
170  outcode2 = clipOutCode( aClipBox, x2, y2 );
171  }
172  }
173  return false;
174 }
int GetBottom() const
int GetRight() const
static int clipOutCode(const EDA_RECT *aClipBox, int x, int y)
Definition: gr_basic.cpp:84
int GetX() const
int GetY() const
static int clipOutCode ( const EDA_RECT aClipBox,
int  x,
int  y 
)
inlinestatic

Definition at line 84 of file gr_basic.cpp.

References EDA_RECT::GetBottom(), and EDA_RECT::GetRight().

Referenced by clipLine().

85 {
86  int code;
87  if( y < aClipBox->GetY() )
88  code = 2;
89  else if( y > aClipBox->GetBottom() )
90  code = 1;
91  else
92  code = 0;
93  if( x < aClipBox->GetX() )
94  code |= 4;
95  else if( x > aClipBox->GetRight() )
96  code |= 8;
97  return code;
98 }
int GetBottom() const
int GetRight() const
bool GetGRForceBlackPenState ( void  )

Function GetGRForceBlackPenState.

Returns
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  xc,
int  yc,
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(), and GRArc1().

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 Bezier2Poly(), and GRPoly().

1235 {
1236  std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3 );
1237  GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
1238 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:767
std::vector< wxPoint > Bezier2Poly(wxPoint c1, wxPoint c2, wxPoint c3, wxPoint c4)
Function Bezier2Poly convert a Bezier curve to a polyline.
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 1241 of file gr_basic.cpp.

References Bezier2Poly(), and GRPoly().

1253 {
1254  std::vector<wxPoint> Points = Bezier2Poly( x1, y1, x2, y2, x3, y3, x4, y4 );
1255  GRPoly( ClipBox, DC, Points.size(), &Points[0], false, width, Color, Color );
1256 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:767
std::vector< wxPoint > Bezier2Poly(wxPoint c1, wxPoint c2, wxPoint c3, wxPoint c4)
Function Bezier2Poly convert a Bezier curve to a polyline.
void GRCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  xc,
int  yc,
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(), and GRCircle().

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 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 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(), and GRClosedPoly().

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

References GRLine().

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

1261 {
1262  int anchor_size = aDC->DeviceToLogicalXRel( aSize );
1263 
1264  GRLine( aClipBox, aDC,
1265  x - anchor_size, y,
1266  x + anchor_size, y, 0, aColor );
1267  GRLine( aClipBox, aDC,
1268  x, y - anchor_size,
1269  x, y + anchor_size, 0, aColor );
1270 }
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,
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 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 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(), D_CODE::DrawFlashedShape(), LIB_CIRCLE::drawGraphic(), drawMarker(), D_PAD::DrawShape(), GRFilledCircle(), 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(), and D_PAD::DrawShape().

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
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(), RATSNEST_ITEM::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(), 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_PROPERTIES::OnPaintShowPanel(), PCB_EDIT_FRAME::Solve(), and PCB_BASE_FRAME::TraceAirWiresToTargets().

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 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 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= 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,
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 GRRect ( EDA_RECT aClipBox,
wxDC *  aDC,
const EDA_RECT aRect,
int  aWidth,
COLOR4D  aColor 
)

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 GRRectPs ( EDA_RECT aClipBox,
wxDC *  aDC,
const EDA_RECT aRect,
COLOR4D  aColor,
wxPenStyle  aStyle 
)

Definition at line 1083 of file gr_basic.cpp.

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

1084 {
1085  int x1 = aRect.GetX();
1086  int y1 = aRect.GetY();
1087  int x2 = aRect.GetRight();
1088  int y2 = aRect.GetBottom();
1089 
1090  GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor, aStyle );
1091 }
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 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_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
static void GRSClosedPoly ( EDA_RECT aClipBox,
wxDC *  aDC,
int  aPointCount,
wxPoint  aPoints[],
bool  aFill,
int  aWidth,
COLOR4D  aColor,
COLOR4D  aBgColor 
)
static

Definition at line 700 of file gr_basic.cpp.

References ClipAndDrawPoly(), FILLED, GRLastMoveToX, GRLastMoveToY, GRLineTo(), GRMoveTo(), GRSetBrush(), GRSetColorPen(), IsGRSPolyDrawable(), wxPoint::x, and wxPoint::y.

Referenced by GRClosedPoly(), and GRSRect().

705 {
706  if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
707  return;
708 
709  if( aFill && ( aPointCount > 2 ) )
710  {
711  GRLastMoveToX = aPoints[aPointCount - 1].x;
712  GRLastMoveToY = aPoints[aPointCount - 1].y;
713  GRSetBrush( aDC, aBgColor, FILLED );
714  GRSetColorPen( aDC, aColor, aWidth );
715  ClipAndDrawPoly( aClipBox, aDC, aPoints, aPointCount );
716  }
717  else
718  {
719 #if defined( __WXMAC__ ) && defined( USE_WX_GRAPHICS_CONTEXT )
720  wxGCDC *gcdc = wxDynamicCast( aDC, wxGCDC );
721  if( gcdc )
722  {
723  wxGraphicsContext *gc = gcdc->GetGraphicsContext();
724 
725  // set pen
726  GRSetColorPen( aDC, aColor, aWidth );
727 
728  // create path
729  wxGraphicsPath path = gc->CreatePath();
730  path.MoveToPoint( aPoints[0].x, aPoints[0].y );
731  for( int i = 1; i < aPointCount; ++i )
732  {
733  path.AddLineToPoint( aPoints[i].x, aPoints[i].y );
734  }
735  if( aPoints[aPointCount - 1] != aPoints[0] )
736  path.AddLineToPoint( aPoints[0].x, aPoints[0].y );
737  // draw path
738  gc->StrokePath( path );
739 
740  // correctly update last position
741  GRMoveTo( aPoints[aPointCount - 1].x, aPoints[aPointCount - 1].y );
742  }
743  else
744 #endif
745  {
746  GRMoveTo( aPoints[0].x, aPoints[0].y );
747  for( int i = 1; i < aPointCount; ++i )
748  {
749  GRLineTo( aClipBox, aDC, aPoints[i].x, aPoints[i].y, aWidth, aColor );
750  }
751 
752  int lastpt = aPointCount - 1;
753 
754  // Close the polygon
755  if( aPoints[lastpt] != aPoints[0] )
756  {
757  GRLineTo( aClipBox, aDC, aPoints[0].x, aPoints[0].y, aWidth, aColor );
758  }
759  }
760  }
761 }
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
static bool IsGRSPolyDrawable(EDA_RECT *ClipBox, int n, wxPoint Points[])
Definition: gr_basic.cpp:600
static int GRLastMoveToX
Definition: gr_basic.cpp:67
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:401
static int GRLastMoveToY
Definition: gr_basic.cpp:67
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:240
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
void GRSetBrush ( wxDC *  DC,
COLOR4D  Color,
bool  fill 
)

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 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 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 GRSetDrawMode ( wxDC *  DC,
GR_DRAWMODE  draw_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(), RATSNEST_ITEM::Draw(), GBR_LAYOUT::Draw(), BLOCK_SELECTOR::Draw(), ZONE_CONTAINER::Draw(), SCH_TEXT::Draw(), SCH_FIELD::Draw(), TEXTE_MODULE::Draw(), TRACK::Draw(), DRAWSEGMENT::Draw(), DIMENSION::Draw(), GERBER_DRAW_ITEM::Draw(), LIB_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 aClipBox,
wxDC *  aDC,
int  x1,
int  y1,
int  x2,
int  y2,
int  aWidth,
COLOR4D  aColor,
COLOR4D  aBgColor 
)

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.
static void GRSPoly ( EDA_RECT ClipBox,
wxDC *  DC,
int  n,
wxPoint  Points[],
bool  Fill,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)
static

Definition at line 642 of file gr_basic.cpp.

References ClipAndDrawPoly(), FILLED, GRLineTo(), GRMoveTo(), GRSetBrush(), GRSetColorPen(), and IsGRSPolyDrawable().

Referenced by GRPoly().

645 {
646  if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
647  return;
648 
649  if( Fill && ( n > 2 ) )
650  {
651  GRSetBrush( DC, BgColor, FILLED );
652  GRSetColorPen( DC, Color, width );
653 
654  /* clip before send the filled polygon to wxDC, because under linux
655  * (GTK?) polygons having large coordinates are incorrectly drawn
656  * (integer overflow in coordinates, I am guessing)
657  */
658  ClipAndDrawPoly( ClipBox, DC, Points, n );
659  }
660  else
661  {
662 #if defined( __WXMAC__ ) && defined( USE_WX_GRAPHICS_CONTEXT )
663  wxGCDC *gcdc = wxDynamicCast( DC, wxGCDC );
664  if( gcdc )
665  {
666  wxGraphicsContext *gc = gcdc->GetGraphicsContext();
667 
668  // set pen
669  GRSetColorPen( DC, Color, width );
670 
671  // create path
672  wxGraphicsPath path = gc->CreatePath();
673  path.MoveToPoint( Points[0].x, Points[0].y );
674  for( int i = 1; i < n; ++i )
675  {
676  path.AddLineToPoint( Points[i].x, Points[i].y );
677  }
678  // draw path
679  gc->StrokePath( path );
680 
681  // correctly update last position
682  GRMoveTo( Points[n - 1].x, Points[n - 1].y );
683  }
684  else
685 #endif
686  {
687  GRMoveTo( Points[0].x, Points[0].y );
688  for( int i = 1; i < n; ++i )
689  {
690  GRLineTo( ClipBox, DC, Points[i].x, Points[i].y, width, Color );
691  }
692  }
693  }
694 }
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
static bool IsGRSPolyDrawable(EDA_RECT *ClipBox, int n, wxPoint Points[])
Definition: gr_basic.cpp:600
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:401
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:240
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
void GRSRect ( EDA_RECT aClipBox,
wxDC *  aDC,
int  x1,
int  y1,
int  x2,
int  y2,
int  aWidth,
COLOR4D  aColor,
wxPenStyle  aStyle = wxPENSTYLE_SOLID 
)
static

Definition at line 1138 of file gr_basic.cpp.

References GRSClosedPoly(), and NOT_FILLED.

Referenced by GRRect(), and GRRectPs().

1140 {
1141  wxPoint points[5];
1142  points[0] = wxPoint(x1, y1);
1143  points[1] = wxPoint(x1, y2);
1144  points[2] = wxPoint(x2, y2);
1145  points[3] = wxPoint(x2, y1);
1146  points[4] = points[0];
1147  GRSClosedPoly( aClipBox, aDC, 5, points, NOT_FILLED, aWidth,
1148  aColor, aColor );
1149 }
static const bool NOT_FILLED
Definition: gr_basic.cpp:21
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
static bool IsGRSPolyDrawable ( EDA_RECT ClipBox,
int  n,
wxPoint  Points[] 
)
static

Definition at line 600 of file gr_basic.cpp.

References EDA_RECT::GetBottom(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), max, min, wxPoint::x, xcliphi, xcliplo, wxPoint::y, ycliphi, and ycliplo.

Referenced by GRSClosedPoly(), and GRSPoly().

601 {
602  if( !ClipBox )
603  return true;
604 
605  if( n <= 0 )
606  return false;
607 
608  int Xmin, Xmax, Ymin, Ymax;
609 
610  Xmin = Xmax = Points[0].x;
611  Ymin = Ymax = Points[0].y;
612 
613  for( int ii = 1; ii < n; ii++ ) // calculate rectangle
614  {
615  Xmin = std::min( Xmin, Points[ii].x );
616  Xmax = std::max( Xmax, Points[ii].x );
617  Ymin = std::min( Ymin, Points[ii].y );
618  Ymax = std::max( Ymax, Points[ii].y );
619  }
620 
621  xcliplo = ClipBox->GetX();
622  ycliplo = ClipBox->GetY();
623  xcliphi = ClipBox->GetRight();
624  ycliphi = ClipBox->GetBottom();
625 
626  if( Xmax < xcliplo )
627  return false;
628  if( Xmin > xcliphi )
629  return false;
630  if( Ymax < ycliplo )
631  return false;
632  if( Ymin > ycliphi )
633  return false;
634 
635  return true;
636 }
static int ycliplo
Definition: gr_basic.cpp:71
static int ycliphi
Definition: gr_basic.cpp:73
static int xcliphi
Definition: gr_basic.cpp:72
static int xcliplo
Definition: gr_basic.cpp:70
int GetBottom() const
int GetRight() const
#define max(a, b)
Definition: auxiliary.h:86
int GetX() const
int GetY() const
#define min(a, b)
Definition: auxiliary.h:85
static void WinClipAndDrawLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width 
)
static

Definition at line 176 of file gr_basic.cpp.

References clipLine(), GRLastMoveToX, GRLastMoveToY, and EDA_RECT::Inflate().

Referenced by GRDashedLine(), GRFillCSegm(), GRFilledSegment(), and GRLine().

177 {
178  GRLastMoveToX = x2;
179  GRLastMoveToY = y2;
180 
181  if( ClipBox )
182  {
183  EDA_RECT clipbox(*ClipBox);
184  clipbox.Inflate(width/2);
185  if( clipLine( &clipbox, x1, y1, x2, y2 ) )
186  return;
187  }
188 
189  DC->DrawLine( x1, y1, x2, y2 );
190 }
static int GRLastMoveToX
Definition: gr_basic.cpp:67
static int GRLastMoveToY
Definition: gr_basic.cpp:67
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
Class EDA_RECT handles the component boundary box.

Variable Documentation

const bool FILLED = true
static

Definition at line 20 of file gr_basic.cpp.

Referenced by GRFilledArc(), GRFilledCircle(), GRSClosedPoly(), GRSFilledRect(), and GRSPoly().

int GRLastMoveToX
static
int GRLastMoveToY
static
const bool NOT_FILLED = false
static

Definition at line 21 of file gr_basic.cpp.

Referenced by GRArc(), GRCircle(), GRCSegm(), and GRSRect().

COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
static

Referenced by GRResetPenAndBrush(), and GRSetBrush().

bool s_DC_lastbrushfill = false
static

Definition at line 77 of file gr_basic.cpp.

Referenced by GRSetBrush().

COLOR4D s_DC_lastcolor(0, 0, 0, 0)
static

Referenced by GRDashedLine(), and GRResetPenAndBrush().

wxDC* s_DC_lastDC = NULL
static

Definition at line 78 of file gr_basic.cpp.

Referenced by GRResetPenAndBrush(), and GRSetBrush().

bool s_ForceBlackPen
static

Definition at line 68 of file gr_basic.cpp.

Referenced by GetGRForceBlackPenState(), GRForceBlackPen(), GRSetBrush(), and GRSetColorPen().

int xcliphi = 2000
static

Definition at line 72 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().

int xcliplo = 0
static

Definition at line 70 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().

int ycliphi = 2000
static

Definition at line 73 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().

int ycliplo = 0
static

Definition at line 71 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().