KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gr_basic.cpp File Reference
#include <gr_basic.h>
#include <trigo.h>
#include <eda_item.h>
#include <wx/graphics.h>
#include <math/vector2wx.h>
#include <algorithm>

Go to the source code of this file.

Functions

static void GRSRect (wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor)
 
static void vector2IwxDrawPolygon (wxDC *aDC, const VECTOR2I *Points, int n)
 
static void winDrawLine (wxDC *DC, int x1, int y1, int x2, int y2, int width)
 
void GRResetPenAndBrush (wxDC *DC)
 
void GRSetColorPen (wxDC *DC, const COLOR4D &Color, int width, wxPenStyle style)
 
void GRSetBrush (wxDC *DC, const COLOR4D &Color, bool fill)
 
void GRForceBlackPen (bool flagforce)
 
bool GetGRForceBlackPenState (void)
 
void GRLine (wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, wxPenStyle aStyle)
 
void GRLine (wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, wxPenStyle aStyle)
 
void GRMoveTo (int x, int y)
 
void GRLineTo (wxDC *DC, int x, int y, int width, const COLOR4D &Color)
 
void GRCSegm (wxDC *DC, const VECTOR2I &A, const VECTOR2I &B, int width, const COLOR4D &Color)
 
void GRFilledSegment (wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
 
static void GRSPoly (wxDC *DC, int n, const VECTOR2I *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
 Draw a new polyline and fill it if Fill, in screen space.
 
static void GRSClosedPoly (wxDC *aDC, int aPointCount, const VECTOR2I *aPoints, bool aFill, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
 Draw a new closed polyline and fill it if Fill, in screen space.
 
void GRPoly (wxDC *DC, int n, const VECTOR2I *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
 Draw a new polyline and fill it if Fill, in drawing space.
 
void GRClosedPoly (wxDC *DC, int n, const VECTOR2I *Points, bool Fill, const COLOR4D &Color)
 Draw a closed polyline and fill it if Fill, in object space.
 
void GRCircle (wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
 
void GRFilledCircle (wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aStrokeColor, const COLOR4D &aFillColor)
 Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
 
void GRArc (wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int aWidth, const COLOR4D &aColor)
 
void GRFilledArc (wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int width, const COLOR4D &Color, const COLOR4D &BgColor)
 
void GRRect (wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
 
void GRFilledRect (wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
 
void GRSFilledRect (wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
 

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 COLOR4D s_DC_lastbrushcolor (0, 0, 0, 0)
 
static bool s_DC_lastbrushfill = false
 
static wxDC * s_DC_lastDC = nullptr
 

Function Documentation

◆ GetGRForceBlackPenState()

◆ GRArc()

void GRArc ( wxDC *  aDC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
const VECTOR2I aCenter,
int  aWidth,
const COLOR4D aColor 
)

◆ GRCircle()

void GRCircle ( wxDC *  aDC,
const VECTOR2I aPos,
int  aRadius,
int  aWidth,
const COLOR4D aColor 
)

◆ GRClosedPoly()

void GRClosedPoly ( wxDC *  DC,
int  n,
const VECTOR2I Points,
bool  Fill,
const COLOR4D Color 
)

Draw a closed polyline and fill it if Fill, in object space.

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

Definition at line 351 of file gr_basic.cpp.

References GRSClosedPoly().

Referenced by D_CODE::DrawFlashedPolygon(), GRPrintText(), GERBER_DRAW_ITEM::PrintGerberPoly(), and MARKER_BASE::PrintMarker().

◆ GRCSegm()

void GRCSegm ( wxDC *  DC,
const VECTOR2I A,
const VECTOR2I B,
int  width,
const COLOR4D Color 
)

◆ GRFilledArc()

void GRFilledArc ( wxDC *  DC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
const VECTOR2I aCenter,
int  width,
const COLOR4D Color,
const COLOR4D BgColor 
)

◆ GRFilledCircle()

void GRFilledCircle ( wxDC *  aDC,
const VECTOR2I aPos,
int  aRadius,
int  aWidth,
const COLOR4D aStrokeColor,
const COLOR4D aFillColor 
)

Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).

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

References FILLED, GRSetBrush(), GRSetColorPen(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by D_CODE::DrawFlashedShape(), LIB_SHAPE::Print(), SCH_JUNCTION::Print(), SCH_SHAPE::Print(), SCH_LABEL_BASE::Print(), and SCH_SHAPE::PrintBackground().

◆ GRFilledRect()

void GRFilledRect ( wxDC *  DC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aWidth,
const COLOR4D aColor,
const COLOR4D aBgColor 
)

◆ GRFilledSegment()

void GRFilledSegment ( wxDC *  aDC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aWidth,
const COLOR4D aColor 
)

◆ GRForceBlackPen()

void GRForceBlackPen ( bool  flagforce)
Parameters
flagforceTrue to force a black pen whenever the asked color.

Definition at line 159 of file gr_basic.cpp.

References s_ForceBlackPen.

Referenced by SCH_EDIT_FRAME::DrawCurrentSheetToClipboard(), PLEDITOR_PRINTOUT::PrintPage(), and SCH_PRINTOUT::PrintPage().

◆ GRLine() [1/2]

void GRLine ( wxDC *  aDC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aWidth,
const COLOR4D aColor,
wxPenStyle  aStyle 
)

Definition at line 181 of file gr_basic.cpp.

References GRLine(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ GRLine() [2/2]

◆ GRLineTo()

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

Definition at line 195 of file gr_basic.cpp.

References GRLastMoveToX, GRLastMoveToY, and GRLine().

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

◆ GRMoveTo()

void GRMoveTo ( int  x,
int  y 
)

Definition at line 188 of file gr_basic.cpp.

References GRLastMoveToX, and GRLastMoveToY.

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

◆ GRPoly()

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

Draw a new polyline and fill it if Fill, in drawing space.

Definition at line 341 of file gr_basic.cpp.

References GRSPoly().

Referenced by LIB_SHAPE::Print(), SCH_SHAPE::Print(), SCH_LABEL_BASE::Print(), SCH_SHAPE::PrintBackground(), and DS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem().

◆ GRRect()

void GRRect ( wxDC *  DC,
const VECTOR2I aStart,
const VECTOR2I aEnd,
int  aWidth,
const COLOR4D aColor 
)

◆ GRResetPenAndBrush()

◆ GRSClosedPoly()

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

Draw a new closed polyline and fill it if Fill, in screen space.

Definition at line 311 of file gr_basic.cpp.

References FILLED, GRLastMoveToX, GRLastMoveToY, GRLineTo(), GRMoveTo(), GRSetBrush(), GRSetColorPen(), vector2IwxDrawPolygon(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GRClosedPoly(), and GRSRect().

◆ GRSetBrush()

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

◆ GRSetColorPen()

void GRSetColorPen ( wxDC *  DC,
const COLOR4D Color,
int  width,
wxPenStyle  style 
)

◆ GRSFilledRect()

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

Definition at line 422 of file gr_basic.cpp.

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

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

◆ GRSPoly()

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

Draw a new polyline and fill it if Fill, in screen space.

Definition at line 288 of file gr_basic.cpp.

References FILLED, GRLineTo(), GRMoveTo(), GRSetBrush(), GRSetColorPen(), and vector2IwxDrawPolygon().

Referenced by GRPoly().

◆ GRSRect()

void GRSRect ( wxDC *  aDC,
int  x1,
int  y1,
int  x2,
int  y2,
int  aWidth,
const COLOR4D aColor 
)
static

Definition at line 410 of file gr_basic.cpp.

References GRSClosedPoly(), and NOT_FILLED.

Referenced by GRRect().

◆ vector2IwxDrawPolygon()

static void vector2IwxDrawPolygon ( wxDC *  aDC,
const VECTOR2I Points,
int  n 
)
static

Definition at line 53 of file gr_basic.cpp.

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

◆ winDrawLine()

static void winDrawLine ( wxDC *  DC,
int  x1,
int  y1,
int  x2,
int  y2,
int  width 
)
static

Definition at line 65 of file gr_basic.cpp.

References GRLastMoveToX, and GRLastMoveToY.

Referenced by GRFilledSegment(), and GRLine().

Variable Documentation

◆ FILLED

◆ g_XorMode

GR_DRAWMODE g_XorMode = GR_NXOR

Definition at line 34 of file gr_basic.cpp.

◆ GRLastMoveToX

int GRLastMoveToX
static

Definition at line 45 of file gr_basic.cpp.

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

◆ GRLastMoveToY

int GRLastMoveToY
static

Definition at line 45 of file gr_basic.cpp.

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

◆ NOT_FILLED

const bool NOT_FILLED = false
static

Definition at line 31 of file gr_basic.cpp.

Referenced by 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 49 of file gr_basic.cpp.

Referenced by GRSetBrush().

◆ s_DC_lastDC

wxDC* s_DC_lastDC = nullptr
static

Definition at line 50 of file gr_basic.cpp.

Referenced by GRResetPenAndBrush(), and GRSetBrush().

◆ s_ForceBlackPen

bool s_ForceBlackPen
static

Definition at line 46 of file gr_basic.cpp.

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