KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_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, [email protected]
5 * Copyright (C) 2004-2022 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
25#ifndef LIB_TEXT_H
26#define LIB_TEXT_H
27
28#include <eda_text.h>
29#include <lib_item.h>
30
31
39class LIB_TEXT : public LIB_ITEM, public EDA_TEXT
40{
41public:
42 LIB_TEXT( LIB_SYMBOL* aParent );
43
44 // Do not create a copy constructor. The one generated by the compiler is adequate.
45
47
48 wxString GetClass() const override
49 {
50 return wxT( "LIB_TEXT" );
51 }
52
53 static inline bool ClassOf( const EDA_ITEM* aItem )
54 {
55 return aItem && aItem->Type() == LIB_TEXT_T;
56 }
57
58 wxString GetTypeName() const override
59 {
60 return _( "Text" );
61 }
62
63 void ViewGetLayers( int aLayers[], int& aCount ) const override;
64
65 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
66
67 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
68 {
70 return false;
71
72 BOX2I rect = aRect;
73
74 rect.Inflate( aAccuracy );
75
76 BOX2I textBox = GetTextBox();
77 textBox.RevertYAxis();
78
79 if( aContained )
80 return rect.Contains( textBox );
81
82 return rect.Intersects( textBox, GetTextAngle() );
83 }
84
85 int GetPenWidth() const override;
86
87 KIFONT::FONT* getDrawFont() const override;
88
89 const BOX2I GetBoundingBox() const override;
90
91 void BeginEdit( const VECTOR2I& aStartPoint ) override;
92 void CalcEdit( const VECTOR2I& aPosition ) override;
93
94 void Offset( const VECTOR2I& aOffset ) override;
95
96 void MoveTo( const VECTOR2I& aPosition ) override;
97
98 VECTOR2I GetPosition() const override { return EDA_TEXT::GetTextPos(); }
99
100 void MirrorHorizontal( const VECTOR2I& aCenter ) override;
101 void MirrorVertical( const VECTOR2I& aCenter ) override;
102 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW = true ) override;
103
104 void NormalizeJustification( bool inverse );
105
106 void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset,
107 const TRANSFORM& aTransform, bool aDimmed ) const override;
108
109 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
110 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
111
112 BITMAPS GetMenuImage() const override;
113
114 EDA_ITEM* Clone() const override;
115
116 double Similarity( const LIB_ITEM& aOther ) const override;
117
118 bool operator==( const LIB_ITEM& aOther ) const override;
119
120private:
131 int compare( const LIB_ITEM& aOther, int aCompareFlags = 0 ) const override;
132
133 void print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, void* aData,
134 const TRANSFORM& aTransform, bool aDimmed ) override;
135};
136
137
138#endif // LIB_TEXT_H
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
void RevertYAxis()
Mirror the rectangle from the X axis (negate Y pos and size).
Definition: box2.h:690
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:270
bool Contains(const Vec &aPoint) const
Definition: box2.h:142
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:507
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:487
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
BOX2I 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:549
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:230
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:68
Define a library symbol object.
Definition: lib_symbol.h:99
Define a symbol library graphical text item.
Definition: lib_text.h:40
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: lib_text.cpp:74
wxString GetTypeName() const override
Provide a user-consumable name of the object type.
Definition: lib_text.h:58
~LIB_TEXT()
Definition: lib_text.h:46
void MirrorHorizontal(const VECTOR2I &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_text.cpp:175
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: lib_text.cpp:485
const BOX2I GetBoundingBox() const override
Definition: lib_text.cpp:454
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:50
KIFONT::FONT * getDrawFont() const override
Definition: lib_text.cpp:341
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:419
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_text.cpp:233
bool operator==(const LIB_ITEM &aOther) const override
Test LIB_ITEM objects for equivalence.
Definition: lib_text.cpp:503
double Similarity(const LIB_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: lib_text.cpp:514
void MoveTo(const VECTOR2I &aPosition) override
Move a draw object to aPosition.
Definition: lib_text.cpp:129
void NormalizeJustification(bool inverse)
Definition: lib_text.cpp:135
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:91
void print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, void *aData, const TRANSFORM &aTransform, bool aDimmed) override
Print the item to aDC.
Definition: lib_text.cpp:352
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: lib_text.cpp:58
VECTOR2I GetPosition() const override
Definition: lib_text.h:98
int GetPenWidth() const override
Definition: lib_text.cpp:335
wxString GetClass() const override
Return the class name.
Definition: lib_text.h:48
void BeginEdit(const VECTOR2I &aStartPoint) override
Begin drawing a symbol library draw item at aPosition.
Definition: lib_text.cpp:491
static bool ClassOf(const EDA_ITEM *aItem)
Definition: lib_text.h:53
bool HitTest(const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
Test if aRect intersects this item.
Definition: lib_text.h:67
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: lib_text.cpp:479
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
Definition: lib_text.cpp:497
void Plot(PLOTTER *aPlotter, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const override
Plot the draw item using the plot object.
Definition: lib_text.cpp:267
void Offset(const VECTOR2I &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_text.cpp:123
void MirrorVertical(const VECTOR2I &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_text.cpp:204
Base plotter engine class.
Definition: plotter.h:104
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
#define _(s)
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
@ LIB_TEXT_T
Definition: typeinfo.h:200