KiCad PCB EDA Suite
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 {
71 else
72 return m_stroke.GetPlotStyle();
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 ) const override;
99
100 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
101
102 wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override;
103
104 BITMAPS GetMenuImage() const override;
105
106 EDA_ITEM* Clone() const override;
107
108 void ViewGetLayers( int aLayers[], int& aCount ) const override;
109
110#if defined(DEBUG)
111 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
112#endif
113
114private:
115 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
116 void PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
117
118 EDA_ANGLE getParentOrientation() const override { return ANGLE_0; }
119 VECTOR2I getParentPosition() const override { return VECTOR2I(); }
120};
121
122
123#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:397
void calcEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1268
bool continueEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1241
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:696
void beginEdit(const VECTOR2I &aStartPoint)
Definition: eda_shape.cpp:1210
void endEdit(bool aClosed=true)
Finishes editing the shape.
Definition: eda_shape.cpp:1396
void setPosition(const VECTOR2I &aPos)
Definition: eda_shape.cpp:93
const BOX2I getBoundingBox() const
Definition: eda_shape.cpp:635
VECTOR2I getPosition() const
Definition: eda_shape.cpp:99
STROKE_PARAMS m_stroke
Definition: eda_shape.h:364
void setEditState(int aState)
Definition: eda_shape.h:348
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Base plotter engine class.
Definition: plotter.h:110
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
PLOT_DASH_TYPE GetEffectiveLineStyle() const
Definition: sch_shape.h:67
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: sch_shape.cpp:402
void SetPosition(const VECTOR2I &aPos) override
Definition: sch_shape.h:78
void CalcEdit(const VECTOR2I &aPosition)
Definition: sch_shape.h:84
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:451
bool ContinueEdit(const VECTOR2I &aPosition)
Definition: sch_shape.h:83
VECTOR2I getParentPosition() const override
Definition: sch_shape.h:119
SCH_SHAPE(SHAPE_T aShape, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL, KICAD_T aType=SCH_SHAPE_T)
Definition: sch_shape.cpp:38
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_shape.cpp:94
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:67
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 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
VECTOR2I GetCenter() const
Definition: sch_shape.h:80
void Normalize()
Definition: sch_shape.cpp:73
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:100
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:394
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:106
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
Definition: sch_shape.cpp:112
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:460
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:434
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
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:244
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_shape.cpp:310
~SCH_SHAPE()
Definition: sch_shape.h:40
EDA_ANGLE getParentOrientation() const override
Definition: sch_shape.h:118
int GetPenWidth() const override
Definition: sch_shape.cpp:226
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:88
PLOT_DASH_TYPE GetPlotStyle() const
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
SHAPE_T
Definition: eda_shape.h:41
FILL_T
Definition: eda_shape.h:54
PLOT_DASH_TYPE
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:146
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618