KiCad PCB EDA Suite
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
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  *
20  * or you may search the 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  */
25 #ifndef LIB_SHAPE_H
26 #define LIB_SHAPE_H
28 #include <lib_item.h>
29 #include <eda_shape.h>
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 );
38  // Do not create a copy constructor. The one generated by the compiler is adequate.
40  ~LIB_SHAPE() { }
42  wxString GetClass() const override
43  {
44  return wxT( "LIB_SHAPE" );
45  }
47  wxString GetTypeName() const override
48  {
49  return ShowShape();
50  }
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;
55  int GetPenWidth() const override;
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".
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  }
70  const EDA_RECT GetBoundingBox() const override;
72  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
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 ); }
78  void EndEdit() override { endEdit( false ); }
79  void SetEditState( int aState ) { setEditState( aState ); }
81  void AddPoint( const wxPoint& aPosition );
83  void Offset( const wxPoint& aOffset ) override;
85  void MoveTo( const wxPoint& aPosition ) override;
87  wxPoint GetPosition() const override { return getPosition(); }
88  void SetPosition( const wxPoint& aPosition ) override { setPosition( aPosition ); }
90  wxPoint GetCenter() const { return getCenter(); }
92  void CalcArcAngles( int& aStartAngle, int& aEndAngle ) const;
94  void MirrorHorizontal( const wxPoint& aCenter ) override;
95  void MirrorVertical( const wxPoint& aCenter ) override;
96  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
98  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
99  const TRANSFORM& aTransform ) const override;
101  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
103  BITMAPS GetMenuImage() const override;
105  EDA_ITEM* Clone() const override;
107 private:
116  int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
118  void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
119  const TRANSFORM& aTransform ) override;
121  double getParentOrientation() const override { return 0.0; }
122  wxPoint getParentPosition() const override { return wxPoint(); }
123 };
126 #endif // LIB_SHAPE_H
void CalcArcAngles(int &aStartAngle, int &aEndAngle) const
Definition: lib_shape.cpp:430
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:357
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:414
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_shape.cpp:397
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:78
void calcEdit(const wxPoint &aPosition)
Definition: eda_shape.cpp:1291
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:79
void setEditState(int aState)
Definition: eda_shape.h:315
void beginEdit(const wxPoint &aStartPoint)
Definition: eda_shape.cpp:1233
Definition: lib_shape.h:40
The base class for create windows for drawing purpose.
wxString ShowShape() const
Definition: eda_shape.cpp:56
void endEdit(bool aClosed=true)
Finishes editing the shape.
Definition: eda_shape.cpp:1416
Define a library symbol object.
Definition: lib_symbol.h:96
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:88
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
wxString GetClass() const override
Return the class name.
Definition: lib_shape.h:42
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
int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_shape.cpp:69
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 inside or on the boundary of this item.
Definition: lib_shape.cpp:45
wxPoint GetCenter() const
Definition: lib_shape.h:90
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:347
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:365
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
wxPoint GetPosition() const override
Definition: lib_shape.h:87
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:1264
FILL_T GetFillType() const
Definition: eda_shape.h:88