KiCad PCB EDA Suite
lib_rectangle.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-2019 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_RECTANGLE_H
26 #define LIB_RECTANGLE_H
27 
28 #include <lib_item.h>
29 
30 
31 class LIB_RECTANGLE : public LIB_ITEM
32 {
33  wxPoint m_End; // Rectangle end point.
34  wxPoint m_Pos; // Rectangle start point.
35  int m_Width; // Line width
36 
37  void print( wxDC* aDC, const wxPoint& aOffset, void* aData,
38  const TRANSFORM& aTransform ) override;
39 
40 public:
41  LIB_RECTANGLE( LIB_PART * aParent );
42 
43  // Do not create a copy constructor. The one generated by the compiler is adequate.
44 
46 
47  wxString GetClass() const override
48  {
49  return wxT( "LIB_RECTANGLE" );
50  }
51 
52  wxString GetTypeName() override
53  {
54  return _( "Rectangle" );
55  }
56 
57  void SetEndPosition( const wxPoint& aPosition ) { m_End = aPosition; }
58 
59  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
60 
61  int GetPenSize( ) const override;
62 
63  const EDA_RECT GetBoundingBox() const override;
64 
65  void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList ) override;
66 
67  void BeginEdit( const wxPoint aStartPoint ) override;
68  void CalcEdit( const wxPoint& aPosition ) override;
69 
70  void Offset( const wxPoint& aOffset ) override;
71 
72  bool Inside( EDA_RECT& aRect ) const override;
73 
74  void MoveTo( const wxPoint& aPosition ) override;
75 
76  wxPoint GetPosition() const override { return m_Pos; }
77 
78  void MirrorHorizontal( const wxPoint& aCenter ) override;
79  void MirrorVertical( const wxPoint& aCenter ) override;
80  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
81 
82  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
83  const TRANSFORM& aTransform ) override;
84 
85  int GetWidth() const override { return m_Width; }
86  void SetWidth( int aWidth ) override { m_Width = aWidth; }
87 
88  void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; }
89  wxPoint GetEnd() const { return m_End; }
90 
91  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
92 
93  BITMAP_DEF GetMenuImage() const override;
94 
95  EDA_ITEM* Clone() const override;
96 
97 private:
98 
108  int compare( const LIB_ITEM& aOther ) const override;
109 };
110 
111 
112 #endif // LIB_RECTANGLE_H
EDA_UNITS
Definition: common.h:72
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
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 print(wxDC *aDC, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
PNG memory record (file in memory).
Definition: bitmap_def.h:29
wxPoint GetEnd() const
Definition: lib_rectangle.h:89
int GetPenSize() const override
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
bool Inside(EDA_RECT &aRect) const override
Test if any part of the draw object is inside rectangle bounds of aRect.
void BeginEdit(const wxPoint aStartPoint) override
Begin drawing a component library draw item at aPosition.
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
The base class for drawable items used by schematic library components.
Definition: lib_item.h:60
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void SetWidth(int aWidth) override
Definition: lib_rectangle.h:86
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
int GetWidth() const override
Definition: lib_rectangle.h:85
Define a library symbol object.
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
void SetEndPosition(const wxPoint &aPosition)
Definition: lib_rectangle.h:57
Base plotter engine class.
Definition: plotter.h:103
LIB_RECTANGLE(LIB_PART *aParent)
void SetEnd(const wxPoint &aEnd)
Definition: lib_rectangle.h:88
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_rectangle.h:47
#define _(s)
Definition: 3d_actions.cpp:31
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
const EDA_RECT GetBoundingBox() const override
wxPoint GetPosition() const override
Definition: lib_rectangle.h:76
wxString GetTypeName() override
Provide a user-consumable name of the object type.
Definition: lib_rectangle.h:52