KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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, jaen-pierre.charras@gipsa-lab.inpg.com
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
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,
37 KICAD_T aType = SCH_SHAPE_T );
38
39 // Do not create a copy constructor. The one generated by the compiler is adequate.
40
41 virtual ~SCH_SHAPE() override {}
42
43 wxString GetClass() const override
44 {
45 return wxT( "SCH_SHAPE" );
46 }
47
48 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
49 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
50
51 int GetPenWidth() const override { return GetStroke().GetWidth(); }
52
53 bool HasLineStroke() const override { return true; }
54 STROKE_PARAMS GetStroke() const override { return m_stroke; }
55 void SetStroke( const STROKE_PARAMS& aStroke ) override;
56
57 int GetEffectiveWidth() const override;
58
60 {
61 if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT )
62 return LINE_STYLE::SOLID;
63 else
64 return m_stroke.GetLineStyle();
65 }
66
67 int GetHatchLineWidth() const override
68 {
69 return GetEffectiveWidth() / 2;
70 }
71
72 int GetHatchLineSpacing() const override
73 {
74 return GetHatchLineWidth() * 40;
75 }
76
77 void SetFilled( bool aFilled ) override;
78
79 const BOX2I GetBoundingBox() const override;
80
81 VECTOR2I GetPosition() const override { return getPosition(); }
82 void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
83
84 VECTOR2I GetCenter() const { return getCenter(); }
85
86 void BeginEdit( const VECTOR2I& aStartPoint ) override { beginEdit( aStartPoint ); }
87 bool ContinueEdit( const VECTOR2I& aPosition ) override { return continueEdit( aPosition ); }
88 void CalcEdit( const VECTOR2I& aPosition ) override { calcEdit( aPosition ); }
89 void EndEdit( bool aClosed = false ) override { endEdit(); }
90 void SetEditState( int aState ) { setEditState( aState ); }
91
92 void Move( const VECTOR2I& aOffset ) override;
93
94 void Normalize();
95
96 void MirrorHorizontally( int aCenter ) override;
97 void MirrorVertically( int aCenter ) override;
98 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
99
100 void AddPoint( const VECTOR2I& aPosition );
101
108 std::vector<SHAPE*> MakeEffectiveShapes( bool aEdgeOnly = false ) const override
109 {
110 return makeEffectiveShapes( aEdgeOnly, true );
111 }
112
113 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
114 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
115
116 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
117
118 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
119
120 BITMAPS GetMenuImage() const override;
121
122 EDA_ITEM* Clone() const override;
123
124 std::vector<int> ViewGetLayers() const override;
125
126 double Similarity( const SCH_ITEM& aOther ) const override;
127
128 bool operator==( const SCH_ITEM& aOther ) const override;
129
130#if defined(DEBUG)
131 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
132#endif
133
134protected:
135 void swapData( SCH_ITEM* aItem ) override;
136
137 void setFilled( bool aFlag ) override
138 {
139 m_fill = aFlag ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL;
140 }
141
150 int compare( const SCH_ITEM& aOther, int aCompareFlags = 0 ) const override;
151};
152
153
154#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:95
VECTOR2I getCenter() const
Definition: eda_shape.cpp:886
void calcEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1919
bool continueEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1885
std::vector< SHAPE * > makeEffectiveShapes(bool aEdgeOnly, bool aLineChainOnly=false) const
Make a set of SHAPE objects representing the EDA_SHAPE.
Definition: eda_shape.cpp:1718
void beginEdit(const VECTOR2I &aStartPoint)
Definition: eda_shape.cpp:1844
void endEdit(bool aClosed=true)
Finish editing the shape.
Definition: eda_shape.cpp:2073
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:485
void setEditState(int aState)
Definition: eda_shape.h:465
FILL_T m_fill
Definition: eda_shape.h:486
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:168
void SetPosition(const VECTOR2I &aPos) override
Definition: sch_shape.h:82
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_shape.cpp:107
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_shape.cpp:320
std::vector< SHAPE * > MakeEffectiveShapes(bool aEdgeOnly=false) const override
Make a set of SHAPE objects representing the SCH_SHAPE.
Definition: sch_shape.h:108
virtual ~SCH_SHAPE() override
Definition: sch_shape.h:41
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: sch_shape.h:86
void SetFilled(bool aFilled) override
Definition: sch_shape.cpp:69
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition: sch_shape.cpp:80
void SetEditState(int aState)
Definition: sch_shape.h:90
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:137
void EndEdit(bool aClosed=false) override
End an object editing action.
Definition: sch_shape.h:89
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_shape.cpp:63
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:59
VECTOR2I GetCenter() const
Definition: sch_shape.h:84
bool ContinueEdit(const VECTOR2I &aPosition) override
Continue an edit in progress at aPosition.
Definition: sch_shape.h:87
void Normalize()
Definition: sch_shape.cpp:86
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:424
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:140
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_shape.cpp:303
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_shape.cpp:113
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:309
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:394
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:352
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:125
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: sch_shape.h:88
int GetHatchLineSpacing() const override
Definition: sch_shape.h:72
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:119
bool HasLineStroke() const override
Check if this schematic item has line stoke properties.
Definition: sch_shape.h:53
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:413
wxString GetClass() const override
Return the class name.
Definition: sch_shape.h:43
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:370
int GetPenWidth() const override
Definition: sch_shape.h:51
int GetHatchLineWidth() const override
Definition: sch_shape.h:67
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:54
VECTOR2I GetPosition() const override
Definition: sch_shape.h:81
int GetEffectiveWidth() const override
Definition: sch_shape.cpp:285
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:442
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:438
@ LAYER_NOTES
Definition: layer_ids.h:456
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