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 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
37FP_TEXTBOX::FP_TEXTBOX( FOOTPRINT* aParentFootprint ) :
38 FP_SHAPE( aParentFootprint, SHAPE_T::RECT, PCB_FP_TEXTBOX_T ),
40{
43 SetMultilineAllowed( true );
44
46}
47
48
50{
51}
52
53
55{
56 return KiROUND( GetTextSize().y * 0.8 );
57}
58
59
61{
62 EDA_ANGLE rotation = GetDrawRotation();
63
64 if( rotation == ANGLE_90 )
65 return VECTOR2I( GetStartX(), GetEndY() );
66 else if( rotation == ANGLE_180 )
67 return GetEnd();
68 else if( rotation == ANGLE_270 )
69 return VECTOR2I( GetEndX(), GetStartY() );
70 else
71 return GetStart();
72}
73
74
76{
77 EDA_ANGLE rotation = GetDrawRotation();
78
79 if( rotation == ANGLE_90 )
80 return VECTOR2I( GetEndX(), GetStartY() );
81 else if( rotation == ANGLE_180 )
82 return GetStart();
83 else if( rotation == ANGLE_270 )
84 return VECTOR2I( GetStartX(), GetEndY() );
85 else
86 return GetEnd();
87}
88
89
90void FP_TEXTBOX::SetTop( int aVal )
91{
92 EDA_ANGLE rotation = GetDrawRotation();
93
94 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
95 SetEndY( aVal );
96 else
97 SetStartY( aVal );
98}
99
100
101void FP_TEXTBOX::SetBottom( int aVal )
102{
103 EDA_ANGLE rotation = GetDrawRotation();
104
105 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
106 SetStartY( aVal );
107 else
108 SetEndY( aVal );
109}
110
111
112void FP_TEXTBOX::SetLeft( int aVal )
113{
114 EDA_ANGLE rotation = GetDrawRotation();
115
116 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
117 SetEndX( aVal );
118 else
119 SetStartX( aVal );
120}
121
122
123void FP_TEXTBOX::SetRight( int aVal )
124{
125 EDA_ANGLE rotation = GetDrawRotation();
126
127 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
128 SetStartX( aVal );
129 else
130 SetEndX( aVal );
131}
132
133
135{
136 FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
137 EDA_ANGLE rotation = GetTextAngle();
138
139 if( parentFootprint )
140 rotation += parentFootprint->GetOrientation();
141
142 rotation.Normalize();
143
144 return rotation;
145}
146
147
148std::vector<VECTOR2I> FP_TEXTBOX::GetAnchorAndOppositeCorner() const
149{
150 std::vector<VECTOR2I> pts;
151 std::vector<VECTOR2I> corners = GetCorners();
152 EDA_ANGLE textAngle( GetDrawRotation() );
153
154 textAngle.Normalize();
155
156 pts.emplace_back( corners[0] );
157
158 if( textAngle < ANGLE_90 )
159 {
160 if( corners[1].y <= corners[0].y )
161 pts.emplace_back( corners[1] );
162 else
163 pts.emplace_back( corners[3] );
164 }
165 else if( textAngle < ANGLE_180 )
166 {
167 if( corners[1].x <= corners[0].x )
168 pts.emplace_back( corners[1] );
169 else
170 pts.emplace_back( corners[3] );
171 }
172 else if( textAngle < ANGLE_270 )
173 {
174 if( corners[1].y >= corners[0].y )
175 pts.emplace_back( corners[1] );
176 else
177 pts.emplace_back( corners[3] );
178 }
179 else
180 {
181 if( corners[1].x >= corners[0].x )
182 pts.emplace_back( corners[1] );
183 else
184 pts.emplace_back( corners[3] );
185 }
186
187 return pts;
188}
189
190
192{
193 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
194 GR_TEXT_H_ALIGN_T effectiveAlignment = GetHorizJustify();
195 VECTOR2I textAnchor;
196 VECTOR2I offset;
197
198 if( IsMirrored() )
199 {
200 switch( GetHorizJustify() )
201 {
202 case GR_TEXT_H_ALIGN_LEFT: effectiveAlignment = GR_TEXT_H_ALIGN_RIGHT; break;
203 case GR_TEXT_H_ALIGN_CENTER: effectiveAlignment = GR_TEXT_H_ALIGN_CENTER; break;
204 case GR_TEXT_H_ALIGN_RIGHT: effectiveAlignment = GR_TEXT_H_ALIGN_LEFT; break;
205 }
206 }
207
208 switch( effectiveAlignment )
209 {
211 textAnchor = corners[0];
212 offset = VECTOR2I( GetTextMargin(), GetTextMargin() );
213 break;
215 textAnchor = ( corners[0] + corners[1] ) / 2;
216 offset = VECTOR2I( 0, GetTextMargin() );
217 break;
219 textAnchor = corners[1];
220 offset = VECTOR2I( -GetTextMargin(), GetTextMargin() );
221 break;
222 }
223
224 RotatePoint( offset, GetDrawRotation() );
225 return textAnchor + offset;
226}
227
228
229bool FP_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
230{
231 BOX2I rect = GetBoundingBox();
232
233 rect.Inflate( aAccuracy );
234
235 return rect.Contains( aPosition );
236}
237
238
239bool FP_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
240{
241 BOX2I rect = aRect;
242
243 rect.Inflate( aAccuracy );
244
245 if( aContained )
246 return rect.Contains( GetBoundingBox() );
247
248 return rect.Intersects( GetBoundingBox() );
249}
250
251
252void FP_TEXTBOX::Move( const VECTOR2I& aMoveVector )
253{
254 FP_SHAPE::Move( aMoveVector );
255 EDA_TEXT::Offset( aMoveVector );
256}
257
258
259void FP_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
260{
261 FP_SHAPE::Rotate( aRotCentre, aAngle );
262 SetTextAngle( GetTextAngle() + aAngle );
263}
264
265
266void FP_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
267{
268 // flipping the footprint is relative to the X axis
269 if( aFlipLeftRight )
270 {
271 SetTextX( MIRRORVAL( GetTextPos().x, aCentre.x ) );
273 }
274 else
275 {
276 SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
278 }
279
280 SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
281
282 if( ( GetLayerSet() & LSET::SideSpecificMask() ).any() )
284
286}
287
288
289void FP_TEXTBOX::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
290{
291 // the position is mirrored, but not the text (or its justification)
292 FP_SHAPE::Mirror( aCentre, aMirrorAroundXAxis );
293
294 BOX2I rect( m_start0, m_end0 - m_start0 );
295 rect.Normalize();
296 m_start0 = VECTOR2I( rect.GetLeft(), rect.GetTop() );
297 m_end0 = VECTOR2I( rect.GetRight(), rect.GetBottom() );
298
299 SetDrawCoord();
300}
301
302
303void FP_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
304{
305 // Don't use GetShownText() here; we want to show the user the variable references
306 aList.emplace_back( _( "Text Box" ), UnescapeString( GetText() ) );
307
308 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
309 aList.emplace_back( _( "Status" ), _( "Locked" ) );
310
311 aList.emplace_back( _( "Layer" ), GetLayerName() );
312 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
313 aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
314
315 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
316 aList.emplace_back( _( "Thickness" ), aFrame->MessageTextFromValue( GetTextThickness() ) );
317 aList.emplace_back( _( "Text Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
318 aList.emplace_back( _( "Text Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
319
320 wxString msg = aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) );
321 aList.emplace_back( _( "Box Width" ), msg );
322
323 msg = aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) );
324 aList.emplace_back( _( "Box Height" ), msg );
325
326 m_stroke.GetMsgPanelInfo( aFrame, aList );
327}
328
329
330wxString FP_TEXTBOX::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
331{
332 return wxString::Format( _( "Footprint Text Box of %s" ),
333 static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
334}
335
336
338{
340}
341
342
344{
345 return new FP_TEXTBOX( *this );
346}
347
348
349void FP_TEXTBOX::ViewGetLayers( int aLayers[], int& aCount ) const
350{
351 if( IsVisible() )
352 aLayers[0] = GetLayer();
353 else
354 aLayers[0] = LAYER_MOD_TEXT_INVISIBLE;
355
356 aCount = 1;
357}
358
359
360double FP_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
361{
362 constexpr double HIDE = (double)std::numeric_limits<double>::max();
363
364 if( !aView )
365 return 0.0;
366
367 // Hidden text gets put on the LAYER_MOD_TEXT_INVISIBLE for rendering, but
368 // should only render if its native layer is visible.
369 if( !aView->IsLayerVisible( GetLayer() ) )
370 return HIDE;
371
372 RENDER_SETTINGS* renderSettings = aView->GetPainter()->GetSettings();
373 COLOR4D backgroundColor = renderSettings->GetLayerColor( LAYER_PCB_BACKGROUND );
374
375 // Handle Render tab switches
376 if( renderSettings->GetLayerColor( LAYER_MOD_TEXT ) == backgroundColor )
377 return HIDE;
378
379 if( !IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) )
380 return HIDE;
381
382 if( IsParentFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) )
383 return HIDE;
384
385 if( !aView->IsLayerVisible( LAYER_MOD_TEXT ) )
386 return HIDE;
387
388 // Other layers are shown without any conditions
389 return 0.0;
390}
391
392
393wxString FP_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
394{
395 const FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( GetParent() );
396 wxASSERT( parentFootprint );
397 const BOARD* board = parentFootprint->GetBoard();
398
399 std::function<bool( wxString* )> footprintResolver =
400 [&]( wxString* token ) -> bool
401 {
402 return parentFootprint && parentFootprint->ResolveTextVar( token, aDepth );
403 };
404
405 std::function<bool( wxString* )> boardTextResolver =
406 [&]( wxString* token ) -> bool
407 {
408 return board->ResolveTextVar( token, aDepth + 1 );
409 };
410
411 wxString text = EDA_TEXT::GetShownText();
412
413 if( HasTextVars() )
414 {
415 PROJECT* project = nullptr;
416
417 if( parentFootprint && parentFootprint->GetParent() )
418 project = static_cast<BOARD*>( parentFootprint->GetParent() )->GetProject();
419
420 if( aDepth < 10 )
421 text = ExpandTextVars( text, &footprintResolver, &boardTextResolver, project );
422 }
423
424 KIFONT::FONT* font = getDrawFont();
425 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
426 int colWidth = ( corners[1] - corners[0] ).EuclideanNorm();
427
428 colWidth -= GetTextMargin() * 2;
429 font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
430
431 return text;
432}
433
434
435std::shared_ptr<SHAPE> FP_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
436{
437 std::shared_ptr<SHAPE_COMPOUND> shape = GetEffectiveTextShape();
438
439 if( PCB_SHAPE::GetStroke().GetWidth() >= 0 )
440 shape->AddShape( PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ) );
441
442 return shape;
443}
444
445
447 int aClearance, int aError, ERROR_LOC aErrorLoc ) const
448{
450 KIFONT::FONT* font = getDrawFont();
451 int penWidth = GetEffectiveTextPenWidth();
452
453 // Note: this function is mainly used in 3D viewer.
454 // the polygonal shape of a text can have many basic shapes,
455 // so combining these shapes can be very useful to create a final shape
456 // swith a lot less vertices to speedup calculations using this final shape
457 // Simplify shapes is not usually always efficient, but in this case it is.
458 SHAPE_POLY_SET buffer;
459
460 CALLBACK_GAL callback_gal( empty_opts,
461 // Stroke callback
462 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
463 {
464 TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth + ( 2 * aClearance ), aError,
465 ERROR_INSIDE );
466 },
467 // Triangulation callback
468 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
469 {
470 buffer.NewOutline();
471
472 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
473 buffer.Append( point.x, point.y );
474 } );
475
477 attrs.m_Angle = GetDrawRotation();
478
479 font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs );
480
482 aBuffer.Append( buffer );
483}
484
485
487 int aClearance, int aError, ERROR_LOC aErrorLoc,
488 bool aIgnoreLineWidth ) const
489{
490 // Don't use FP_SHAPE::TransformShapeToPolygon. We want to treat the textbox as filled even
491 // if there's no background colour.
492
493 std::vector<VECTOR2I> pts = GetRectCorners();
494
495 aBuffer.NewOutline();
496
497 for( const VECTOR2I& pt : pts )
498 aBuffer.Append( pt );
499
500 int width = GetWidth() + ( 2 * aClearance );
501
502 if( width > 0 )
503 {
504 // Add in segments
505 TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aError, aErrorLoc );
506 TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aError, aErrorLoc );
507 TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aError, aErrorLoc );
508 TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aError, aErrorLoc );
509 }
510}
511
512
514{
515 if( FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( m_parent ) )
516 return fp->GetReference();
517
518 return m_parent->m_Uuid.AsString();
519}
520
521
522static struct FP_TEXTBOX_DESC
523{
525 {
532
533 propMgr.AddProperty( new PROPERTY<FP_TEXTBOX, wxString>( _HKI( "Parent" ),
535 }
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:180
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:214
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:43
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
Definition: board_item.h:185
virtual bool IsLocked() const
Definition: board_item.cpp:71
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:94
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:310
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
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:494
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:498
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
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
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:1023
int GetWidth() const
Definition: eda_shape.h:109
int GetStartX() const
Definition: eda_shape.h:122
STROKE_PARAMS m_stroke
Definition: eda_shape.h:365
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:195
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:201
bool IsItalic() const
Definition: eda_text.h:123
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:129
void SetTextX(int aX)
Definition: eda_text.cpp:377
KIFONT::FONT * GetFont() const
Definition: eda_text.h:181
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:224
void SetTextY(int aY)
Definition: eda_text.cpp:383
int GetTextWidth() const
Definition: eda_text.h:192
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:248
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:389
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:142
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:426
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:165
bool IsMirrored() const
Definition: eda_text.h:132
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:297
bool IsBold() const
Definition: eda_text.h:126
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:853
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:193
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:232
VECTOR2I GetTextSize() const
Definition: eda_text.h:189
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
Definition: footprint.cpp:490
EDA_ANGLE GetOrientation() const
Definition: footprint.h:191
bool IsParentFlipped() const
Definition: fp_shape.cpp:285
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
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:292
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:229
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:393
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: fp_textbox.cpp:360
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:435
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:486
FP_TEXTBOX(FOOTPRINT *aParentFootprint)
Definition: fp_textbox.cpp:37
void SetBottom(int aVal) override
Definition: fp_textbox.cpp:101
void SetTop(int aVal) override
Definition: fp_textbox.cpp:90
wxString GetParentAsString() const
Definition: fp_textbox.cpp:513
int GetTextMargin() const
Definition: fp_textbox.cpp:54
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: fp_textbox.cpp:252
VECTOR2I GetDrawPos() const override
Definition: fp_textbox.cpp:191
void SetRight(int aVal) override
Definition: fp_textbox.cpp:123
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Definition: fp_textbox.cpp:446
virtual EDA_ANGLE GetDrawRotation() const override
Definition: fp_textbox.cpp:134
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:303
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis) override
Mirror the textbox's position, but not the text (or its justification).
Definition: fp_textbox.cpp:289
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip entity relative to aCentre.
Definition: fp_textbox.cpp:266
std::vector< VECTOR2I > GetAnchorAndOppositeCorner() const
Definition: fp_textbox.cpp:148
void SetLeft(int aVal) override
Definition: fp_textbox.cpp:112
void Rotate(const VECTOR2I &aOffset, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: fp_textbox.cpp:259
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: fp_textbox.cpp:330
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:349
VECTOR2I GetTopLeft() const override
Definition: fp_textbox.cpp:60
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: fp_textbox.cpp:337
VECTOR2I GetBotRight() const override
Definition: fp_textbox.cpp:75
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_textbox.cpp:343
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:159
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:423
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
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:251
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
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
std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:133
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:71
Container for project specific data.
Definition: project.h:63
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:67
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:69
void 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:57
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:416
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
static constexpr EDA_ANGLE & ANGLE_270
Definition: eda_angle.h:417
#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
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:544
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:401
#define TYPE_HASH(x)
Definition: property.h:61
#define NO_SETTER(owner, type)
Definition: property.h:657
#define REGISTER_TYPE(x)
Definition: property_mgr.h:292
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)
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:618