KiCad PCB EDA Suite
lib_bezier.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  *
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 
25 #ifndef LIB_BEZIER_H
26 #define LIB_BEZIER_H
27 
28 #include <lib_item.h>
29 
30 
34 class LIB_BEZIER : public LIB_ITEM
35 {
36 public:
37  LIB_BEZIER( LIB_SYMBOL* aParent );
38 
39  // Do not create a copy constructor. The one generated by the compiler is adequate.
40 
42 
43  wxString GetClass() const override
44  {
45  return wxT( "LIB_BEZIER" );
46  }
47 
48  wxString GetTypeName() const override
49  {
50  return _( "Bezier" );
51  }
52 
53  void Reserve( size_t aCount ) { m_BezierPoints.reserve( aCount ); }
54  void AddPoint( const wxPoint& aPoint ) { m_BezierPoints.push_back( aPoint ); }
55 
56  void Offset( const wxPoint& aOffset ) override;
57  const wxPoint GetOffset() const;
58 
62  unsigned GetCornerCount() const { return m_PolyPoints.size(); }
63 
64  const std::vector< wxPoint >& GetPoints() const { return m_BezierPoints; }
65 
66  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
67  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
68 
69  const EDA_RECT GetBoundingBox() const override;
70 
71  void MoveTo( const wxPoint& aPosition ) override;
72 
73  wxPoint GetPosition() const override;
74 
75  void MirrorHorizontal( const wxPoint& aCenter ) override;
76  void MirrorVertical( const wxPoint& aCenter ) override;
77  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
78 
79  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
80  const TRANSFORM& aTransform ) const override;
81 
82  int GetWidth() const override { return m_Width; }
83  void SetWidth( int aWidth ) override { m_Width = aWidth; }
84 
85  int GetPenWidth() const override;
86 
87  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
88 
89  EDA_ITEM* Clone() const override;
90 
91 private:
99  int compare( const LIB_ITEM& aOther,
100  LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
101 
102  void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset,
103  void* aData, const TRANSFORM& aTransform ) override;
104 
105  int m_Width; // Line width
106  std::vector<wxPoint> m_BezierPoints; // list of parameter (3|4)
107  std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
108 };
109 
110 
111 #endif // LIB_BEZIER_H
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_bezier.cpp:92
const wxPoint GetOffset() const
Definition: lib_bezier.cpp:101
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
std::vector< wxPoint > m_BezierPoints
Definition: lib_bezier.h:106
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: lib_bezier.cpp:298
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_bezier.cpp:240
LIB_BEZIER(LIB_SYMBOL *aParent)
Definition: lib_bezier.cpp:38
The base class for create windows for drawing purpose.
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_bezier.cpp:327
Define a library symbol object.
Definition: lib_symbol.h:96
wxPoint GetPosition() const override
Definition: lib_bezier.cpp:347
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
int GetWidth() const override
Definition: lib_bezier.h:82
void Reserve(size_t aCount)
Definition: lib_bezier.h:53
unsigned GetCornerCount() const
Definition: lib_bezier.h:62
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_bezier.cpp:80
void print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_bezier.cpp:203
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_bezier.cpp:110
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_bezier.cpp:154
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) const override
Plot the draw item using the plot object.
Definition: lib_bezier.cpp:166
COMPARE_FLAGS
The list of flags used by the compare function.
Definition: lib_item.h:81
wxString GetClass() const override
Return the class name.
Definition: lib_bezier.h:43
std::vector< wxPoint > m_PolyPoints
Definition: lib_bezier.h:107
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_bezier.cpp:53
wxString GetTypeName() const override
Provide a user-consumable name of the object type.
Definition: lib_bezier.h:48
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:64
#define _(s)
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_bezier.cpp:47
Base plotter engine class.
Definition: plotter.h:121
Handle the component boundary box.
Definition: eda_rect.h:42
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_bezier.cpp:132
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void SetWidth(int aWidth) override
Definition: lib_bezier.h:83
void AddPoint(const wxPoint &aPoint)
Definition: lib_bezier.h:54
int GetPenWidth() const override
Definition: lib_bezier.cpp:197
Define a bezier curve graphic body item.
Definition: lib_bezier.h:34