33 using namespace KIGFX;
56 size_t palette_size = aSettings->
m_Palette.size();
57 size_t palette_idx = 0;
66 baseColor = aSettings->
m_Palette[ ( palette_idx++ ) % palette_size ];
108 const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
113 gbrItem = static_cast<const GERBER_DRAW_ITEM*>( item );
168 if( aActualThickness == 0 )
171 return aActualThickness;
177 const EDA_ITEM* item = dynamic_cast<const EDA_ITEM*>( aItem );
183 switch( item->
Type() )
186 draw( static_cast<GERBER_DRAW_ITEM*>( const_cast<EDA_ITEM*>( item ) ), aLayer );
204 int width = aItem->
m_Size.x;
205 bool isFilled =
true;
222 codeText.Printf(
"D%d", aItem->
m_DCode );
261 if( isNegative && !isFilled )
272 for(
auto& pt : pts )
313 wxPoint arcStart = aItem->
m_End;
314 wxPoint arcEnd = aItem->
m_Start;
327 double startAngle = startVec.
Angle();
328 double endAngle = endVec.Angle();
333 if( startAngle > endAngle )
334 endAngle += (2 * M_PI);
337 if( arcStart == arcEnd )
339 endAngle = startAngle + 2*M_PI;
344 #if 0 // Arc Debugging only 354 #if 0 // Bbox arc Debugging only 388 if( isNegative && !isFilled )
411 wxASSERT_MSG(
false,
"GERBER_DRAW_ITEM shape is unknown!" );
441 for(
auto& pt : pts )
460 wxASSERT_MSG( code,
"drawFlashedShape: Item has no D_CODE!" );
473 int radius = code->
m_Size.x >> 1;
494 wxPoint aShapePos = aItem->
m_Start;
495 codeStart.x = aShapePos.x - code->
m_Size.x / 2;
496 codeStart.y = aShapePos.y - code->
m_Size.y / 2;
497 wxPoint codeEnd = codeStart + code->
m_Size;
519 wxPoint codeStart = aItem->
m_Start;
520 wxPoint codeEnd = aItem->
m_Start;
525 codeStart.x -= delta;
532 codeStart.y -= delta;
568 wxASSERT_MSG(
false, wxT(
"Unknown Gerber flashed shape!" ) );
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
virtual void SetFillColor(const COLOR4D &aColor)
Set the fill color.
virtual void DrawPolyline(const std::deque< VECTOR2D > &aPointList)
Draw a polyline.
bool m_DisplayPolygonsFill
Option to draw polygons (filled/sketch)
virtual void DrawRectangle(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a rectangle.
D_CODE * GetDcodeDescr() const
Return the GetDcodeDescr of this object, or NULL.
bool m_showNegativeItems
Flag determining if negative items should be drawn with a "ghost" color.
bool IsDCodeLayer(int aLayer)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
GERBVIEW_PAINTER(GAL *aGal)
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
The Cairo implementation of the graphics abstraction layer.
static const double MAX_FONT_SIZE
Maximum font size for D-Codes and other strings.
virtual void BitmapText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
Draw a text using a bitmap font.
COLOR4D m_layerColorsHi[LAYER_ID_COUNT]
wxSize m_Size
Horizontal and vertical dimensions.
COLOR4D m_layerColors[LAYER_ID_COUNT]
void draw(GERBER_DRAW_ITEM *aVia, int aLayer)
APERTURE_T m_Shape
shape ( Line, rectangle, circle , oval .. )
COLOR4D m_BgDrawColor
The background color.
bool m_lineFill
Flag determining if lines should be drawn with fill.
virtual const BOX2I ViewBBox() const override
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
void drawFlashedShape(GERBER_DRAW_ITEM *aItem, bool aFilled)
Helper to draw a flashed shape (aka spot)
static const COLOR4D BLACK
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
bool IsBrightened() const
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
bool m_DisplayNegativeObjects
Option to draw negative objects in a specific color.
An abstract base class for deriving all objects that can be added to a VIEW.
COLOR4D Darkened(double aFactor) const
Return a color that is darker by a given factor, without modifying object.
virtual void DrawLine(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint)
Draw a line.
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
int PointCount() const
Function PointCount()
bool m_spotFill
Flag determining if spots should be drawn with fill.
std::set< unsigned int > m_highContrastLayers
GAL * m_gal
Instance of graphic abstraction layer that gives an interface to call commands used to draw (eg.
virtual void SetLineWidth(float aLineWidth)
Set the line width.
bool m_DisplayLinesFill
Option to draw line items (filled/sketch)
COLOR4D m_hiContrastColor[LAYER_ID_COUNT]
COLOR4D Brightened(double aFactor) const
Return a color that is brighter by a given factor, without modifying object.
bool m_showCodes
Flag determining if D-Codes should be drawn.
const wxPoint GetEnd() const
void SetFontBold(const bool aBold)
Set bold property of current font.
void SetClosed(bool aClosed)
Function SetClosed()
void drawApertureMacro(GERBER_DRAW_ITEM *aParent, bool aFilled)
Helper to draw an aperture macro shape.
Contains all the knowledge about how to draw graphical object onto any particular output device.
bool m_DiffMode
Display layers in diff mode.
wxPoint GetABPosition(const wxPoint &aXYPosition) const
Return the image position of aPosition for this object.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
SHAPE_POLY_SET * GetApertureMacroShape(const GERBER_DRAW_ITEM *aParent, wxPoint aShapePos)
Function GetApertureMacroShape Calculate the primitive shape for flashed items.
COLOR4D m_layerColorsDark[LAYER_ID_COUNT]
virtual void DrawSegment(const VECTOR2D &aStartPoint, const VECTOR2D &aEndPoint, double aWidth)
Draw a rounded segment.
VECTOR2< double > VECTOR2D
#define GERBER_DRAWLAYERS_COUNT
wxString m_netHighlightString
If set to anything but an empty string, will highlight items with matching net.
wxString m_attributeHighlightString
If set to anything but an empty string, will highlight items with matching attribute.
virtual void SetIsFill(bool aIsFillEnabled)
Enable/disable fill.
const std::vector< VECTOR2I > & CPoints() const
bool m_hiContrastEnabled
Parameters for display modes.
virtual void update()
Precalculates extra colors for layers (e.g.
Represent a set of closed polygons.
const wxPoint GetOrigin() const
bool m_DisplayFlashedItemsFill
Option to draw flashed items (filled/sketch)
bool GetTextD_CodePrms(int &aSize, wxPoint &aPos, double &aOrientation)
Return the best size and orientation to display the D_Code on screen.
virtual bool IsOpenGlEngine()
Return true if the GAL engine is a OpenGL based type.
void SetTextMirrored(const bool aMirrored)
Set a mirrored property of text.
wxString m_componentHighlightString
If set to anything but an empty string, will highlight items with matching component.
const GBR_NETLIST_METADATA & GetNetAttributes() const
void SetVerticalJustify(const EDA_TEXT_VJUSTIFY_T aVerticalJustify)
Set the vertical justify for text drawing.
double Angle() const
Compute the angle of the vector.
void SetFontItalic(bool aItalic)
Set italic property of current font.
int NewOutline()
Creates a new hole in a given outline.
void ConvertSegmentToPolygon()
Convert a line to an equivalent polygon.
GERBVIEW_RENDER_SETTINGS()
wxString m_AperFunction
the aperture attribute (created by a TA.AperFunction command) attached to the D_CODE
APERTURE_DEF_HOLETYPE m_DrillShape
shape of the hole (0 = no hole, round = 1, rect = 2) */
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
std::vector< COLOR4D > m_Palette
m_Pallete stores a list of colors that are used, in order, when a list of colors needs to be generate...
COLOR4D GetColor(int aLayer) const
virtual void SetStrokeColor(const COLOR4D &aColor)
Set the stroke color.
virtual GERBVIEW_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
COLOR4D m_backgroundColor
void SetGlyphSize(const VECTOR2D aSize)
Set the font glyph size.
bool m_polygonFill
Flag determining if polygons should be drawn with fill.
void LoadColors(const COLOR_SETTINGS *aSettings) override
virtual void DrawPolygon(const std::deque< VECTOR2D > &aPointList)
Draw a polygon.
void SetFontUnderlined(bool aUnderlined)
D_CODE holds a gerber DCODE (also called Aperture) definition.
virtual void DrawCircle(const VECTOR2D &aCenterPoint, double aRadius)
Draw a circle using world coordinates.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Handle the component boundary box.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
A base class for most all the KiCad significant classes used in schematics and boards.
void drawPolygon(GERBER_DRAW_ITEM *aParent, const SHAPE_POLY_SET &aPolygon, bool aFilled, bool aShift=false)
Helper routine to draw a polygon.
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS &aOptions)
Function LoadDisplayOptions Loads settings related to display options.
APERTURE_MACRO * GetMacro() const
Color settings are a bit different than most of the settings objects in that there can be more than o...
virtual void DrawArcSegment(const VECTOR2D &aCenterPoint, double aRadius, double aStartAngle, double aEndAngle, double aWidth)
Draw an arc segment.
void CacheTriangulation(bool aPartition=true)
void ConvertShapeToPolygon()
Function ConvertShapeToPolygon convert a shape to an equivalent polygon.
void SetHorizontalJustify(const EDA_TEXT_HJUSTIFY_T aHorizontalJustify)
Set the horizontal justify for text drawing.
Struct APERTURE_MACRO helps support the "aperture macro" defined within standard RS274X.
const Vec & GetOrigin() const
virtual void SetIsStroke(bool aIsStrokeEnabled)
Enable/disable stroked outlines.
bool m_DisplayDCodes
Option to show dcode values on items drawn with a dcode tool.
static constexpr int Millimeter2iu(double mm)
bool GetLayerPolarity() const
virtual void SetNegativeDrawMode(bool aSetting)
Set negative draw mode in the renderer.
GERBER_FILE_IMAGE * m_GerberImageFile
bool m_diffMode
Flag determining if layers should be rendered in "diff" mode.
COLOR4D m_layerColorsSel[LAYER_ID_COUNT]
KICAD_T Type() const
Returns the type of object.
Abstract interface for drawing on a 2D-surface.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
A color representation with 4 components: red, green, blue, alpha.