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-2021 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 #include <math/vector2d.h>
31 
32 class TRANSFORM;
33 
34 
35 class LIB_ARC : public LIB_ITEM
36 {
37 public:
38  LIB_ARC( LIB_PART * aParent );
39 
40  // Do not create a copy constructor. The one generated by the compiler is adequate.
41 
42  ~LIB_ARC() { }
43 
44  wxString GetClass() const override
45  {
46  return wxT( "LIB_ARC" );
47  }
48 
49  wxString GetTypeName() const override
50  {
51  return _( "Arc" );
52  }
53 
54  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
55  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
56 
57  const EDA_RECT GetBoundingBox() const override;
58 
59  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
60 
61  int GetPenWidth() const override;
62 
63  void BeginEdit( const wxPoint aStartPoint ) override;
64  void CalcEdit( const wxPoint& aPosition ) override;
65  void SetEditState( int aState ) { m_editState = aState; }
66 
67  void Offset( const wxPoint& aOffset ) override;
68 
69  void MoveTo( const wxPoint& aPosition ) override;
70 
71  wxPoint GetPosition() const override { return m_Pos; }
72 
73  void MirrorHorizontal( const wxPoint& aCenter ) override;
74  void MirrorVertical( const wxPoint& aCenter ) override;
75  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
76 
77  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
78  const TRANSFORM& aTransform ) const override;
79 
80  int GetWidth() const override { return m_Width; }
81  void SetWidth( int aWidth ) override { m_Width = aWidth; }
82 
83  void SetRadius( int aRadius ) { m_Radius = aRadius; }
84  int GetRadius() const { return m_Radius; }
85 
86  void SetFirstRadiusAngle( int aAngle ) { m_t1 = aAngle; }
87  int GetFirstRadiusAngle() const { return m_t1; }
88 
89  void SetSecondRadiusAngle( int aAngle ) { m_t2 = aAngle; }
90  int GetSecondRadiusAngle() const { return m_t2; }
91 
92  wxPoint GetStart() const { return m_ArcStart; }
93  void SetStart( const wxPoint& aPoint ) { m_ArcStart = aPoint; }
94 
95  wxPoint GetEnd() const { return m_ArcEnd; }
96  void SetEnd( const wxPoint& aPoint ) { m_ArcEnd = aPoint; }
97 
106  VECTOR2I CalcMidPoint() const;
107 
111  void CalcRadiusAngles();
112 
113 
114  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
115 
116  BITMAPS GetMenuImage() const override;
117 
118  EDA_ITEM* Clone() const override;
119 
120 private:
121  void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
122  const TRANSFORM& aTransform ) override;
123 
133  int compare( const LIB_ITEM& aOther,
134  LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
135 
136  enum SELECT_T // When creating an arc: status of arc
137  {
141  };
142 
143  int m_Radius;
144  int m_t1; // First radius angle of the arc in 0.1 degrees.
145  int m_t2; /* Second radius angle of the arc in 0.1 degrees. */
146  wxPoint m_ArcStart;
147  wxPoint m_ArcEnd; /* Arc end position. */
148  wxPoint m_Pos; /* Radius center point. */
149  int m_Width; /* Line width */
151 };
152 
153 
154 #endif // LIB_ARC_H
int m_Radius
Definition: lib_arc.h:143
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_arc.cpp:231
int m_t1
Definition: lib_arc.h:144
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
void print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_arc.cpp:294
int m_t2
Definition: lib_arc.h:145
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_arc.cpp:336
void SetFirstRadiusAngle(int aAngle)
Definition: lib_arc.h:86
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) const override
Plot the draw item using the plot object.
Definition: lib_arc.cpp:253
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points.
Definition: lib_arc.cpp:537
VECTOR2I CalcMidPoint() const
Calculate the arc mid point using the arc start and end angles and radius length.
Definition: lib_arc.cpp:577
wxPoint m_ArcEnd
Definition: lib_arc.h:147
The base class for create windows for drawing purpose.
The base class for drawable items used by schematic library components.
Definition: lib_item.h:62
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_arc.cpp:204
void SetWidth(int aWidth) override
Definition: lib_arc.h:81
SELECT_T
Definition: lib_arc.h:136
int GetSecondRadiusAngle() const
Definition: lib_arc.h:90
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void SetEnd(const wxPoint &aPoint)
Definition: lib_arc.h:96
wxString GetClass() const override
Return the class name.
Definition: lib_arc.h:44
COMPARE_FLAGS
The list of flags used by the compare function.
Definition: lib_item.h:82
wxPoint m_Pos
Definition: lib_arc.h:148
~LIB_ARC()
Definition: lib_arc.h:42
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_arc.cpp:127
wxPoint GetStart() const
Definition: lib_arc.h:92
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: lib_arc.cpp:59
Define a library symbol object.
Definition: lib_symbol.h:93
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_arc.cpp:168
int m_editState
Definition: lib_arc.h:150
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: lib_arc.cpp:393
wxString GetTypeName() const override
Provide a user-consumable name of the object type.
Definition: lib_arc.h:49
void CalcEdit(const wxPoint &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_arc.cpp:431
void SetSecondRadiusAngle(int aAngle)
Definition: lib_arc.h:89
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_arc.cpp:177
int GetRadius() const
Definition: lib_arc.h:84
EDA_UNITS
Definition: eda_units.h:38
Base plotter engine class.
Definition: plotter.h:121
int GetWidth() const override
Definition: lib_arc.h:80
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
int GetPenWidth() const override
Definition: lib_arc.cpp:284
#define _(s)
Definition: 3d_actions.cpp:33
LIB_ARC(LIB_PART *aParent)
Definition: lib_arc.cpp:47
void SetRadius(int aRadius)
Definition: lib_arc.h:83
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_arc.cpp:160
wxPoint GetEnd() const
Definition: lib_arc.h:95
Handle the component boundary box.
Definition: eda_rect.h:42
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_arc.cpp:418
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
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_arc.cpp:133
int GetFirstRadiusAngle() const
Definition: lib_arc.h:87
void SetStart(const wxPoint &aPoint)
Definition: lib_arc.h:93
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_arc.cpp:411
wxPoint m_ArcStart
Definition: lib_arc.h:146
void BeginEdit(const wxPoint aStartPoint) override
Begin drawing a component library draw item at aPosition.
Definition: lib_arc.cpp:424
int m_Width
Definition: lib_arc.h:149
wxPoint GetPosition() const override
Definition: lib_arc.h:71
void SetEditState(int aState)
Definition: lib_arc.h:65