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-2017 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_BEZIER_H_
30 #define _LIB_BEZIER_H_
31 
32 #include <lib_draw_item.h>
33 
34 
39 class LIB_BEZIER : public LIB_ITEM
40 {
41  int m_Width; // Line width
42  std::vector<wxPoint> m_BezierPoints; // list of parameter (3|4)
43  std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
44 
45  void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
46  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
47  const TRANSFORM& aTransform ) override;
48 
49 public:
50  LIB_BEZIER( LIB_PART * aParent );
51 
52  // Do not create a copy constructor. The one generated by the compiler is adequate.
53 
55 
56  wxString GetClass() const override
57  {
58  return wxT( "LIB_BEZIER" );
59  }
60 
61  wxString GetTypeName() override
62  {
63  return _( "Bezier" );
64  }
65 
66  void AddPoint( const wxPoint& aPoint ) { m_BezierPoints.push_back( aPoint ); }
67 
68  void SetOffset( const wxPoint& aOffset ) override;
69 
73  unsigned GetCornerCount() const { return m_PolyPoints.size(); }
74 
75  const std::vector< wxPoint >& GetPoints() const
76  {
77  return m_BezierPoints;
78  }
79 
80  bool HitTest( const wxPoint& aPosition ) const override;
81 
82  bool HitTest( const wxPoint& aPosRef, int aThreshold, const TRANSFORM& aTransform ) const override;
83 
84  const EDA_RECT GetBoundingBox() const override;
85 
86  bool Inside( EDA_RECT& aRect ) const override;
87 
88  void Move( const wxPoint& aPosition ) override;
89 
90  wxPoint GetPosition() const override { return m_PolyPoints[0]; }
91 
92  void MirrorHorizontal( const wxPoint& aCenter ) override;
93 
94  void MirrorVertical( const wxPoint& aCenter ) override;
95 
96  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
97 
98  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
99  const TRANSFORM& aTransform ) override;
100 
101  int GetWidth() const override { return m_Width; }
102 
103  void SetWidth( int aWidth ) override { m_Width = aWidth; }
104 
105  int GetPenSize( ) const override;
106 
107  void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
108 
109  EDA_ITEM* Clone() const override;
110 
111 private:
112 
120  int compare( const LIB_ITEM& aOther ) const override;
121 };
122 
123 
124 #endif // _LIB_BEZIER_H_
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_bezier.cpp:58
wxString GetTypeName() override
Provide a user-consumable name of the object type.
Definition: lib_bezier.h:61
void SetOffset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_bezier.cpp:80
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_bezier.cpp:104
LIB_BEZIER(LIB_PART *aParent)
Definition: lib_bezier.cpp:43
std::vector< wxPoint > m_BezierPoints
Definition: lib_bezier.h:42
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Definition: lib_bezier.cpp:322
const EDA_RECT GetBoundingBox() const override
Definition: lib_bezier.cpp:293
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
Definition: lib_bezier.cpp:172
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:75
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_bezier.h:90
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:66
int GetWidth() const override
Return the width of the draw item.
Definition: lib_bezier.h:101
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_bezier.cpp:110
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
bool Inside(EDA_RECT &aRect) const override
Test if any part of the draw object is inside rectangle bounds of aRect.
Definition: lib_bezier.cpp:92
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_bezier.h:56
std::vector< wxPoint > m_PolyPoints
Definition: lib_bezier.h:43
Define a library symbol object.
unsigned GetCornerCount() const
Definition: lib_bezier.h:73
virtual void Rotate()
Rotate the draw item.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_bezier.cpp:52
int GetPenSize() const override
Definition: lib_bezier.cpp:199
Base plotter engine class.
Definition: plotter.h:96
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_bezier.cpp:261
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void drawGraphic(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform) override
Draw the item on aPanel.
Definition: lib_bezier.cpp:205
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_bezier.cpp:131
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
int m_Width
Definition: lib_bezier.h:41
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
Definition: lib_bezier.h:103
void AddPoint(const wxPoint &aPoint)
Definition: lib_bezier.h:66
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:39
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39