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-2017 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_RECTANGLE_H_
30 #define _LIB_RECTANGLE_H_
31 
32 #include <lib_draw_item.h>
33 
34 
35 class LIB_RECTANGLE : public LIB_ITEM
36 {
37  wxPoint m_End; // Rectangle end point.
38  wxPoint m_Pos; // Rectangle start point.
39  int m_Width; // Line width
40  bool m_isWidthLocked; // Flag: Keep width locked
41  bool m_isHeightLocked; // Flag: Keep height locked
42  bool m_isStartPointSelected; // Flag: is the upper left edge selected?
43 
44  void drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset,
45  COLOR4D aColor, GR_DRAWMODE aDrawMode, void* aData,
46  const TRANSFORM& aTransform ) override;
47 
48  void calcEdit( const wxPoint& aPosition ) override;
49 
50 public:
51  LIB_RECTANGLE( LIB_PART * aParent );
52 
53  // Do not create a copy constructor. The one generated by the compiler is adequate.
54 
56 
57  wxString GetClass() const override
58  {
59  return wxT( "LIB_RECTANGLE" );
60  }
61 
62  wxString GetTypeName() override
63  {
64  return _( "Rectangle" );
65  }
66 
67  void SetEndPosition( const wxPoint& aPosition ) { m_End = aPosition; }
68 
69  bool HitTest( const wxPoint& aPosition ) const override;
70 
71  bool HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const override;
72 
73  int GetPenSize( ) const override;
74 
75  const EDA_RECT GetBoundingBox() const override;
76 
77  void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override;
78 
79  void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override;
80 
81  bool ContinueEdit( const wxPoint aNextPoint ) override;
82 
83  void EndEdit( const wxPoint& aPosition, bool aAbort = false ) override;
84 
85  void SetOffset( const wxPoint& aOffset ) override;
86 
87  bool Inside( EDA_RECT& aRect ) const override;
88 
89  void Move( const wxPoint& aPosition ) override;
90 
91  wxPoint GetPosition() const override { return m_Pos; }
92 
93  void MirrorHorizontal( const wxPoint& aCenter ) override;
94 
95  void MirrorVertical( const wxPoint& aCenter ) override;
96 
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 
104  void SetWidth( int aWidth ) override { m_Width = aWidth; }
105 
106  void SetEnd( const wxPoint& aEnd ) { m_End = aEnd; }
107 
108  wxPoint GetEnd() const { return m_End; }
109 
110  wxString GetSelectMenuText() const override;
111 
112  BITMAP_DEF GetMenuImage() const override;
113 
114  EDA_ITEM* Clone() const override;
115 
116 private:
117 
127  int compare( const LIB_ITEM& aOther ) const override;
128 };
129 
130 
131 #endif // _LIB_RECTANGLE_H_
void SetOffset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
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.
void BeginEdit(STATUS_FLAGS aEditMode, const wxPoint aStartPoint=wxPoint(0, 0)) override
Begin an editing a component library draw item in aEditMode at aPosition.
PNG memory record (file in memory).
Definition: bitmap_types.h:41
int GetPenSize() const override
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
bool Inside(EDA_RECT &aRect) const override
Test if any part of the draw object is inside rectangle bounds of aRect.
bool m_isHeightLocked
Definition: lib_rectangle.h:41
void calcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:66
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
bool ContinueEdit(const wxPoint aNextPoint) override
Continue an edit in progress at aPosition.
int GetWidth() const override
Return the width of the draw item.
wxPoint GetEnd() const
Define a library symbol object.
unsigned STATUS_FLAGS
Definition: base_struct.h:142
virtual void Rotate()
Rotate the draw item.
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
void drawGraphic(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform) override
Draw the item on aPanel.
void SetEndPosition(const wxPoint &aPosition)
Definition: lib_rectangle.h:67
bool m_isWidthLocked
Definition: lib_rectangle.h:40
void Move(const wxPoint &aPosition) override
Move a draw object to aPosition.
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
Base plotter engine class.
Definition: plotter.h:96
LIB_RECTANGLE(LIB_PART *aParent)
void SetEnd(const wxPoint &aEnd)
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:57
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
void EndEdit(const wxPoint &aPosition, bool aAbort=false) override
End an object editing action.
bool m_isStartPointSelected
Definition: lib_rectangle.h:42
const EDA_RECT GetBoundingBox() const override
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_rectangle.h:91
wxString GetTypeName() override
Provide a user-consumable name of the object type.
Definition: lib_rectangle.h:62
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39