KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_text.cpp
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) 2012 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <pcb_edit_frame.h>
27#include <base_units.h>
28#include <bitmaps.h>
29#include <board.h>
31#include <core/mirror.h>
32#include <footprint.h>
33#include <pcb_text.h>
34#include <pcb_painter.h>
35#include <trigo.h>
36#include <string_utils.h>
38#include <callback_gal.h>
40
41
43 BOARD_ITEM( parent, idtype ),
45{
46 SetMultilineAllowed( true );
47}
48
49
51 BOARD_ITEM( aParent, PCB_TEXT_T ),
53{
54 SetKeepUpright( true );
55
56 // Set text thickness to a default value
59
60 if( aParent )
61 {
62 SetTextPos( aParent->GetPosition() );
63
64 if( IsBackLayer( aParent->GetLayer() ) )
65 {
67 SetMirrored( true );
68 }
69 }
70}
71
72
74{
75}
76
77
78wxString PCB_TEXT::GetShownText( bool aAllowExtraText, int aDepth ) const
79{
80 const FOOTPRINT* parentFootprint = GetParentFootprint();
81 const BOARD* board = GetBoard();
82
83 std::function<bool( wxString* )> resolver =
84 [&]( wxString* token ) -> bool
85 {
86 if( parentFootprint && parentFootprint->ResolveTextVar( token, aDepth + 1 ) )
87 return true;
88
89 if( token->IsSameAs( wxT( "LAYER" ) ) )
90 {
91 *token = GetLayerName();
92 return true;
93 }
94
95 if( board->ResolveTextVar( token, aDepth + 1 ) )
96 return true;
97
98 return false;
99 };
100
101 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
102
103 if( HasTextVars() )
104 {
105 if( aDepth < 10 )
107 }
108
109 return text;
110}
111
112
113bool PCB_TEXT::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
114{
115 return BOARD_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
116}
117
118
120{
121 EDA_ANGLE rotation = GetTextAngle();
122
124 {
125 // Keep angle between ]-90..90] deg. Otherwise the text is not easy to read
126 while( rotation > ANGLE_90 )
127 rotation -= ANGLE_180;
128
129 while( rotation <= -ANGLE_90 )
130 rotation += ANGLE_180;
131 }
132 else
133 {
134 rotation.Normalize();
135 }
136
137 return rotation;
138}
139
140
142{
143 return GetBoundingBox();
144}
145
146
147void PCB_TEXT::ViewGetLayers( int aLayers[], int& aCount ) const
148{
149 if( GetParentFootprint() == nullptr || IsVisible() )
150 aLayers[0] = GetLayer();
151 else
152 aLayers[0] = LAYER_HIDDEN_TEXT;
153
154 aCount = 1;
155
156 if( IsLocked() )
157 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
158}
159
160
161double PCB_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
162{
163 constexpr double HIDE = std::numeric_limits<double>::max();
164
165 if( !aView )
166 return 0.0;
167
168 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() );
169 KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
170
171 // Hidden text gets put on the LAYER_HIDDEN_TEXT for rendering, but
172 // should only render if its native layer is visible.
173 if( !aView->IsLayerVisible( GetLayer() ) )
174 return HIDE;
175
176 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
177 {
178 // Hide shadow on dimmed tracks
179 if( renderSettings->GetHighContrast() )
180 {
181 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
182 return HIDE;
183 }
184 }
185
186 if( FOOTPRINT* parentFP = GetParentFootprint() )
187 {
188 // Handle Render tab switches
189 if( GetText() == wxT( "${VALUE}" ) )
190 {
191 if( !aView->IsLayerVisible( LAYER_FP_VALUES ) )
192 return HIDE;
193 }
194
195 if( GetText() == wxT( "${REFERENCE}" ) )
196 {
197 if( !aView->IsLayerVisible( LAYER_FP_REFERENCES ) )
198 return HIDE;
199 }
200
201 if( parentFP->GetLayer() == F_Cu && !aView->IsLayerVisible( LAYER_FOOTPRINTS_FR ) )
202 return HIDE;
203
204 if( parentFP->GetLayer() == B_Cu && !aView->IsLayerVisible( LAYER_FOOTPRINTS_BK ) )
205 return HIDE;
206
207 if( !aView->IsLayerVisible( LAYER_FP_TEXT ) )
208 return HIDE;
209 }
210
211 return 0.0;
212}
213
214
215void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
216{
217 FOOTPRINT* parentFP = GetParentFootprint();
218
219 if( parentFP && aFrame->GetName() == PCB_EDIT_FRAME_NAME )
220 aList.emplace_back( _( "Footprint" ), parentFP->GetReference() );
221
222 // Don't use GetShownText() here; we want to show the user the variable references
223 if( parentFP )
224 aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
225 else
226 aList.emplace_back( _( "PCB Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
227
228 if( parentFP )
229 aList.emplace_back( _( "Type" ), GetTextTypeDescription() );
230
231 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
232 aList.emplace_back( _( "Status" ), _( "Locked" ) );
233
234 if( parentFP )
235 aList.emplace_back( _( "Display" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
236
237 aList.emplace_back( _( "Layer" ), GetLayerName() );
238
239 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
240
241 aList.emplace_back( _( "Angle" ), wxString::Format( wxT( "%g" ), GetTextAngle().AsDegrees() ) );
242
243 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
244 aList.emplace_back( _( "Thickness" ), aFrame->MessageTextFromValue( GetTextThickness() ) );
245 aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
246 aList.emplace_back( _( "Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
247}
248
249
251{
253}
254
255
257{
258 SetTextSize( settings.GetTextSize( GetLayer() ) );
260 SetItalic( settings.GetTextItalic( GetLayer() ) );
261 SetKeepUpright( settings.GetTextUpright( GetLayer() ) );
263}
264
265
266void PCB_TEXT::KeepUpright( const EDA_ANGLE& aNewOrientation )
267{
268 if( !IsKeepUpright() )
269 return;
270
271 EDA_ANGLE newAngle = GetTextAngle() + aNewOrientation;
272 newAngle.Normalize();
273
274 bool needsFlipped = newAngle >= ANGLE_180;
275
276 if( needsFlipped )
277 {
280 }
281}
282
283
285{
286 EDA_ANGLE angle = GetDrawRotation();
287 BOX2I rect = GetTextBox();
288
289 if( IsKnockout() )
290 rect.Inflate( getKnockoutMargin() );
291
292 if( !angle.IsZero() )
294
295 return rect;
296}
297
298
299bool PCB_TEXT::TextHitTest( const VECTOR2I& aPoint, int aAccuracy ) const
300{
301 int accuracy = aAccuracy;
302
303 if( IsKnockout() )
305
306 return EDA_TEXT::TextHitTest( aPoint, accuracy );
307}
308
309
310bool PCB_TEXT::TextHitTest( const BOX2I& aRect, bool aContains, int aAccuracy ) const
311{
312 BOX2I rect = aRect;
313
314 rect.Inflate( aAccuracy );
315
316 if( aContains )
317 return rect.Contains( GetBoundingBox() );
318
319 return rect.Intersects( GetBoundingBox() );
320}
321
322
323void PCB_TEXT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
324{
325 VECTOR2I pt = GetTextPos();
326 RotatePoint( pt, aRotCentre, aAngle );
327 SetTextPos( pt );
328
329 EDA_ANGLE new_angle = GetTextAngle() + aAngle;
330 new_angle.Normalize180();
331 SetTextAngle( new_angle );
332}
333
334
335void PCB_TEXT::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
336{
337 // the position and justification are mirrored, but not the text itself
338
339 if( aMirrorAroundXAxis )
340 {
343
344 SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
345 }
346 else
347 {
350
351 SetTextX( MIRRORVAL( GetTextPos().x, aCentre.x ) );
352 }
353}
354
355
356void PCB_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
357{
358 if( aFlipLeftRight )
359 {
360 SetTextX( MIRRORVAL( GetTextPos().x, aCentre.x ) );
362 }
363 else
364 {
365 SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
367 }
368
369 SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
370
371 if( ( GetLayerSet() & LSET::SideSpecificMask() ).any() )
373}
374
375
377{
378 return _( "Text" );
379}
380
381
382wxString PCB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
383{
384 if( FOOTPRINT* parentFP = GetParentFootprint() )
385 {
386 return wxString::Format( _( "Footprint Text '%s' of %s" ),
387 KIUI::EllipsizeMenuText( GetText() ), parentFP->GetReference() );
388 }
389
390 return wxString::Format( _( "PCB Text '%s' on %s" ),
392 GetLayerName() );
393}
394
395
397{
398 return BITMAPS::text;
399}
400
401
403{
404 return new PCB_TEXT( *this );
405}
406
407
409{
410 assert( aImage->Type() == PCB_TEXT_T );
411
412 std::swap( *((PCB_TEXT*) this), *((PCB_TEXT*) aImage) );
413}
414
415
416std::shared_ptr<SHAPE> PCB_TEXT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
417{
418 if( IsKnockout() )
419 {
420 SHAPE_POLY_SET poly;
421
422 TransformTextToPolySet( poly, 0, GetBoard()->GetDesignSettings().m_MaxError, ERROR_INSIDE );
423
424 return std::make_shared<SHAPE_POLY_SET>( poly );
425 }
426
427 return GetEffectiveTextShape();
428}
429
430
431void PCB_TEXT::buildBoundingHull( SHAPE_POLY_SET* aBuffer, const SHAPE_POLY_SET& aRenderedText,
432 int aClearance ) const
433{
434 SHAPE_POLY_SET poly( aRenderedText );
435
436 poly.Rotate( -GetDrawRotation(), GetDrawPos() );
437
438 BOX2I rect = poly.BBox( aClearance );
439 VECTOR2I corners[4];
440
441 corners[0].x = rect.GetOrigin().x;
442 corners[0].y = rect.GetOrigin().y;
443 corners[1].y = corners[0].y;
444 corners[1].x = rect.GetRight();
445 corners[2].x = corners[1].x;
446 corners[2].y = rect.GetBottom();
447 corners[3].y = corners[2].y;
448 corners[3].x = corners[0].x;
449
450 aBuffer->NewOutline();
451
452 for( VECTOR2I& corner : corners )
453 {
454 RotatePoint( corner, GetDrawPos(), GetDrawRotation() );
455 aBuffer->Append( corner.x, corner.y );
456 }
457}
458
459
460void PCB_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, int aMaxError,
461 ERROR_LOC aErrorLoc ) const
462{
464 KIFONT::FONT* font = getDrawFont();
465 int penWidth = GetEffectiveTextPenWidth();
467
468 attrs.m_Angle = GetDrawRotation();
469
470 // The polygonal shape of a text can have many basic shapes, so combining these shapes can
471 // be very useful to create a final shape with a lot less vertices to speedup calculations.
472 // Simplify shapes is not usually always efficient, but in this case it is.
473 SHAPE_POLY_SET textShape;
474
475 CALLBACK_GAL callback_gal( empty_opts,
476 // Stroke callback
477 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
478 {
479 TransformOvalToPolygon( textShape, aPt1, aPt2, penWidth, aMaxError, aErrorLoc );
480 },
481 // Triangulation callback
482 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
483 {
484 textShape.NewOutline();
485
486 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
487 textShape.Append( point.x, point.y );
488 } );
489
490 font->Draw( &callback_gal, GetShownText( true ), GetTextPos(), attrs, GetFontMetrics() );
492
493 if( IsKnockout() )
494 {
495 SHAPE_POLY_SET finalPoly;
496 int margin = GetKnockoutTextMargin( attrs.m_Size, penWidth );
497
498 buildBoundingHull( &finalPoly, textShape, margin + aClearance );
499 finalPoly.BooleanSubtract( textShape, SHAPE_POLY_SET::PM_FAST );
500
501 aBuffer.Append( finalPoly );
502 }
503 else
504 {
505 if( aClearance > 0 || aErrorLoc == ERROR_OUTSIDE )
506 {
507 if( aErrorLoc == ERROR_OUTSIDE )
508 aClearance += aMaxError;
509
510 textShape.Inflate( aClearance, CORNER_STRATEGY::ROUND_ALL_CORNERS, aMaxError );
511 }
512
513 aBuffer.Append( textShape );
514 }
515}
516
517
519 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
520 bool aIgnoreLineWidth ) const
521{
522 SHAPE_POLY_SET poly;
523
524 TransformTextToPolySet( poly, 0, aMaxError, aErrorLoc );
525
526 buildBoundingHull( &aBuffer, poly, aClearance );
527}
528
529
530bool PCB_TEXT::operator==( const BOARD_ITEM& aOther ) const
531{
532 if( aOther.Type() != Type() )
533 return false;
534
535 const PCB_TEXT& other = static_cast<const PCB_TEXT&>( aOther );
536
537 return EDA_TEXT::operator==( other );
538}
539
540
541double PCB_TEXT::Similarity( const BOARD_ITEM& aOther ) const
542{
543 if( aOther.Type() != Type() )
544 return 0.0;
545
546 const PCB_TEXT& other = static_cast<const PCB_TEXT&>( aOther );
547
548 return EDA_TEXT::Similarity( other );
549}
550
551
552static struct PCB_TEXT_DESC
553{
555 {
562
563 propMgr.Mask( TYPE_HASH( PCB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Color" ) );
564
565 propMgr.AddProperty( new PROPERTY<PCB_TEXT, bool, BOARD_ITEM>( _HKI( "Knockout" ),
567 _HKI( "Text Properties" ) );
568
569 propMgr.AddProperty( new PROPERTY<PCB_TEXT, bool, EDA_TEXT>( _HKI( "Keep Upright" ),
571 _HKI( "Text Properties" ) );
572
573 auto isFootprintText =
574 []( INSPECTABLE* aItem ) -> bool
575 {
576 if( PCB_TEXT* text = dynamic_cast<PCB_TEXT*>( aItem ) )
577 return text->GetParentFootprint();
578
579 return false;
580 };
581
583 _HKI( "Visible" ), isFootprintText );
584
586 _HKI( "Keep Upright" ), isFootprintText );
587
589 _HKI( "Hyperlink" ),
590 []( INSPECTABLE* aItem ) { return false; } );
591 }
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
#define DEFAULT_TEXT_WIDTH
Container for design settings for a BOARD object.
bool GetTextUpright(PCB_LAYER_ID aLayer) const
int GetTextThickness(PCB_LAYER_ID aLayer) const
Return the default text thickness from the layer class for the given layer.
bool GetTextItalic(PCB_LAYER_ID aLayer) const
VECTOR2I GetTextSize(PCB_LAYER_ID aLayer) const
Return the default text size from the layer class for the given layer.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:226
PCB_LAYER_ID m_layer
Definition: board_item.h:388
virtual bool IsKnockout() const
Definition: board_item.h:296
virtual void SetIsKnockout(bool aKnockout)
Definition: board_item.h:297
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:260
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:46
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:248
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:231
const KIFONT::METRICS & GetFontMetrics() const
Definition: board_item.cpp:97
virtual bool IsLocked() const
Definition: board_item.cpp:74
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:103
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:276
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:433
const Vec & GetOrigin() const
Definition: box2.h:184
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
coord_type GetRight() const
Definition: box2.h:190
const BOX2< Vec > GetBoundingBoxRotated(const VECTOR2I &aRotCenter, const EDA_ANGLE &aAngle) const
Useful to calculate bounding box of rotated items, when rotation is not cardinal.
Definition: box2.h:651
coord_type GetBottom() const
Definition: box2.h:191
EDA_ANGLE Normalize()
Definition: eda_angle.h:255
bool IsZero() const
Definition: eda_angle.h:175
EDA_ANGLE Normalize180()
Definition: eda_angle.h:294
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
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:372
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
int GetTextHeight() const
Definition: eda_text.h:225
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:567
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:231
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:374
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
bool IsKeepUpright() const
Definition: eda_text.h:167
virtual bool IsVisible() const
Definition: eda_text.h:148
void SetTextPos(const VECTOR2I &aPoint)
Definition: eda_text.cpp:419
void SetTextX(int aX)
Definition: eda_text.cpp:425
KIFONT::FONT * GetFont() const
Definition: eda_text.h:208
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:252
void SetTextY(int aY)
Definition: eda_text.cpp:431
virtual VECTOR2I GetDrawPos() const
Definition: eda_text.h:339
int GetTextWidth() const
Definition: eda_text.h:222
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:161
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:114
virtual KIFONT::FONT * getDrawFont() const
Definition: eda_text.cpp:482
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1151
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:197
virtual bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition: eda_text.cpp:706
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:192
bool IsMirrored() const
Definition: eda_text.h:151
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:324
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, const BOX2I &aBBox=BOX2I(), const EDA_ANGLE &aAngle=ANGLE_0) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
Definition: eda_text.cpp:985
void SetKeepUpright(bool aKeepUpright)
Definition: eda_text.cpp:284
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:106
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:205
int GetTextThickness() const
Definition: eda_text.h:123
void SetItalic(bool aItalic)
Definition: eda_text.cpp:213
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:354
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:260
VECTOR2I GetTextSize() const
Definition: eda_text.h:219
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:268
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
Definition: footprint.cpp:643
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:218
const wxString & GetReference() const
Definition: footprint.h:581
VECTOR2I GetPosition() const override
Definition: footprint.h:206
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:36
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttributes, const METRICS &aFontMetrics) const
Draw a string.
Definition: font.cpp:257
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:164
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: pcb_painter.h:169
PCB specific render settings.
Definition: pcb_painter.h:77
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:412
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:215
static LSET SideSpecificMask()
Definition: lset.cpp:998
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: pcb_text.cpp:215
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
Definition: pcb_text.cpp:541
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
Definition: pcb_text.cpp:518
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_text.cpp:141
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_text.cpp:408
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_text.cpp:416
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: pcb_text.cpp:113
void KeepUpright(const EDA_ANGLE &aNewOrientation)
Called when rotating the parent footprint.
Definition: pcb_text.cpp:266
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: pcb_text.cpp:78
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_text.cpp:356
~PCB_TEXT()
Definition: pcb_text.cpp:73
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: pcb_text.cpp:382
PCB_TEXT(BOARD_ITEM *parent, KICAD_T idtype=PCB_TEXT_T)
Definition: pcb_text.cpp:42
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_text.cpp:161
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Definition: pcb_text.cpp:256
int getKnockoutMargin() const
Definition: pcb_text.cpp:250
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis)
Definition: pcb_text.cpp:335
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
Definition: pcb_text.cpp:460
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_text.cpp:284
virtual wxString GetTextTypeDescription() const
Definition: pcb_text.cpp:376
void buildBoundingHull(SHAPE_POLY_SET *aBuffer, const SHAPE_POLY_SET &aRenderedText, int aClearance) const
Build a nominally rectangular bounding box for the rendered text.
Definition: pcb_text.cpp:431
bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const override
Test if aPoint is within the bounds of this object.
Definition: pcb_text.cpp:299
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_text.cpp:402
EDA_ANGLE GetDrawRotation() const override
Definition: pcb_text.cpp:119
void ViewGetLayers(int aLayers[], int &aCount) const override
Definition: pcb_text.cpp:147
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_text.cpp:323
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_text.cpp:396
bool operator==(const BOARD_ITEM &aBoardItem) const override
Definition: pcb_text.cpp:530
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:87
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void OverrideAvailability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override availability functor for a base class property of a given derived class.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void BooleanSubtract(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Perform boolean polyset difference For aFastMode meaning, see function booleanOp.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
void Simplify(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
int NewOutline()
Creates a new empty polygon in the set and returns its index.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject)
Definition: common.cpp:58
void TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:437
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:432
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:431
static constexpr EDA_ANGLE ANGLE_180
Definition: eda_angle.h:439
#define PCB_EDIT_FRAME_NAME
static FILENAME_RESOLVER * resolver
Definition: export_idf.cpp:53
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_OUTSIDE
@ ERROR_INSIDE
int GetKnockoutTextMargin(const VECTOR2I &aSize, int aThickness)
Returns the margin for knocking out text.
Definition: gr_text.h:92
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:148
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:976
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:242
@ LAYER_FOOTPRINTS_FR
show footprints on front
Definition: layer_ids.h:211
@ LAYER_FP_REFERENCES
show footprints references (when texts are visible)
Definition: layer_ids.h:214
@ LAYER_HIDDEN_TEXT
text marked as invisible
Definition: layer_ids.h:203
@ LAYER_FP_TEXT
Definition: layer_ids.h:201
@ LAYER_FOOTPRINTS_BK
show footprints on back
Definition: layer_ids.h:212
@ LAYER_FP_VALUES
show footprints values (when texts are visible)
Definition: layer_ids.h:213
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Cu
Definition: layer_ids.h:96
@ F_SilkS
Definition: layer_ids.h:105
@ B_SilkS
Definition: layer_ids.h:104
@ F_Cu
Definition: layer_ids.h:65
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:634
T MIRRORVAL(T aPoint, T aMirrorRef)
Returns the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:31
wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:210
wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
Definition: ui_common.cpp:192
static struct PCB_TEXT_DESC _PCB_TEXT_DESC
#define TYPE_HASH(x)
Definition: property.h:67
#define REGISTER_TYPE(x)
Definition: property_mgr.h:366
wxString UnescapeString(const wxString &aSource)
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
GR_TEXT_H_ALIGN_T
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition: trigo.cpp:228
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:92
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588