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:
36 SCH_SHAPE( SHAPE_T aShape = SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer = LAYER_NOTES,
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 wxString GetClass() const override
45 {
46 return wxT( "SCH_SHAPE" );
47 }
48
49 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
50 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
51
52 bool IsEndPoint( const VECTOR2I& aPoint ) const override;
53
54 int GetPenWidth() const override { return GetStroke().GetWidth(); }
55
56 bool HasLineStroke() const override { return true; }
57 STROKE_PARAMS GetStroke() const override { return m_stroke; }
58 void SetStroke( const STROKE_PARAMS& aStroke ) override;
59
60 int GetEffectiveWidth() const override;
61
63 {
64 if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT )
65 return LINE_STYLE::SOLID;
66 else
67 return m_stroke.GetLineStyle();
68 }
69
70 int GetHatchLineWidth() const override
71 {
72 return GetEffectiveWidth() / 2;
73 }
74
75 int GetHatchLineSpacing() const override
76 {
77 return GetHatchLineWidth() * 40;
78 }
79
80 void SetFilled( bool aFilled ) override;
81
82 const BOX2I GetBoundingBox() const override;
83
84 VECTOR2I GetPosition() const override { return getPosition(); }
85 void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
86
87 VECTOR2I GetCenter() const { return getCenter(); }
88
89 void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); }
90 bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
91 void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
92 void EndEdit( bool aClosed = false ) override { endEdit(); }
93 void SetEditState( int aState ) { setEditState( aState ); }
94
95 void Move( const VECTOR2I& aOffset ) override;
96
97 void Normalize();
98
99 void MirrorHorizontally( int aCenter ) override;
100 void MirrorVertically( int aCenter ) override;
101 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
102
103 void AddPoint( const VECTOR2I& aPosition );
104
111 std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override
112 {
113 return makeEffectiveShapes( aEdgeOnly, true );
114 }
115
116 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
117 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
118
119 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
120
121 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
122
123 BITMAPS GetMenuImage() const override;
124
125 EDA_ITEM* Clone() const override;
126
127 std::vector<int> ViewGetLayers() const override;
128
129 double Similarity( const SCH_ITEM& aOther ) const override;
130
131 bool operator==( const SCH_ITEM& aOther ) const override;
132
133#if defined(DEBUG)
134 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
135#endif
136
137protected:
138 void swapData( SCH_ITEM* aItem ) override;
139
140 void setFilled( bool aFlag ) override
141 {
142 m_fill = aFlag ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL;
143 }
144
145 bool isMoving() const override { return IsMoving(); }
146
147 int getMaxError() const override
148 {
149 if( SCHEMATIC* schematic = Schematic() )
150 return schematic->Settings().m_MaxError;
151 else
153 }
154
163 int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
164};
165
166
167#endif // SCH_SHAPE_H
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:114
constexpr double ARC_LOW_DEF_MM
Definition: base_units.h:118
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:98
bool IsMoving() const
Definition: eda_item.h:125
VECTOR2I getCenter() const
Definition: eda_shape.cpp:930
void calcEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1991
bool continueEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1957
std::vector< SHAPE * > makeEffectiveShapes(bool aEdgeOnly, bool aLineChainOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.cpp:1790
void beginEdit(const VECTOR2I &aStartPoint)
Definition: eda_shape.cpp:1916
void endEdit(bool aClosed=true)
Finish editing the shape.
Definition: eda_shape.cpp:2145
void setPosition(const VECTOR2I &aPos)
Definition: eda_shape.cpp:360
VECTOR2I getPosition() const
Definition: eda_shape.cpp:366
STROKE_PARAMS m_stroke
Definition: eda_shape.h:490
void setEditState(int aState)
Definition: eda_shape.h:468
FILL_T m_fill
Definition: eda_shape.h:491
Base plotter engine class.
Definition: plotter.h:121
Holds all the data relating to one schematic.
Definition: schematic.h:88
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:168
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:246
void SetPosition(const VECTOR2I &aPos) override
Definition: sch_shape.h:85
bool isMoving() const override
Definition: sch_shape.h:145
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_shape.cpp:105
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_shape.cpp:326
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition: sch_shape.h:111
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:89
void SetFilled(bool aFilled) override
Definition: sch_shape.cpp:67
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition: sch_shape.cpp:78
void SetEditState(int aState)
Definition: sch_shape.h:93
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_shape.cpp:46
void setFilled(bool aFlag) override
Definition: sch_shape.h:140
void EndEdit(bool aClosed=false) override
End an object editing action.
Definition: sch_shape.h:92
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_shape.cpp:61
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_shape.cpp:52
LINE_STYLE GetEffectiveLineStyle() const
Definition: sch_shape.h:62
VECTOR2I GetCenter() const
Definition: sch_shape.h:87
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition: sch_shape.h:90
void Normalize()
Definition: sch_shape.cpp:84
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: sch_shape.cpp:430
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.
Definition: sch_shape.cpp:149
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_shape.cpp:312
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_shape.cpp:111
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.
Definition: sch_shape.cpp:318
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:400
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:358
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_shape.cpp:123
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: sch_shape.h:91
int GetHatchLineSpacing() const override
Definition: sch_shape.h:75
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:117
bool HasLineStroke() const override
Check if this schematic item has line stoke properties.
Definition: sch_shape.h:56
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:419
wxString GetClass() const override
Return the class name.
Definition: sch_shape.h:44
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_shape.cpp:376
int GetPenWidth() const override
Definition: sch_shape.h:54
bool IsEndPoint(const VECTOR2I &aPoint) const override
Test if aPt is an end point of this schematic object.
Definition: sch_shape.cpp:138
int GetHatchLineWidth() const override
Definition: sch_shape.h:70
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:57
VECTOR2I GetPosition() const override
Definition: sch_shape.h:84
int GetEffectiveWidth() const override
Definition: sch_shape.cpp:294
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: sch_shape.cpp:448
int getMaxError() const override
Definition: sch_shape.h:147
Simple container to manage line stroke parameters.
Definition: stroke_params.h:94
int GetWidth() const
LINE_STYLE GetLineStyle() const
SHAPE_T
Definition: eda_shape.h:43
FILL_T
Definition: eda_shape.h:56
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:439
@ LAYER_NOTES
Definition: layer_ids.h:457
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
constexpr int mmToIU(double mm) const
Definition: base_units.h:92
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_SHAPE_T
Definition: typeinfo.h:150