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
162 void ConvertSegmentToPolygon( SHAPE_POLY_SET* aPolygon ) const;
163
167 void PrintGerberPoly( wxDC* aDC, const COLOR4D& aColor, const VECTOR2I& aOffset,
168 bool aFilledShape );
169
171
172 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
173
174 wxString ShowGBRShape() const;
175
182 bool HitTest( const VECTOR2I& aRefPos, int aAccuracy = 0 ) const override;
183
192 bool HitTest( const BOX2I& aRefArea, bool aContained, int aAccuracy = 0 ) const override;
193
197 wxString GetClass() const override
198 {
199 return wxT( "GERBER_DRAW_ITEM" );
200 }
201
202#if defined(DEBUG)
203 void Show( int nestLevel, std::ostream& os ) const override;
204#endif
205
207 virtual std::vector<int> ViewGetLayers() const override;
208
210 virtual const BOX2I ViewBBox() const override;
211
213 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
214
216 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
217 const std::vector<KICAD_T>& aScanTypes ) override;
218
220 virtual wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
221
223 BITMAPS GetMenuImage() const override;
224
225public:
226 bool m_UnitsMetric; // store here the gerber units (inch/mm). Used
227 // only to calculate aperture macros shapes sizes
228 GBR_BASIC_SHAPE_TYPE m_ShapeType; // Shape type of this gerber item
229 VECTOR2I m_Start; // Line or arc start point or position of the shape
230 // for flashed items
231 VECTOR2I m_End; // Line or arc end point
232 VECTOR2I m_ArcCentre; // for arcs only: Center of arc
233 SHAPE_POLY_SET m_ShapeAsPolygon; // Polygon shape data from G36 to G37 coordinates
234 // or for complex shapes which are converted to polygon
235 VECTOR2I m_Size; // Flashed shapes: size of the shape
236 // Lines : m_Size.x = m_Size.y = line width
237 bool m_Flashed; // True for flashed items
238 int m_DCode; // DCode used to draw this item.
239 // Allowed values are >= 10. 0 when unknown
240 // values 0 to 9 can be used for special purposes
241 // Regions (polygons) do not use DCode,
242 // so it is set to 0
243 wxString m_AperFunction; // the aperture function set by a %TA.AperFunction, xxx
244 // (stores the xxx value). Used for regions that do
245 // not have a attached DCode, but
246 // have a TA.AperFunction defined
247 GERBER_FILE_IMAGE* m_GerberImageFile; /* Gerber file image source of this item
248 * Note: some params stored in this class are common
249 * to the whole gerber file (i.e) the whole graphic
250 * layer and some can change when reading the file,
251 * so they are stored inside this item if there is no
252 * redundancy for these parameters
253 */
254
255 // This polygon is to draw this item (mainly GBR_POLYGON), according to layer parameters
256 SHAPE_POLY_SET m_AbsolutePolygon; // the polygon to draw, in absolute coordinates
257
258private:
259 // These values are used to draw this item, according to gerber layers parameters
260 // Because they can change inside a gerber image, they are stored here
261 // for each item
262 bool m_LayerNegative; // true = item in negative Layer
263 bool m_swapAxis; // false if A = X, B = Y; true if A =Y, B = Y
264 bool m_mirrorA; // true: mirror / axis A
265 bool m_mirrorB; // true: mirror / ax's B
266 VECTOR2I m_drawScale; // A and B scaling factor
267 VECTOR2I m_layerOffset; // Offset for A and B axis, from OF parameter
268 double m_lyrRotation; // Fine rotation, from OR parameter, in degrees
272};
273
274
275#endif /* GERBER_DRAW_ITEM_H */
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
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:37
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
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 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
virtual wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a pointer to an image to be used in menus.
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
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
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: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:42
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:89
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:29
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683