KiCad PCB EDA Suite
lib_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 LIB_SHAPE_H
26 #define LIB_SHAPE_H
27 
28 #include <lib_item.h>
29 #include <eda_shape.h>
30 
31 
32 class LIB_SHAPE : public LIB_ITEM, public EDA_SHAPE
33 {
34 public:
35  LIB_SHAPE( LIB_SYMBOL* aParent, SHAPE_T aShape, int aLineWidth = 0,
36  FILL_T aFillType = FILL_T::NO_FILL );
37 
38  // Do not create a copy constructor. The one generated by the compiler is adequate.
39 
40  ~LIB_SHAPE() { }
41 
42  wxString GetClass() const override
43  {
44  return wxT( "LIB_SHAPE" );
45  }
46 
47  wxString GetTypeName() const override
48  {
49  return ShowShape();
50  }
51 
52  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
53  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
54 
55  int GetPenWidth() const override;
56 
57  int GetEffectivePenWidth( const RENDER_SETTINGS* aSettings ) const override
58  {
59  // For historical reasons, a stored value of 0 means "default width" and negative
60  // numbers meant "don't stroke".
61 
62  if( GetPenWidth() < 0 && GetFillType() != FILL_T::NO_FILL )
63  return 0;
64  else if( GetPenWidth() == 0 )
65  return aSettings->GetDefaultPenWidth();
66  else
67  return std::max( GetPenWidth(), aSettings->GetMinPenWidth() );
68  }
69 
70  const EDA_RECT GetBoundingBox() const override;
71 
72  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
73 
74  void BeginEdit( const wxPoint& aStartPoint ) override { beginEdit( aStartPoint ); }
75  bool ContinueEdit( const wxPoint& aPosition ) override { return continueEdit( aPosition ); }
76  void CalcEdit( const wxPoint& aPosition ) override { calcEdit( aPosition ); }
77  void EndEdit() override { endEdit(); }
78  void SetEditState( int aState ) { setEditState( aState ); }
79 
80  void AddPoint( const wxPoint& aPosition );
81 
82  void Offset( const wxPoint& aOffset ) override;
83 
84  void MoveTo( const wxPoint& aPosition ) override;
85 
86  wxPoint GetPosition() const override { return getPosition(); }
87  void SetPosition( const wxPoint& aPosition ) override { setPosition( aPosition ); }
88 
89  wxPoint GetCenter() const { return getCenter(); }
90 
91  void CalcArcAngles( int& aStartAngle, int& aEndAngle ) const;
92 
93  void MirrorHorizontal( const wxPoint& aCenter ) override;
94  void MirrorVertical( const wxPoint& aCenter ) override;
95  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
96 
97  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
98  const TRANSFORM& aTransform ) const override;
99 
100  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
101 
102  BITMAPS GetMenuImage() const override;
103 
104  EDA_ITEM* Clone() const override;
105 
106 private:
115  int compare( const LIB_ITEM& aOther,
116  LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
117 
118  void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
119  const TRANSFORM& aTransform ) override;
120 
121  double getParentOrientation() const override { return 0.0; }
122  wxPoint getParentPosition() const override { return wxPoint(); }
123 };
124 
125 
126 #endif // LIB_SHAPE_H
void CalcArcAngles(int &aStartAngle, int &aEndAngle) const
Definition: lib_shape.cpp:423
double getParentOrientation() const override
Definition: lib_shape.h:121
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_shape.cpp:350
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_shape.cpp:63
void AddPoint(const wxPoint &aPosition)
Definition: lib_shape.cpp:407
void endEdit()
Definition: eda_shape.cpp:1375
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_shape.cpp:390
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
wxPoint getCenter() const
Definition: eda_shape.cpp:393
void EndEdit() override
End an object editing action.
Definition: lib_shape.h:77
void calcEdit(const wxPoint &aPosition)
Definition: eda_shape.cpp:1250
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_shape.cpp:104
void SetEditState(int aState)
Definition: lib_shape.h:78
void setEditState(int aState)
Definition: eda_shape.h:292
void beginEdit(const wxPoint &aStartPoint)
Definition: eda_shape.cpp:1192
~LIB_SHAPE()
Definition: lib_shape.h:40
The base class for create windows for drawing purpose.
wxString ShowShape() const
Definition: eda_shape.cpp:56
Define a library symbol object.
Definition: lib_symbol.h:96
FILL_T
Definition: eda_shape.h:53
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_shape.cpp:92
int GetPenWidth() const override
Definition: lib_shape.cpp:208
wxString GetTypeName() const override
Provide a user-consumable name of the object type.
Definition: lib_shape.h:47
void SetPosition(const wxPoint &aPosition) override
Definition: lib_shape.h:87
int GetEffectivePenWidth(const RENDER_SETTINGS *aSettings) const override
Definition: lib_shape.h:57
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
COMPARE_FLAGS
The list of flags used by the compare function.
Definition: lib_item.h:80
wxString GetClass() const override
Return the class name.
Definition: lib_shape.h:42
SHAPE_T
Definition: eda_shape.h:40
void BeginEdit(const wxPoint &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_shape.h:74
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_shape.cpp:98
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) const override
Plot the draw item using the plot object.
Definition: lib_shape.cpp:112
wxPoint getParentPosition() const override
Definition: lib_shape.h:122
void CalcEdit(const wxPoint &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_shape.h:76
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: lib_shape.cpp:45
wxPoint GetCenter() const
Definition: lib_shape.h:89
void setPosition(const wxPoint &aPos)
Definition: eda_shape.cpp:89
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_shape.cpp:80
const EDA_RECT GetBoundingBox() const override
Definition: lib_shape.cpp:340
EDA_UNITS
Definition: eda_units.h:38
void print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_shape.cpp:214
Base plotter engine class.
Definition: plotter.h:121
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_shape.cpp:86
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: lib_shape.cpp:358
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
Handle the component boundary box.
Definition: eda_rect.h:42
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
LIB_SHAPE(LIB_SYMBOL *aParent, SHAPE_T aShape, int aLineWidth=0, FILL_T aFillType=FILL_T::NO_FILL)
Definition: lib_shape.cpp:36
wxPoint getPosition() const
Definition: eda_shape.cpp:95
int GetDefaultPenWidth() const
int compare(const LIB_ITEM &aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags=LIB_ITEM::COMPARE_FLAGS::NORMAL) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_shape.cpp:69
wxPoint GetPosition() const override
Definition: lib_shape.h:86
bool ContinueEdit(const wxPoint &aPosition) override
Continue an edit in progress at aPosition.
Definition: lib_shape.h:75
bool continueEdit(const wxPoint &aPosition)
Definition: eda_shape.cpp:1223
FILL_T GetFillType() const
Definition: eda_shape.h:79