KiCad PCB EDA Suite
gerber_draw_item.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 1992-2016 <Jean-Pierre Charras>
5 * Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#ifndef GERBER_DRAW_ITEM_H
26#define GERBER_DRAW_ITEM_H
27
28#include <eda_item.h>
29#include <layer_ids.h>
30#include <gr_basic.h>
32#include <dcode.h>
34#include <geometry/eda_angle.h>
35
37class GBR_LAYOUT;
38class D_CODE;
39class MSG_PANEL_ITEM;
41class PCB_BASE_FRAME;
42
43namespace KIGFX
44{
45 class VIEW;
46}
47
48
49/* Shapes id for basic shapes ( .m_Shape member ) */
51{
52 GBR_SEGMENT = 0, // usual segment : line with rounded ends
53 GBR_ARC, // Arcs (with rounded ends)
54 GBR_CIRCLE, // ring
55 GBR_POLYGON, // polygonal shape
56 GBR_SPOT_CIRCLE, // flashed shape: round shape (can have hole)
57 GBR_SPOT_RECT, // flashed shape: rectangular shape can have hole)
58 GBR_SPOT_OVAL, // flashed shape: oval shape
59 GBR_SPOT_POLY, // flashed shape: regular polygon, 3 to 12 edges
60 GBR_SPOT_MACRO, // complex shape described by a macro
61 GBR_LAST // last value for this list
62};
63
65{
66public:
67 GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberparams );
69
70 void SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttributes );
72
76 int GetLayer() const;
77
78 bool GetLayerPolarity() const { return m_LayerNegative; }
79
88 bool GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, EDA_ANGLE& aOrientation );
89
96 bool HasNegativeItems();
97
104 void SetLayerParameters();
105
106 void SetLayerPolarity( bool aNegative) { m_LayerNegative = aNegative; }
107
113 void MoveXY( const VECTOR2I& aMoveVector );
114
122 VECTOR2I GetPosition() const override { return m_Start; }
123 void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
124
134 VECTOR2I GetABPosition( const VECTOR2I& aXYPosition ) const;
135
145 VECTOR2I GetXYPosition( const VECTOR2I& aABPosition ) const;
146
152 D_CODE* GetDcodeDescr() const;
153
154 const BOX2I GetBoundingBox() const override;
155
156 void Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OPTIONS* aOptions );
157
167 void ConvertSegmentToPolygon( SHAPE_POLY_SET* aPolygon ) const;
168
172 void PrintGerberPoly( wxDC* aDC, const COLOR4D& aColor, const VECTOR2I& aOffset,
173 bool aFilledShape );
174
175 int Shape() const { return m_Shape; }
176
177 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
178
179 wxString ShowGBRShape() const;
180
187 bool HitTest( const VECTOR2I& aRefPos, int aAccuracy = 0 ) const override;
188
197 bool HitTest( const BOX2I& aRefArea, bool aContained, int aAccuracy = 0 ) const override;
198
202 wxString GetClass() const override
203 {
204 return wxT( "GERBER_DRAW_ITEM" );
205 }
206
207#if defined(DEBUG)
208 void Show( int nestLevel, std::ostream& os ) const override;
209#endif
210
212 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
213
215 virtual const BOX2I ViewBBox() const override;
216
218 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
219
221 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
222 const std::vector<KICAD_T>& aScanTypes ) override;
223
225 virtual wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
226
228 BITMAPS GetMenuImage() const override;
229
230public:
231 bool m_UnitsMetric; // store here the gerber units (inch/mm). Used
232 // only to calculate aperture macros shapes sizes
233 int m_Shape; // Shape and type of this gerber item
234 VECTOR2I m_Start; // Line or arc start point or position of the shape
235 // for flashed items
236 VECTOR2I m_End; // Line or arc end point
237 VECTOR2I m_ArcCentre; // for arcs only: Center of arc
238 SHAPE_POLY_SET m_Polygon; // Polygon shape data (G36 to G37 coordinates)
239 // or for complex shapes which are converted to polygon
240 wxSize m_Size; // Flashed shapes: size of the shape
241 // Lines : m_Size.x = m_Size.y = line width
242 bool m_Flashed; // True for flashed items
243 int m_DCode; // DCode used to draw this item.
244 // Allowed values are >= 10. 0 when unknown
245 // values 0 to 9 can be used for special purposes
246 // Regions (polygons) do not use DCode,
247 // so it is set to 0
248 wxString m_AperFunction; // the aperture function set by a %TA.AperFunction, xxx
249 // (stores the xxx value). Used for regions that do
250 // not have a attached DCode, but
251 // have a TA.AperFunction defined
252 GERBER_FILE_IMAGE* m_GerberImageFile; /* Gerber file image source of this item
253 * Note: some params stored in this class are common
254 * to the whole gerber file (i.e) the whole graphic
255 * layer and some can change when reading the file,
256 * so they are stored inside this item if there is no
257 * redundancy for these parameters
258 */
259
260 // This polygon is to draw this item (mainly GBR_POLYGON), according to layer parameters
261 SHAPE_POLY_SET m_AbsolutePolygon; // the polygon to draw, in absolute coordinates
262
263private:
264 // These values are used to draw this item, according to gerber layers parameters
265 // Because they can change inside a gerber image, they are stored here
266 // for each item
267 bool m_LayerNegative; // true = item in negative Layer
268 bool m_swapAxis; // false if A = X, B = Y; true if A =Y, B = Y
269 bool m_mirrorA; // true: mirror / axis A
270 bool m_mirrorB; // true: mirror / ax's B
271 VECTOR2I m_drawScale; // A and B scaling factor
272 VECTOR2I m_layerOffset; // Offset for A and B axis, from OF parameter
273 double m_lyrRotation; // Fine rotation, from OR parameter, in degrees
277};
278
279
280#endif /* GERBER_DRAW_ITEM_H */
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
A gerber DCODE (also called Aperture) definition.
Definition: dcode.h:80
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
A list of GERBER_DRAW_ITEM objects currently loaded.
Definition: gbr_layout.h:46
Information which can be added in a gerber file as attribute of an object.
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
bool GetTextD_CodePrms(int &aSize, VECTOR2I &aPos, EDA_ANGLE &aOrientation)
Return the best size and orientation to display the D_Code on screen.
void SetLayerPolarity(bool aNegative)
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
D_CODE * GetDcodeDescr() const
Return the GetDcodeDescr of this object, or NULL.
VECTOR2I GetPosition() const override
Return the position of this object.
void SetLayerParameters()
Initialize parameters from Image and Layer parameters found in the gerber file: m_UnitsMetric,...
SHAPE_POLY_SET m_Polygon
wxString ShowGBRShape() const
bool HasNegativeItems()
Optimize screen refresh (when no items are in background color refresh can be faster).
VECTOR2I GetABPosition(const VECTOR2I &aXYPosition) const
Return the image position of aPosition for this object.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
VECTOR2I GetXYPosition(const VECTOR2I &aABPosition) const
Return the image position of aPosition for this object.
void MoveXY(const VECTOR2I &aMoveVector)
Move this object.
bool GetLayerPolarity() const
int GetLayer() const
Return the layer this item is on.
void SetPosition(const VECTOR2I &aPos) override
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a pointer to an image to be used in menus.
void ConvertSegmentToPolygon()
Convert a line to an equivalent polygon.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
GERBER_DRAW_ITEM(GERBER_FILE_IMAGE *aGerberparams)
GERBER_FILE_IMAGE * m_GerberImageFile
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
wxString GetClass() const override
void PrintGerberPoly(wxDC *aDC, const COLOR4D &aColor, const VECTOR2I &aOffset, bool aFilledShape)
Print the polygon stored in m_PolyCorners.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
Return a user-visible description string of this item.
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
SHAPE_POLY_SET m_AbsolutePolygon
virtual const BOX2I ViewBBox() const override
bool HitTest(const VECTOR2I &aRefPos, int aAccuracy=0) const override
Test if the given wxPoint is within the bounds of this object.
const GBR_NETLIST_METADATA & GetNetAttributes() const
GBR_NETLIST_METADATA m_netAttributes
the string given by a TO attribute set in aperture (dcode).
void Print(wxDC *aDC, const VECTOR2I &aOffset, GBR_DISPLAY_OPTIONS *aOptions)
Hold the image data and parameters for one gerber file and layer parameters.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Represent a set of closed polygons.
INSPECT_RESULT
Definition: eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:78
Gbr_Basic_Shapes
@ GBR_SPOT_OVAL
@ GBR_SEGMENT
@ GBR_SPOT_POLY
@ GBR_SPOT_RECT
@ GBR_CIRCLE
@ GBR_POLYGON
@ GBR_SPOT_CIRCLE
@ GBR_LAST
@ GBR_ARC
@ GBR_SPOT_MACRO
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:266