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 AUTHORS.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_POLYLINE_H_
26 #define _LIB_POLYLINE_H_
28 #include <lib_item.h>
31 class LIB_POLYLINE : public LIB_ITEM
32 {
33 public:
34  LIB_POLYLINE( LIB_PART * aParent );
36  // Do not create a copy constructor. The one generated by the compiler is adequate.
40  wxString GetClass() const override
41  {
42  return wxT( "LIB_POLYLINE" );
43  }
45  wxString GetTypeName() const override
46  {
47  return _( "PolyLine" );
48  }
50  void ClearPoints() { m_PolyPoints.clear(); }
51  void Reserve( size_t aPointCount ) { m_PolyPoints.reserve( aPointCount ); }
52  void AddPoint( const wxPoint& aPoint );
54  const std::vector< wxPoint >& GetPolyPoints() const { return m_PolyPoints; }
59  void DeleteSegment( const wxPoint aPosition );
61  void AddCorner( const wxPoint& aPosition );
62  void RemoveCorner( int aIdx );
67  unsigned GetCornerCount() const { return m_PolyPoints.size(); }
69  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
70  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override;
72  const EDA_RECT GetBoundingBox() const override;
74  int GetPenWidth() const override;
76  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
78  void BeginEdit( const wxPoint aStartPoint ) override;
79  void CalcEdit( const wxPoint& aPosition ) override;
80  bool ContinueEdit( const wxPoint aNextPoint ) override;
81  void EndEdit() override;
83  void Offset( const wxPoint& aOffset ) override;
85  void MoveTo( const wxPoint& aPosition ) override;
87  wxPoint GetPosition() const override { return m_PolyPoints[0]; }
89  void MirrorHorizontal( const wxPoint& aCenter ) override;
90  void MirrorVertical( const wxPoint& aCenter ) override;
91  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
93  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
94  const TRANSFORM& aTransform ) const override;
96  int GetWidth() const override { return m_Width; }
97  void SetWidth( int aWidth ) override { m_Width = aWidth; }
99  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
101  BITMAPS GetMenuImage() const override;
103  EDA_ITEM* Clone() const override;
105 private:
114  int compare( const LIB_ITEM& aOther,
115  LIB_ITEM::COMPARE_FLAGS aCompareFlags = LIB_ITEM::COMPARE_FLAGS::NORMAL ) const override;
117  void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
118  const TRANSFORM& aTransform ) override;
120  int m_Width; // Line width
121  std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
122 };
125 #endif // _LIB_POLYLINE_H_
void AddCorner(const wxPoint &aPosition)
wxPoint GetPosition() const override
Definition: lib_polyline.h:87
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
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.
EDA_ITEM * Clone() const override
Create 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:97
int GetWidth() const override
Definition: lib_polyline.h:96
unsigned GetCornerCount() const
Definition: lib_polyline.h:67
The base class for drawable items used by schematic library components.
Definition: lib_item.h:62
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) const override
Plot the draw item using the plot object.
const std::vector< wxPoint > & GetPolyPoints() const
Definition: lib_polyline.h:54
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test 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
The list of flags used by the compare function.
Definition: lib_item.h:82
void Reserve(size_t aPointCount)
Definition: lib_polyline.h:51
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Define a library symbol object.
Definition: lib_symbol.h:93
void print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
std::vector< wxPoint > m_PolyPoints
Definition: lib_polyline.h:121
void AddPoint(const wxPoint &aPoint)
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void DeleteSegment(const wxPoint aPosition)
Delete the segment at aPosition.
Definition: eda_units.h:38
void ClearPoints()
Definition: lib_polyline.h:50
Base plotter engine class.
Definition: plotter.h:121
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.
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
wxString GetClass() const override
Return the class name.
Definition: lib_polyline.h:40
void BeginEdit(const wxPoint aStartPoint) override
Begin drawing a component library draw item at aPosition.
#define _(s)
Definition: 3d_actions.cpp:33
Handle the component boundary box.
Definition: eda_rect.h:42
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
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)
wxString GetTypeName() const override
Provide a user-consumable name of the object type.
Definition: lib_polyline.h:45
void CalcEdit(const wxPoint &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.