KiCad PCB EDA Suite
class_pcb_text.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) 1992-2011 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
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 
30 #ifndef CLASS_PCB_TEXT_H
31 #define CLASS_PCB_TEXT_H
32 
33 #include <mutex>
34 #include <eda_text.h>
35 #include <class_board_item.h>
36 #include <PolyLine.h>
37 
38 
39 class LINE_READER;
40 class EDA_DRAW_PANEL;
41 class MSG_PANEL_ITEM;
42 
43 
44 // A mutex which is unique to each instance it appears in (ie: a new std::mutex is allocated
45 // on copy or assignment).
46 class UNIQUE_MUTEX : public std::mutex
47 {
48 public:
49  UNIQUE_MUTEX() : std::mutex() {}
50  UNIQUE_MUTEX( const UNIQUE_MUTEX& ) : std::mutex() {}
51  UNIQUE_MUTEX& operator= (const UNIQUE_MUTEX& ) { return *this; }
52 };
53 
54 
55 class TEXTE_PCB : public BOARD_ITEM, public EDA_TEXT
56 {
57 public:
58  TEXTE_PCB( BOARD_ITEM* parent );
59 
60  // Do not create a copy constructor & operator=.
61  // The ones generated by the compiler are adequate.
62 
63  ~TEXTE_PCB();
64 
65  static inline bool ClassOf( const EDA_ITEM* aItem )
66  {
67  return aItem && PCB_TEXT_T == aItem->Type();
68  }
69 
70  virtual const wxPoint GetPosition() const override
71  {
72  return EDA_TEXT::GetTextPos();
73  }
74 
75  virtual void SetPosition( const wxPoint& aPos ) override
76  {
77  EDA_TEXT::SetTextPos( aPos );
78  }
79 
80  void Move( const wxPoint& aMoveVector ) override
81  {
82  EDA_TEXT::Offset( aMoveVector );
83  }
84 
85  void SetTextAngle( double aAngle );
86 
87  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
88 
89  void Flip( const wxPoint& aCentre ) override;
90 
91  void Draw( EDA_DRAW_PANEL* panel, wxDC* DC,
92  GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override;
93 
94  void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override;
95 
96  virtual bool HitTest( const wxPoint& aPosition ) const override
97  {
98  return TextHitTest( aPosition );
99  }
100 
104  virtual bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override
105  {
106  return TextHitTest( aRect, aContained, aAccuracy );
107  }
108 
109  wxString GetClass() const override
110  {
111  return wxT( "PTEXT" );
112  }
113 
125  void TransformBoundingBoxWithClearanceToPolygon(
126  SHAPE_POLY_SET& aCornerBuffer,
127  int aClearanceValue ) const;
128 
141  void TransformShapeWithClearanceToPolygonSet( SHAPE_POLY_SET& aCornerBuffer,
142  int aClearanceValue,
143  int aCircleToSegmentsCount,
144  double aCorrectionFactor ) const;
145 
146  wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override;
147 
148  BITMAP_DEF GetMenuImage() const override;
149 
150  // Virtual function
151  const EDA_RECT GetBoundingBox() const override;
152 
153  EDA_ITEM* Clone() const override;
154 
155  virtual void SwapData( BOARD_ITEM* aImage ) override;
156 
158 
159 #if defined(DEBUG)
160  virtual void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
161 #endif
162 };
163 
164 #endif // #define CLASS_PCB_TEXT_H
virtual bool HitTest(const EDA_RECT &aRect, bool aContained=true, int aAccuracy=0) const override
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
void Offset(const wxPoint &aOffset)
Definition: eda_text.h:227
Class LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived...
Definition: richio.h:81
static bool ClassOf(const EDA_ITEM *aItem)
PNG memory record (file in memory).
Definition: bitmap_types.h:41
const wxPoint & GetTextPos() const
Definition: eda_text.h:222
UNIQUE_MUTEX & operator=(const UNIQUE_MUTEX &)
wxString GetClass() const override
Function GetClass returns the class name.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
Classes BOARD_ITEM and BOARD_CONNECTED_ITEM.
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:221
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
Template specialization to enable wxStrings for certain containers (e.g. unordered_map) ...
Definition: bitmap.cpp:54
Definition of base KiCad text object.
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels...
Definition: eda_text.h:112
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
Class SHAPE_POLY_SET.
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
virtual const wxPoint GetPosition() const override
std::unique_ptr< typename std::remove_const< T >::type > Clone(const T &aItem)
Definition: pns_item.h:380
virtual void SetPosition(const wxPoint &aPos) override
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
void Move(const wxPoint &aMoveVector) override
Function Move move this object.
UNIQUE_MUTEX(const UNIQUE_MUTEX &)
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
void Flip(T &aValue)
EDA_UNITS_T
Definition: common.h:159
UNIQUE_MUTEX m_mutex