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, [email protected]
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_TEXT_H
26 #define LIB_TEXT_H
28 #include <eda_text.h>
29 #include <lib_item.h>
39 class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
40 {
41 public:
42  LIB_TEXT( LIB_SYMBOL* aParent );
44  // Do not create a copy constructor. The one generated by the compiler is adequate.
46  ~LIB_TEXT() { }
48  wxString GetClass() const override
49  {
50  return wxT( "LIB_TEXT" );
51  }
53  wxString GetTypeName() const override
54  {
55  return _( "Text" );
56  }
58  void ViewGetLayers( int aLayers[], int& aCount ) const override;
60  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override;
62  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override
63  {
65  return false;
67  EDA_RECT rect = aRect;
69  rect.Inflate( aAccuracy );
71  EDA_RECT textBox = GetTextBox();
72  textBox.RevertYAxis();
74  if( aContained )
75  return rect.Contains( textBox );
77  return rect.Intersects( textBox, GetTextAngle() );
78  }
80  int GetPenWidth() const override;
82  const EDA_RECT GetBoundingBox() const override;
84  void BeginEdit( const wxPoint& aStartPoint ) override;
85  void CalcEdit( const wxPoint& aPosition ) override;
87  void Offset( const wxPoint& aOffset ) override;
89  void MoveTo( const wxPoint& aPosition ) override;
91  wxPoint GetPosition() const override { return EDA_TEXT::GetTextPos(); }
93  void MirrorHorizontal( const wxPoint& aCenter ) override;
94  void MirrorVertical( const wxPoint& aCenter ) override;
95  void Rotate( const wxPoint& aCenter, bool aRotateCCW = true ) override;
97  void NormalizeJustification( bool inverse );
99  void Plot( PLOTTER* aPlotter, const wxPoint& aOffset, bool aFill,
100  const TRANSFORM& aTransform ) const override;
102  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
103  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
105  BITMAPS GetMenuImage() const override;
107  EDA_ITEM* Clone() const override;
109 private:
120  int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
122  void print( const RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
123  const TRANSFORM& aTransform ) override;
124 };
127 #endif // LIB_TEXT_H
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_text.cpp:126
bool HitTest(const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
Test if aRect intersects this item.
Definition: lib_text.h:62
int compare(const LIB_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_text.cpp:88
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Define a symbol library graphical text item.
Definition: lib_text.h:39
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.
Definition: lib_text.cpp:343
void NormalizeJustification(bool inverse)
Definition: lib_text.cpp:132
void CalcEdit(const wxPoint &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_text.cpp:420
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_text.cpp:169
wxPoint GetPosition() const override
Definition: lib_text.h:91
EDA_RECT GetTextBox(int aLine=-1, bool aInvertY=false) const
Useful in multiline texts to calculate the full text or a line area (for zones filling,...
Definition: eda_text.cpp:239
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) const override
Plot the draw item using the plot object.
Definition: lib_text.cpp:261
double GetTextAngle() const
Definition: eda_text.h:195
Definition: eda_item.h:480
The base class for create windows for drawing purpose.
Define a library symbol object.
Definition: lib_symbol.h:96
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: eda_rect.h:207
void print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print the item to aDC.
Definition: lib_text.cpp:300
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
Definition: lib_text.h:46
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: lib_text.cpp:48
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: lib_text.cpp:56
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:140
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void BeginEdit(const wxPoint &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_text.cpp:414
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_text.cpp:227
wxString GetTypeName() const override
Provide a user-consumable name of the object type.
Definition: lib_text.h:53
flag indication structures to be erased
#define _(s)
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_text.cpp:198
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: lib_text.cpp:402
Definition: eda_units.h:38
Base plotter engine class.
Definition: plotter.h:121
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_text.cpp:120
flag indicating that the structure should be ignored
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
const EDA_RECT GetBoundingBox() const override
Definition: lib_text.cpp:377
wxString GetClass() const override
Return the class name.
Definition: lib_text.h:48
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:99
Definition: lib_text.cpp:40
int GetPenWidth() const override
Definition: lib_text.cpp:294
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_text.cpp:408
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
const wxPoint & GetTextPos() const
Definition: eda_text.h:268
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_text.cpp:72
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364