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.GetPlotStyle() == PLOT_DASH_TYPE::DEFAULT )
70 return PLOT_DASH_TYPE::SOLID;
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 GetItemDescription( 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
119
120#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:514
void calcEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1371
bool continueEdit(const VECTOR2I &aPosition)
Definition: eda_shape.cpp:1344
bool hitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:823
void beginEdit(const VECTOR2I &aStartPoint)
Definition: eda_shape.cpp:1313
void endEdit(bool aClosed=true)
Finishes editing the shape.
Definition: eda_shape.cpp:1497
void setPosition(const VECTOR2I &aPos)
Definition: eda_shape.cpp:105
const BOX2I getBoundingBox() const
Definition: eda_shape.cpp:769
VECTOR2I getPosition() const
Definition: eda_shape.cpp:111
STROKE_PARAMS m_stroke
Definition: eda_shape.h:377
void setEditState(int aState)
Definition: eda_shape.h:361
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:150
PLOT_DASH_TYPE GetEffectiveLineStyle() const
Definition: sch_shape.h:67
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:436
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:485
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 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:63
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
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:428
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_shape.cpp:108
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
Definition: sch_shape.cpp:114
void AddPoint(const VECTOR2I &aPosition)
Definition: sch_shape.cpp:494
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_shape.cpp:468
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:234
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
Definition: sch_shape.cpp:300
~SCH_SHAPE()
Definition: sch_shape.h:40
int GetPenWidth() const override
Definition: sch_shape.cpp:216
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
PLOT_DASH_TYPE GetPlotStyle() const
Definition: stroke_params.h:94
SHAPE_T
Definition: eda_shape.h:42
FILL_T
Definition: eda_shape.h:55
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