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 (C) 2004-2021 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
31
32class SCH_SHAPE : public SCH_ITEM, public EDA_SHAPE
33{
34public:
35 SCH_SHAPE( SHAPE_T aShape = SHAPE_T::UNDEFINED, SCH_LAYER_ID aLayer = LAYER_NOTES,
36 int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL, KICAD_T aType = SCH_SHAPE_T );
37
38 // Do not create a copy constructor. The one generated by the compiler is adequate.
39
40 virtual ~SCH_SHAPE() override {}
41
42 wxString GetClass() const override
43 {
44 return wxT( "SCH_SHAPE" );
45 }
46
47 void SwapData( SCH_ITEM* aItem ) override;
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 int GetPenWidth() const override { return GetStroke().GetWidth(); }
53
54 bool HasLineStroke() const override { return true; }
55 STROKE_PARAMS GetStroke() const override { return m_stroke; }
56 void SetStroke( const STROKE_PARAMS& aStroke ) override;
57
58 int GetEffectiveWidth() const override;
59
61 {
62 if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT )
63 return LINE_STYLE::SOLID;
64 else
65 return m_stroke.GetLineStyle();
66 }
67
68 const BOX2I GetBoundingBox() const override;
69
70 VECTOR2I GetPosition() const override { return getPosition(); }
71 void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
72
73 VECTOR2I GetCenter() const { return getCenter(); }
74
75 void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); }
76 bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
77 void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
78 void EndEdit( bool aClosed = false ) override { endEdit(); }
79 void SetEditState( int aState ) { setEditState( aState ); }
80
81 void Move( const VECTOR2I& aOffset ) override;
82
83 void Normalize();
84
85 void MirrorHorizontally( int aCenter ) override;
86 void MirrorVertically( int aCenter ) override;
87 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
88
89 void AddPoint( const VECTOR2I& aPosition );
90
97 std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override
98 {
99 return makeEffectiveShapes( aEdgeOnly, true );
100 }
101
102 void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
103 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override;
104
105 void PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
106 const VECTOR2I& aOffset, bool aDimmed ) override;
107
108 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
109 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
110
111 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
112
113 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
114
115 BITMAPS GetMenuImage() const override;
116
117 EDA_ITEM* Clone() const override;
118
119 std::vector<int> ViewGetLayers() const override;
120
121 double Similarity( const SCH_ITEM& aOther ) const override;
122
123 bool operator==( const SCH_ITEM& aOther ) const override;
124
125#if defined(DEBUG)
126 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
127#endif
128
129protected:
130 void setFilled( bool aFlag ) override
131 {
132 m_fill = aFlag ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL;
133 }
134
143 int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
144};
145
146
147#endif // SCH_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:89
VECTOR2I getCenter() const
Definition: eda_shape.cpp:752
void calcEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1661
bool continueEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1627
std::vector< SHAPE * > makeEffectiveShapes(bool aEdgeOnly, bool aLineChainOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.cpp:1461
void beginEdit(const VECTOR2I &aStartPoint)
Definition: eda_shape.cpp:1586
void endEdit(bool aClosed=true)
Finishes editing the shape.
Definition: eda_shape.cpp:1815
void setPosition(const VECTOR2I &aPos)
Definition: eda_shape.cpp:357
VECTOR2I getPosition() const
Definition: eda_shape.cpp:363
STROKE_PARAMS m_stroke
Definition: eda_shape.h:422
void setEditState(int aState)
Definition: eda_shape.h:406
FILL_T m_fill
Definition: eda_shape.h:423
Base plotter engine class.
Definition: plotter.h:105
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
void SetPosition(const VECTOR2I &aPos) override
Definition: sch_shape.h:71
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_shape.cpp:96
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_shape.cpp:510
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition: sch_shape.h:97
virtual ~SCH_SHAPE() override
Definition: sch_shape.h:40
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print an item.
Definition: sch_shape.cpp:333
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: sch_shape.h:75
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition: sch_shape.cpp:69
void SetEditState(int aState)
Definition: sch_shape.h:79
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:130
void EndEdit(bool aClosed=false) override
End an object editing action.
Definition: sch_shape.h:78
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_shape.cpp:63
LINE_STYLE GetEffectiveLineStyle() const
Definition: sch_shape.h:60
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_shape.cpp:52
VECTOR2I GetCenter() const
Definition: sch_shape.h:73
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition: sch_shape.h:76
void Normalize()
Definition: sch_shape.cpp:75
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:609
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:129
void PrintBackground(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Print just the background fills.
Definition: sch_shape.cpp:271
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_shape.cpp:265
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_shape.cpp:102
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:499
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:579
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:542
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:114
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: sch_shape.h:77
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:108
bool HasLineStroke() const override
Check if this schematic item has line stoke properties.
Definition: sch_shape.h:54
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:598
wxString GetClass() const override
Return the class name.
Definition: sch_shape.h:42
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:560
int GetPenWidth() const override
Definition: sch_shape.h:52
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:55
VECTOR2I GetPosition() const override
Definition: sch_shape.h:70
int GetEffectiveWidth() const override
Definition: sch_shape.cpp:247
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:627
Simple container to manage line stroke parameters.
Definition: stroke_params.h:79
int GetWidth() const
Definition: stroke_params.h:89
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:92
SHAPE_T
Definition: eda_shape.h:43
FILL_T
Definition: eda_shape.h:56
SCH_LAYER_ID
Eeschema drawing layers.
Definition: layer_ids.h:353
@ LAYER_NOTES
Definition: layer_ids.h:371
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_SHAPE_T
Definition: typeinfo.h:149