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-2011 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 
84  void calcRadiusAngles();
85 
86 public:
87  LIB_ARC( LIB_PART * aParent );
88 
89  // Do not create a copy constructor. The one generated by the compiler is adequate.
90 
91  ~LIB_ARC() { }
92 
93  wxString GetClass() const override
94  {
95  return wxT( "LIB_ARC" );
96  }
97 
98 
99  bool Save( OUTPUTFORMATTER& aFormatter ) override;
100 
101  bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override;
102 
103  bool HitTest( const wxPoint& aPosition ) const override;
104 
105  bool HitTest( const wxPoint& aPosition, int aThreshold, const TRANSFORM& aTransform ) const override;
106 
107  const EDA_RECT GetBoundingBox() const override;
108 
109  void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
110 
111  int GetPenSize() const override;
112 
113  void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
114 
115  bool ContinueEdit( const wxPoint aNextPoint ) override;
116 
117  void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
118 
119  void SetOffset( const wxPoint& aOffset ) override;
120 
121  bool Inside( EDA_RECT& aRect ) const override;
122 
123  void Move( const wxPoint& aPosition ) override;
124 
125  wxPoint GetPosition() const override { return m_Pos; }
126 
127  void MirrorHorizontal( const wxPoint& aCenter ) override;
128 
129  void MirrorVertical( const wxPoint& aCenter ) override;
130 
131  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
132 
133  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
134  const TRANSFORM& aTransform ) override;
135 
136  int GetWidth() const override { return m_Width; }
137 
138  void SetWidth( int aWidth ) override { m_Width = aWidth; }
139 
140  void SetRadius( int aRadius ) { m_Radius = aRadius; }
141 
142  int GetRadius() const { return m_Radius; }
143 
144  void SetFirstRadiusAngle( int aAngle ) { m_t1 = aAngle; }
145 
146  int GetFirstRadiusAngle() const { return m_t1; }
147 
148  void SetSecondRadiusAngle( int aAngle ) { m_t2 = aAngle; }
149 
150  int GetSecondRadiusAngle() const { return m_t2; }
151 
152  void SetStart( const wxPoint& aPoint ) { m_ArcStart = aPoint; }
153 
154  void SetEnd( const wxPoint& aPoint ) { m_ArcEnd = aPoint; }
155 
156  wxString GetSelectMenuText() const override;
157 
158  BITMAP_DEF GetMenuImage() const override;
159 
160  EDA_ITEM* Clone() const override;
161 
162 private:
163 
173  int compare( const LIB_ITEM& aOther ) const override;
174 };
175 
176 
177 #endif // _LIB_ARC_H_
int m_Radius
Definition: lib_arc.h:47
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
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:363
PNG memory record (file in memory).
Definition: bitmap_types.h:38
int GetSecondRadiusAngle() const
Definition: lib_arc.h:150
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:494
void SetFirstRadiusAngle(int aAngle)
Definition: lib_arc.h:144
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:178
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
bool Load(LINE_READER &aLineReader, wxString &aErrorMsg) override
Definition: lib_arc.cpp:126
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_arc.cpp:584
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_arc.cpp:575
int GetFirstRadiusAngle() const
Definition: lib_arc.h:146
wxPoint m_ArcEnd
Definition: lib_arc.h:51
void calcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points. ...
Definition: lib_arc.cpp:795
void SetOffset(const wxPoint &aOffset) override
Function Offset sets the drawing object by aOffset from the current position.
Definition: lib_arc.cpp:263
Class LIB_ITEM is the base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
void MirrorVertical(const wxPoint &aCenter) override
Function MirrorVertical mirrors the draw object along the MirrorVertical (Y) axis about aCenter point...
Definition: lib_arc.cpp:314
bool Save(OUTPUTFORMATTER &aFormatter) override
Function Save writes draw item object to aFormatter in component library "*.lib" format.
Definition: lib_arc.cpp:105
void SetWidth(int aWidth) override
Function SetWidth sets the width of the draw item to aWidth.
Definition: lib_arc.h:138
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo displays basic info (type, part and convert) about the current item in messa...
Definition: lib_arc.cpp:557
SELECT_T
Definition: lib_arc.h:40
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
Function Inside tests if any part of the draw object is inside rectangle bounds of aRect...
Definition: lib_arc.cpp:271
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_arc.h:93
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
wxPoint m_Pos
Definition: lib_arc.h:52
~LIB_ARC()
Definition: lib_arc.h:91
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_arc.cpp:235
void Move(const wxPoint &aPosition) override
Function Move moves a draw object to aPosition.
Definition: lib_arc.cpp:278
Class LIB_PART defines a library part object.
unsigned STATUS_FLAGS
Definition: base_struct.h:144
void EndEdit(const wxPoint &aPosition, bool aAbort=false) override
End an object editing action.
Definition: lib_arc.cpp:662
int m_editState
Definition: lib_arc.h:56
int GetRadius() const
Definition: lib_arc.h:142
int compare(const LIB_ITEM &aOther) const override
Function compare provides the draw object specific comparison called by the == and < operators...
Definition: lib_arc.cpp:241
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Definition: lib_arc.cpp:642
int GetPenSize() const override
Function GetPenSize.
Definition: lib_arc.cpp:386
virtual void Rotate()
Rotate the draw item.
void SetSecondRadiusAngle(int aAngle)
Definition: lib_arc.h:148
void MirrorHorizontal(const wxPoint &aCenter) override
Function MirrorHorizontal mirrors the draw object along the horizontal (X) axis about aCenter point...
Definition: lib_arc.cpp:287
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:412
Base plotter engine class.
Definition: plot_common.h:86
int GetWidth() const override
Function GetWidth return the width of the draw item.
Definition: lib_arc.h:136
void drawEditGraphics(EDA_RECT *aClipBox, wxDC *aDC, COLOR4D aColor) override
Draw the graphics when the arc is being edited.
Definition: lib_arc.cpp:392
LIB_ARC(LIB_PART *aParent)
Definition: lib_arc.cpp:88
void SetRadius(int aRadius)
Definition: lib_arc.h:140
Class EDA_RECT handles the component boundary box.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
int m_editDirection
Definition: lib_arc.h:57
void SetStart(const wxPoint &aPoint)
Definition: lib_arc.h:152
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:674
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:590
int m_Width
Definition: lib_arc.h:53
wxPoint GetPosition() const override
Function GetPosition returns the current draw object position.
Definition: lib_arc.h:125
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39