KiCad PCB EDA Suite
lib_arc.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, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2004-2019 KiCad Developers, see change_log.txt for contributors.
6  * Copyright (C) 2019 CERN
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef LIB_ARC_H
27 #define LIB_ARC_H
28 
29 #include <lib_item.h>
30 
31 
32 class TRANSFORM;
33 
34 
35 class LIB_ARC : public LIB_ITEM
36 {
37  enum SELECT_T // When creating an arc: status of arc
38  {
42  };
43 
44  int m_Radius;
45  int m_t1; // First radius angle of the arc in 0.1 degrees.
46  int m_t2; /* Second radius angle of the arc in 0.1 degrees. */
48  wxPoint m_ArcEnd; /* Arc end position. */
49  wxPoint m_Pos; /* Radius center point. */
50  int m_Width; /* Line width */
52 
53  void print( wxDC* aDC, const wxPoint& aOffset, void* aData,
54  const TRANSFORM& aTransform ) override;
55 
56 public:
57  LIB_ARC( LIB_PART * aParent );
58 
59  // Do not create a copy constructor. The one generated by the compiler is adequate.
60 
61  ~LIB_ARC() { }
62 
63  wxString GetClass() const override
64  {
65  return wxT( "LIB_ARC" );
66  }
67 
68  wxString GetTypeName() override
69  {
70  return _( "Arc" );
71  }
72 
73  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
74  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
75 
76  const EDA_RECT GetBoundingBox() const override;
77 
78  void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList ) override;
79 
80  int GetPenSize() const override;
81 
82  void BeginEdit( const wxPoint aStartPoint ) override;
83  void CalcEdit( const wxPoint& aPosition ) override;
84  void SetEditState( int aState ) { m_editState = aState; }
85 
86  void Offset( const wxPoint& aOffset ) override;
87 
88  bool Inside( EDA_RECT& aRect ) const override;
89 
90  void MoveTo( const wxPoint& aPosition ) override;
91 
92  wxPoint GetPosition() const override { return m_Pos; }
93 
94  void MirrorHorizontal( const wxPoint& aCenter ) override;
95  void MirrorVertical( const wxPoint& aCenter ) override;
96  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
97 
98  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
99  const TRANSFORM& aTransform ) override;
100 
101  int GetWidth() const override { return m_Width; }
102  void SetWidth( int aWidth ) override { m_Width = aWidth; }
103 
104  void SetRadius( int aRadius ) { m_Radius = aRadius; }
105  int GetRadius() const { return m_Radius; }
106 
107  void SetFirstRadiusAngle( int aAngle ) { m_t1 = aAngle; }
108  int GetFirstRadiusAngle() const { return m_t1; }
109 
110  void SetSecondRadiusAngle( int aAngle ) { m_t2 = aAngle; }
111  int GetSecondRadiusAngle() const { return m_t2; }
112 
113  wxPoint GetStart() const { return m_ArcStart; }
114  void SetStart( const wxPoint& aPoint ) { m_ArcStart = aPoint; }
115 
116  wxPoint GetEnd() const { return m_ArcEnd; }
117  void SetEnd( const wxPoint& aPoint ) { m_ArcEnd = aPoint; }
118 
122  void CalcRadiusAngles();
123 
124 
125  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
126 
127  BITMAP_DEF GetMenuImage() const override;
128 
129  EDA_ITEM* Clone() const override;
130 
131 private:
132 
142  int compare( const LIB_ITEM& aOther ) const override;
143 };
144 
145 
146 #endif // LIB_ARC_H
int m_Radius
Definition: lib_arc.h:44
EDA_UNITS
Definition: common.h:72
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_arc.cpp:235
int m_t1
Definition: lib_arc.h:45
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
Definition: lib_arc.cpp:257
PNG memory record (file in memory).
Definition: bitmap_def.h:29
int m_t2
Definition: lib_arc.h:46
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: lib_arc.cpp:330
void SetFirstRadiusAngle(int aAngle)
Definition: lib_arc.h:107
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points.
Definition: lib_arc.cpp:539
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_arc.cpp:393
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_arc.cpp:420
wxPoint m_ArcEnd
Definition: lib_arc.h:48
The base class for drawable items used by schematic library components.
Definition: lib_item.h:60
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_arc.cpp:208
void SetWidth(int aWidth) override
Definition: lib_arc.h:102
SELECT_T
Definition: lib_arc.h:37
int GetSecondRadiusAngle() const
Definition: lib_arc.h:111
wxString GetTypeName() override
Provide a user-consumable name of the object type.
Definition: lib_arc.h:68
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void SetEnd(const wxPoint &aPoint)
Definition: lib_arc.h:117
bool Inside(EDA_RECT &aRect) const override
Test if any part of the draw object is inside rectangle bounds of aRect.
Definition: lib_arc.cpp:165
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_arc.h:63
wxPoint m_Pos
Definition: lib_arc.h:49
~LIB_ARC()
Definition: lib_arc.h:61
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_arc.cpp:129
wxPoint GetStart() const
Definition: lib_arc.h:113
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_arc.cpp:61
Define a library symbol object.
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_arc.cpp:172
int m_editState
Definition: lib_arc.h:51
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_arc.cpp:135
int GetPenSize() const override
Definition: lib_arc.cpp:286
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_arc.cpp:433
void SetSecondRadiusAngle(int aAngle)
Definition: lib_arc.h:110
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_arc.cpp:181
int GetRadius() const
Definition: lib_arc.h:105
Base plotter engine class.
Definition: plotter.h:103
int GetWidth() const override
Definition: lib_arc.h:101
#define _(s)
Definition: 3d_actions.cpp:31
LIB_ARC(LIB_PART *aParent)
Definition: lib_arc.cpp:49
void SetRadius(int aRadius)
Definition: lib_arc.h:104
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_arc.cpp:157
wxPoint GetEnd() const
Definition: lib_arc.h:116
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
void print(wxDC *aDC, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_arc.cpp:298
int GetFirstRadiusAngle() const
Definition: lib_arc.h:108
void SetStart(const wxPoint &aPoint)
Definition: lib_arc.h:114
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_arc.cpp:411
wxPoint m_ArcStart
Definition: lib_arc.h:47
void BeginEdit(const wxPoint aStartPoint) override
Begin drawing a component library draw item at aPosition.
Definition: lib_arc.cpp:426
int m_Width
Definition: lib_arc.h:50
wxPoint GetPosition() const override
Definition: lib_arc.h:92
void SetEditState(int aState)
Definition: lib_arc.h:84