KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_shape.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) 2004 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2004-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 LIB_SHAPE_H
26#define LIB_SHAPE_H
27
28#include <lib_item.h>
29#include <eda_shape.h>
30
31
32class LIB_SHAPE : public LIB_ITEM, public EDA_SHAPE
33{
34public:
35 LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth = 0,
36 FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = LIB_SHAPE_T );
37
38 // Do not create a copy constructor. The one generated by the compiler is adequate.
39
41
42 wxString GetClass() const override
43 {
44 return wxT( "LIB_SHAPE" );
45 }
46
47 static inline bool ClassOf( const EDA_ITEM* aItem )
48 {
49 return aItem && aItem->Type() == LIB_SHAPE_T;
50 }
51
52 wxString GetTypeName() const override
53 {
54 return ShowShape();
55 }
56
57 STROKE_PARAMS GetStroke() const { return m_stroke; }
58 void SetStroke( const STROKE_PARAMS& aStroke ) { m_stroke = aStroke; }
59
60 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
61 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
62
63 int GetPenWidth() const override;
64
66 {
67 if( m_stroke.GetPlotStyle() == PLOT_DASH_TYPE::DEFAULT )
68 return PLOT_DASH_TYPE::SOLID;
69 else
70 return m_stroke.GetPlotStyle();
71 }
72
73 const BOX2I GetBoundingBox() const override;
74
75 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
76
77 void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); }
78 bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
79 void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
80
81 void EndEdit( bool aClosed = false ) override { endEdit( aClosed ); }
82 void SetEditState( int aState ) { setEditState( aState ); }
83
84 void AddPoint( const VECTOR2I& aPosition );
85
86 void Offset( const VECTOR2I& aOffset ) override;
87
88 void MoveTo( const VECTOR2I& aPosition ) override;
89
90 VECTOR2I GetPosition() const override { return getPosition(); }
91 void SetPosition( const VECTOR2I& aPosition ) override { setPosition( aPosition ); }
92
93 VECTOR2I GetCenter() const { return getCenter(); }
94
101 virtual std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override
102 {
103 return makeEffectiveShapes( aEdgeOnly, true );
104 }
105
106 void Normalize();
107
108 void MirrorHorizontal( const VECTOR2I& aCenter ) override;
109 void MirrorVertical( const VECTOR2I& aCenter ) override;
110 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
111
112 void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
113 const TRANSFORM& aTransform, bool aDimmed ) const override;
114
115 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
116
117 BITMAPS GetMenuImage() const override;
118
119 EDA_ITEM* Clone() const override;
120
121 void ViewGetLayers( int aLayers[], int& aCount ) const override;
122
123private:
132 int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
133
134 void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
135 const TRANSFORM& aTransform, bool aDimmed ) override;
136};
137
138
139#endif // LIB_SHAPE_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
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
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
VECTOR2I getCenter() const
Definition: eda_shape.cpp:444
void calcEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1284
bool continueEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1257
wxString ShowShape() const
Definition: eda_shape.cpp:57
std::vector< SHAPE * > makeEffectiveShapes(bool aEdgeOnly, bool aLineChainOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.cpp:1095
void beginEdit(const VECTOR2I &aStartPoint)
Definition: eda_shape.cpp:1226
void endEdit(bool aClosed=true)
Finishes editing the shape.
Definition: eda_shape.cpp:1414
void setPosition(const VECTOR2I &aPos)
Definition: eda_shape.cpp:93
VECTOR2I getPosition() const
Definition: eda_shape.cpp:99
STROKE_PARAMS m_stroke
Definition: eda_shape.h:361
void setEditState(int aState)
Definition: eda_shape.h:345
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
~LIB_SHAPE()
Definition: lib_shape.h:40
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: lib_shape.cpp:46
STROKE_PARAMS GetStroke() const
Definition: lib_shape.h:57
void print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, void *aData, const TRANSFORM &aTransform, bool aDimmed) override
Print the item to aDC.
Definition: lib_shape.cpp:275
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_shape.h:77
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_shape.cpp:461
void EndEdit(bool aClosed=false) override
End an object editing action.
Definition: lib_shape.h:81
void MirrorHorizontal(const VECTOR2I &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_shape.cpp:114
void SetStroke(const STROKE_PARAMS &aStroke)
Definition: lib_shape.h:58
void AddPoint(const VECTOR2I &aPosition)
Definition: lib_shape.cpp:518
void MirrorVertical(const VECTOR2I &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_shape.cpp:120
void Offset(const VECTOR2I &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_shape.cpp:81
void Plot(PLOTTER *aPlotter, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const override
Plot the draw item using the plot object.
Definition: lib_shape.cpp:134
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_shape.cpp:64
int GetPenWidth() const override
Definition: lib_shape.cpp:269
const BOX2I GetBoundingBox() const override
Definition: lib_shape.cpp:451
PLOT_DASH_TYPE GetEffectiveLineStyle() const
Definition: lib_shape.h:65
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_shape.cpp:126
wxString GetClass() const override
Return the class name.
Definition: lib_shape.h:42
int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_shape.cpp:70
void SetEditState(int aState)
Definition: lib_shape.h:82
void SetPosition(const VECTOR2I &aPosition) override
Definition: lib_shape.h:91
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition: lib_shape.h:78
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: lib_shape.cpp:469
static bool ClassOf(const EDA_ITEM *aItem)
Definition: lib_shape.h:47
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_shape.h:79
VECTOR2I GetCenter() const
Definition: lib_shape.h:93
wxString GetTypeName() const override
Provide a user-consumable name of the object type.
Definition: lib_shape.h:52
void MoveTo(const VECTOR2I &aPosition) override
Move a draw object to aPosition.
Definition: lib_shape.cpp:87
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_shape.cpp:501
void Normalize()
Definition: lib_shape.cpp:93
VECTOR2I GetPosition() const override
Definition: lib_shape.h:90
virtual std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the LIB_SHAPE.
Definition: lib_shape.h:101
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: lib_shape.cpp:536
Define a library symbol object.
Definition: lib_symbol.h:99
Base plotter engine class.
Definition: plotter.h:110
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88
PLOT_DASH_TYPE GetPlotStyle() const
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
SHAPE_T
Definition: eda_shape.h:41
FILL_T
Definition: eda_shape.h:54
PLOT_DASH_TYPE
Dashed line types.
Definition: stroke_params.h:48
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ LIB_SHAPE_T
Definition: typeinfo.h:189