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-2011 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_POLYLINE_H_
30 #define _LIB_POLYLINE_H_
31 
32 #include <lib_draw_item.h>
33 
34 
35 class LIB_POLYLINE : public LIB_ITEM
36 {
37  int m_Width; // Line width
38  std::vector<wxPoint> m_PolyPoints; // list of points (>= 2)
39 
40  int m_ModifyIndex; // Index of the polyline point to modify
41 
42  void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
43  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
44  const TRANSFORM& aTransform ) override;
45 
46  void calcEdit( const wxPoint& aPosition ) override;
47 
48 public:
49  LIB_POLYLINE( LIB_PART * aParent );
50 
51  // Do not create a copy constructor. The one generated by the compiler is adequate.
52 
54 
55  wxString GetClass() const override
56  {
57  return wxT( "LIB_POLYLINE" );
58  }
59 
60 
61  bool Save( OUTPUTFORMATTER& aFormatter ) override;
62 
63  bool Load( LINE_READER& aLineReader, wxString& aErrorMsg ) override;
64 
65  void AddPoint( const wxPoint& aPoint );
66 
70  void DeleteSegment( const wxPoint aPosition );
71 
75  unsigned GetCornerCount() const { return m_PolyPoints.size(); }
76 
77  bool HitTest( const wxPoint& aPosition ) const override;
78 
79  bool HitTest( const wxPoint &aPosition, int aThreshold, const TRANSFORM& aTransform ) const override;
80 
81  const EDA_RECT GetBoundingBox() const override;
82 
83  int GetPenSize( ) const override;
84 
85  void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
86 
87  void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
88 
89  bool ContinueEdit( const wxPoint aNextPoint ) override;
90 
91  void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
92 
93  void SetOffset( const wxPoint& aOffset ) override;
94 
95  bool Inside( EDA_RECT& aRect ) const override;
96 
97  void Move( const wxPoint& aPosition ) override;
98 
99  wxPoint GetPosition() const override { return m_PolyPoints[0]; }
100 
101  void MirrorHorizontal( const wxPoint& aCenter ) override;
102 
103  void MirrorVertical( const wxPoint& aCenter ) override;
104 
105  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
106 
107  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
108  const TRANSFORM& aTransform ) override;
109 
110  int GetWidth() const override { return m_Width; }
111 
112  void SetWidth( int aWidth ) override { m_Width = aWidth; }
113 
114  wxString GetSelectMenuText() const override;
115 
116  BITMAP_DEF GetMenuImage() const override;
117 
118  EDA_ITEM* Clone() const override;
119 
120 private:
121 
129  int compare( const LIB_ITEM& aOther ) const override;
130 };
131 
132 
133 #endif // _LIB_POLYLINE_H_
wxPoint GetPosition() const override
Function GetPosition returns the current draw object position.
Definition: lib_polyline.h:99
bool Inside(EDA_RECT &aRect) const override
Function Inside tests if any part of the draw object is inside rectangle bounds of aRect...
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
void calcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
PNG memory record (file in memory).
Definition: bitmap_types.h:38
int compare(const LIB_ITEM &aOther) const override
Function compare provides the draw object specific comparison called by the == and < operators...
void MirrorHorizontal(const wxPoint &aCenter) override
Function MirrorHorizontal mirrors the draw object along the horizontal (X) axis about aCenter point...
void MirrorVertical(const wxPoint &aCenter) override
Function MirrorVertical mirrors the draw object along the MirrorVertical (Y) axis about aCenter point...
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo displays basic info (type, part and convert) about the current item in messa...
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
bool Save(OUTPUTFORMATTER &aFormatter) override
Function Save writes draw item object to aFormatter in component library "*.lib" format.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
void SetWidth(int aWidth) override
Function SetWidth sets the width of the draw item to aWidth.
Definition: lib_polyline.h:112
void BeginEdit(STATUS_FLAGS aEditMode, const wxPoint aStartPoint=wxPoint(0, 0)) override
Begin an editing a component library draw item in aEditMode at aPosition.
unsigned GetCornerCount() const
Definition: lib_polyline.h:75
int GetWidth() const override
Function GetWidth return the width of the draw item.
Definition: lib_polyline.h:110
Class LIB_ITEM is the base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:77
void SetOffset(const wxPoint &aOffset) override
Function Offset sets the drawing object by aOffset from the current position.
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
int GetPenSize() const override
Function GetPenSize.
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
void Move(const wxPoint &aPosition) override
Function Move moves a draw object to aPosition.
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
Class LIB_PART defines a library part object.
unsigned STATUS_FLAGS
Definition: base_struct.h:144
std::vector< wxPoint > m_PolyPoints
Definition: lib_polyline.h:38
void AddPoint(const wxPoint &aPoint)
bool Load(LINE_READER &aLineReader, wxString &aErrorMsg) override
virtual void Rotate()
Rotate the draw item.
void DeleteSegment(const wxPoint aPosition)
Delete the segment at aPosition.
Base plotter engine class.
Definition: plot_common.h:86
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_polyline.h:55
Class EDA_RECT handles the component boundary box.
void drawGraphic(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform) override
Function drawGraphic.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
const EDA_RECT GetBoundingBox() const override
void EndEdit(const wxPoint &aPosition, bool aAbort=false) override
End an object editing action.
LIB_POLYLINE(LIB_PART *aParent)
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39