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-2020 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
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  *
20  * or you may search the 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  */
25 #ifndef LIB_BEZIER_H
26 #define LIB_BEZIER_H
28 #include <lib_item.h>
34 class LIB_BEZIER : public LIB_ITEM
35 {
36  int m_Width; // Line width
37  std::vector<wxPoint> m_BezierPoints; // list of parameter (3|4)
38  std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
40  void print( wxDC* aDC, const wxPoint& aOffset, void* aData,
41  const TRANSFORM& aTransform ) override;
43 public:
44  LIB_BEZIER( LIB_PART * aParent );
46  // Do not create a copy constructor. The one generated by the compiler is adequate.
50  wxString GetClass() const override
51  {
52  return wxT( "LIB_BEZIER" );
53  }
55  wxString GetTypeName() override
56  {
57  return _( "Bezier" );
58  }
60  void Reserve( size_t aCount ) { m_BezierPoints.reserve( aCount ); }
61  void AddPoint( const wxPoint& aPoint ) { m_BezierPoints.push_back( aPoint ); }
63  void Offset( const wxPoint& aOffset ) override;
64  const wxPoint GetOffset() const;
69  unsigned GetCornerCount() const { return m_PolyPoints.size(); }
71  const std::vector< wxPoint >& GetPoints() const { return m_BezierPoints; }
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;
76  const EDA_RECT GetBoundingBox() const override;
78  bool Inside( EDA_RECT& aRect ) const override;
80  void MoveTo( const wxPoint& aPosition ) override;
82  wxPoint GetPosition() const override;
84  void MirrorHorizontal( const wxPoint& aCenter ) override;
85  void MirrorVertical( const wxPoint& aCenter ) override;
86  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
88  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
89  const TRANSFORM& aTransform ) override;
91  int GetWidth() const override { return m_Width; }
92  void SetWidth( int aWidth ) override { m_Width = aWidth; }
94  int GetPenSize( ) const override;
96  void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList ) override;
98  EDA_ITEM* Clone() const override;
100 private:
109  int compare( const LIB_ITEM& aOther,
110  LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
111 };
114 #endif // LIB_BEZIER_H
Definition: common.h:184
wxString GetTypeName() override
Provide a user-consumable name of the object type.
Definition: lib_bezier.h:55
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_bezier.cpp:106
const wxPoint GetOffset() const
Definition: lib_bezier.cpp:114
Definition: lib_bezier.cpp:40
std::vector< wxPoint > m_BezierPoints
Definition: lib_bezier.h:37
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: lib_bezier.cpp:313
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_bezier.cpp:255
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:176
void GetMsgPanelInfo(EDA_UNITS aUnits, 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_bezier.cpp:342
wxPoint GetPosition() const override
Definition: lib_bezier.cpp:362
The base class for drawable items used by schematic library components.
Definition: lib_item.h:60
int GetWidth() const override
Definition: lib_bezier.h:91
void Reserve(size_t aCount)
Definition: lib_bezier.h:60
unsigned GetCornerCount() const
Definition: lib_bezier.h:69
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_bezier.cpp:82
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_bezier.cpp:122
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:164
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:94
void print(wxDC *aDC, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_bezier.cpp:220
The list of flags used by the compare function.
Definition: lib_item.h:116
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_bezier.h:50
std::vector< wxPoint > m_PolyPoints
Definition: lib_bezier.h:38
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:55
Define a library symbol object.
const std::vector< wxPoint > & GetPoints() const
Definition: lib_bezier.h:71
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_bezier.cpp:49
int GetPenSize() const override
Definition: lib_bezier.cpp:208
Base plotter engine class.
Definition: plotter.h:104
#define _(s)
Definition: 3d_actions.cpp:33
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_bezier.cpp:143
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
int m_Width
Definition: lib_bezier.h:36
void SetWidth(int aWidth) override
Definition: lib_bezier.h:92
void AddPoint(const wxPoint &aPoint)
Definition: lib_bezier.h:61
Define a bezier curve graphic body item.
Definition: lib_bezier.h:34