KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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_ShapeType 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};
62
64{
65public:
66 GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberparams );
68
69 void SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttributes );
71
75 int GetLayer() const;
76
77 bool GetLayerPolarity() const { return m_LayerNegative; }
78
87 bool GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, EDA_ANGLE& aOrientation );
88
95 bool HasNegativeItems();
96
103 void SetLayerParameters();
104
105 void SetLayerPolarity( bool aNegative) { m_LayerNegative = aNegative; }
106
112 void MoveXY( const VECTOR2I& aMoveVector );
113
121 VECTOR2I GetPosition() const override { return m_Start; }
122 void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
123
133 VECTOR2I GetABPosition( const VECTOR2I& aXYPosition ) const;
134
144 VECTOR2I GetXYPosition( const VECTOR2I& aABPosition ) const;
145
151 D_CODE* GetDcodeDescr() const;
152
153 const BOX2I GetBoundingBox() const override;
154
155 void Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OPTIONS* aOptions );
156
166 void ConvertSegmentToPolygon( SHAPE_POLY_SET* aPolygon ) const;
167
171 void PrintGerberPoly( wxDC* aDC, const COLOR4D& aColor, const VECTOR2I& aOffset,
172 bool aFilledShape );
173
175
176 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
177
178 wxString ShowGBRShape() const;
179
186 bool HitTest( const VECTOR2I& aRefPos, int aAccuracy = 0 ) const override;
187
196 bool HitTest( const BOX2I& aRefArea, bool aContained, int aAccuracy = 0 ) const override;
197
201 wxString GetClass() const override
202 {
203 return wxT( "GERBER_DRAW_ITEM" );
204 }
205
206#if defined(DEBUG)
207 void Show( int nestLevel, std::ostream& os ) const override;
208#endif
209
211 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
212
214 virtual const BOX2I ViewBBox() const override;
215
217 double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
218
220 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
221 const std::vector<KICAD_T>& aScanTypes ) override;
222
224 virtual wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
225
227 BITMAPS GetMenuImage() const override;
228
229public:
230 bool m_UnitsMetric; // store here the gerber units (inch/mm). Used
231 // only to calculate aperture macros shapes sizes
232 GBR_BASIC_SHAPE_TYPE m_ShapeType; // Shape type of this gerber item
233 VECTOR2I m_Start; // Line or arc start point or position of the shape
234 // for flashed items
235 VECTOR2I m_End; // Line or arc end point
236 VECTOR2I m_ArcCentre; // for arcs only: Center of arc
237 SHAPE_POLY_SET m_ShapeAsPolygon; // Polygon shape data from G36 to G37 coordinates
238 // or for complex shapes which are converted to polygon
239 VECTOR2I m_Size; // Flashed shapes: size of the shape
240 // Lines : m_Size.x = m_Size.y = line width
241 bool m_Flashed; // True for flashed items
242 int m_DCode; // DCode used to draw this item.
243 // Allowed values are >= 10. 0 when unknown
244 // values 0 to 9 can be used for special purposes
245 // Regions (polygons) do not use DCode,
246 // so it is set to 0
247 wxString m_AperFunction; // the aperture function set by a %TA.AperFunction, xxx
248 // (stores the xxx value). Used for regions that do
249 // not have a attached DCode, but
250 // have a TA.AperFunction defined
251 GERBER_FILE_IMAGE* m_GerberImageFile; /* Gerber file image source of this item
252 * Note: some params stored in this class are common
253 * to the whole gerber file (i.e) the whole graphic
254 * layer and some can change when reading the file,
255 * so they are stored inside this item if there is no
256 * redundancy for these parameters
257 */
258
259 // This polygon is to draw this item (mainly GBR_POLYGON), according to layer parameters
260 SHAPE_POLY_SET m_AbsolutePolygon; // the polygon to draw, in absolute coordinates
261
262private:
263 // These values are used to draw this item, according to gerber layers parameters
264 // Because they can change inside a gerber image, they are stored here
265 // for each item
266 bool m_LayerNegative; // true = item in negative Layer
267 bool m_swapAxis; // false if A = X, B = Y; true if A =Y, B = Y
268 bool m_mirrorA; // true: mirror / axis A
269 bool m_mirrorB; // true: mirror / ax's B
270 VECTOR2I m_drawScale; // A and B scaling factor
271 VECTOR2I m_layerOffset; // Offset for A and B axis, from OF parameter
272 double m_lyrRotation; // Fine rotation, from OR parameter, in degrees
276};
277
278
279#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:88
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,...
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.
SHAPE_POLY_SET m_ShapeAsPolygon
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.
GBR_BASIC_SHAPE_TYPE m_ShapeType
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
GBR_BASIC_SHAPE_TYPE ShapeType() const
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:68
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:43
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:81
GBR_BASIC_SHAPE_TYPE
@ GBR_SPOT_OVAL
@ GBR_SEGMENT
@ GBR_SPOT_POLY
@ GBR_SPOT_RECT
@ GBR_CIRCLE
@ GBR_POLYGON
@ GBR_SPOT_CIRCLE
@ GBR_ARC
@ GBR_SPOT_MACRO
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247