KiCad PCB EDA Suite
fp_textbox.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) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <pcb_edit_frame.h>
25#include <board.h>
27#include <core/mirror.h>
28#include <footprint.h>
29#include <fp_textbox.h>
31#include <string_utils.h>
32#include <painter.h>
34#include <callback_gal.h>
36#include <macros.h>
37
38
39FP_TEXTBOX::FP_TEXTBOX( FOOTPRINT* aParentFootprint ) :
40 FP_SHAPE( aParentFootprint, SHAPE_T::RECT, PCB_FP_TEXTBOX_T ),
42{
45 SetMultilineAllowed( true );
46
48}
49
50
52{
53}
54
55
57{
58 return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
59}
60
61
63{
64 EDA_ANGLE rotation = GetDrawRotation();
65
66 if( rotation == ANGLE_90 )
67 return VECTOR2I( GetStartX(), GetEndY() );
68 else if( rotation == ANGLE_180 )
69 return GetEnd();
70 else if( rotation == ANGLE_270 )
71 return VECTOR2I( GetEndX(), GetStartY() );
72 else
73 return GetStart();
74}
75
76
78{
79 EDA_ANGLE rotation = GetDrawRotation();
80
81 if( rotation == ANGLE_90 )
82 return VECTOR2I( GetEndX(), GetStartY() );
83 else if( rotation == ANGLE_180 )
84 return GetStart();
85 else if( rotation == ANGLE_270 )
86 return VECTOR2I( GetStartX(), GetEndY() );
87 else
88 return GetEnd();
89}
90
91
92void FP_TEXTBOX::SetTop( int aVal )
93{
94 EDA_ANGLE rotation = GetDrawRotation();
95
96 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
97 SetEndY( aVal );
98 else
99 SetStartY( aVal );
100}
101
102
103void FP_TEXTBOX::SetBottom( int aVal )
104{
105 EDA_ANGLE rotation = GetDrawRotation();
106
107 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
108 SetStartY( aVal );
109 else
110 SetEndY( aVal );
111}
112
113
114void FP_TEXTBOX::SetLeft( int aVal )
115{
116 EDA_ANGLE rotation = GetDrawRotation();
117
118 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
119 SetEndX( aVal );
120 else
121 SetStartX( aVal );
122}
123
124
125void FP_TEXTBOX::SetRight( int aVal )
126{
127 EDA_ANGLE rotation = GetDrawRotation();
128
129 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
130 SetStartX( aVal );
131 else
132 SetEndX( aVal );
133}
134
135
137{
138 EDA_ANGLE delta = aAngle.Normalized() - GetTextAngle();
140}
141
142
143std::vector<VECTOR2I> FP_TEXTBOX::GetCorners() const
144{
145 std::vector<VECTOR2I> pts = FP_SHAPE::GetCorners();
146
147 // SHAPE_T::POLY doesn't use the DrawCoord/LocalCoord architecture and instead stores fully
148 // resolved points (ie: relative to the board, not parent footprint).
149 if( GetShape() == SHAPE_T::POLY )
150 {
151 if( FOOTPRINT* parentFootprint = PCB_SHAPE::GetParentFootprint() )
152 {
153 for( VECTOR2I& pt : pts )
154 RotatePoint( pt, parentFootprint->GetPosition(), parentFootprint->GetOrientation() );
155 }
156 }
157
158 return pts;
159}
160
161
163{
164 EDA_ANGLE rotation = GetTextAngle();
165
166 if( FOOTPRINT* parentFootprint = PCB_SHAPE::GetParentFootprint() )
167 rotation += parentFootprint->GetOrientation();
168
169 rotation.Normalize();
170
171 return rotation;
172}
173
174
175std::vector<VECTOR2I> FP_TEXTBOX::GetNormalizedCorners() const
176{
177 std::vector<VECTOR2I> corners = GetCorners();
178 EDA_ANGLE textAngle( GetDrawRotation() );
179
180 if( FOOTPRINT* parentFootprint = PCB_SHAPE::GetParentFootprint() )
181 {
182 if( parentFootprint->IsFlipped() )
183 std::swap( corners[1], corners[3] );
184 }
185
186 textAngle.Normalize();
187
188 if( textAngle < ANGLE_90 )
189 {
190 if( corners[1].y > corners[0].y )
191 std::swap( corners[1], corners[3] );
192 }
193 else if( textAngle < ANGLE_180 )
194 {
195 if( corners[1].x > corners[0].x )
196 std::swap( corners[1], corners[3] );
197 }
198 else if( textAngle < ANGLE_270 )
199 {
200 if( corners[1].y < corners[0].y )
201 std::swap( corners[1], corners[3] );
202 }
203 else
204 {
205 if( corners[1].x < corners[0].x )
206 std::swap( corners[1], corners[3] );
207 }
208
209 return corners;
210}
211
212
214{
215 std::vector<VECTOR2I> corners = GetNormalizedCorners();
216 GR_TEXT_H_ALIGN_T effectiveAlignment = GetHorizJustify();
217 VECTOR2I textAnchor;
218 VECTOR2I vMargin;
219 VECTOR2I hMargin;
220 bool isFlipped = false;
221
222 if( FOOTPRINT* parentFootprint = PCB_SHAPE::GetParentFootprint() )
223 isFlipped = parentFootprint->IsFlipped();
224
225 if( IsMirrored() != isFlipped )
226 {
227 std::swap( corners[0], corners[1] );
228 std::swap( corners[2], corners[3] );
229
230 switch( GetHorizJustify() )
231 {
232 case GR_TEXT_H_ALIGN_LEFT: effectiveAlignment = GR_TEXT_H_ALIGN_RIGHT; break;
233 case GR_TEXT_H_ALIGN_CENTER: effectiveAlignment = GR_TEXT_H_ALIGN_CENTER; break;
234 case GR_TEXT_H_ALIGN_RIGHT: effectiveAlignment = GR_TEXT_H_ALIGN_LEFT; break;
235 }
236 }
237
238 switch( effectiveAlignment )
239 {
241 textAnchor = corners[0];
242 vMargin = ( corners[2] - corners[1] ).Resize( GetTextMargin() );
243 hMargin = ( corners[1] - corners[0] ).Resize( GetTextMargin() );
244 break;
246 textAnchor = ( corners[0] + corners[1] ) / 2;
247 vMargin = ( corners[2] - corners[1] ).Resize( GetTextMargin() );
248 break;
250 textAnchor = corners[1];
251 vMargin = ( corners[2] - corners[1] ).Resize( GetTextMargin() );
252 hMargin = ( corners[0] - corners[1] ).Resize( GetTextMargin() );
253 break;
254 }
255
256 return textAnchor + hMargin + vMargin;
257}
258
259
260bool FP_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
261{
262 BOX2I rect = GetBoundingBox();
263
264 rect.Inflate( aAccuracy );
265
266 return rect.Contains( aPosition );
267}
268
269
270bool FP_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
271{
272 BOX2I rect = aRect;
273
274 rect.Inflate( aAccuracy );
275
276 if( aContained )
277 return rect.Contains( GetBoundingBox() );
278
279 return rect.Intersects( GetBoundingBox() );
280}
281
282
283void FP_TEXTBOX::Move( const VECTOR2I& aMoveVector )
284{
285 FP_SHAPE::Move( aMoveVector );
286 EDA_TEXT::Offset( aMoveVector );
287}
288
289
290void FP_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
291{
292 FP_SHAPE::Rotate( aRotCentre, aAngle );
293 EDA_TEXT::SetTextAngle( ( GetTextAngle() + aAngle ).Normalized() );
294}
295
296
297void FP_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
298{
299 FP_SHAPE::Flip( aCentre, aFlipLeftRight );
300
301 // flipping the footprint is relative to the X axis
302 if( aFlipLeftRight )
303 {
304 SetTextX( MIRRORVAL( GetTextPos().x, aCentre.x ) );
306 }
307 else
308 {
309 SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
311 }
312
313 if( ( GetLayerSet() & LSET::SideSpecificMask() ).any() )
315
317}
318
319
320void FP_TEXTBOX::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
321{
322 // the position is mirrored, but not the text (or its justification)
323 FP_SHAPE::Mirror( aCentre, aMirrorAroundXAxis );
324
325 BOX2I rect( m_start0, m_end0 - m_start0 );
326 rect.Normalize();
327 m_start0 = VECTOR2I( rect.GetLeft(), rect.GetTop() );
328 m_end0 = VECTOR2I( rect.GetRight(), rect.GetBottom() );
329
330 SetDrawCoord();
331}
332
333
334void FP_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
335{
336 // Don't use GetShownText() here; we want to show the user the variable references
337 aList.emplace_back( _( "Text Box" ), UnescapeString( GetText() ) );
338
339 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
340 aList.emplace_back( _( "Status" ), _( "Locked" ) );
341
342 aList.emplace_back( _( "Layer" ), GetLayerName() );
343 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
344 aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
345
346 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
347 aList.emplace_back( _( "Thickness" ), aFrame->MessageTextFromValue( GetTextThickness() ) );
348 aList.emplace_back( _( "Text Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
349 aList.emplace_back( _( "Text Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
350
351 wxString msg = aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) );
352 aList.emplace_back( _( "Box Width" ), msg );
353
354 msg = aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) );
355 aList.emplace_back( _( "Box Height" ), msg );
356
357 m_stroke.GetMsgPanelInfo( aFrame, aList );
358}
359
360
361wxString FP_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
362{
363 return wxString::Format( _( "Footprint Text Box of %s" ),
364 static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
365}
366
367
369{
371}
372
373
375{
376 return new FP_TEXTBOX( *this );
377}
378
379
380void FP_TEXTBOX::ViewGetLayers( int aLayers[], int& aCount ) const
381{
382 if( IsVisible() )
383 aLayers[0] = GetLayer();
384 else
385 aLayers[0] = LAYER_MOD_TEXT_INVISIBLE;
386
387 aCount = 1;
388}
389
390
391double FP_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
392{
393 constexpr double HIDE = (double)std::numeric_limits<double>::max();
394
395 if( !aView )
396 return 0.0;
397
398 // Hidden text gets put on the LAYER_MOD_TEXT_INVISIBLE for rendering, but
399 // should only render if its native layer is visible.
400 if( !aView->IsLayerVisible( GetLayer() ) )
401 return HIDE;
402
403 RENDER_SETTINGS* renderSettings = aView->GetPainter()->GetSettings();
404 COLOR4D backgroundColor = renderSettings->GetLayerColor( LAYER_PCB_BACKGROUND );
405
406 // Handle Render tab switches
407 if( renderSettings->GetLayerColor( LAYER_MOD_TEXT ) == backgroundColor )
408 return HIDE;
409
410 if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) )
411 return HIDE;
412
413 if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) )
414 return HIDE;
415
416 if( !aView->IsLayerVisible( LAYER_MOD_TEXT ) )
417 return HIDE;
418
419 // Other layers are shown without any conditions
420 return 0.0;
421}
422
423
424wxString FP_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
425{
426 const FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( GetParent() );
427
428 std::function<bool( wxString* )> footprintResolver =
429 [&]( wxString* token ) -> bool
430 {
431 return parentFootprint && parentFootprint->ResolveTextVar( token, aDepth );
432 };
433
434 wxString text = EDA_TEXT::GetShownText();
435
436 if( HasTextVars() )
437 {
438 if( aDepth < 10 )
439 text = ExpandTextVars( text, &footprintResolver );
440 }
441
442 KIFONT::FONT* font = getDrawFont();
443 std::vector<VECTOR2I> corners = GetNormalizedCorners();
444 int colWidth = ( corners[1] - corners[0] ).EuclideanNorm();
445
446 colWidth -= GetTextMargin() * 2;
447 font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
448
449 return text;
450}
451
452
453std::shared_ptr<SHAPE> FP_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
454{
455 std::shared_ptr<SHAPE_COMPOUND> shape = GetEffectiveTextShape();
456
457 if( PCB_SHAPE::GetStroke().GetWidth() >= 0 )
458 shape->AddShape( PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ) );
459
460 return shape;
461}
462
463
465 int aClearance, int aError, ERROR_LOC aErrorLoc ) const
466{
468 KIFONT::FONT* font = getDrawFont();
469 int penWidth = GetEffectiveTextPenWidth();
470
471 // Note: this function is mainly used in 3D viewer.
472 // the polygonal shape of a text can have many basic shapes,
473 // so combining these shapes can be very useful to create a final shape
474 // swith a lot less vertices to speedup calculations using this final shape
475 // Simplify shapes is not usually always efficient, but in this case it is.
476 SHAPE_POLY_SET buffer;
477
478 CALLBACK_GAL callback_gal( empty_opts,
479 // Stroke callback
480 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
481 {
482 TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth + ( 2 * aClearance ), aError,
483 ERROR_INSIDE );
484 },
485 // Triangulation callback
486 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
487 {
488 buffer.NewOutline();
489
490 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
491 buffer.Append( point.x, point.y );
492 } );
493
495 attrs.m_Angle = GetDrawRotation();
496
497 font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs );
498
500 aBuffer.Append( buffer );
501}
502
503
505 int aClearance, int aError, ERROR_LOC aErrorLoc,
506 bool aIgnoreLineWidth ) const
507{
508 // Don't use FP_SHAPE::TransformShapeToPolygon. We want to treat the textbox as filled even
509 // if there's no background colour.
510
511 int width = GetWidth() + ( 2 * aClearance );
512
513 switch( m_shape )
514 {
515 case SHAPE_T::RECT:
516 {
517 std::vector<VECTOR2I> pts = GetRectCorners();
518
519 aBuffer.NewOutline();
520
521 for( const VECTOR2I& pt : pts )
522 aBuffer.Append( pt );
523
524 if( width > 0 )
525 {
526 // Add in segments
527 TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aError, aErrorLoc );
528 TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aError, aErrorLoc );
529 TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aError, aErrorLoc );
530 TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aError, aErrorLoc );
531 }
532
533 break;
534 }
535
536 case SHAPE_T::POLY:
537 {
538 if( !IsPolyShapeValid() )
539 break;
540
541 // The polygon is expected to be a simple polygon; not self intersecting, no hole.
542 EDA_ANGLE orientation = getParentOrientation();
543 VECTOR2I offset = getParentPosition();
544
545 // Build the polygon with the actual position and orientation:
546 std::vector<VECTOR2I> poly;
547 DupPolyPointsList( poly );
548
549 for( VECTOR2I& point : poly )
550 {
551 RotatePoint( point, orientation );
552 point += offset;
553 }
554
555 aBuffer.NewOutline();
556
557 for( const VECTOR2I& point : poly )
558 aBuffer.Append( point.x, point.y );
559
560 if( width > 0 )
561 {
562 VECTOR2I pt1( poly[poly.size() - 1] );
563
564 for( const VECTOR2I& pt2 : poly )
565 {
566 if( pt2 != pt1 )
567 TransformOvalToPolygon( aBuffer, pt1, pt2, width, aError, aErrorLoc );
568
569 pt1 = pt2;
570 }
571 }
572
573 break;
574 }
575
576 default:
578 break;
579 }
580}
581
582
584{
585 if( FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( m_parent ) )
586 return fp->GetReference();
587
588 return m_parent->m_Uuid.AsString();
589}
590
591
592static struct FP_TEXTBOX_DESC
593{
595 {
602
603 propMgr.AddProperty( new PROPERTY<FP_TEXTBOX, wxString>( _HKI( "Parent" ),
606
607 propMgr.Mask( TYPE_HASH( FP_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
608 propMgr.Mask( TYPE_HASH( FP_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ) );
609 propMgr.Mask( TYPE_HASH( FP_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ) );
610 propMgr.Mask( TYPE_HASH( FP_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End X" ) );
611 propMgr.Mask( TYPE_HASH( FP_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End Y" ) );
612 propMgr.Mask( TYPE_HASH( FP_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Width" ) );
613 }
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:192
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:197
virtual bool IsLocked() const
Definition: board_item.cpp:71
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:175
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:94
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
coord_type GetTop() const
Definition: box2.h:194
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
coord_type GetRight() const
Definition: box2.h:189
coord_type GetLeft() const
Definition: box2.h:193
coord_type GetBottom() const
Definition: box2.h:190
EDA_ANGLE Normalize()
Definition: eda_angle.h:249
EDA_ANGLE Normalized() const
Definition: eda_angle.h:260
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
const KIID m_Uuid
Definition: eda_item.h:492
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:496
SHAPE_T m_shape
Definition: eda_shape.h:364
void SetStartX(int x)
Definition: eda_shape.h:136
int GetStartY() const
Definition: eda_shape.h:121
void SetEndY(int y)
Definition: eda_shape.h:155
int GetEndX() const
Definition: eda_shape.h:147
void SetStartY(int y)
Definition: eda_shape.h:130
SHAPE_T GetShape() const
Definition: eda_shape.h:113
int GetEndY() const
Definition: eda_shape.h:146
void SetEndX(int x)
Definition: eda_shape.h:161
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
void DupPolyPointsList(std::vector< VECTOR2I > &aBuffer) const
Duplicate the list of corners in a std::vector<VECTOR2I>
Definition: eda_shape.cpp:1225
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1035
int GetWidth() const
Definition: eda_shape.h:109
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:75
int GetStartX() const
Definition: eda_shape.h:122
STROKE_PARAMS m_stroke
Definition: eda_shape.h:365
bool IsPolyShapeValid() const
Definition: eda_shape.cpp:1242
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
int GetTextHeight() const
Definition: eda_text.h:202
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:208
bool IsItalic() const
Definition: eda_text.h:130
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:120
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
virtual bool IsVisible() const
Definition: eda_text.h:136
void SetTextX(int aX)
Definition: eda_text.cpp:379
KIFONT::FONT * GetFont() const
Definition: eda_text.h:188
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:226
void SetTextY(int aY)
Definition: eda_text.cpp:385
int GetTextWidth() const
Definition: eda_text.h:199
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:250
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:391
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:149
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:103
virtual KIFONT::FONT * getDrawFont() const
Definition: eda_text.cpp:428
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:172
bool IsMirrored() const
Definition: eda_text.h:139
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:299
bool IsBold() const
Definition: eda_text.h:133
std::shared_ptr< SHAPE_COMPOUND > GetEffectiveTextShape(bool aTriangulate=true, bool aUseTextRotation=true) const
build a list of segments (SHAPE_SEGMENT) to describe a text shape.
Definition: eda_text.cpp:855
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:195
int GetTextThickness() const
Definition: eda_text.h:112
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:98
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:234
VECTOR2I GetTextSize() const
Definition: eda_text.h:196
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:242
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
Definition: footprint.cpp:494
bool IsParentFlipped() const
Definition: fp_shape.cpp:286
VECTOR2I m_start0
Start point or circle center, relative to footprint origin, orient 0.
Definition: fp_shape.h:143
virtual void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:80
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip entity relative to aCentre.
Definition: fp_shape.cpp:219
VECTOR2I m_end0
End point or circle edge, relative to footprint origin, orient 0.
Definition: fp_shape.h:144
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis) override
Mirror horizontally or vertically.
Definition: fp_shape.cpp:294
virtual void SetLocalCoord()
Set relative coordinates from draw coordinates.
Definition: fp_shape.cpp:52
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: fp_shape.cpp:343
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: fp_shape.cpp:355
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
Definition: fp_textbox.cpp:260
virtual wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: fp_textbox.cpp:424
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: fp_textbox.cpp:391
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: fp_textbox.cpp:453
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
Definition: fp_textbox.cpp:504
FP_TEXTBOX(FOOTPRINT *aParentFootprint)
Definition: fp_textbox.cpp:39
void SetBottom(int aVal) override
Definition: fp_textbox.cpp:103
void SetTop(int aVal) override
Definition: fp_textbox.cpp:92
wxString GetParentAsString() const
Definition: fp_textbox.cpp:583
int GetTextMargin() const
Definition: fp_textbox.cpp:56
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
Definition: fp_textbox.cpp:361
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: fp_textbox.cpp:283
VECTOR2I GetDrawPos() const override
Definition: fp_textbox.cpp:213
void SetTextAngle(const EDA_ANGLE &aAngle) override
Definition: fp_textbox.cpp:136
void SetRight(int aVal) override
Definition: fp_textbox.cpp:125
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Definition: fp_textbox.cpp:464
virtual EDA_ANGLE GetDrawRotation() const override
Definition: fp_textbox.cpp:162
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: fp_textbox.cpp:334
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis) override
Mirror the textbox's position, but not the text (or its justification).
Definition: fp_textbox.cpp:320
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip entity relative to aCentre.
Definition: fp_textbox.cpp:297
void SetLeft(int aVal) override
Definition: fp_textbox.cpp:114
std::vector< VECTOR2I > GetNormalizedCorners() const
Definition: fp_textbox.cpp:175
std::vector< VECTOR2I > GetCorners() const override
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: fp_textbox.cpp:143
void Rotate(const VECTOR2I &aOffset, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: fp_textbox.cpp:290
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: fp_textbox.cpp:380
VECTOR2I GetTopLeft() const override
Definition: fp_textbox.cpp:62
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: fp_textbox.cpp:368
VECTOR2I GetBotRight() const override
Definition: fp_textbox.cpp:77
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_textbox.cpp:374
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:105
void Draw(KIGFX::GAL *aGal, const wxString &aText, const VECTOR2I &aPosition, const VECTOR2I &aCursor, const TEXT_ATTRIBUTES &aAttrs) const
Draw a string.
Definition: font.cpp:232
void LinebreakText(wxString &aText, int aColumnWidth, const VECTOR2I &aGlyphSize, int aThickness, bool aBold, bool aItalic) const
Insert characters into text to ensure that no lines are wider than aColumnWidth.
Definition: font.cpp:509
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:102
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:410
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
wxString AsString() const
Definition: kiid.cpp:257
static LSET SideSpecificMask()
Definition: lset.cpp:908
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.h:101
EDA_ANGLE getParentOrientation() const override
Definition: pcb_shape.cpp:258
FOOTPRINT * GetParentFootprint() const
Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
Definition: pcb_shape.cpp:252
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Make a set of SHAPE objects representing the PCB_SHAPE.
Definition: pcb_shape.cpp:344
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:133
VECTOR2I getParentPosition() const override
Definition: pcb_shape.cpp:267
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:71
VECTOR2I GetPosition() const override
Definition: pcb_shape.h:65
PROPERTY_BASE & SetIsHiddenFromLibraryEditors(bool aIsHidden=true)
Definition: property.h:298
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
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:76
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Represent a set of closed polygons.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
void Simplify(POLYGON_MODE aFastMode)
int NewOutline()
Creates a new hole in a given outline.
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
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_180
Definition: eda_angle.h:433
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:431
static constexpr EDA_ANGLE & ANGLE_270
Definition: eda_angle.h:434
#define PCB_EDIT_FRAME_NAME
SHAPE_T
Definition: eda_shape.h:41
static struct FP_TEXTBOX_DESC _FP_TEXTBOX_DESC
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_INSIDE
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:147
@ LAYER_MOD_TEXT_INVISIBLE
text marked as invisible
Definition: layer_ids.h:200
@ LAYER_MOD_TEXT
Definition: layer_ids.h:198
@ LAYER_PCB_BACKGROUND
PCB background color.
Definition: layer_ids.h:220
@ LAYER_MOD_FR
show footprints on front
Definition: layer_ids.h:208
@ LAYER_MOD_BK
show footprints on back
Definition: layer_ids.h:209
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:120
T MIRRORVAL(T aPoint, T aMirrorRef)
Returns the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:31
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:418
#define TYPE_HASH(x)
Definition: property.h:63
#define NO_SETTER(owner, type)
Definition: property.h:734
#define REGISTER_TYPE(x)
Definition: property_mgr.h:328
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString UnescapeString(const wxString &aSource)
constexpr int delta
GR_TEXT_H_ALIGN_T
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_TOP
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590