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 <base_screen.h>
#include <bezier_curves.h>
#include <math_for_graphics.h>
#include <wx/graphics.h>
#include <wx/tokenzr.h>
#include <geometry/geometry_utils.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 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, wxPenStyle aStyle)
 
void GRLine (EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle)
 
void GRDashedLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRDottedLine (EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
 
void GRMoveTo (int x, int y)
 
void GRLineTo (EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
 
void 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...
 
static bool clipCircle (EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
 
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)
 
void GRDrawWrappedText (wxDC &aDC, wxString const &aText)
 Draw text centered on a wxDC with wrapping. More...
 

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

#define DEBUG_DUMP_CLIP_ERROR_COORDS   0

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

1117 {
1118  if( aClipBox == NULL )
1119  {
1120  aDC->DrawPolygon( n, aPoints );
1121  return;
1122  }
1123 
1124  // A clip box exists: clip and draw the polygon.
1125  static std::vector<wxPoint> clippedPolygon;
1126  static pointVector inputPolygon, outputPolygon;
1127 
1128  inputPolygon.clear();
1129  outputPolygon.clear();
1130  clippedPolygon.clear();
1131 
1132  for( int ii = 0; ii < n; ii++ )
1133  inputPolygon.push_back( PointF( (REAL) aPoints[ii].x, (REAL) aPoints[ii].y ) );
1134 
1135  RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(),
1136  (REAL) aClipBox->GetWidth(), (REAL) aClipBox->GetHeight() );
1137 
1138  SutherlandHodgman sh( window );
1139  sh.Clip( inputPolygon, outputPolygon );
1140 
1141  for( cpointIterator cit = outputPolygon.begin(); cit != outputPolygon.end(); ++cit )
1142  {
1143  clippedPolygon.push_back( wxPoint( KiROUND( cit->X ), KiROUND( cit->Y ) ) );
1144  }
1145 
1146  if( clippedPolygon.size() )
1147  aDC->DrawPolygon( clippedPolygon.size(), &clippedPolygon[0] );
1148 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
std::vector< PointF > pointVector
double REAL
int GetHeight() const
Definition: eda_rect.h:118
std::vector< PointF >::const_iterator cpointIterator
int GetX() const
Definition: eda_rect.h:109
int GetWidth() const
Definition: eda_rect.h:117
int GetY() const
Definition: eda_rect.h:110
static bool clipCircle ( EDA_RECT aClipBox,
int  xc,
int  yc,
int  r,
int  aWidth 
)
static

Definition at line 725 of file gr_basic.cpp.

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

Referenced by GRCircle(), and GRFilledCircle().

726 {
727  // Clip circles that are outside the ClipBox.
728  if( aClipBox )
729  {
730  int x0, y0, xm, ym;
731  x0 = aClipBox->GetX();
732  y0 = aClipBox->GetY();
733  xm = aClipBox->GetRight();
734  ym = aClipBox->GetBottom();
735 
736  r += aWidth;
737 
738  if( xc < ( x0 - r ) )
739  return true;
740 
741  if( yc < ( y0 - r ) )
742  return true;
743 
744  if( xc > ( r + xm ) )
745  return true;
746 
747  if( yc > ( r + ym ) )
748  return true;
749  }
750 
751  return false;
752 }
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
int GetX() const
Definition: eda_rect.h:109
int GetY() const
Definition: eda_rect.h:110
bool GetGRForceBlackPenState ( void  )

Function GetGRForceBlackPenState.

Returns
s_ForceBlackPen (True if a black pen was forced)

Definition at line 214 of file gr_basic.cpp.

References s_ForceBlackPen.

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

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

Definition at line 908 of file gr_basic.cpp.

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

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

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

Definition at line 952 of file gr_basic.cpp.

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

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

Definition at line 799 of file gr_basic.cpp.

References GRArc1().

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

801 {
802  GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
803 }
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, COLOR4D Color)
Definition: gr_basic.cpp:799
void GRArc1 ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  xc,
int  yc,
int  width,
COLOR4D  Color 
)

Definition at line 809 of file gr_basic.cpp.

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

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

Definition at line 837 of file gr_basic.cpp.

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

839 {
840  GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
841  aWidth, aColor );
842 }
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, COLOR4D Color)
Definition: gr_basic.cpp:799
void GRBezier ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  x3,
int  y3,
int  width,
COLOR4D  Color 
)

Definition at line 1151 of file gr_basic.cpp.

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

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

Definition at line 1171 of file gr_basic.cpp.

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

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

Definition at line 755 of file gr_basic.cpp.

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

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

756 {
757  if( clipCircle( ClipBox, xc, yc, r, width ) || r <= 0 )
758  return;
759 
760  GRSetBrush( DC, Color, NOT_FILLED );
761  GRSetColorPen( DC, Color, width );
762  DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
763 }
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:725
static const bool NOT_FILLED
Definition: gr_basic.cpp:44
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:136
void GRCircle ( EDA_RECT ClipBox,
wxDC *  aDC,
int  x,
int  y,
int  aRadius,
COLOR4D  aColor 
)

Function GRCircle draws a circle onto the drawing context aDC centered at the user coordinates (x,y)

Parameters
ClipBoxdefines a rectangular boundary outside of which no drawing will occur.
aDCthe device context into which drawing should occur.
xThe x coordinate in user space of the center of the circle.
yThe y coordinate in user space of the center of the circle.
aRadiusis the radius of the circle.
aColoris the color to draw
See also
COLOR4D

Definition at line 766 of file gr_basic.cpp.

References GRCircle().

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

Definition at line 772 of file gr_basic.cpp.

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

773 {
774  GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
775 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:755
void GRClosedPoly ( EDA_RECT ClipBox,
wxDC *  aDC,
int  aPointCount,
wxPoint  aPoints[],
bool  doFill,
COLOR4D  aPenColor,
COLOR4D  aFillColor 
)

Function GRClosedPoly draws a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around it.

Parameters
ClipBoxdefines a rectangular boundary outside of which no drawing will occur.
aDCthe device context into which drawing should occur.
aPointCountthe number of points in the array aPoints.
aPointsThe points to draw.
doFilltrue if polygon is to be filled, else false and only the boundary is drawn.
aPenColorthe color of the border.
aFillColorthe fill color of the polygon's interior.

Definition at line 711 of file gr_basic.cpp.

References GRClosedPoly().

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

713 {
714  GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
715 }
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, COLOR4D Color, COLOR4D BgColor)
Function GRClosedPoly draws a closed polygon onto the drawing context aDC and optionally fills and/or...
Definition: gr_basic.cpp:711
void GRClosedPoly ( EDA_RECT ClipBox,
wxDC *  aDC,
int  aPointCount,
wxPoint  aPoints[],
bool  doFill,
int  aPenWidth,
COLOR4D  aPenColor,
COLOR4D  aFillColor 
)

Function GRClosedPoly draws a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around it.

Parameters
ClipBoxdefines a rectangular boundary outside of which no drawing will occur.
aDCthe device context into which drawing should occur.
aPointCountthe number of points in the array aPointArray.
aPointsthe points to draw.
doFilltrue if polygon is to be filled, else false and only the boundary is drawn.
aPenWidthis the width of the pen to use on the perimeter, can be zero.
aPenColorthe color of the border.
aFillColorthe fill color of the polygon's interior.

Definition at line 718 of file gr_basic.cpp.

References GRSClosedPoly().

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

Definition at line 415 of file gr_basic.cpp.

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

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

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

Definition at line 501 of file gr_basic.cpp.

References GRCSegm().

503 {
504  GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
505 }
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
Definition: gr_basic.cpp:415
void GRCSegm ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 508 of file gr_basic.cpp.

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

510 {
511  GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
512 }
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
Definition: gr_basic.cpp:415
void GRDashedLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 308 of file gr_basic.cpp.

References GRLine().

Referenced by LIB_ARC::drawEditGraphics().

311 {
312  GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_SHORT_DASH );
313 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:285
void GRDottedLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 316 of file gr_basic.cpp.

References GRLine().

319 {
320  GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_DOT );
321 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:285
void GRDrawAnchor ( EDA_RECT aClipBox,
wxDC *  aDC,
int  x,
int  y,
int  aSize,
COLOR4D  aColor 
)

Definition at line 1193 of file gr_basic.cpp.

References GRLine().

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

1195 {
1196  int anchor_size = aDC->DeviceToLogicalXRel( aSize );
1197 
1198  GRLine( aClipBox, aDC,
1199  x - anchor_size, y,
1200  x + anchor_size, y, 0, aColor );
1201  GRLine( aClipBox, aDC,
1202  x, y - anchor_size,
1203  x, y + anchor_size, 0, aColor );
1204 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:285
void GRDrawWrappedText ( wxDC &  aDC,
wxString const &  aText 
)

Draw text centered on a wxDC with wrapping.

Parameters
aDCwxDC instance onto which the text will be drawn
aTextthe text to draw

Definition at line 1207 of file gr_basic.cpp.

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

Definition at line 518 of file gr_basic.cpp.

References GRSetColorPen(), and WinClipAndDrawLine().

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

520 {
521  GRSetColorPen( DC, Color, width );
522  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
523 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:103
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:136
void GRFilledArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 848 of file gr_basic.cpp.

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

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

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

Definition at line 897 of file gr_basic.cpp.

References GRFilledArc().

900 {
901  GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
902 }
void GRFilledArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:848
void GRFilledCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  r,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 778 of file gr_basic.cpp.

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

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

780 {
781  if( clipCircle( ClipBox, x, y, r, width ) || r <= 0 )
782  return;
783 
784  GRSetBrush( DC, BgColor, FILLED );
785  GRSetColorPen( DC, Color, width );
786  DC->DrawEllipse( x - r, y - r, r + r, r + r );
787 }
static const bool FILLED
Definition: gr_basic.cpp:43
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:725
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:136
void GRFilledCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aPos,
int  aRadius,
COLOR4D  aColor 
)

Definition at line 790 of file gr_basic.cpp.

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

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

Definition at line 1043 of file gr_basic.cpp.

References GRSFilledRect().

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

1045 {
1046  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
1047 }
void GRSFilledRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:1078
void GRFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 1053 of file gr_basic.cpp.

References GRSFilledRect().

1055 {
1056  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
1057 }
void GRSFilledRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:1078
void GRFilledSegment ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 526 of file gr_basic.cpp.

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

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

528 {
529  GRSetColorPen( aDC, aColor, aWidth );
530  WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
531 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:103
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:136
void GRForceBlackPen ( bool  flagforce)

Function GRForceBlackPen.

Parameters
flagforceTrue to force a black pen whenever the asked color

Definition at line 204 of file gr_basic.cpp.

References s_ForceBlackPen.

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

205 {
206  s_ForceBlackPen = flagforce;
207 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:91
void GRLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color,
wxPenStyle  aStyle 
)

Definition at line 285 of file gr_basic.cpp.

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

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

294 {
295  GRSetColorPen( DC, Color, width, aStyle );
296  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
297  GRLastMoveToX = x2;
298  GRLastMoveToY = y2;
299 }
static int GRLastMoveToX
Definition: gr_basic.cpp:90
static int GRLastMoveToY
Definition: gr_basic.cpp:90
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:103
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:136
void GRLine ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor,
wxPenStyle  aStyle 
)

Definition at line 302 of file gr_basic.cpp.

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

303 {
304  GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
305 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:285
void 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 361 of file gr_basic.cpp.

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

Referenced by ZONE_CONTAINER::Draw().

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

Definition at line 337 of file gr_basic.cpp.

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

338 {
339  GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
340 }
static int GRLastMoveToX
Definition: gr_basic.cpp:90
static int GRLastMoveToY
Definition: gr_basic.cpp:90
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:285
void GRMixedLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 343 of file gr_basic.cpp.

References GRLine().

345 {
346  GRLine( ClipBox, DC, x1, y1, x2, y2, width, Color, wxPENSTYLE_DOT_DASH );
347 }
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:285
void GRMoveTo ( int  x,
int  y 
)

Definition at line 327 of file gr_basic.cpp.

References GRLastMoveToX, and GRLastMoveToY.

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

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

Definition at line 701 of file gr_basic.cpp.

References GRSPoly().

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

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

Definition at line 272 of file gr_basic.cpp.

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

Referenced by DisplayRoutingMatrix().

273 {
274  if( ClipBox && !ClipBox->Contains( x, y ) )
275  return;
276 
277  GRSetColorPen( DC, Color );
278  DC->DrawPoint( x, y );
279 }
bool Contains(const wxPoint &aPoint) const
Function Contains.
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:136
void GRRect ( EDA_RECT aClipBox,
wxDC *  aDC,
int  x1,
int  y1,
int  x2,
int  y2,
COLOR4D  aColor 
)
void GRRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 1023 of file gr_basic.cpp.

References GRSRect().

1024 {
1025  GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
1026 }
static void GRSRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:1064
void GRRect ( EDA_RECT aClipBox,
wxDC *  aDC,
const EDA_RECT aRect,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 1029 of file gr_basic.cpp.

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

1030 {
1031  int x1 = aRect.GetX();
1032  int y1 = aRect.GetY();
1033  int x2 = aRect.GetRight();
1034  int y2 = aRect.GetBottom();
1035 
1036  GRSRect( aClipBox, aDC, x1, y1, x2, y2, aWidth, aColor );
1037 }
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
int GetX() const
Definition: eda_rect.h:109
int GetY() const
Definition: eda_rect.h:110
static void GRSRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:1064
void GRRectPs ( EDA_RECT aClipBox,
wxDC *  aDC,
const EDA_RECT aRect,
COLOR4D  aColor,
wxPenStyle  aStyle 
)

Definition at line 1009 of file gr_basic.cpp.

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

1010 {
1011  int x1 = aRect.GetX();
1012  int y1 = aRect.GetY();
1013  int x2 = aRect.GetRight();
1014  int y2 = aRect.GetBottom();
1015 
1016  GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor, aStyle );
1017 }
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
int GetX() const
Definition: eda_rect.h:109
int GetY() const
Definition: eda_rect.h:110
static void GRSRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:1064
void GRResetPenAndBrush ( wxDC *  DC)

Definition at line 123 of file gr_basic.cpp.

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

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

124 {
125  GRSetBrush( DC, BLACK ); // Force no fill
126  s_DC_lastbrushcolor = COLOR4D::UNSPECIFIED;
127  s_DC_lastcolor = COLOR4D::UNSPECIFIED;
128  s_DC_lastDC = NULL;
129 }
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:101
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
static COLOR4D s_DC_lastcolor(0, 0, 0, 0)
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
Definition: colors.h:45
static void GRSClosedPoly ( EDA_RECT aClipBox,
wxDC *  aDC,
int  aPointCount,
wxPoint  aPoints[],
bool  aFill,
int  aWidth,
COLOR4D  aColor,
COLOR4D  aBgColor 
)
static

Definition at line 634 of file gr_basic.cpp.

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

Referenced by GRClosedPoly(), and GRSRect().

639 {
640  if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
641  return;
642 
643  if( aFill && ( aPointCount > 2 ) )
644  {
645  GRLastMoveToX = aPoints[aPointCount - 1].x;
646  GRLastMoveToY = aPoints[aPointCount - 1].y;
647  GRSetBrush( aDC, aBgColor, FILLED );
648  GRSetColorPen( aDC, aColor, aWidth );
649  ClipAndDrawPoly( aClipBox, aDC, aPoints, aPointCount );
650  }
651  else
652  {
653 #if defined( __WXMAC__ ) && defined( USE_WX_GRAPHICS_CONTEXT )
654  wxGCDC *gcdc = wxDynamicCast( aDC, wxGCDC );
655  if( gcdc )
656  {
657  wxGraphicsContext *gc = gcdc->GetGraphicsContext();
658 
659  // set pen
660  GRSetColorPen( aDC, aColor, aWidth );
661 
662  // create path
663  wxGraphicsPath path = gc->CreatePath();
664  path.MoveToPoint( aPoints[0].x, aPoints[0].y );
665  for( int i = 1; i < aPointCount; ++i )
666  {
667  path.AddLineToPoint( aPoints[i].x, aPoints[i].y );
668  }
669  if( aPoints[aPointCount - 1] != aPoints[0] )
670  path.AddLineToPoint( aPoints[0].x, aPoints[0].y );
671  // draw path
672  gc->StrokePath( path );
673 
674  // correctly update last position
675  GRMoveTo( aPoints[aPointCount - 1].x, aPoints[aPointCount - 1].y );
676  }
677  else
678 #endif
679  {
680  GRMoveTo( aPoints[0].x, aPoints[0].y );
681  for( int i = 1; i < aPointCount; ++i )
682  {
683  GRLineTo( aClipBox, aDC, aPoints[i].x, aPoints[i].y, aWidth, aColor );
684  }
685 
686  int lastpt = aPointCount - 1;
687 
688  // Close the polygon
689  if( aPoints[lastpt] != aPoints[0] )
690  {
691  GRLineTo( aClipBox, aDC, aPoints[0].x, aPoints[0].y, aWidth, aColor );
692  }
693  }
694  }
695 }
static void ClipAndDrawPoly(EDA_RECT *ClipBox, wxDC *DC, wxPoint Points[], int n)
Function ClipAndDrawPoly Used to clip a polygon and draw it as Filled Polygon uses the Sutherland and...
Definition: gr_basic.cpp:1116
static const bool FILLED
Definition: gr_basic.cpp:43
static bool IsGRSPolyDrawable(EDA_RECT *ClipBox, int n, wxPoint Points[])
Definition: gr_basic.cpp:534
static int GRLastMoveToX
Definition: gr_basic.cpp:90
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:337
static int GRLastMoveToY
Definition: gr_basic.cpp:90
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:327
size_t i
Definition: json11.cpp:597
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:136
void GRSetBrush ( wxDC *  DC,
COLOR4D  Color,
bool  fill 
)

Definition at line 173 of file gr_basic.cpp.

References BLACK, s_DC_lastbrushcolor, s_DC_lastbrushfill, s_DC_lastDC, and s_ForceBlackPen.

Referenced by GRArc(), GRArc1(), GRCircle(), GRCSegm(), GRFilledArc(), GRFilledCircle(), GRResetPenAndBrush(), GRSClosedPoly(), GRSFilledRect(), and GRSPoly().

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

References BLACK, and s_ForceBlackPen.

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

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

Definition at line 223 of file gr_basic.cpp.

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

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

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

Definition at line 1078 of file gr_basic.cpp.

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

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

1080 {
1081  wxPoint points[5];
1082  points[0] = wxPoint(x1, y1);
1083  points[1] = wxPoint(x1, y2);
1084  points[2] = wxPoint(x2, y2);
1085  points[3] = wxPoint(x2, y1);
1086  points[4] = points[0];
1087 
1088  GRSetBrush( aDC, aBgColor, FILLED );
1089  GRSetColorPen( aDC, aBgColor, aWidth );
1090 
1091  if( aClipBox && (aWidth > 0) )
1092  {
1093  EDA_RECT clipbox(*aClipBox);
1094  clipbox.Inflate(aWidth);
1095  ClipAndDrawPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
1096  }
1097  else
1098  ClipAndDrawPoly(aClipBox, aDC, points, 5 );
1099 }
static void ClipAndDrawPoly(EDA_RECT *ClipBox, wxDC *DC, wxPoint Points[], int n)
Function ClipAndDrawPoly Used to clip a polygon and draw it as Filled Polygon uses the Sutherland and...
Definition: gr_basic.cpp:1116
static const bool FILLED
Definition: gr_basic.cpp:43
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:136
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static void GRSPoly ( EDA_RECT ClipBox,
wxDC *  DC,
int  n,
wxPoint  Points[],
bool  Fill,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)
static

Definition at line 576 of file gr_basic.cpp.

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

Referenced by GRPoly().

579 {
580  if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
581  return;
582 
583  if( Fill && ( n > 2 ) )
584  {
585  GRSetBrush( DC, BgColor, FILLED );
586  GRSetColorPen( DC, Color, width );
587 
588  /* clip before send the filled polygon to wxDC, because under linux
589  * (GTK?) polygons having large coordinates are incorrectly drawn
590  * (integer overflow in coordinates, I am guessing)
591  */
592  ClipAndDrawPoly( ClipBox, DC, Points, n );
593  }
594  else
595  {
596 #if defined( __WXMAC__ ) && defined( USE_WX_GRAPHICS_CONTEXT )
597  wxGCDC *gcdc = wxDynamicCast( DC, wxGCDC );
598  if( gcdc )
599  {
600  wxGraphicsContext *gc = gcdc->GetGraphicsContext();
601 
602  // set pen
603  GRSetColorPen( DC, Color, width );
604 
605  // create path
606  wxGraphicsPath path = gc->CreatePath();
607  path.MoveToPoint( Points[0].x, Points[0].y );
608  for( int i = 1; i < n; ++i )
609  {
610  path.AddLineToPoint( Points[i].x, Points[i].y );
611  }
612  // draw path
613  gc->StrokePath( path );
614 
615  // correctly update last position
616  GRMoveTo( Points[n - 1].x, Points[n - 1].y );
617  }
618  else
619 #endif
620  {
621  GRMoveTo( Points[0].x, Points[0].y );
622  for( int i = 1; i < n; ++i )
623  {
624  GRLineTo( ClipBox, DC, Points[i].x, Points[i].y, width, Color );
625  }
626  }
627  }
628 }
static void ClipAndDrawPoly(EDA_RECT *ClipBox, wxDC *DC, wxPoint Points[], int n)
Function ClipAndDrawPoly Used to clip a polygon and draw it as Filled Polygon uses the Sutherland and...
Definition: gr_basic.cpp:1116
static const bool FILLED
Definition: gr_basic.cpp:43
static bool IsGRSPolyDrawable(EDA_RECT *ClipBox, int n, wxPoint Points[])
Definition: gr_basic.cpp:534
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:337
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:173
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:327
size_t i
Definition: json11.cpp:597
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width, wxPenStyle style)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context...
Definition: gr_basic.cpp:136
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 1064 of file gr_basic.cpp.

References GRSClosedPoly(), and NOT_FILLED.

Referenced by GRRect(), and GRRectPs().

1066 {
1067  wxPoint points[5];
1068  points[0] = wxPoint(x1, y1);
1069  points[1] = wxPoint(x1, y2);
1070  points[2] = wxPoint(x2, y2);
1071  points[3] = wxPoint(x2, y1);
1072  points[4] = points[0];
1073  GRSClosedPoly( aClipBox, aDC, 5, points, NOT_FILLED, aWidth,
1074  aColor, aColor );
1075 }
static const bool NOT_FILLED
Definition: gr_basic.cpp:44
static void GRSClosedPoly(EDA_RECT *aClipBox, wxDC *aDC, int aPointCount, wxPoint aPoints[], bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:634
static bool IsGRSPolyDrawable ( EDA_RECT ClipBox,
int  n,
wxPoint  Points[] 
)
static

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

535 {
536  if( !ClipBox )
537  return true;
538 
539  if( n <= 0 )
540  return false;
541 
542  int Xmin, Xmax, Ymin, Ymax;
543 
544  Xmin = Xmax = Points[0].x;
545  Ymin = Ymax = Points[0].y;
546 
547  for( int ii = 1; ii < n; ii++ ) // calculate rectangle
548  {
549  Xmin = std::min( Xmin, Points[ii].x );
550  Xmax = std::max( Xmax, Points[ii].x );
551  Ymin = std::min( Ymin, Points[ii].y );
552  Ymax = std::max( Ymax, Points[ii].y );
553  }
554 
555  xcliplo = ClipBox->GetX();
556  ycliplo = ClipBox->GetY();
557  xcliphi = ClipBox->GetRight();
558  ycliphi = ClipBox->GetBottom();
559 
560  if( Xmax < xcliplo )
561  return false;
562  if( Xmin > xcliphi )
563  return false;
564  if( Ymax < ycliplo )
565  return false;
566  if( Ymin > ycliphi )
567  return false;
568 
569  return true;
570 }
static int ycliplo
Definition: gr_basic.cpp:94
static int ycliphi
Definition: gr_basic.cpp:96
static int xcliphi
Definition: gr_basic.cpp:95
static int xcliplo
Definition: gr_basic.cpp:93
int GetBottom() const
Definition: eda_rect.h:122
int GetRight() const
Definition: eda_rect.h:119
#define max(a, b)
Definition: auxiliary.h:86
int GetX() const
Definition: eda_rect.h:109
int GetY() const
Definition: eda_rect.h:110
#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 103 of file gr_basic.cpp.

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

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

104 {
105  GRLastMoveToX = x2;
106  GRLastMoveToY = y2;
107 
108  if( ClipBox )
109  {
110  EDA_RECT clipbox(*ClipBox);
111  clipbox.Inflate(width/2);
112  if( ClipLine( &clipbox, x1, y1, x2, y2 ) )
113  return;
114  }
115 
116  DC->DrawLine( x1, y1, x2, y2 );
117 }
static int GRLastMoveToX
Definition: gr_basic.cpp:90
static int GRLastMoveToY
Definition: gr_basic.cpp:90
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.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44

Variable Documentation

const bool FILLED = true
static

Definition at line 43 of file gr_basic.cpp.

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

int GRLastMoveToX
static

Definition at line 90 of file gr_basic.cpp.

Referenced by GRCSegm(), GRLine(), GRLineTo(), GRMoveTo(), GRSClosedPoly(), and WinClipAndDrawLine().

int GRLastMoveToY
static

Definition at line 90 of file gr_basic.cpp.

Referenced by GRCSegm(), GRLine(), GRLineTo(), GRMoveTo(), GRSClosedPoly(), and WinClipAndDrawLine().

const bool NOT_FILLED = false
static

Definition at line 44 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 100 of file gr_basic.cpp.

Referenced by GRSetBrush().

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

Referenced by GRResetPenAndBrush().

wxDC* s_DC_lastDC = NULL
static

Definition at line 101 of file gr_basic.cpp.

Referenced by GRResetPenAndBrush(), and GRSetBrush().

bool s_ForceBlackPen
static

Definition at line 91 of file gr_basic.cpp.

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

int xcliphi = 2000
static

Definition at line 95 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().

int xcliplo = 0
static

Definition at line 93 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().

int ycliphi = 2000
static

Definition at line 96 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().

int ycliplo = 0
static

Definition at line 94 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().