KiCad PCB EDA Suite
lib_polyline.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  *
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_POLYLINE_H_
26 #define _LIB_POLYLINE_H_
27 
28 #include <lib_item.h>
29 
30 
31 class LIB_POLYLINE : public LIB_ITEM
32 {
33  int m_Width; // Line width
34  std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
35 
36  void print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
37  const TRANSFORM& aTransform ) override;
38 
39 public:
40  LIB_POLYLINE( LIB_PART * aParent );
41 
42  // Do not create a copy constructor. The one generated by the compiler is adequate.
43 
45 
46  wxString GetClass() const override
47  {
48  return wxT( "LIB_POLYLINE" );
49  }
50 
51  wxString GetTypeName() override
52  {
53  return _( "PolyLine" );
54  }
55 
56  void ClearPoints() { m_PolyPoints.clear(); }
57  void Reserve( size_t aPointCount ) { m_PolyPoints.reserve( aPointCount ); }
58  void AddPoint( const wxPoint& aPoint );
59 
60  const std::vector< wxPoint >& GetPolyPoints() const { return m_PolyPoints; }
61 
65  void DeleteSegment( const wxPoint aPosition );
66 
67  void AddCorner( const wxPoint& aPosition );
68  void RemoveCorner( int aIdx );
69 
73  unsigned GetCornerCount() const { return m_PolyPoints.size(); }
74 
75  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
76  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
77 
78  const EDA_RECT GetBoundingBox() const override;
79 
80  int GetPenWidth() const override;
81 
82  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
83 
84  void BeginEdit( const wxPoint aStartPoint ) override;
85  void CalcEdit( const wxPoint& aPosition ) override;
86  bool ContinueEdit( const wxPoint aNextPoint ) override;
87  void EndEdit() override;
88 
89  void Offset( const wxPoint& aOffset ) override;
90 
91  void MoveTo( const wxPoint& aPosition ) override;
92 
93  const wxPoint GetPosition() const override { return m_PolyPoints[0]; }
94 
95  void MirrorHorizontal( const wxPoint& aCenter ) override;
96  void MirrorVertical( const wxPoint& aCenter ) override;
97  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
98 
99  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
100  const TRANSFORM& aTransform ) override;
101 
102  int GetWidth() const override { return m_Width; }
103  void SetWidth( int aWidth ) override { m_Width = aWidth; }
104 
105  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
106 
107  BITMAP_DEF GetMenuImage() const override;
108 
109  EDA_ITEM* Clone() const override;
110 
111 private:
112 
120  int compare( const LIB_ITEM& aOther,
121  LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
122 };
123 
124 
125 #endif // _LIB_POLYLINE_H_
EDA_UNITS
Definition: common.h:196
void AddCorner(const wxPoint &aPosition)
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...
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
The base class for create windows for drawing purpose.
void SetWidth(int aWidth) override
Definition: lib_polyline.h:103
int GetWidth() const override
Definition: lib_polyline.h:102
unsigned GetCornerCount() const
Definition: lib_polyline.h:73
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:60
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.
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
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.
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
int GetPenWidth() const override
COMPARE_FLAGS
The list of flags used by the compare function.
Definition: lib_item.h:116
void Reserve(size_t aPointCount)
Definition: lib_polyline.h:57
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Define a library symbol object.
std::vector< wxPoint > m_PolyPoints
Definition: lib_polyline.h:34
void AddPoint(const wxPoint &aPoint)
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
void print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
const wxPoint GetPosition() const override
Definition: lib_polyline.h:93
void DeleteSegment(const wxPoint aPosition)
Delete the segment at aPosition.
void ClearPoints()
Definition: lib_polyline.h:56
Base plotter engine class.
Definition: plotter.h:104
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_polyline.h:46
void BeginEdit(const wxPoint aStartPoint) override
Begin drawing a component library draw item at aPosition.
#define _(s)
Definition: 3d_actions.cpp:33
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxString GetTypeName() override
Provide a user-consumable name of the object type.
Definition: lib_polyline.h:51
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
void EndEdit() override
End an object editing action.
const EDA_RECT GetBoundingBox() const override
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
void RemoveCorner(int aIdx)
LIB_POLYLINE(LIB_PART *aParent)
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.