KiCad PCB EDA Suite
pcb_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 <base_units.h>
26#include <bitmaps.h>
27#include <board.h>
29#include <footprint.h>
30#include <pcb_textbox.h>
31#include <pcb_painter.h>
32#include <trigo.h>
33#include <string_utils.h>
35#include <callback_gal.h>
37#include <macros.h>
38#include <ignore.h>
39
40
44{
47 SetMultilineAllowed( true );
48}
49
50
52{
53}
54
55
57{
58 return KiROUND( GetTextSize().y * 0.8 );
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 PCB_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
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 PCB_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 PCB_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
136std::vector<VECTOR2I> PCB_TEXTBOX::GetAnchorAndOppositeCorner() const
137{
138 std::vector<VECTOR2I> pts;
139 std::vector<VECTOR2I> corners = GetCorners();
140 EDA_ANGLE textAngle( GetDrawRotation() );
141
142 textAngle.Normalize();
143
144 pts.emplace_back( corners[0] );
145
146 if( textAngle < ANGLE_90 )
147 {
148 if( corners[1].y <= corners[0].y )
149 pts.emplace_back( corners[1] );
150 else
151 pts.emplace_back( corners[3] );
152 }
153 else if( textAngle < ANGLE_180 )
154 {
155 if( corners[1].x <= corners[0].x )
156 pts.emplace_back( corners[1] );
157 else
158 pts.emplace_back( corners[3] );
159 }
160 else if( textAngle < ANGLE_270 )
161 {
162 if( corners[1].y >= corners[0].y )
163 pts.emplace_back( corners[1] );
164 else
165 pts.emplace_back( corners[3] );
166 }
167 else
168 {
169 if( corners[1].x >= corners[0].x )
170 pts.emplace_back( corners[1] );
171 else
172 pts.emplace_back( corners[3] );
173 }
174
175 return pts;
176}
177
178
180{
181 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
182 GR_TEXT_H_ALIGN_T effectiveAlignment = GetHorizJustify();
183 VECTOR2I textAnchor;
184 VECTOR2I offset;
185
186 if( IsMirrored() )
187 {
188 switch( GetHorizJustify() )
189 {
190 case GR_TEXT_H_ALIGN_LEFT: effectiveAlignment = GR_TEXT_H_ALIGN_RIGHT; break;
191 case GR_TEXT_H_ALIGN_CENTER: effectiveAlignment = GR_TEXT_H_ALIGN_CENTER; break;
192 case GR_TEXT_H_ALIGN_RIGHT: effectiveAlignment = GR_TEXT_H_ALIGN_LEFT; break;
193 }
194 }
195
196 switch( effectiveAlignment )
197 {
199 textAnchor = corners[0];
200 offset = VECTOR2I( GetTextMargin(), GetTextMargin() );
201 break;
203 textAnchor = ( corners[0] + corners[1] ) / 2;
204 offset = VECTOR2I( 0, GetTextMargin() );
205 break;
207 textAnchor = corners[1];
208 offset = VECTOR2I( -GetTextMargin(), GetTextMargin() );
209 break;
210 }
211
212 RotatePoint( offset, GetDrawRotation() );
213 return textAnchor + offset;
214}
215
216
217double PCB_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
218{
219 constexpr double HIDE = std::numeric_limits<double>::max();
220
221 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() );
222 KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
223
224 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
225 {
226 // Hide shadow if the main layer is not shown
227 if( !aView->IsLayerVisible( m_layer ) )
228 return HIDE;
229
230 // Hide shadow on dimmed tracks
231 if( renderSettings->GetHighContrast() )
232 {
233 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
234 return HIDE;
235 }
236 }
237
238 return 0.0;
239}
240
241
242wxString PCB_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
243{
244 BOARD* board = dynamic_cast<BOARD*>( GetParent() );
245
246 std::function<bool( wxString* )> pcbTextResolver =
247 [&]( wxString* token ) -> bool
248 {
249 if( token->IsSameAs( wxT( "LAYER" ) ) )
250 {
251 *token = GetLayerName();
252 return true;
253 }
254
255 if( token->Contains( ':' ) )
256 {
257 wxString remainder;
258 wxString ref = token->BeforeFirst( ':', &remainder );
259 BOARD_ITEM* refItem = board->GetItem( KIID( ref ) );
260
261 if( refItem && refItem->Type() == PCB_FOOTPRINT_T )
262 {
263 FOOTPRINT* refFP = static_cast<FOOTPRINT*>( refItem );
264
265 if( refFP->ResolveTextVar( &remainder, aDepth + 1 ) )
266 {
267 *token = remainder;
268 return true;
269 }
270 }
271 }
272 return false;
273 };
274
275 std::function<bool( wxString* )> boardTextResolver =
276 [&]( wxString* token ) -> bool
277 {
278 return board->ResolveTextVar( token, aDepth + 1 );
279 };
280
281 wxString text = EDA_TEXT::GetShownText();
282
283 if( board && HasTextVars() && aDepth < 10 )
284 text = ExpandTextVars( text, &pcbTextResolver, &boardTextResolver, board->GetProject() );
285
286 KIFONT::FONT* font = getDrawFont();
287 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
288 int colWidth = ( corners[1] - corners[0] ).EuclideanNorm();
289
290 colWidth -= GetTextMargin() * 2;
291 font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
292
293 return text;
294}
295
296
297void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
298{
299 // Don't use GetShownText() here; we want to show the user the variable references
300 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
301
302 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
303 aList.emplace_back( _( "Status" ), _( "Locked" ) );
304
305 aList.emplace_back( _( "Layer" ), GetLayerName() );
306 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
307 aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
308
309 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
310 aList.emplace_back( _( "Text Thickness" ), aFrame->MessageTextFromValue( GetTextThickness() ) );
311 aList.emplace_back( _( "Text Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
312 aList.emplace_back( _( "Text Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
313
314 aList.emplace_back( _( "Box Width" ),
315 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
316
317 aList.emplace_back( _( "Box Height" ),
318 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ));
319
320 m_stroke.GetMsgPanelInfo( aFrame, aList );
321}
322
323
324void PCB_TEXTBOX::Move( const VECTOR2I& aMoveVector )
325{
326 PCB_SHAPE::Move( aMoveVector );
327 EDA_TEXT::Offset( aMoveVector );
328}
329
330
331void PCB_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
332{
333 PCB_SHAPE::Rotate( aRotCentre, aAngle );
334 SetTextAngle( GetTextAngle() + aAngle );
335
336 if( GetTextAngle().IsCardinal() && GetShape() != SHAPE_T::RECT )
337 {
338 std::vector<VECTOR2I> corners = GetCorners();
339 VECTOR2I diag = corners[2] - corners[0];
341
343 SetStart( corners[0] );
344
345 angle.Normalize();
346
347 if( angle == ANGLE_90 )
348 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y - abs( diag.y ) ) );
349 else if( angle == ANGLE_180 )
350 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y - abs( diag.y ) ) );
351 else if( angle == ANGLE_270 )
352 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y + abs( diag.y ) ) );
353 else
354 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y + abs( diag.y ) ) );
355 }
356}
357
358
359void PCB_TEXTBOX::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
360{
361 // the position is mirrored, but not the text (or its justification)
362 PCB_SHAPE::Mirror( aCentre, aMirrorAroundXAxis );
363
364 BOX2I rect( m_start, m_end - m_start );
365 rect.Normalize();
366 m_start = VECTOR2I( rect.GetLeft(), rect.GetTop() );
367 m_end = VECTOR2I( rect.GetRight(), rect.GetBottom() );
368}
369
370
371void PCB_TEXTBOX::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
372{
373 if( aFlipLeftRight )
374 {
375 m_start.x = aCentre.x - ( m_start.x - aCentre.x );
376 m_end.x = aCentre.x - ( m_end.x - aCentre.x );
378 }
379 else
380 {
381 m_start.y = aCentre.y - ( m_start.y - aCentre.y );
382 m_end.y = aCentre.y - ( m_end.y - aCentre.y );
384 }
385
386 SetLayer( FlipLayer( GetLayer(), GetBoard()->GetCopperLayerCount() ) );
387
388 if( ( GetLayerSet() & LSET::SideSpecificMask() ).any() )
390}
391
392
393bool PCB_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
394{
395 BOX2I rect = GetBoundingBox();
396
397 rect.Inflate( aAccuracy );
398
399 return rect.Contains( aPosition );
400}
401
402
403bool PCB_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
404{
405 BOX2I rect = aRect;
406
407 rect.Inflate( aAccuracy );
408
409 if( aContained )
410 return rect.Contains( GetBoundingBox() );
411
412 return rect.Intersects( GetBoundingBox() );
413}
414
415
416wxString PCB_TEXTBOX::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
417{
418 return wxString::Format( _( "PCB Text Box on %s"), GetLayerName() );
419}
420
421
423{
425}
426
427
429{
430 return new PCB_TEXTBOX( *this );
431}
432
433
435{
436 assert( aImage->Type() == PCB_TEXTBOX_T );
437
438 std::swap( *((PCB_TEXTBOX*) this), *((PCB_TEXTBOX*) aImage) );
439}
440
441
442std::shared_ptr<SHAPE> PCB_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
443{
444 std::shared_ptr<SHAPE_COMPOUND> shape = GetEffectiveTextShape();
445
446 if( PCB_SHAPE::GetStroke().GetWidth() >= 0 )
447 shape->AddShape( PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ) );
448
449 return shape;
450}
451
452
454 int aClearance, int aError, ERROR_LOC aErrorLoc ) const
455{
457 KIFONT::FONT* font = getDrawFont();
458 int penWidth = GetEffectiveTextPenWidth();
459
460 // Note: this function is mainly used in 3D viewer.
461 // the polygonal shape of a text can have many basic shapes,
462 // so combining these shapes can be very useful to create a final shape
463 // swith a lot less vertices to speedup calculations using this final shape
464 // Simplify shapes is not usually always efficient, but in this case it is.
465 SHAPE_POLY_SET buffer;
466
467 CALLBACK_GAL callback_gal( empty_opts,
468 // Stroke callback
469 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
470 {
471 TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth + ( 2 * aClearance ), aError,
472 ERROR_INSIDE );
473 },
474 // Triangulation callback
475 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
476 {
477 buffer.NewOutline();
478
479 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
480 buffer.Append( point.x, point.y );
481 } );
482
483 font->Draw( &callback_gal, GetShownText(), GetDrawPos(), GetAttributes() );
484
486 aBuffer.Append( buffer );
487}
488
489
491 int aClearance, int aError, ERROR_LOC aErrorLoc,
492 bool aIgnoreLineWidth ) const
493{
494 // Don't use PCB_SHAPE::TransformShapeToPolygon. We want to treat the textbox as filled even
495 // if there's no background colour.
496
497 std::vector<VECTOR2I> pts = GetRectCorners();
498
499 aBuffer.NewOutline();
500
501 for( const VECTOR2I& pt : pts )
502 aBuffer.Append( pt );
503
504 int width = GetWidth() + ( 2 * aClearance );
505
506 if( width > 0 )
507 {
508 // Add in segments
509 TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aError, aErrorLoc );
510 TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aError, aErrorLoc );
511 TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aError, aErrorLoc );
512 TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aError, aErrorLoc );
513 }
514}
515
516
517static struct PCB_TEXTBOX_DESC
518{
520 {
527
528 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
529 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ) );
530 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ) );
531 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End X" ) );
532 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End Y" ) );
533 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Width" ) );
534 }
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:180
PCB_LAYER_ID m_layer
Definition: board_item.h:329
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
BOARD_ITEM * GetItem(const KIID &aID) const
Definition: board.cpp:958
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:310
PROJECT * GetProject() const
Definition: board.h:440
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
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
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
VECTOR2I m_start
Definition: eda_shape.h:369
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:124
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:112
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1023
int GetWidth() const
Definition: eda_shape.h:109
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:149
int GetStartX() const
Definition: eda_shape.h:122
VECTOR2I m_end
Definition: eda_shape.h:370
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
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
KIFONT::FONT * GetFont() const
Definition: eda_text.h:181
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:224
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:310
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
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
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:157
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:162
PCB specific render settings.
Definition: pcb_painter.h:72
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: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
Definition: kiid.h:48
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
virtual void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:191
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
virtual void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:163
virtual void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis)
Definition: pcb_shape.cpp:205
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
virtual void swapData(BOARD_ITEM *aImage) override
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
int GetTextMargin() const
Definition: pcb_textbox.cpp:56
std::vector< VECTOR2I > GetAnchorAndOppositeCorner() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc) const
Function TransformTextToPolySet Convert the text to a polygonSet describing the actual character stro...
virtual 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.
VECTOR2I GetDrawPos() const override
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.
void SetLeft(int aVal) override
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
void SetRight(int aVal) override
void SetTop(int aVal) override
Definition: pcb_textbox.cpp:92
PCB_TEXTBOX(BOARD_ITEM *parent)
Definition: pcb_textbox.cpp:41
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the shape to a closed polygon.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
void SetBottom(int aVal) override
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis) override
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
VECTOR2I GetTopLeft() const override
Definition: pcb_textbox.cpp:62
VECTOR2I GetBotRight() const override
Definition: pcb_textbox.cpp:77
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.
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:69
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
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_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:239
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
This file contains miscellaneous commonly used macros and functions.
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:185
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
static struct PCB_TEXTBOX_DESC _PCB_TEXTBOX_DESC
#define TYPE_HASH(x)
Definition: property.h:61
#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
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_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
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