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, int aLineWidth = 0, FILL_T aFillType = FILL_T::NO_FILL,
36 KICAD_T aType = SCH_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( "SCH_SHAPE" );
45 }
46
47 void SwapData( SCH_ITEM* aItem ) override;
48
49 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
50 {
51 return hitTest( aPosition, aAccuracy );
52 }
53
54 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
55 {
56 return hitTest( aRect, aContained, aAccuracy );
57 }
58
59 int GetPenWidth() const override;
60
61 int GetEffectiveWidth() const override { return GetPenWidth(); }
62
63 bool HasLineStroke() const override { return true; }
64 STROKE_PARAMS GetStroke() const override { return m_stroke; }
65 void SetStroke( const STROKE_PARAMS& aStroke ) override;
66
68 {
69 if( m_stroke.GetLineStyle() == LINE_STYLE::DEFAULT )
70 return LINE_STYLE::SOLID;
71 else
72 return m_stroke.GetLineStyle();
73 }
74
75 const BOX2I GetBoundingBox() const override { return getBoundingBox(); }
76
77 VECTOR2I GetPosition() const override { return getPosition(); }
78 void SetPosition( const VECTOR2I& aPos ) override { setPosition( aPos ); }
79
80 VECTOR2I GetCenter() const { return getCenter(); }
81
82 void BeginEdit( const VECTOR2I& aStartPoint ) { beginEdit( aStartPoint ); }
83 bool ContinueEdit( const VECTOR2I& aPosition ) { return continueEdit( aPosition ); }
84 void CalcEdit( const VECTOR2I& aPosition ) { calcEdit( aPosition ); }
85 void EndEdit() { endEdit(); }
86 void SetEditState( int aState ) { setEditState( aState ); }
87
88 void Move( const VECTOR2I& aOffset ) override;
89
90 void Normalize();
91
92 void MirrorHorizontally( int aCenter ) override;
93 void MirrorVertically( int aCenter ) override;
94 void Rotate( const VECTOR2I& aCenter ) override;
95
96 void AddPoint( const VECTOR2I& aPosition );
97
98 void Plot( PLOTTER* aPlotter, bool aBackground,
99 const SCH_PLOT_SETTINGS& aPlotSettings ) const override;
100
101 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
102
103 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
104
105 BITMAPS GetMenuImage() const override;
106
107 EDA_ITEM* Clone() const override;
108
109 void ViewGetLayers( int aLayers[], int& aCount ) const override;
110
111 double Similarity( const SCH_ITEM& aOther ) const override;
112
113 bool operator==( const SCH_ITEM& aOther ) const override;
114
115#if defined(DEBUG)
116 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
117#endif
118
119protected:
120 void setFilled( bool aFlag ) override
121 {
122 m_fill = aFlag ? FILL_T::FILLED_WITH_COLOR : FILL_T::NO_FILL;
123 }
124
125
126private:
127 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
128 void PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
129};
130
131
132#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:85
VECTOR2I getCenter() const
Definition: eda_shape.cpp:512
void calcEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1415
bool continueEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1381
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:837
void beginEdit(const VECTOR2I &aStartPoint)
Definition: eda_shape.cpp:1340
void endEdit(bool aClosed=true)
Finishes editing the shape.
Definition: eda_shape.cpp:1569
void setPosition(const VECTOR2I &aPos)
Definition: eda_shape.cpp:103
const BOX2I getBoundingBox() const
Definition: eda_shape.cpp:783
VECTOR2I getPosition() const
Definition: eda_shape.cpp:109
STROKE_PARAMS m_stroke
Definition: eda_shape.h:395
void setEditState(int aState)
Definition: eda_shape.h:379
FILL_T m_fill
Definition: eda_shape.h:396
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
Definition: plotter.h:104
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:165
void SetPosition(const VECTOR2I &aPos) override
Definition: sch_shape.h:78
void CalcEdit(const VECTOR2I &aPosition)
Definition: sch_shape.h:84
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: sch_shape.cpp:432
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_shape.cpp:482
bool ContinueEdit(const VECTOR2I &aPosition)
Definition: sch_shape.h:83
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_shape.cpp:96
bool HitTest(const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
Test if aRect intersects this item.
Definition: sch_shape.h:54
void BeginEdit(const VECTOR2I &aStartPoint)
Definition: sch_shape.h:82
void Move(const VECTOR2I &aOffset) override
Move the item by aMoveVector to a new position.
Definition: sch_shape.cpp:69
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_SETTINGS &aPlotSettings) const override
Plot the schematic item to aPlotter.
Definition: sch_shape.cpp:114
void SetEditState(int aState)
Definition: sch_shape.h:86
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:120
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: sch_shape.cpp:63
LINE_STYLE GetEffectiveLineStyle() const
Definition: sch_shape.h:67
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:80
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:518
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_shape.h:75
void EndEdit()
Definition: sch_shape.h:85
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:424
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:108
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:491
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:464
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.h:49
bool HasLineStroke() const override
Check if this schematic item has line stoke properties.
Definition: sch_shape.h:63
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_shape.cpp:507
wxString GetClass() const override
Return the class name.
Definition: sch_shape.h:42
void PrintBackground(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print the (optional) backaground elements if they exist.
Definition: sch_shape.cpp:230
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_shape.cpp:296
~SCH_SHAPE()
Definition: sch_shape.h:40
int GetPenWidth() const override
Definition: sch_shape.cpp:212
STROKE_PARAMS GetStroke() const override
Definition: sch_shape.h:64
VECTOR2I GetPosition() const override
Definition: sch_shape.h:77
int GetEffectiveWidth() const override
Definition: sch_shape.h:61
Simple container to manage line stroke parameters.
Definition: stroke_params.h:81
LINE_STYLE GetLineStyle() const
Definition: stroke_params.h:94
SHAPE_T
Definition: eda_shape.h:42
FILL_T
Definition: eda_shape.h:54
LINE_STYLE
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
@ SCH_SHAPE_T
Definition: typeinfo.h:149