KiCad PCB EDA Suite
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,
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
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  *
21  * or you may search the 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  */
26 #ifndef LIB_ARC_H
27 #define LIB_ARC_H
29 #include <lib_item.h>
30 #include <math/vector2d.h>
32 class TRANSFORM;
35 class LIB_ARC : public LIB_ITEM
36 {
37 public:
38  LIB_ARC( LIB_SYMBOL* aParent );
40  // Do not create a copy constructor. The one generated by the compiler is adequate.
42  ~LIB_ARC() { }
44  wxString GetClass() const override
45  {
46  return wxT( "LIB_ARC" );
47  }
49  wxString GetTypeName() const override
50  {
51  return _( "Arc" );
52  }
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;
57  const EDA_RECT GetBoundingBox() const override;
59  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
61  int GetPenWidth() const override;
63  void BeginEdit( const wxPoint& aStartPoint ) override;
64  void CalcEdit( const wxPoint& aPosition ) override;
65  void SetEditState( int aState ) { m_editState = aState; }
67  void Offset( const wxPoint& aOffset ) override;
69  void MoveTo( const wxPoint& aPosition ) override;
71  wxPoint GetPosition() const override { return m_Pos; }
73  void MirrorHorizontal( const wxPoint& aCenter ) override;
74  void MirrorVertical( const wxPoint& aCenter ) override;
75  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
77  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
78  const TRANSFORM& aTransform ) const override;
80  int GetWidth() const override { return m_Width; }
81  void SetWidth( int aWidth ) override { m_Width = aWidth; }
83  void SetRadius( int aRadius ) { m_Radius = aRadius; }
84  int GetRadius() const { return m_Radius; }
86  void SetFirstRadiusAngle( int aAngle ) { m_t1 = aAngle; }
87  int GetFirstRadiusAngle() const { return m_t1; }
89  void SetSecondRadiusAngle( int aAngle ) { m_t2 = aAngle; }
90  int GetSecondRadiusAngle() const { return m_t2; }
92  wxPoint GetStart() const { return m_ArcStart; }
93  void SetStart( const wxPoint& aPoint ) { m_ArcStart = aPoint; }
95  wxPoint GetEnd() const { return m_ArcEnd; }
96  void SetEnd( const wxPoint& aPoint ) { m_ArcEnd = aPoint; }
106  VECTOR2I CalcMidPoint() const;
111  void CalcEndPoints();
116  void CalcRadiusAngles();
119  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
121  BITMAPS GetMenuImage() const override;
123  EDA_ITEM* Clone() const override;
125 private:
126  void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
127  const TRANSFORM& aTransform ) override;
138  int compare( const LIB_ITEM& aOther,
139  LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
141  enum SELECT_T // When creating an arc: status of arc
142  {
146  };
148  int m_Radius;
149  int m_t1; // First radius angle of the arc in 0.1 degrees.
150  int m_t2; /* Second radius angle of the arc in 0.1 degrees. */
151  wxPoint m_ArcStart;
152  wxPoint m_ArcEnd; /* Arc end position. */
153  wxPoint m_Pos; /* Radius center point. */
154  int m_Width; /* Line width */
156 };
159 #endif // LIB_ARC_H
int m_Radius
Definition: lib_arc.h:148
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:149
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:292
int m_t2
Definition: lib_arc.h:150
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_arc.cpp:332
void BeginEdit(const wxPoint &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_arc.cpp:420
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:257
void CalcRadiusAngles()
Calculate the radius and angle of an arc using the start, end, and center points.
Definition: lib_arc.cpp:533
Definition: lib_arc.cpp:47
VECTOR2I CalcMidPoint() const
Calculate the arc mid point using the arc start and end angles and radius length.
Definition: lib_arc.cpp:573
wxPoint m_ArcEnd
Definition: lib_arc.h:152
void CalcEndPoints()
Calculate the start and end points using the center point and the two angles.
Definition: lib_arc.cpp:593
The base class for create windows for drawing purpose.
Define a library symbol object.
Definition: lib_symbol.h:96
The base class for drawable items used by schematic library symbols.
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:206
void SetWidth(int aWidth) override
Definition: lib_arc.h:81
Definition: lib_arc.h:141
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
The list of flags used by the compare function.
Definition: lib_item.h:81
wxPoint m_Pos
Definition: lib_arc.h:153
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
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_arc.cpp:168
int m_editState
Definition: lib_arc.h:155
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:389
#define _(s)
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:427
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
Definition: eda_units.h:38
Base plotter engine class.
Definition: plotter.h:121
int GetWidth() const override
Definition: lib_arc.h:80
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
int GetPenWidth() const override
Definition: lib_arc.cpp:286
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:414
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
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:407
wxPoint m_ArcStart
Definition: lib_arc.h:151
int m_Width
Definition: lib_arc.h:154
wxPoint GetPosition() const override
Definition: lib_arc.h:71
void SetEditState(int aState)
Definition: lib_arc.h:65