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 <math/util.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, const wxPoint *Points, 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 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 GRMoveTo (int x, int y)
 
void GRLineTo (EDA_RECT *ClipBox, wxDC *DC, int x, int y, 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, const wxPoint *Points)
 
static void GRSPoly (EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
 
static void GRSClosedPoly (EDA_RECT *aClipBox, wxDC *aDC, int aPointCount, const wxPoint *aPoints, bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
 
void GRPoly (EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
 
void GRClosedPoly (EDA_RECT *ClipBox, wxDC *DC, int n, const 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, const 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 *aClipBox, wxDC *aDC, std::vector< wxPoint > &aPoint, int aWidth, COLOR4D aColor)
 Draw cubic (4 points: start control1, control2, end) bezier curve. More...
 
void GRDrawAnchor (EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor)
 
void GRDrawWrappedText (wxDC &aDC, wxString const &aText)
 Draw text centered on a wxDC with wrapping. More...
 

Variables

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

◆ DEBUG_DUMP_CLIP_COORDS

#define DEBUG_DUMP_CLIP_COORDS   0

Definition at line 68 of file gr_basic.cpp.

◆ DEBUG_DUMP_CLIP_ERROR_COORDS

#define DEBUG_DUMP_CLIP_ERROR_COORDS   0

Definition at line 67 of file gr_basic.cpp.

Function Documentation

◆ ClipAndDrawPoly()

void ClipAndDrawPoly ( EDA_RECT aClipBox,
wxDC *  aDC,
const wxPoint Points,
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 957 of file gr_basic.cpp.

958 {
959  if( aClipBox == NULL )
960  {
961  aDC->DrawPolygon( n, Points );
962  return;
963  }
964 
965  // A clip box exists: clip and draw the polygon.
966  static std::vector<wxPoint> clippedPolygon;
967  static pointVector inputPolygon, outputPolygon;
968 
969  inputPolygon.clear();
970  outputPolygon.clear();
971  clippedPolygon.clear();
972 
973  for( int ii = 0; ii < n; ii++ )
974  inputPolygon.push_back( PointF( (REAL) Points[ii].x, (REAL) Points[ii].y ) );
975 
976  RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(),
977  (REAL) aClipBox->GetWidth(), (REAL) aClipBox->GetHeight() );
978 
979  SutherlandHodgman sh( window );
980  sh.Clip( inputPolygon, outputPolygon );
981 
982  for( cpointIterator cit = outputPolygon.begin(); cit != outputPolygon.end(); ++cit )
983  {
984  clippedPolygon.emplace_back( KiROUND( cit->X ), KiROUND( cit->Y ) );
985  }
986 
987  if( clippedPolygon.size() )
988  aDC->DrawPolygon( clippedPolygon.size(), &clippedPolygon[0] );
989 }
int GetX() const
Definition: eda_rect.h:111
int GetWidth() const
Definition: eda_rect.h:119
#define NULL
int GetHeight() const
Definition: eda_rect.h:120
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
int GetY() const
Definition: eda_rect.h:112

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

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

◆ clipCircle()

static bool clipCircle ( EDA_RECT aClipBox,
int  xc,
int  yc,
int  r,
int  aWidth 
)
static

Definition at line 566 of file gr_basic.cpp.

567 {
568  // Clip circles that are outside the ClipBox.
569  if( aClipBox )
570  {
571  int x0, y0, xm, ym;
572  x0 = aClipBox->GetX();
573  y0 = aClipBox->GetY();
574  xm = aClipBox->GetRight();
575  ym = aClipBox->GetBottom();
576 
577  r += aWidth;
578 
579  if( xc < ( x0 - r ) )
580  return true;
581 
582  if( yc < ( y0 - r ) )
583  return true;
584 
585  if( xc > ( r + xm ) )
586  return true;
587 
588  if( yc > ( r + ym ) )
589  return true;
590  }
591 
592  return false;
593 }
int GetX() const
Definition: eda_rect.h:111
int GetBottom() const
Definition: eda_rect.h:124
int GetRight() const
Definition: eda_rect.h:121
int GetY() const
Definition: eda_rect.h:112

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

Referenced by GRCircle(), and GRFilledCircle().

◆ GetGRForceBlackPenState()

bool GetGRForceBlackPenState ( void  )

Function GetGRForceBlackPenState.

Returns
s_ForceBlackPen (True if a black pen was forced)

Definition at line 211 of file gr_basic.cpp.

212 {
213  return s_ForceBlackPen;
214 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:88

References s_ForceBlackPen.

Referenced by BITMAP_BASE::DrawBitmap(), LIB_PART::Print(), VIA::Print(), and D_PAD::PrintShape().

◆ GRArc() [1/2]

void GRArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  xc,
int  yc,
double  StAngle,
double  EndAngle,
int  r,
COLOR4D  Color 
)

Definition at line 749 of file gr_basic.cpp.

751 {
752  int x1, y1, x2, y2;
753 
754  /* Clip arcs off screen */
755  if( ClipBox )
756  {
757  int radius = r + 1;
758  int x0, y0, xm, ym, x, y;
759  x0 = ClipBox->GetX();
760  y0 = ClipBox->GetY();
761  xm = ClipBox->GetRight();
762  ym = ClipBox->GetBottom();
763  x = xc;
764  y = yc;
765 
766  if( x < ( x0 - radius ) )
767  return;
768  if( y < ( y0 - radius ) )
769  return;
770  if( x > ( xm + radius ) )
771  return;
772  if( y > ( ym + radius ) )
773  return;
774  }
775 
776  x1 = r;
777  y1 = 0;
778  RotatePoint( &x1, &y1, EndAngle );
779 
780  x2 = r;
781  y2 = 0;
782  RotatePoint( &x2, &y2, StAngle );
783 
784  GRSetBrush( DC, Color, NOT_FILLED );
785  GRSetColorPen( DC, Color );
786  DC->DrawArc( xc + x1, yc - y1, xc + x2, yc - y2, xc, yc );
787 }
int GetX() const
Definition: eda_rect.h:111
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
int GetBottom() const
Definition: eda_rect.h:124
static const bool NOT_FILLED
Definition: gr_basic.cpp:42
int GetRight() const
Definition: eda_rect.h:121
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
int GetY() const
Definition: eda_rect.h:112

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

Referenced by EDGE_MODULE::Print(), and DRAWSEGMENT::Print().

◆ GRArc() [2/2]

void GRArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
int  width,
COLOR4D  Color 
)

Definition at line 793 of file gr_basic.cpp.

802 {
803  int x1, y1, x2, y2;
804 
805  /* Clip arcs off screen. */
806  if( ClipBox )
807  {
808  int x0, y0, xm, ym;
809  x0 = ClipBox->GetX();
810  y0 = ClipBox->GetY();
811  xm = ClipBox->GetRight();
812  ym = ClipBox->GetBottom();
813 
814  if( x < ( x0 - r - width ) )
815  return;
816 
817  if( y < ( y0 - r - width ) )
818  return;
819 
820  if( x > ( r + xm + width ) )
821  return;
822 
823  if( y > ( r + ym + width ) )
824  return;
825  }
826 
827  x1 = r;
828  y1 = 0;
829  RotatePoint( &x1, &y1, EndAngle );
830 
831  x2 = r;
832  y2 = 0;
833  RotatePoint( &x2, &y2, StAngle );
834 
835  GRSetBrush( DC, Color );
836  GRSetColorPen( DC, Color, width );
837  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
838 }
int GetX() const
Definition: eda_rect.h:111
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
int GetBottom() const
Definition: eda_rect.h:124
int GetRight() const
Definition: eda_rect.h:121
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
int GetY() const
Definition: eda_rect.h:112

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

◆ GRArc1() [1/3]

void GRArc1 ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  xc,
int  yc,
COLOR4D  Color 
)

Definition at line 640 of file gr_basic.cpp.

642 {
643  GRArc1( ClipBox, DC, x1, y1, x2, y2, xc, yc, 0, Color );
644 }
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:640

References GRArc1().

Referenced by GRArc1(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), LIB_ARC::print(), and GERBER_DRAW_ITEM::Print().

◆ GRArc1() [2/3]

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

652 {
653  /* Clip arcs off screen. */
654  if( ClipBox )
655  {
656  int x0, y0, xm, ym, r;
657  x0 = ClipBox->GetX();
658  y0 = ClipBox->GetY();
659  xm = ClipBox->GetRight();
660  ym = ClipBox->GetBottom();
661  r = KiROUND( Distance( x1, y1, xc, yc ) );
662  if( xc < ( x0 - r ) )
663  return;
664  if( yc < ( y0 - r ) )
665  return;
666  if( xc > ( r + xm ) )
667  return;
668  if( yc > ( r + ym ) )
669  return;
670  }
671 
672  GRSetBrush( DC, Color );
673  GRSetColorPen( DC, Color, width );
674  DC->DrawArc( x1, y1, x2, y2, xc, yc );
675 }
int GetX() const
Definition: eda_rect.h:111
int GetBottom() const
Definition: eda_rect.h:124
int GetRight() const
Definition: eda_rect.h:121
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
int GetY() const
Definition: eda_rect.h:112

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

◆ GRArc1() [3/3]

void GRArc1 ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
wxPoint  aCenter,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 678 of file gr_basic.cpp.

680 {
681  GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
682  aWidth, aColor );
683 }
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:640

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

◆ GRBezier()

void GRBezier ( EDA_RECT aClipBox,
wxDC *  aDC,
std::vector< wxPoint > &  aPoint,
int  aWidth,
COLOR4D  aColor 
)

Draw cubic (4 points: start control1, control2, end) bezier curve.

Definition at line 992 of file gr_basic.cpp.

995 {
996  std::vector<wxPoint> output;
997 
998  BEZIER_POLY converter( aPoint );
999  converter.GetPoly( output, aWidth );
1000 
1001  GRPoly( aClipBox, aDC, output.size(), &output[0], false, aWidth, aColor, aColor );
1002 }
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:542
Bezier curves to polygon converter.
Definition: bezier_curves.h:35

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

◆ GRCircle() [1/3]

void GRCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  xc,
int  yc,
int  r,
int  width,
COLOR4D  Color 
)

Definition at line 596 of file gr_basic.cpp.

597 {
598  if( clipCircle( ClipBox, xc, yc, r, width ) || r <= 0 )
599  return;
600 
601  GRSetBrush( DC, Color, NOT_FILLED );
602  GRSetColorPen( DC, Color, width );
603  DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
604 }
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:566
static const bool NOT_FILLED
Definition: gr_basic.cpp:42
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133

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

Referenced by D_CODE::DrawFlashedShape(), GRCircle(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), LIB_CIRCLE::print(), PCB_TARGET::Print(), EDGE_MODULE::Print(), DRAWSEGMENT::Print(), GERBER_DRAW_ITEM::Print(), VIA::Print(), LIB_PIN::PrintPinSymbol(), and D_PAD::PrintShape().

◆ GRCircle() [2/3]

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

608 {
609  GRCircle( ClipBox, DC, x, y, r, 0, Color );
610 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:596

References GRCircle().

◆ GRCircle() [3/3]

void GRCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aPos,
int  aRadius,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 613 of file gr_basic.cpp.

614 {
615  GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
616 }
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:596

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

◆ GRClosedPoly() [1/2]

void GRClosedPoly ( EDA_RECT ClipBox,
wxDC *  aDC,
int  aPointCount,
const 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 552 of file gr_basic.cpp.

554 {
555  GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
556 }
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const 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:552

References GRClosedPoly().

Referenced by APERTURE_MACRO::DrawApertureMacroShape(), D_CODE::DrawFlashedPolygon(), GRClosedPoly(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), DRAWSEGMENT::Print(), GERBER_DRAW_ITEM::PrintGerberPoly(), MARKER_BASE::PrintMarker(), and D_PAD::PrintShape().

◆ GRClosedPoly() [2/2]

void GRClosedPoly ( EDA_RECT ClipBox,
wxDC *  aDC,
int  aPointCount,
const 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 559 of file gr_basic.cpp.

561 {
562  GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
563 }
static void GRSClosedPoly(EDA_RECT *aClipBox, wxDC *aDC, int aPointCount, const wxPoint *aPoints, bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:505

References GRSClosedPoly().

◆ GRCSegm() [1/3]

void GRCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
int  aPenSize,
COLOR4D  Color 
)

Definition at line 312 of file gr_basic.cpp.

314 {
315  GRLastMoveToX = x2;
316  GRLastMoveToY = y2;
317 
318  if( ClipBox )
319  {
320  EDA_RECT clipbox(*ClipBox);
321  clipbox.Inflate(width/2);
322 
323  if( ClipLine( &clipbox, x1, y1, x2, y2 ) )
324  return;
325  }
326 
327 
328  if( width <= 2 ) /* single line or 2 pixels */
329  {
330  GRSetColorPen( DC, Color, width );
331  DC->DrawLine( x1, y1, x2, y2 );
332  return;
333  }
334 
335  GRSetBrush( DC, Color, NOT_FILLED );
336  GRSetColorPen( DC, Color, aPenSize );
337 
338  int radius = (width + 1) >> 1;
339  int dx = x2 - x1;
340  int dy = y2 - y1;
341  double angle = -ArcTangente( dy, dx );
342  wxPoint start;
343  wxPoint end;
344  wxPoint org( x1, y1);
345  int len = (int) hypot( dx, dy );
346 
347  // We know if the DC is mirrored, to draw arcs
348  int slx = DC->DeviceToLogicalX( 1 ) - DC->DeviceToLogicalX( 0 );
349  int sly = DC->DeviceToLogicalY( 1 ) - DC->DeviceToLogicalY( 0 );
350  bool mirrored = (slx > 0 && sly < 0) || (slx < 0 && sly > 0);
351 
352  // first edge
353  start.x = 0;
354  start.y = radius;
355  end.x = len;
356  end.y = radius;
357  RotatePoint( &start, angle);
358  RotatePoint( &end, angle);
359 
360  start += org;
361  end += org;
362 
363  DC->DrawLine( start, end );
364 
365  // first rounded end
366  end.x = 0;
367  end.y = -radius;
368  RotatePoint( &end, angle);
369  end += org;
370 
371  if( !mirrored )
372  DC->DrawArc( end, start, org );
373  else
374  DC->DrawArc( start, end, org );
375 
376 
377  // second edge
378  start.x = len;
379  start.y = -radius;
380  RotatePoint( &start, angle);
381  start += org;
382 
383  DC->DrawLine( start, end );
384 
385  // second rounded end
386  end.x = len;
387  end.y = radius;
388  RotatePoint( &end, angle);
389  end += org;
390 
391  if( !mirrored )
392  DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
393  else
394  DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
395 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
static int GRLastMoveToX
Definition: gr_basic.cpp:87
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 const bool NOT_FILLED
Definition: gr_basic.cpp:42
static int GRLastMoveToY
Definition: gr_basic.cpp:87
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162

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

Referenced by D_CODE::DrawFlashedShape(), BASIC_GAL::DrawLine(), BASIC_GAL::DrawPolyline(), GRCSegm(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), PCB_TARGET::Print(), EDGE_MODULE::Print(), TRACK::Print(), DIMENSION::Print(), DRAWSEGMENT::Print(), GERBER_DRAW_ITEM::Print(), ZONE_CONTAINER::PrintFilledArea(), and D_PAD::PrintShape().

◆ GRCSegm() [2/3]

void GRCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 398 of file gr_basic.cpp.

400 {
401  GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
402 }
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:312

References GRCSegm().

◆ GRCSegm() [3/3]

void GRCSegm ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 405 of file gr_basic.cpp.

407 {
408  GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
409 }
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:312

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

◆ GRDrawAnchor()

void GRDrawAnchor ( EDA_RECT aClipBox,
wxDC *  aDC,
int  x,
int  y,
int  aSize,
COLOR4D  aColor 
)

Definition at line 1005 of file gr_basic.cpp.

1007 {
1008  int anchor_size = aDC->DeviceToLogicalXRel( aSize );
1009 
1010  GRLine( aClipBox, aDC,
1011  x - anchor_size, y,
1012  x + anchor_size, y, 0, aColor );
1013  GRLine( aClipBox, aDC,
1014  x, y - anchor_size,
1015  x, y + anchor_size, 0, aColor );
1016 }
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:230

References GRLine().

◆ GRDrawWrappedText()

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

1020 {
1021  wxStringTokenizer tokenizer( aText, " " );
1022  wxSize const dc_size = aDC.GetSize();
1023  wxSize const margin = aDC.GetTextExtent( " " );
1024  std::vector<wxString> lines;
1025  wxString line_accumulator;
1026  int total_height = 0;
1027 
1028  while( tokenizer.HasMoreTokens() )
1029  {
1030  wxString word = tokenizer.GetNextToken();
1031  wxSize linesize = aDC.GetTextExtent( line_accumulator + " " + word );
1032 
1033  if( linesize.x >= dc_size.x - margin.x && !line_accumulator.IsEmpty() )
1034  {
1035  lines.push_back( line_accumulator );
1036  line_accumulator = word;
1037  }
1038  else
1039  {
1040  line_accumulator += " ";
1041  line_accumulator += word;
1042  }
1043  }
1044 
1045  if( !line_accumulator.IsEmpty() )
1046  {
1047  lines.push_back( line_accumulator );
1048  }
1049 
1050  for( auto const& line: lines )
1051  {
1052  wxSize linesize = aDC.GetTextExtent( line );
1053  total_height += linesize.y;
1054  }
1055 
1056  int top = ( dc_size.y - total_height ) / 2;
1057  int pos = top;
1058 
1059  for( auto const& line: lines )
1060  {
1061  wxSize linesize = aDC.GetTextExtent( line );
1062  aDC.DrawText( line, ( dc_size.x - linesize.x ) / 2, pos );
1063  pos += linesize.y;
1064  }
1065 }

◆ GRFillCSegm()

void GRFillCSegm ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 415 of file gr_basic.cpp.

417 {
418  GRSetColorPen( DC, Color, width );
419  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
420 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:100
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:133

References GRSetColorPen(), and WinClipAndDrawLine().

Referenced by D_CODE::DrawFlashedShape(), TRACK::Print(), DRAWSEGMENT::Print(), and D_PAD::PrintShape().

◆ GRFilledArc() [1/2]

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

699 {
700  int x1, y1, x2, y2;
701 
702  /* Clip arcs off screen */
703  if( ClipBox )
704  {
705  int x0, y0, xm, ym;
706  x0 = ClipBox->GetX();
707  y0 = ClipBox->GetY();
708  xm = ClipBox->GetRight();
709  ym = ClipBox->GetBottom();
710 
711  if( x < ( x0 - r - 1 ) )
712  return;
713 
714  if( y < ( y0 - r - 1 ) )
715  return;
716 
717  if( x > ( r + xm + 1 ) )
718  return;
719 
720  if( y > ( r + ym + 1 ) )
721  return;
722  }
723 
724  x1 = r;
725  y1 = 0;
726  RotatePoint( &x1, &y1, EndAngle );
727 
728  x2 = r;
729  y2 = 0;
730  RotatePoint( &x2, &y2, StAngle );
731 
732  GRSetBrush( DC, BgColor, FILLED );
733  GRSetColorPen( DC, Color, width );
734  DC->DrawArc( x + x1, y - y1, x + x2, y - y2, x, y );
735 }
static const bool FILLED
Definition: gr_basic.cpp:41
int GetX() const
Definition: eda_rect.h:111
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
int GetBottom() const
Definition: eda_rect.h:124
int GetRight() const
Definition: eda_rect.h:121
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133
int GetY() const
Definition: eda_rect.h:112

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

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

◆ GRFilledArc() [2/2]

void GRFilledArc ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
double  StAngle,
double  EndAngle,
int  r,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 738 of file gr_basic.cpp.

741 {
742  GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
743 }
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:689

References GRFilledArc().

◆ GRFilledCircle() [1/2]

void GRFilledCircle ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  r,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 619 of file gr_basic.cpp.

621 {
622  if( clipCircle( ClipBox, x, y, r, width ) || r <= 0 )
623  return;
624 
625  GRSetBrush( DC, BgColor, FILLED );
626  GRSetColorPen( DC, Color, width );
627  DC->DrawEllipse( x - r, y - r, r + r, r + r );
628 }
static const bool FILLED
Definition: gr_basic.cpp:41
static bool clipCircle(EDA_RECT *aClipBox, int xc, int yc, int r, int aWidth)
Definition: gr_basic.cpp:566
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
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:133

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

Referenced by D_CODE::DrawFlashedShape(), GRFilledCircle(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), LIB_CIRCLE::print(), SCH_JUNCTION::Print(), VIA::Print(), and D_PAD::PrintShape().

◆ GRFilledCircle() [2/2]

void GRFilledCircle ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aPos,
int  aRadius,
COLOR4D  aColor 
)

Definition at line 631 of file gr_basic.cpp.

632 {
633  GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor );
634 }
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:619

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

◆ GRFilledRect() [1/2]

void GRFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 884 of file gr_basic.cpp.

886 {
887  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
888 }
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:919

References GRSFilledRect().

Referenced by D_CODE::DrawFlashedShape(), LIB_RECTANGLE::print(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

◆ GRFilledRect() [2/2]

void GRFilledRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 894 of file gr_basic.cpp.

896 {
897  GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
898 }
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:919

References GRSFilledRect().

◆ GRFilledSegment()

void GRFilledSegment ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 423 of file gr_basic.cpp.

425 {
426  GRSetColorPen( aDC, aColor, aWidth );
427  WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
428 }
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:100
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:133

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

Referenced by DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), EDGE_MODULE::Print(), DRAWSEGMENT::Print(), GERBER_DRAW_ITEM::Print(), ZONE_CONTAINER::PrintFilledArea(), and D_PAD::PrintShape().

◆ GRForceBlackPen()

void GRForceBlackPen ( bool  flagforce)

Function GRForceBlackPen.

Parameters
flagforceTrue to force a black pen whenever the asked color

Definition at line 201 of file gr_basic.cpp.

202 {
203  s_ForceBlackPen = flagforce;
204 }
static bool s_ForceBlackPen
Definition: gr_basic.cpp:88

References s_ForceBlackPen.

Referenced by SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), VIA::Print(), SCH_PRINTOUT::PrintPage(), and D_PAD::PrintShape().

◆ GRLine() [1/2]

void GRLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color,
wxPenStyle  aStyle 
)

Definition at line 230 of file gr_basic.cpp.

239 {
240  GRSetColorPen( DC, Color, width, aStyle );
241  WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
242  GRLastMoveToX = x2;
243  GRLastMoveToY = y2;
244 }
static int GRLastMoveToX
Definition: gr_basic.cpp:87
static int GRLastMoveToY
Definition: gr_basic.cpp:87
static void WinClipAndDrawLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width)
Definition: gr_basic.cpp:100
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:133

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

Referenced by BASIC_GAL::DrawLine(), GRDrawAnchor(), GRLine(), GRLineTo(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), SCH_NO_CONNECT::Print(), SCH_BUS_ENTRY_BASE::Print(), PCB_TARGET::Print(), EDGE_MODULE::Print(), TRACK::Print(), SCH_LINE::Print(), DIMENSION::Print(), VIA::Print(), LIB_PIN::PrintPinSymbol(), D_PAD::PrintShape(), and WS_DRAW_ITEM_LINE::PrintWsItem().

◆ GRLine() [2/2]

void GRLine ( EDA_RECT aClipBox,
wxDC *  aDC,
wxPoint  aStart,
wxPoint  aEnd,
int  aWidth,
COLOR4D  aColor,
wxPenStyle  aStyle 
)

Definition at line 247 of file gr_basic.cpp.

248 {
249  GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
250 }
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:230

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

◆ GRLineArray()

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

286 {
287  if( aLines.empty() )
288  return;
289 
290  GRSetColorPen( aDC, aColor, aWidth );
291 
292  if( aClipBox )
293  aClipBox->Inflate( aWidth / 2 );
294 
295  for( unsigned i = 0; i < aLines.size(); i += 2 )
296  {
297  int x1 = aLines[i].x;
298  int y1 = aLines[i].y;
299  int x2 = aLines[i + 1].x;
300  int y2 = aLines[i + 1].y;
301  if( ( aClipBox == NULL ) || !ClipLine( aClipBox, x1, y1, x2, y2 ) )
302  aDC->DrawLine( x1, y1, x2, y2 );
303  }
304 
305  GRMoveTo( aLines[aLines.size() - 1].x, aLines[aLines.size() - 1].y );
306 
307  if( aClipBox )
308  aClipBox->Inflate(-aWidth/2);
309 }
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.
#define NULL
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:256
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:133
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.

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

Referenced by ZONE_CONTAINER::Print().

◆ GRLineTo()

void GRLineTo ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
int  width,
COLOR4D  Color 
)

Definition at line 266 of file gr_basic.cpp.

267 {
268  GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
269 }
static int GRLastMoveToX
Definition: gr_basic.cpp:87
static int GRLastMoveToY
Definition: gr_basic.cpp:87
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:230

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

◆ GRMoveTo()

void GRMoveTo ( int  x,
int  y 
)

Definition at line 256 of file gr_basic.cpp.

257 {
258  GRLastMoveToX = x;
259  GRLastMoveToY = y;
260 }
static int GRLastMoveToX
Definition: gr_basic.cpp:87
static int GRLastMoveToY
Definition: gr_basic.cpp:87

References GRLastMoveToX, and GRLastMoveToY.

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

◆ GRPoly()

void GRPoly ( EDA_RECT ClipBox,
wxDC *  DC,
int  n,
const wxPoint Points,
bool  Fill,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)

Definition at line 542 of file gr_basic.cpp.

544 {
545  GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
546 }
static void GRSPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:473

References GRSPoly().

Referenced by BASIC_GAL::DrawPolyline(), GRBezier(), LIB_POLYLINE::print(), LIB_BEZIER::print(), EDGE_MODULE::Print(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), ZONE_CONTAINER::PrintFilledArea(), and WS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem().

◆ GRPutPixel()

void GRPutPixel ( EDA_RECT ClipBox,
wxDC *  DC,
int  x,
int  y,
COLOR4D  Color 
)

Definition at line 217 of file gr_basic.cpp.

218 {
219  if( ClipBox && !ClipBox->Contains( x, y ) )
220  return;
221 
222  GRSetColorPen( DC, Color );
223  DC->DrawPoint( x, y );
224 }
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:133

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

◆ GRRect() [1/3]

void GRRect ( EDA_RECT aClipBox,
wxDC *  aDC,
int  x1,
int  y1,
int  x2,
int  y2,
COLOR4D  aColor 
)

Definition at line 844 of file gr_basic.cpp.

845 {
846  GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor );
847 }
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:905

References GRSRect().

Referenced by D_CODE::DrawFlashedShape(), LIB_RECTANGLE::print(), SCH_SHEET::Print(), and WS_DRAW_ITEM_RECT::PrintWsItem().

◆ GRRect() [2/3]

void GRRect ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width,
COLOR4D  Color 
)

Definition at line 864 of file gr_basic.cpp.

865 {
866  GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
867 }
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:905

References GRSRect().

◆ GRRect() [3/3]

void GRRect ( EDA_RECT aClipBox,
wxDC *  aDC,
const EDA_RECT aRect,
int  aWidth,
COLOR4D  aColor 
)

Definition at line 870 of file gr_basic.cpp.

871 {
872  int x1 = aRect.GetX();
873  int y1 = aRect.GetY();
874  int x2 = aRect.GetRight();
875  int y2 = aRect.GetBottom();
876 
877  GRSRect( aClipBox, aDC, x1, y1, x2, y2, aWidth, aColor );
878 }
int GetX() const
Definition: eda_rect.h:111
int GetBottom() const
Definition: eda_rect.h:124
int GetRight() const
Definition: eda_rect.h:121
int GetY() const
Definition: eda_rect.h:112
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:905

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

◆ GRRectPs()

void GRRectPs ( EDA_RECT aClipBox,
wxDC *  aDC,
const EDA_RECT aRect,
COLOR4D  aColor,
wxPenStyle  aStyle 
)

Definition at line 850 of file gr_basic.cpp.

851 {
852  int x1 = aRect.GetX();
853  int y1 = aRect.GetY();
854  int x2 = aRect.GetRight();
855  int y2 = aRect.GetBottom();
856 
857  GRSRect( aClipBox, aDC, x1, y1, x2, y2, 0, aColor, aStyle );
858 }
int GetX() const
Definition: eda_rect.h:111
int GetBottom() const
Definition: eda_rect.h:124
int GetRight() const
Definition: eda_rect.h:121
int GetY() const
Definition: eda_rect.h:112
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:905

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

◆ GRResetPenAndBrush()

void GRResetPenAndBrush ( wxDC *  DC)

Definition at line 120 of file gr_basic.cpp.

121 {
122  GRSetBrush( DC, BLACK ); // Force no fill
123  s_DC_lastbrushcolor = COLOR4D::UNSPECIFIED;
124  s_DC_lastcolor = COLOR4D::UNSPECIFIED;
125  s_DC_lastDC = NULL;
126 }
#define NULL
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:98
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:170
Definition: colors.h:45

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

Referenced by SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), SCH_PRINTOUT::PrintPage(), and DIALOG_PAGES_SETTINGS::UpdatePageLayoutExample().

◆ GRSClosedPoly()

static void GRSClosedPoly ( EDA_RECT aClipBox,
wxDC *  aDC,
int  aPointCount,
const wxPoint aPoints,
bool  aFill,
int  aWidth,
COLOR4D  aColor,
COLOR4D  aBgColor 
)
static

Definition at line 505 of file gr_basic.cpp.

507 {
508  if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
509  return;
510 
511  if( aFill && ( aPointCount > 2 ) )
512  {
513  GRLastMoveToX = aPoints[aPointCount - 1].x;
514  GRLastMoveToY = aPoints[aPointCount - 1].y;
515  GRSetBrush( aDC, aBgColor, FILLED );
516  GRSetColorPen( aDC, aColor, aWidth );
517  ClipAndDrawPoly( aClipBox, aDC, aPoints, aPointCount );
518  }
519  else
520  {
521 
522  GRMoveTo( aPoints[0].x, aPoints[0].y );
523  for( int i = 1; i < aPointCount; ++i )
524  {
525  GRLineTo( aClipBox, aDC, aPoints[i].x, aPoints[i].y, aWidth, aColor );
526  }
527 
528  int lastpt = aPointCount - 1;
529 
530  // Close the polygon
531  if( aPoints[lastpt] != aPoints[0] )
532  {
533  GRLineTo( aClipBox, aDC, aPoints[0].x, aPoints[0].y, aWidth, aColor );
534  }
535  }
536 }
static const bool FILLED
Definition: gr_basic.cpp:41
static int GRLastMoveToX
Definition: gr_basic.cpp:87
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:266
static int GRLastMoveToY
Definition: gr_basic.cpp:87
static bool IsGRSPolyDrawable(EDA_RECT *ClipBox, int n, const wxPoint *Points)
Definition: gr_basic.cpp:431
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:256
static void ClipAndDrawPoly(EDA_RECT *ClipBox, wxDC *DC, const 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:957
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:133

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

Referenced by GRClosedPoly(), and GRSRect().

◆ GRSetBrush()

void GRSetBrush ( wxDC *  DC,
COLOR4D  Color,
bool  fill 
)

Definition at line 170 of file gr_basic.cpp.

171 {
172  if( s_ForceBlackPen )
173  Color = COLOR4D::BLACK;
174 
175  if( s_DC_lastbrushcolor != Color
176  || s_DC_lastbrushfill != fill
177  || s_DC_lastDC != DC )
178  {
179  wxBrush brush;
180 
181  brush.SetColour( Color.ToColour() );
182 
183  if( fill )
184  brush.SetStyle( wxBRUSHSTYLE_SOLID );
185  else
186  brush.SetStyle( wxBRUSHSTYLE_TRANSPARENT );
187 
188  DC->SetBrush( brush );
189 
190  s_DC_lastbrushcolor = Color;
191  s_DC_lastbrushfill = fill;
192  s_DC_lastDC = DC;
193  }
194 }
static wxDC * s_DC_lastDC
Definition: gr_basic.cpp:98
static COLOR4D s_DC_lastbrushcolor(0, 0, 0, 0)
Definition: colors.h:45
static bool s_DC_lastbrushfill
Definition: gr_basic.cpp:97
static bool s_ForceBlackPen
Definition: gr_basic.cpp:88

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

◆ GRSetColorPen()

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

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

References BLACK, and s_ForceBlackPen.

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

◆ GRSFilledRect()

void GRSFilledRect ( EDA_RECT aClipBox,
wxDC *  aDC,
int  x1,
int  y1,
int  x2,
int  y2,
int  aWidth,
COLOR4D  aColor,
COLOR4D  aBgColor 
)

Definition at line 919 of file gr_basic.cpp.

921 {
922  wxPoint points[5];
923  points[0] = wxPoint(x1, y1);
924  points[1] = wxPoint(x1, y2);
925  points[2] = wxPoint(x2, y2);
926  points[3] = wxPoint(x2, y1);
927  points[4] = points[0];
928 
929  GRSetBrush( aDC, aBgColor, FILLED );
930  GRSetColorPen( aDC, aBgColor, aWidth );
931 
932  if( aClipBox && (aWidth > 0) )
933  {
934  EDA_RECT clipbox(*aClipBox);
935  clipbox.Inflate(aWidth);
936  ClipAndDrawPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
937  }
938  else
939  ClipAndDrawPoly(aClipBox, aDC, points, 5 );
940 }
static const bool FILLED
Definition: gr_basic.cpp:41
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
static void ClipAndDrawPoly(EDA_RECT *ClipBox, wxDC *DC, const 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:957
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:133
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44

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

Referenced by GRFilledRect(), and SCH_PRINTOUT::PrintPage().

◆ GRSPoly()

static void GRSPoly ( EDA_RECT ClipBox,
wxDC *  DC,
int  n,
const wxPoint Points,
bool  Fill,
int  width,
COLOR4D  Color,
COLOR4D  BgColor 
)
static

Definition at line 473 of file gr_basic.cpp.

475 {
476  if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
477  return;
478 
479  if( Fill && ( n > 2 ) )
480  {
481  GRSetBrush( DC, BgColor, FILLED );
482  GRSetColorPen( DC, Color, width );
483 
484  /* clip before send the filled polygon to wxDC, because under linux
485  * (GTK?) polygons having large coordinates are incorrectly drawn
486  * (integer overflow in coordinates, I am guessing)
487  */
488  ClipAndDrawPoly( ClipBox, DC, Points, n );
489  }
490  else
491  {
492 
493  GRMoveTo( Points[0].x, Points[0].y );
494  for( int i = 1; i < n; ++i )
495  {
496  GRLineTo( ClipBox, DC, Points[i].x, Points[i].y, width, Color );
497  }
498  }
499 }
static const bool FILLED
Definition: gr_basic.cpp:41
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:266
static bool IsGRSPolyDrawable(EDA_RECT *ClipBox, int n, const wxPoint *Points)
Definition: gr_basic.cpp:431
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill)
Definition: gr_basic.cpp:170
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:256
static void ClipAndDrawPoly(EDA_RECT *ClipBox, wxDC *DC, const 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:957
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:133

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

Referenced by GRPoly().

◆ GRSRect()

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

907 {
908  wxPoint points[5];
909  points[0] = wxPoint(x1, y1);
910  points[1] = wxPoint(x1, y2);
911  points[2] = wxPoint(x2, y2);
912  points[3] = wxPoint(x2, y1);
913  points[4] = points[0];
914  GRSClosedPoly( aClipBox, aDC, 5, points, NOT_FILLED, aWidth,
915  aColor, aColor );
916 }
static const bool NOT_FILLED
Definition: gr_basic.cpp:42
static void GRSClosedPoly(EDA_RECT *aClipBox, wxDC *aDC, int aPointCount, const wxPoint *aPoints, bool aFill, int aWidth, COLOR4D aColor, COLOR4D aBgColor)
Definition: gr_basic.cpp:505

References GRSClosedPoly(), and NOT_FILLED.

Referenced by GRRect(), and GRRectPs().

◆ IsGRSPolyDrawable()

static bool IsGRSPolyDrawable ( EDA_RECT ClipBox,
int  n,
const wxPoint Points 
)
static

Definition at line 431 of file gr_basic.cpp.

432 {
433  if( !ClipBox )
434  return true;
435 
436  if( n <= 0 )
437  return false;
438 
439  int Xmin, Xmax, Ymin, Ymax;
440 
441  Xmin = Xmax = Points[0].x;
442  Ymin = Ymax = Points[0].y;
443 
444  for( int ii = 1; ii < n; ii++ ) // calculate rectangle
445  {
446  Xmin = std::min( Xmin, Points[ii].x );
447  Xmax = std::max( Xmax, Points[ii].x );
448  Ymin = std::min( Ymin, Points[ii].y );
449  Ymax = std::max( Ymax, Points[ii].y );
450  }
451 
452  xcliplo = ClipBox->GetX();
453  ycliplo = ClipBox->GetY();
454  xcliphi = ClipBox->GetRight();
455  ycliphi = ClipBox->GetBottom();
456 
457  if( Xmax < xcliplo )
458  return false;
459  if( Xmin > xcliphi )
460  return false;
461  if( Ymax < ycliplo )
462  return false;
463  if( Ymin > ycliphi )
464  return false;
465 
466  return true;
467 }
static int ycliplo
Definition: gr_basic.cpp:91
static int ycliphi
Definition: gr_basic.cpp:93
int GetX() const
Definition: eda_rect.h:111
static int xcliphi
Definition: gr_basic.cpp:92
int GetBottom() const
Definition: eda_rect.h:124
static int xcliplo
Definition: gr_basic.cpp:90
int GetRight() const
Definition: eda_rect.h:121
int GetY() const
Definition: eda_rect.h:112

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

Referenced by GRSClosedPoly(), and GRSPoly().

◆ WinClipAndDrawLine()

static void WinClipAndDrawLine ( EDA_RECT ClipBox,
wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width 
)
static

Definition at line 100 of file gr_basic.cpp.

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

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

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

Variable Documentation

◆ FILLED

const bool FILLED = true
static

Definition at line 41 of file gr_basic.cpp.

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

◆ g_XorMode

GR_DRAWMODE g_XorMode = GR_NXOR

Definition at line 72 of file gr_basic.cpp.

◆ GRLastMoveToX

int GRLastMoveToX
static

Definition at line 87 of file gr_basic.cpp.

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

◆ GRLastMoveToY

int GRLastMoveToY
static

Definition at line 87 of file gr_basic.cpp.

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

◆ NOT_FILLED

const bool NOT_FILLED = false
static

Definition at line 42 of file gr_basic.cpp.

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

◆ s_DC_lastbrushcolor

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

Referenced by GRResetPenAndBrush(), and GRSetBrush().

◆ s_DC_lastbrushfill

bool s_DC_lastbrushfill = false
static

Definition at line 97 of file gr_basic.cpp.

Referenced by GRSetBrush().

◆ s_DC_lastcolor

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

Referenced by GRResetPenAndBrush().

◆ s_DC_lastDC

wxDC* s_DC_lastDC = NULL
static

Definition at line 98 of file gr_basic.cpp.

Referenced by GRResetPenAndBrush(), and GRSetBrush().

◆ s_ForceBlackPen

bool s_ForceBlackPen
static

Definition at line 88 of file gr_basic.cpp.

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

◆ xcliphi

int xcliphi = 2000
static

Definition at line 92 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().

◆ xcliplo

int xcliplo = 0
static

Definition at line 90 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().

◆ ycliphi

int ycliphi = 2000
static

Definition at line 93 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().

◆ ycliplo

int ycliplo = 0
static

Definition at line 91 of file gr_basic.cpp.

Referenced by IsGRSPolyDrawable().