KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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 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, 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 SCH_SHAPE_H
26#define SCH_SHAPE_H
27
28#include <sch_item.h>
29#include <eda_shape.h>
30#include <schematic.h>
31
32
33class SCH_SHAPE : public SCH_ITEM, public EDA_SHAPE
34{
35public:
37 int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL,
38 KICAD_T aType = SCH_SHAPE_T );
39
40 // Do not create a copy constructor. The one generated by the compiler is adequate.
41
42 virtual ~SCH_SHAPE() override {}
43
44 void Serialize( google::protobuf::Any& aContainer ) const override;
45 bool Deserialize( const google::protobuf::Any& aContainer ) override;
46
47 wxString GetClass() const override
48 {
49 return wxT( "SCH_SHAPE" );
50 }
51
52 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
53 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
54 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
55
56 bool IsEndPoint( const VECTOR2I& aPoint ) const override;
57
58 int GetPenWidth() const override { return GetStroke().GetWidth(); }
59
60 bool HasLineStroke() const override { return true; }
61 STROKE_PARAMS GetStroke() const override { return m_stroke; }
62 void SetStroke( const STROKE_PARAMS& aStroke ) override;
63
64 int GetEffectiveWidth() const override;
65
67 {
68 if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT )
69 return LINE_STYLE::SOLID;
70 else
71 return m_stroke.GetLineStyle();
72 }
73
74 int GetHatchLineWidth() const override
75 {
76 return GetEffectiveWidth() / 2;
77 }
78
79 int GetHatchLineSpacing() const override
80 {
81 return GetHatchLineWidth() * 40;
82 }
83
84 void SetFilled( bool aFilled ) override;
85
86 const BOX2I GetBoundingBox() const override;
87
88 VECTOR2I GetPosition() const override { return getPosition(); }
89 void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
90
91 VECTOR2I GetCenter() const { return getCenter(); }
92
93 void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); }
94 bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
95 void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
96 void EndEdit( bool aClosed = false ) override { endEdit(); }
97 void SetEditState( int aState ) { setEditState( aState ); }
98
99 void Move( const VECTOR2I& aOffset ) override;
100
101 void Normalize();
102
103 void MirrorHorizontally( int aCenter ) override;
104 void MirrorVertically( int aCenter ) override;
105 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
106
107 void AddPoint( const VECTOR2I& aPosition );
108
115 std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override
116 {
117 return makeEffectiveShapes( aEdgeOnly, true );
118 }
119
120 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
121 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
122
123 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
124
125 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
126
127 BITMAPS GetMenuImage() const override;
128
129 EDA_ITEM* Clone() const override;
130
131 std::vector<int> ViewGetLayers() const override;
132
133 double Similarity( const SCH_ITEM& aOther ) const override;
134
135 bool operator==( const SCH_ITEM& aOther ) const override;
136
137#if defined(DEBUG)
138 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
139#endif
140
141protected:
142 void swapData( SCH_ITEM* aItem ) override;
143
144 void setFilled( bool aFlag ) override
145 {
147 }
148
149 bool isMoving() const override { return IsMoving(); }
150
151 int getMaxError() const override { return GetMaxError(); }
152
161 int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
162};
163
164
165#endif // SCH_SHAPE_H
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
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:100
bool IsMoving() const
Definition eda_item.h:127
VECTOR2I getCenter() const
std::vector< SHAPE * > makeEffectiveShapes(bool aEdgeOnly, bool aLineChainOnly=false, bool aHittesting=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
void calcEdit(const VECTOR2I &aPosition)
bool continueEdit(const VECTOR2I &aPosition)
EDA_SHAPE(SHAPE_T aType, int aLineWidth, FILL_T aFill)
Definition eda_shape.cpp:55
void beginEdit(const VECTOR2I &aStartPoint)
void endEdit(bool aClosed=true)
Finish editing the shape.
void setPosition(const VECTOR2I &aPos)
VECTOR2I getPosition() const
STROKE_PARAMS m_stroke
Definition eda_shape.h:519
void setEditState(int aState)
Definition eda_shape.h:492
FILL_T m_fill
Definition eda_shape.h:520
Base plotter engine class.
Definition plotter.h:136
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
int GetMaxError() const
Definition sch_item.cpp:761
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:56
void SetPosition(const VECTOR2I &aPos) override
Definition sch_shape.h:89
bool isMoving() const override
Definition sch_shape.h:149
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition sch_shape.cpp:74
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition sch_shape.h:115
virtual ~SCH_SHAPE() override
Definition sch_shape.h:42
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition sch_shape.h:93
void SetFilled(bool aFilled) override
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
void SetEditState(int aState)
Definition sch_shape.h:97
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition sch_shape.cpp:51
void setFilled(bool aFlag) override
Definition sch_shape.h:144
void EndEdit(bool aClosed=false) override
End an object editing action.
Definition sch_shape.h:96
void SetStroke(const STROKE_PARAMS &aStroke) override
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition sch_shape.cpp:92
LINE_STYLE GetEffectiveLineStyle() const
Definition sch_shape.h:66
VECTOR2I GetCenter() const
Definition sch_shape.h:91
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition sch_shape.h:94
void Normalize()
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
SCH_SHAPE(SHAPE_T aShape=SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer=LAYER_NOTES, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=SCH_SHAPE_T)
Definition sch_shape.cpp:42
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
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.
void AddPoint(const VECTOR2I &aPosition)
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition sch_shape.h:95
int GetHatchLineSpacing() const override
Definition sch_shape.h:79
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
bool HasLineStroke() const override
Check if this schematic item has line stoke properties.
Definition sch_shape.h:60
bool operator==(const SCH_ITEM &aOther) const override
wxString GetClass() const override
Return the class name.
Definition sch_shape.h:47
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
int GetPenWidth() const override
Definition sch_shape.h:58
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition sch_shape.cpp:57
int GetHatchLineWidth() const override
Definition sch_shape.h:74
STROKE_PARAMS GetStroke() const override
Definition sch_shape.h:61
VECTOR2I GetPosition() const override
Definition sch_shape.h:88
int GetEffectiveWidth() const override
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
int getMaxError() const override
Definition sch_shape.h:151
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Simple container to manage line stroke parameters.
int GetWidth() const
SHAPE_T
Definition eda_shape.h:46
@ UNDEFINED
Definition eda_shape.h:47
FILL_T
Definition eda_shape.h:59
@ FILLED_WITH_COLOR
Definition eda_shape.h:63
@ NO_FILL
Definition eda_shape.h:60
SCH_LAYER_ID
Eeschema drawing layers.
Definition layer_ids.h:451
@ LAYER_NOTES
Definition layer_ids.h:469
LINE_STYLE
Dashed line types.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:75
@ SCH_SHAPE_T
Definition typeinfo.h:150
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687