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-2017 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
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 
29 #ifndef _LIB_ARC_H_
30 #define _LIB_ARC_H_
31 
32 #include <lib_draw_item.h>
33 
34 
35 class TRANSFORM;
36 
37 
38 class LIB_ARC : public LIB_ITEM
39 {
40  enum SELECT_T // When creating an arc: status of arc
41  {
45  };
46 
47  int m_Radius;
48  int m_t1; // First radius angle of the arc in 0.1 degrees.
49  int m_t2; /* Second radius angle of the arc in 0.1 degrees. */
51  wxPoint m_ArcEnd; /* Arc end position. */
52  wxPoint m_Pos; /* Radius center point. */
53  int m_Width; /* Line width */
59 
63  void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
64  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
65  const TRANSFORM& aTransform ) override;
66 
70  void drawEditGraphics( EDA_RECT* aClipBox, wxDC* aDC, COLOR4D aColor ) override;
71 
79  void calcEdit( const wxPoint& aPosition ) override;
80 
81 
82 public:
83  LIB_ARC( LIB_PART * aParent );
84 
85  // Do not create a copy constructor. The one generated by the compiler is adequate.
86 
87  ~LIB_ARC() { }
88 
89  wxString GetClass() const override
90  {
91  return wxT( "LIB_ARC" );
92  }
93 
94  wxString GetTypeName() override
95  {
96  return _( "Arc" );
97  }
98 
99  bool HitTest( const wxPoint& aPosition ) const override;
100 
101  bool HitTest( const wxPoint& aPosition, int aThreshold, const TRANSFORM& aTransform ) const override;
102 
103  const EDA_RECT GetBoundingBox() const override;
104 
105  void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
106 
107  int GetPenSize() const override;
108 
109  void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
110 
111  bool ContinueEdit( const wxPoint aNextPoint ) override;
112 
113  void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
114 
115  void SetOffset( const wxPoint& aOffset ) override;
116 
117  bool Inside( EDA_RECT& aRect ) const override;
118 
119  void Move( const wxPoint& aPosition ) override;
120 
121  wxPoint GetPosition() const override { return m_Pos; }
122 
123  void MirrorHorizontal( const wxPoint& aCenter ) override;
124 
125  void MirrorVertical( const wxPoint& aCenter ) override;
126 
127  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
128 
129  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
130  const TRANSFORM& aTransform ) override;
131 
132  int GetWidth() const override { return m_Width; }
133 
134  void SetWidth( int aWidth ) override { m_Width = aWidth; }
135 
136  void SetRadius( int aRadius ) { m_Radius = aRadius; }
137 
138  int GetRadius() const { return m_Radius; }
139 
140  void SetFirstRadiusAngle( int aAngle ) { m_t1 = aAngle; }
141 
142  int GetFirstRadiusAngle() const { return m_t1; }
143 
144  void SetSecondRadiusAngle( int aAngle ) { m_t2 = aAngle; }
145 
146  int GetSecondRadiusAngle() const { return m_t2; }
147 
148  wxPoint GetStart() const { return m_ArcStart; }
149 
150  void SetStart( const wxPoint& aPoint ) { m_ArcStart = aPoint; }
151 
152  wxPoint GetEnd() const { return m_ArcEnd; }
153 
154  void SetEnd( const wxPoint& aPoint ) { m_ArcEnd = aPoint; }
155 
159  void CalcRadiusAngles();
160 
161 
162  wxString GetSelectMenuText() const override;
163 
164  BITMAP_DEF GetMenuImage() const override;
165 
166  EDA_ITEM* Clone() const override;
167 
168 private:
169 
179  int compare( const LIB_ITEM& aOther ) const override;
180 };
181 
182 
183 #endif // _LIB_ARC_H_
int m_Radius
Definition: lib_arc.h:47
int m_t1
Definition: lib_arc.h:48
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:287
PNG memory record (file in memory).
Definition: bitmap_types.h:41
int GetSecondRadiusAngle() const
Definition: lib_arc.h:146
wxPoint GetStart() const
Definition: lib_arc.h:148
double m_editCenterDistance
Definition: lib_arc.h:54
int m_t2
Definition: lib_arc.h:49
int m_lastEditState
Definition: lib_arc.h:58
const EDA_RECT GetBoundingBox() const override
Definition: lib_arc.cpp:418
void SetFirstRadiusAngle(int aAngle)
Definition: lib_arc.h:140
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
Definition: lib_arc.cpp:102
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points. ...
Definition: lib_arc.cpp:719
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_arc.cpp:508
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_arc.cpp:499
int GetFirstRadiusAngle() const
Definition: lib_arc.h:142
wxPoint m_ArcEnd
Definition: lib_arc.h:51
void SetOffset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_arc.cpp:187
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:66
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_arc.cpp:238
wxPoint GetEnd() const
Definition: lib_arc.h:152
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
Definition: lib_arc.h:134
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_arc.cpp:481
SELECT_T
Definition: lib_arc.h:40
wxString GetTypeName() override
Provide a user-consumable name of the object type.
Definition: lib_arc.h:94
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void SetEnd(const wxPoint &aPoint)
Definition: lib_arc.h:154
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:195
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_arc.h:89
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
wxPoint m_Pos
Definition: lib_arc.h:52
~LIB_ARC()
Definition: lib_arc.h:87
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_arc.cpp:159
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_arc.cpp:202
Define a library symbol object.
unsigned STATUS_FLAGS
Definition: base_struct.h:160
void EndEdit(const wxPoint &aPosition, bool aAbort=false) override
End an object editing action.
Definition: lib_arc.cpp:586
int m_editState
Definition: lib_arc.h:56
int GetRadius() const
Definition: lib_arc.h:138
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_arc.cpp:165
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Definition: lib_arc.cpp:566
int GetPenSize() const override
Definition: lib_arc.cpp:310
virtual void Rotate()
Rotate the draw item.
void SetSecondRadiusAngle(int aAngle)
Definition: lib_arc.h:144
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_arc.cpp:211
void drawGraphic(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform) override
Draws the arc.
Definition: lib_arc.cpp:336
Base plotter engine class.
Definition: plotter.h:96
int GetWidth() const override
Return the width of the draw item.
Definition: lib_arc.h:132
void drawEditGraphics(EDA_RECT *aClipBox, wxDC *aDC, COLOR4D aColor) override
Draw the graphics when the arc is being edited.
Definition: lib_arc.cpp:316
LIB_ARC(LIB_PART *aParent)
Definition: lib_arc.cpp:86
void SetRadius(int aRadius)
Definition: lib_arc.h:136
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:180
int m_editDirection
Definition: lib_arc.h:57
void SetStart(const wxPoint &aPoint)
Definition: lib_arc.h:150
SELECT_T m_editSelectPoint
Definition: lib_arc.h:55
wxPoint m_ArcStart
Definition: lib_arc.h:50
void calcEdit(const wxPoint &aPosition) override
Calculates the center, radius, and angles at aPosition when the arc is being edited.
Definition: lib_arc.cpp:598
void BeginEdit(STATUS_FLAGS aEditMode, const wxPoint aStartPoint=wxPoint(0, 0)) override
Begin an editing a component library draw item in aEditMode at aPosition.
Definition: lib_arc.cpp:514
int m_Width
Definition: lib_arc.h:53
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_arc.h:121
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39