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,
5  * Copyright (C) 2004-2020 KiCad Developers, see change_log.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_CIRCLE_H
26 #define LIB_CIRCLE_H
28 #include <lib_item.h>
29 #include <math/util.h> // for KiROUND
32 class LIB_CIRCLE : public LIB_ITEM
33 {
34  wxPoint m_Pos; // Position or centre (Arc and Circle) or start point (segments).
35  wxPoint m_EndPos; // A point on the circumference of the circle.
36  int m_Width; // Line width.
38  void print( wxDC* aDC, const wxPoint& aOffset, void* aData,
39  const TRANSFORM& aTransform ) override;
41 public:
42  LIB_CIRCLE( LIB_PART * aParent );
44  // Do not create a copy constructor. The one generated by the compiler is adequate.
48  wxString GetClass() const override
49  {
50  return wxT( "LIB_CIRCLE" );
51  }
53  wxString GetTypeName() override
54  {
55  return _( "Circle" );
56  }
58  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
59  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
61  int GetPenSize( ) const override;
63  const EDA_RECT GetBoundingBox() const override;
65  void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList ) override;
67  void BeginEdit( const wxPoint aStartPoint ) override;
68  void CalcEdit( const wxPoint& aPosition ) override;
70  void Offset( const wxPoint& aOffset ) override;
72  bool Inside( EDA_RECT& aRect ) const override;
74  void MoveTo( const wxPoint& aPosition ) override;
76  wxPoint GetPosition() const override { return m_Pos; }
78  void SetEnd( const wxPoint& aPosition ) { m_EndPos = aPosition; }
79  wxPoint GetEnd() const { return m_EndPos; }
81  void MirrorHorizontal( const wxPoint& aCenter ) override;
82  void MirrorVertical( const wxPoint& aCenter ) override;
83  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
85  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
86  const TRANSFORM& aTransform ) override;
88  int GetWidth() const override { return m_Width; }
89  void SetWidth( int aWidth ) override { m_Width = aWidth; }
91  void SetRadius( int aRadius ) { m_EndPos = wxPoint( m_Pos.x + aRadius, m_Pos.y ); }
92  int GetRadius() const { return KiROUND( GetLineLength( m_EndPos, m_Pos ) ); }
94  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
96  BITMAP_DEF GetMenuImage() const override;
98  EDA_ITEM* Clone() const override;
100 private:
110  int compare( const LIB_ITEM& aOther,
111  LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
112 };
115 #endif // LIB_CIRCLE_H
Definition: common.h:184
int GetPenSize() const override
Definition: lib_circle.cpp:195
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:206
PNG memory record (file in memory).
Definition: bitmap_def.h:29
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: lib_circle.cpp:51
void BeginEdit(const wxPoint aStartPoint) override
Begin drawing a component library draw item at aPosition.
Definition: lib_circle.cpp:278
wxPoint GetPosition() const override
Definition: lib_circle.h:76
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_circle.cpp:163
void print(wxDC *aDC, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_circle.cpp:207
wxPoint m_Pos
Definition: lib_circle.h:34
int GetWidth() const override
Definition: lib_circle.h:88
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_circle.cpp:88
The base class for drawable items used by schematic library components.
Definition: lib_item.h:60
wxPoint GetEnd() const
Definition: lib_circle.h:79
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
The list of flags used by the compare function.
Definition: lib_item.h:116
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_circle.cpp:152
void SetRadius(int aRadius)
Definition: lib_circle.h:91
Define a library symbol object.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_circle.cpp:272
int GetRadius() const
Definition: lib_circle.h:92
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_circle.cpp:263
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_circle.h:48
Base plotter engine class.
Definition: plotter.h:104
Definition: lib_circle.cpp:42
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_circle.cpp:94
#define _(s)
Definition: 3d_actions.cpp:33
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_circle.cpp:141
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_circle.cpp:121
bool Inside(EDA_RECT &aRect) const override
Test if any part of the draw object is inside rectangle bounds of aRect.
Definition: lib_circle.cpp:128
void SetWidth(int aWidth) override
Definition: lib_circle.h:89
int m_Width
Definition: lib_circle.h:36
wxPoint m_EndPos
Definition: lib_circle.h:35
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_circle.cpp:135
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_circle.cpp:284
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: lib_circle.cpp:224
wxString GetTypeName() override
Provide a user-consumable name of the object type.
Definition: lib_circle.h:53
void SetEnd(const wxPoint &aPosition)
Definition: lib_circle.h:78
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: lib_circle.cpp:239
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
Definition: lib_circle.cpp:172