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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef GERBER_DRAW_ITEM_H
22#define GERBER_DRAW_ITEM_H
23
24#include <eda_item.h>
25#include <layer_ids.h>
26#include <gr_basic.h>
28#include <dcode.h>
30#include <geometry/eda_angle.h>
31
33class GBR_LAYOUT;
34class D_CODE;
35class MSG_PANEL_ITEM;
37class PCB_BASE_FRAME;
38
39namespace KIGFX
40{
41 class VIEW;
42}
43
44
45/* Shapes id for basic shapes ( .m_ShapeType member ) */
47{
48 GBR_SEGMENT = 0, // usual segment : line with rounded ends
49 GBR_ARC, // Arcs (with rounded ends)
50 GBR_CIRCLE, // ring
51 GBR_POLYGON, // polygonal shape
52 GBR_SPOT_CIRCLE, // flashed shape: round shape (can have hole)
53 GBR_SPOT_RECT, // flashed shape: rectangular shape can have hole)
54 GBR_SPOT_OVAL, // flashed shape: oval shape
55 GBR_SPOT_POLY, // flashed shape: regular polygon, 3 to 12 edges
56 GBR_SPOT_MACRO // complex shape described by a macro
57};
58
60{
61public:
62 GERBER_DRAW_ITEM( GERBER_FILE_IMAGE* aGerberparams );
64
65 void SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttributes );
67
71 int GetLayer() const;
72
73 bool GetLayerPolarity() const { return m_LayerNegative; }
74
83 bool GetTextD_CodePrms( int& aSize, VECTOR2I& aPos, EDA_ANGLE& aOrientation );
84
91 bool HasNegativeItems();
92
99 void SetLayerParameters();
100
101 void SetLayerPolarity( bool aNegative) { m_LayerNegative = aNegative; }
102
108 void MoveXY( const VECTOR2I& aMoveVector );
109
117 VECTOR2I GetPosition() const override { return m_Start; }
118 void SetPosition( const VECTOR2I& aPos ) override { m_Start = aPos; }
119
129 VECTOR2I GetABPosition( const VECTOR2I& aXYPosition ) const;
130
140 VECTOR2I GetXYPosition( const VECTOR2I& aABPosition ) const;
141
147 D_CODE* GetDcodeDescr() const;
148
149 const BOX2I GetBoundingBox() const override;
150
151 void Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OPTIONS* aOptions );
152
157
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
187 bool HitTest( const VECTOR2I& aRefPos, int aAccuracy = 0 ) const override;
188
199 bool HitTest( const BOX2I& aRefArea, bool aContained, int aAccuracy = 0 ) const override;
200
204 wxString GetClass() const override
205 {
206 return wxT( "GERBER_DRAW_ITEM" );
207 }
208
209#if defined(DEBUG)
210 void Show( int nestLevel, std::ostream& os ) const override;
211#endif
212
213 virtual std::vector<int> ViewGetLayers() const override;
214
215 virtual const BOX2I ViewBBox() const override;
216
217 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
218
220 INSPECT_RESULT Visit( INSPECTOR aInspector, void* aTestData,
221 const std::vector<KICAD_T>& aScanTypes ) override;
222
224 virtual wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) 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 VECTOR2D 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.
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
A gerber DCODE (also called Aperture) definition.
Definition dcode.h:76
The base class for create windows for drawing purpose.
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
A list of GERBER_DRAW_ITEM objects currently loaded.
Definition gbr_layout.h:42
Information which can be added in a gerber file as attribute of an object.
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
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)
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
void ConvertSegmentToPolygon()
Convert a lines in m_ShapeAsPolygon 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
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
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.
void SetNetAttributes(const GBR_NETLIST_METADATA &aNetAttributes)
SHAPE_POLY_SET m_AbsolutePolygon
INSPECT_RESULT Visit(INSPECTOR aInspector, void *aTestData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
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:101
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:50
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
Represent a set of closed polygons.
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
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 eda_group.h:30
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707