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-2020 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  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( RENDER_SETTINGS* aSettings, 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_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
79 
80  int GetPenWidth() 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  void MoveTo( const wxPoint& aPosition ) override;
89 
90  wxPoint GetPosition() const override { return m_Pos; }
91 
92  void MirrorHorizontal( const wxPoint& aCenter ) override;
93  void MirrorVertical( const wxPoint& aCenter ) override;
94  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
95 
96  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
97  const TRANSFORM& aTransform ) override;
98 
99  int GetWidth() const override { return m_Width; }
100  void SetWidth( int aWidth ) override { m_Width = aWidth; }
101 
102  void SetRadius( int aRadius ) { m_Radius = aRadius; }
103  int GetRadius() const { return m_Radius; }
104 
105  void SetFirstRadiusAngle( int aAngle ) { m_t1 = aAngle; }
106  int GetFirstRadiusAngle() const { return m_t1; }
107 
108  void SetSecondRadiusAngle( int aAngle ) { m_t2 = aAngle; }
109  int GetSecondRadiusAngle() const { return m_t2; }
110 
111  wxPoint GetStart() const { return m_ArcStart; }
112  void SetStart( const wxPoint& aPoint ) { m_ArcStart = aPoint; }
113 
114  wxPoint GetEnd() const { return m_ArcEnd; }
115  void SetEnd( const wxPoint& aPoint ) { m_ArcEnd = aPoint; }
116 
125  VECTOR2I CalcMidPoint() const;
126 
130  void CalcRadiusAngles();
131 
132 
133  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
134 
135  BITMAP_DEF GetMenuImage() const override;
136 
137  EDA_ITEM* Clone() const override;
138 
139 private:
140 
150  int compare( const LIB_ITEM& aOther,
151  LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
152 };
153 
154 
155 #endif // LIB_ARC_H
int m_Radius
Definition: lib_arc.h:44
EDA_UNITS
Definition: common.h:198
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_arc.cpp:234
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:256
PNG memory record (file in memory).
Definition: bitmap_def.h:29
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
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:338
void SetFirstRadiusAngle(int aAngle)
Definition: lib_arc.h:105
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points.
Definition: lib_arc.cpp:547
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_arc.cpp:428
VECTOR2I CalcMidPoint() const
Calculate the arc mid point using the arc start and end angles and radius length.
Definition: lib_arc.cpp:587
wxPoint m_ArcEnd
Definition: lib_arc.h:48
The base class for create windows for drawing purpose.
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_arc.cpp:207
void SetWidth(int aWidth) override
Definition: lib_arc.h:100
SELECT_T
Definition: lib_arc.h:37
int GetSecondRadiusAngle() const
Definition: lib_arc.h:109
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:115
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_arc.h:63
COMPARE_FLAGS
The list of flags used by the compare function.
Definition: lib_item.h:116
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:130
wxPoint GetStart() const
Definition: lib_arc.h:111
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:62
void print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_arc.cpp:296
Define a library symbol object.
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_arc.cpp:171
int m_editState
Definition: lib_arc.h:51
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, 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:401
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_arc.cpp:441
void SetSecondRadiusAngle(int aAngle)
Definition: lib_arc.h:108
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_arc.cpp:180
int GetRadius() const
Definition: lib_arc.h:103
Base plotter engine class.
Definition: plotter.h:114
int GetWidth() const override
Definition: lib_arc.h:99
int GetPenWidth() const override
Definition: lib_arc.cpp:286
#define _(s)
Definition: 3d_actions.cpp:33
LIB_ARC(LIB_PART *aParent)
Definition: lib_arc.cpp:50
void SetRadius(int aRadius)
Definition: lib_arc.h:102
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_arc.cpp:163
wxPoint GetEnd() const
Definition: lib_arc.h:114
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:159
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:136
int GetFirstRadiusAngle() const
Definition: lib_arc.h:106
void SetStart(const wxPoint &aPoint)
Definition: lib_arc.h:112
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:419
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:434
int m_Width
Definition: lib_arc.h:50
wxPoint GetPosition() const override
Definition: lib_arc.h:90
void SetEditState(int aState)
Definition: lib_arc.h:84