KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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 <advanced_config.h>
25#include <pcb_edit_frame.h>
26#include <base_units.h>
27#include <bitmaps.h>
28#include <board.h>
30#include <footprint.h>
31#include <pcb_textbox.h>
32#include <pcb_painter.h>
33#include <trigo.h>
34#include <string_utils.h>
36#include <geometry/shape_rect.h>
38#include <callback_gal.h>
40#include <macros.h>
41#include <core/ignore.h>
42#include <api/api_enums.h>
43#include <api/api_utils.h>
44#include <api/board/board_types.pb.h>
45
47 PCB_SHAPE( aParent, aType, SHAPE_T::RECTANGLE ),
49 m_borderEnabled( true )
50{
53 SetMultilineAllowed( true );
54
55 int defaultMargin = GetLegacyTextMargin();
56 m_marginLeft = defaultMargin;
57 m_marginTop = defaultMargin;
58 m_marginRight = defaultMargin;
59 m_marginBottom = defaultMargin;
60}
61
63{
64}
65
66
67void PCB_TEXTBOX::CopyFrom( const BOARD_ITEM* aOther )
68{
69 wxCHECK( aOther && aOther->Type() == PCB_TEXTBOX_T, /* void */ );
70 *this = *static_cast<const PCB_TEXTBOX*>( aOther );
71}
72
73
74void PCB_TEXTBOX::Serialize( google::protobuf::Any &aContainer ) const
75{
76 using namespace kiapi::common::types;
77 using namespace kiapi::board;
78 types::BoardTextBox boardText;
79 boardText.set_layer( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>( GetLayer() ) );
80 boardText.mutable_id()->set_value( m_Uuid.AsStdString() );
81 boardText.set_locked( IsLocked() ? LockedState::LS_LOCKED : LockedState::LS_UNLOCKED );
82
83 TextBox& text = *boardText.mutable_textbox();
84
85 kiapi::common::PackVector2( *text.mutable_top_left(), GetPosition() );
86 kiapi::common::PackVector2( *text.mutable_bottom_right(), GetEnd() );
87 text.set_text( GetText().ToStdString() );
88 //text.set_hyperlink( GetHyperlink().ToStdString() );
89
90 TextAttributes* attrs = text.mutable_attributes();
91
92 if( GetFont() )
93 attrs->set_font_name( GetFont()->GetName().ToStdString() );
94
95 attrs->set_horizontal_alignment(
96 ToProtoEnum<GR_TEXT_H_ALIGN_T, HorizontalAlignment>( GetHorizJustify() ) );
97
98 attrs->set_vertical_alignment(
99 ToProtoEnum<GR_TEXT_V_ALIGN_T, VerticalAlignment>( GetVertJustify() ) );
100
101 attrs->mutable_angle()->set_value_degrees( GetTextAngleDegrees() );
102 attrs->set_line_spacing( GetLineSpacing() );
103 attrs->mutable_stroke_width()->set_value_nm( GetTextThickness() );
104 attrs->set_italic( IsItalic() );
105 attrs->set_bold( IsBold() );
106 attrs->set_underlined( GetAttributes().m_Underlined );
107 attrs->set_mirrored( IsMirrored() );
108 attrs->set_multiline( IsMultilineAllowed() );
109 attrs->set_keep_upright( IsKeepUpright() );
110 kiapi::common::PackVector2( *attrs->mutable_size(), GetTextSize() );
111
112 aContainer.PackFrom( boardText );
113}
114
115
116bool PCB_TEXTBOX::Deserialize( const google::protobuf::Any &aContainer )
117{
118 using namespace kiapi::board;
119 types::BoardTextBox boardText;
120
121 if( !aContainer.UnpackTo( &boardText ) )
122 return false;
123
124 const_cast<KIID&>( m_Uuid ) = KIID( boardText.id().value() );
125 SetLayer( FromProtoEnum<PCB_LAYER_ID, types::BoardLayer>( boardText.layer() ) );
126 SetLocked( boardText.locked() == kiapi::common::types::LockedState::LS_LOCKED );
127
128 const kiapi::common::types::TextBox& text = boardText.textbox();
129
131 SetEnd( kiapi::common::UnpackVector2( text.bottom_right() ) );
132 SetText( wxString( text.text().c_str(), wxConvUTF8 ) );
133 //SetHyperlink( wxString::FromUTF8( text.hyperlink() );
134
135 if( text.has_attributes() )
136 {
138
139 attrs.m_Bold = text.attributes().bold();
140 attrs.m_Italic = text.attributes().italic();
141 attrs.m_Underlined = text.attributes().underlined();
142 attrs.m_Mirrored = text.attributes().mirrored();
143 attrs.m_Multiline = text.attributes().multiline();
144 attrs.m_KeepUpright = text.attributes().keep_upright();
145 attrs.m_Size = kiapi::common::UnpackVector2( text.attributes().size() );
146
147 if( !text.attributes().font_name().empty() )
148 {
150 wxString( text.attributes().font_name().c_str(), wxConvUTF8 ), attrs.m_Bold,
151 attrs.m_Italic );
152 }
153
154 attrs.m_Angle = EDA_ANGLE( text.attributes().angle().value_degrees(), DEGREES_T );
155 attrs.m_LineSpacing = text.attributes().line_spacing();
156 attrs.m_StrokeWidth = text.attributes().stroke_width().value_nm();
157 attrs.m_Halign =
158 FromProtoEnum<GR_TEXT_H_ALIGN_T, kiapi::common::types::HorizontalAlignment>(
159 text.attributes().horizontal_alignment() );
160
161 attrs.m_Valign = FromProtoEnum<GR_TEXT_V_ALIGN_T, kiapi::common::types::VerticalAlignment>(
162 text.attributes().vertical_alignment() );
163
164 SetAttributes( attrs );
165 }
166
167 return true;
168}
169
170
172{
174
175 SetTextSize( settings.GetTextSize( GetLayer() ) );
177 SetItalic( settings.GetTextItalic( GetLayer() ) );
178 SetKeepUpright( settings.GetTextUpright( GetLayer() ) );
179
180 if( BOARD* board = GetBoard() )
181 SetMirrored( board->IsBackLayer( GetLayer() ) );
182 else
184}
185
186
188{
189 return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
190}
191
192
194{
195 EDA_ANGLE rotation = GetDrawRotation();
196
197 if( rotation == ANGLE_90 )
198 return VECTOR2I( GetStartX(), GetEndY() );
199 else if( rotation == ANGLE_180 )
200 return GetEnd();
201 else if( rotation == ANGLE_270 )
202 return VECTOR2I( GetEndX(), GetStartY() );
203 else
204 return GetStart();
205}
206
207
209{
210 EDA_ANGLE rotation = GetDrawRotation();
211
212 if( rotation == ANGLE_90 )
213 return VECTOR2I( GetEndX(), GetStartY() );
214 else if( rotation == ANGLE_180 )
215 return GetStart();
216 else if( rotation == ANGLE_270 )
217 return VECTOR2I( GetStartX(), GetEndY() );
218 else
219 return GetEnd();
220}
221
222
223void PCB_TEXTBOX::SetTop( int aVal )
224{
225 EDA_ANGLE rotation = GetDrawRotation();
226
227 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
228 SetEndY( aVal );
229 else
230 SetStartY( aVal );
231}
232
233
235{
236 EDA_ANGLE rotation = GetDrawRotation();
237
238 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
239 SetStartY( aVal );
240 else
241 SetEndY( aVal );
242}
243
244
245void PCB_TEXTBOX::SetLeft( int aVal )
246{
247 EDA_ANGLE rotation = GetDrawRotation();
248
249 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
250 SetEndX( aVal );
251 else
252 SetStartX( aVal );
253}
254
255
256void PCB_TEXTBOX::SetRight( int aVal )
257{
258 EDA_ANGLE rotation = GetDrawRotation();
259
260 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
261 SetStartX( aVal );
262 else
263 SetEndX( aVal );
264}
265
266
268{
269 EDA_ANGLE delta = aAngle.Normalized() - GetTextAngle();
271}
272
273
275{
276 return GetDrawPos( false );
277}
278
279
280VECTOR2I PCB_TEXTBOX::GetDrawPos( bool aIsFlipped ) const
281{
282 EDA_ANGLE drawAngle = GetDrawRotation();
283 std::vector<VECTOR2I> corners = GetCornersInSequence( drawAngle );
284 GR_TEXT_H_ALIGN_T horizontalAlignment = GetHorizJustify();
285 GR_TEXT_V_ALIGN_T verticalAlignment = GetVertJustify();
286 VECTOR2I textAnchor;
287 VECTOR2I offset;
288
289 // Calculate midpoints
290 VECTOR2I midTop = ( corners[0] + corners[1] ) / 2;
291 VECTOR2I midBottom = ( corners[3] + corners[2] ) / 2;
292 VECTOR2I midLeft = ( corners[0] + corners[3] ) / 2;
293 VECTOR2I midRight = ( corners[1] + corners[2] ) / 2;
294 VECTOR2I center = ( corners[0] + corners[1] + corners[2] + corners[3] ) / 4;
295
296 if( IsMirrored() != aIsFlipped )
297 {
298 switch( GetHorizJustify() )
299 {
300 case GR_TEXT_H_ALIGN_LEFT: horizontalAlignment = GR_TEXT_H_ALIGN_RIGHT; break;
301 case GR_TEXT_H_ALIGN_CENTER: horizontalAlignment = GR_TEXT_H_ALIGN_CENTER; break;
302 case GR_TEXT_H_ALIGN_RIGHT: horizontalAlignment = GR_TEXT_H_ALIGN_LEFT; break;
304 horizontalAlignment = GR_TEXT_H_ALIGN_INDETERMINATE;
305 break;
306 }
307 }
308
309 wxASSERT_MSG(
310 horizontalAlignment != GR_TEXT_H_ALIGN_INDETERMINATE
311 && verticalAlignment != GR_TEXT_V_ALIGN_INDETERMINATE,
312 wxS( "Indeterminate state legal only in dialogs. Horizontal and vertical alignment "
313 "must be set before calling PCB_TEXTBOX::GetDrawPos." ) );
314
315 if( horizontalAlignment == GR_TEXT_H_ALIGN_INDETERMINATE
316 || verticalAlignment == GR_TEXT_V_ALIGN_INDETERMINATE )
317 {
318 return center;
319 }
320
321 if( horizontalAlignment == GR_TEXT_H_ALIGN_LEFT && verticalAlignment == GR_TEXT_V_ALIGN_TOP )
322 {
323 textAnchor = corners[0];
324 }
325 else if( horizontalAlignment == GR_TEXT_H_ALIGN_CENTER
326 && verticalAlignment == GR_TEXT_V_ALIGN_TOP )
327 {
328 textAnchor = midTop;
329 }
330 else if( horizontalAlignment == GR_TEXT_H_ALIGN_RIGHT
331 && verticalAlignment == GR_TEXT_V_ALIGN_TOP )
332 {
333 textAnchor = corners[1];
334 }
335 else if( horizontalAlignment == GR_TEXT_H_ALIGN_LEFT
336 && verticalAlignment == GR_TEXT_V_ALIGN_CENTER )
337 {
338 textAnchor = midLeft;
339 }
340 else if( horizontalAlignment == GR_TEXT_H_ALIGN_CENTER
341 && verticalAlignment == GR_TEXT_V_ALIGN_CENTER )
342 {
343 textAnchor = center;
344 }
345 else if( horizontalAlignment == GR_TEXT_H_ALIGN_RIGHT
346 && verticalAlignment == GR_TEXT_V_ALIGN_CENTER )
347 {
348 textAnchor = midRight;
349 }
350 else if( horizontalAlignment == GR_TEXT_H_ALIGN_LEFT
351 && verticalAlignment == GR_TEXT_V_ALIGN_BOTTOM )
352 {
353 textAnchor = corners[3];
354 }
355 else if( horizontalAlignment == GR_TEXT_H_ALIGN_CENTER
356 && verticalAlignment == GR_TEXT_V_ALIGN_BOTTOM )
357 {
358 textAnchor = midBottom;
359 }
360 else if( horizontalAlignment == GR_TEXT_H_ALIGN_RIGHT
361 && verticalAlignment == GR_TEXT_V_ALIGN_BOTTOM )
362 {
363 textAnchor = corners[2];
364 }
365
366 int marginLeft = GetMarginLeft();
367 int marginRight = GetMarginRight();
368 int marginTop = GetMarginTop();
369 int marginBottom = GetMarginBottom();
370
371 if( horizontalAlignment == GR_TEXT_H_ALIGN_LEFT )
372 offset.x = marginLeft;
373 else if( horizontalAlignment == GR_TEXT_H_ALIGN_RIGHT )
374 offset.x = -marginRight;
375
376 if( verticalAlignment == GR_TEXT_V_ALIGN_TOP )
377 offset.y = marginTop;
378 else if( verticalAlignment == GR_TEXT_V_ALIGN_BOTTOM )
379 offset.y = -marginBottom;
380
381 RotatePoint( offset, GetDrawRotation() );
382 return textAnchor + offset;
383}
384
385
386double PCB_TEXTBOX::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
387{
388 KIGFX::PCB_PAINTER& painter = static_cast<KIGFX::PCB_PAINTER&>( *aView->GetPainter() );
389 KIGFX::PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
390
391 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
392 {
393 // Hide shadow if the main layer is not shown
394 if( !aView->IsLayerVisible( m_layer ) )
395 return LOD_HIDE;
396
397 // Hide shadow on dimmed tracks
398 if( renderSettings.GetHighContrast() )
399 {
400 if( m_layer != renderSettings.GetPrimaryHighContrastLayer() )
401 return LOD_HIDE;
402 }
403 }
404
405 return LOD_SHOW;
406}
407
408
409std::vector<int> PCB_TEXTBOX::ViewGetLayers() const
410{
413
414 return { GetLayer() };
415}
416
417
418wxString PCB_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const
419{
420 const FOOTPRINT* parentFootprint = GetParentFootprint();
421 const BOARD* board = GetBoard();
422
423 std::function<bool( wxString* )> resolver = [&]( wxString* token ) -> bool
424 {
425 if( token->IsSameAs( wxT( "LAYER" ) ) )
426 {
427 *token = GetLayerName();
428 return true;
429 }
430
431 if( parentFootprint && parentFootprint->ResolveTextVar( token, aDepth + 1 ) )
432 return true;
433
434 if( board->ResolveTextVar( token, aDepth + 1 ) )
435 return true;
436
437 return false;
438 };
439
440 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
441
442 if( HasTextVars() )
443 {
444 if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
446 }
447
448 KIFONT::FONT* font = GetDrawFont( nullptr );
449 EDA_ANGLE drawAngle = GetDrawRotation();
450 std::vector<VECTOR2I> corners = GetCornersInSequence( drawAngle );
451 int colWidth = ( corners[1] - corners[0] ).EuclideanNorm();
452
453 if( GetTextAngle().IsHorizontal() )
454 colWidth -= ( GetMarginLeft() + GetMarginRight() );
455 else
456 colWidth -= ( GetMarginTop() + GetMarginBottom() );
457
458 font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
459
460 return text;
461}
462
463
464bool PCB_TEXTBOX::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
465{
466 return BOARD_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
467}
468
469
470void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
471{
472 // Don't use GetShownText() here; we want to show the user the variable references
473 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
474
475 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
476 aList.emplace_back( _( "Status" ), _( "Locked" ) );
477
478 aList.emplace_back( _( "Layer" ), GetLayerName() );
479 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
480 aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
481
482 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
483
484 if( GetTextThickness() )
485 aList.emplace_back( _( "Text Thickness" ), aFrame->MessageTextFromValue( GetEffectiveTextPenWidth() ) );
486 else
487 aList.emplace_back( _( "Text Thickness" ), _( "Auto" ) );
488
489 aList.emplace_back( _( "Text Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
490 aList.emplace_back( _( "Text Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
491
492 aList.emplace_back( _( "Box Width" ),
493 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
494
495 aList.emplace_back( _( "Box Height" ),
496 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ));
497
498 m_stroke.GetMsgPanelInfo( aFrame, aList );
499}
500
501
502void PCB_TEXTBOX::Move( const VECTOR2I& aMoveVector )
503{
504 PCB_SHAPE::Move( aMoveVector );
505 EDA_TEXT::Offset( aMoveVector );
506}
507
508
509void PCB_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
510{
511 PCB_SHAPE::Rotate( aRotCentre, aAngle );
513
514 if( GetTextAngle().IsCardinal() && GetShape() != SHAPE_T::RECTANGLE )
515 {
516 // To convert the polygon to its equivalent rectangle, we use GetCornersInSequence( drawAngle )
517 // but this method uses the polygon bounding box.
518 // set the line thickness to 0 to get the actual rectangle corner
519 int lineWidth = GetWidth();
520 SetWidth( 0 );
521 EDA_ANGLE drawAngle = GetDrawRotation();
522 std::vector<VECTOR2I> corners = GetCornersInSequence( drawAngle );
523 SetWidth( lineWidth );
524 VECTOR2I diag = corners[2] - corners[0];
525 EDA_ANGLE angle = GetTextAngle();
526
527 SetShape( SHAPE_T::RECTANGLE );
528 SetStart( corners[0] );
529
530 if( angle == ANGLE_90 )
531 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y - abs( diag.y ) ) );
532 else if( angle == ANGLE_180 )
533 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y - abs( diag.y ) ) );
534 else if( angle == ANGLE_270 )
535 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y + abs( diag.y ) ) );
536 else
537 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y + abs( diag.y ) ) );
538 }
539}
540
541
542void PCB_TEXTBOX::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
543{
544 // the position and angle are mirrored, but not the text (or its justification)
545 PCB_SHAPE::Mirror( aCentre, aFlipDirection );
546
547 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
549 else
551}
552
553
554void PCB_TEXTBOX::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
555{
556 PCB_SHAPE::Flip( aCentre, aFlipDirection );
557
559
560 if( IsSideSpecific() )
562}
563
564
565bool PCB_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
566{
567 BOX2I rect = GetBoundingBox();
568
569 rect.Inflate( aAccuracy );
570
571 return rect.Contains( aPosition );
572}
573
574
575bool PCB_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
576{
577 BOX2I rect = aRect;
578
579 rect.Inflate( aAccuracy );
580
581 if( aContained )
582 return rect.Contains( GetBoundingBox() );
583
584 return rect.Intersects( GetBoundingBox() );
585}
586
587
588bool PCB_TEXTBOX::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
589{
590 return PCB_SHAPE::HitTest( aPoly, aContained );
591}
592
593
594wxString PCB_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
595{
596 return wxString::Format( _( "PCB Text Box '%s' on %s" ),
597 aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ),
598 GetLayerName() );
599}
600
601
603{
604 return BITMAPS::add_textbox;
605}
606
607
609{
610 return new PCB_TEXTBOX( *this );
611}
612
613
615{
616 wxASSERT( aImage->Type() == PCB_TEXTBOX_T );
617
618 std::swap( *((PCB_TEXTBOX*) this), *((PCB_TEXTBOX*) aImage) );
619}
620
621
622std::shared_ptr<SHAPE> PCB_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
623{
624 std::shared_ptr<SHAPE_COMPOUND> shape = GetEffectiveTextShape();
625
626 if( PCB_SHAPE::GetStroke().GetWidth() >= 0 )
627 shape->AddShape( PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ) );
628
629 return shape;
630}
631
632
633void PCB_TEXTBOX::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, int aMaxError,
634 ERROR_LOC aErrorLoc ) const
635{
637 KIFONT::FONT* font = GetDrawFont( nullptr );
638 int penWidth = GetEffectiveTextPenWidth();
640 wxString shownText = GetShownText( true );
641
642 // The polygonal shape of a text can have many basic shapes, so combining these shapes can
643 // be very useful to create a final shape with a lot less vertices to speedup calculations.
644 // Simplify shapes is not usually always efficient, but in this case it is.
645 SHAPE_POLY_SET textShape;
646
647 CALLBACK_GAL callback_gal( empty_opts,
648 // Stroke callback
649 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
650 {
651 TransformOvalToPolygon( textShape, aPt1, aPt2, penWidth, aMaxError, aErrorLoc );
652 },
653 // Triangulation callback
654 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
655 {
656 textShape.NewOutline();
657
658 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
659 textShape.Append( point.x, point.y );
660 } );
661
662 if( auto* cache = GetRenderCache( font, shownText ) )
663 callback_gal.DrawGlyphs( *cache );
664 else
665 font->Draw( &callback_gal, shownText, GetDrawPos(), attrs, GetFontMetrics() );
666
667 textShape.Simplify();
668
669 if( IsKnockout() )
670 {
671 SHAPE_POLY_SET finalPoly;
672
673 TransformShapeToPolygon( finalPoly, GetLayer(), aClearance, aMaxError, aErrorLoc );
674 finalPoly.BooleanSubtract( textShape );
675
676 aBuffer.Append( finalPoly );
677 }
678 else
679 {
680 if( aClearance > 0 || aErrorLoc == ERROR_OUTSIDE )
681 {
682 if( aErrorLoc == ERROR_OUTSIDE )
683 aClearance += aMaxError;
684
685 textShape.Inflate( aClearance, CORNER_STRATEGY::ROUND_ALL_CORNERS, aMaxError, true );
686 }
687
688 aBuffer.Append( textShape );
689 }
690}
691
692
694 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
695 bool aIgnoreLineWidth ) const
696{
697 // Don't use PCB_SHAPE::TransformShapeToPolygon. We want to treat the textbox as filled even
698 // if there's no background colour.
699
700 int width = GetWidth() + ( 2 * aClearance );
701
702 if( GetShape() == SHAPE_T::RECTANGLE )
703 {
704 std::vector<VECTOR2I> pts = GetRectCorners();
705
706 aBuffer.NewOutline();
707
708 for( const VECTOR2I& pt : pts )
709 aBuffer.Append( pt );
710
711 if( m_borderEnabled && width > 0 )
712 {
713 // Add in segments
714 TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aMaxError, aErrorLoc );
715 TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aMaxError, aErrorLoc );
716 TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aMaxError, aErrorLoc );
717 TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aMaxError, aErrorLoc );
718 }
719 }
720 else if( GetShape() == SHAPE_T::POLY ) // Non-cardinally-rotated rect
721 {
722 aBuffer.NewOutline();
723
724 const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
725
726 for( int ii = 0; ii < poly.PointCount(); ++ii )
727 aBuffer.Append( poly.GetPoint( ii ) );
728
729 if( m_borderEnabled && width > 0 )
730 {
731 for( int ii = 0; ii < poly.SegmentCount(); ++ii )
732 {
733 const SEG& seg = poly.GetSegment( ii );
734 TransformOvalToPolygon( aBuffer, seg.A, seg.B, width, aMaxError, aErrorLoc );
735 }
736 }
737 }
738}
739
740
742{
743 return m_borderEnabled;
744}
745
746
748{
749 m_borderEnabled = enabled;
750}
751
752
753void PCB_TEXTBOX::SetBorderWidth( const int aSize )
754{
755 m_stroke.SetWidth( aSize );
756}
757
758
759bool PCB_TEXTBOX::operator==( const BOARD_ITEM& aBoardItem ) const
760{
761 if( aBoardItem.Type() != Type() )
762 return false;
763
764 const PCB_TEXTBOX& other = static_cast<const PCB_TEXTBOX&>( aBoardItem );
765
766 return *this == other;
767}
768
769
770bool PCB_TEXTBOX::operator==( const PCB_TEXTBOX& aOther ) const
771{
772 return m_borderEnabled == aOther.m_borderEnabled
773 && EDA_TEXT::operator==( aOther );
774}
775
776
777double PCB_TEXTBOX::Similarity( const BOARD_ITEM& aBoardItem ) const
778{
779 if( aBoardItem.Type() != Type() )
780 return 0.0;
781
782 const PCB_TEXTBOX& other = static_cast<const PCB_TEXTBOX&>( aBoardItem );
783
784 double similarity = 1.0;
785
786 if( m_borderEnabled != other.m_borderEnabled )
787 similarity *= 0.9;
788
789 if( GetMarginLeft() != other.GetMarginLeft() )
790 similarity *= 0.9;
791
792 if( GetMarginTop() != other.GetMarginTop() )
793 similarity *= 0.9;
794
795 if( GetMarginRight() != other.GetMarginRight() )
796 similarity *= 0.9;
797
798 if( GetMarginBottom() != other.GetMarginBottom() )
799 similarity *= 0.9;
800
801 similarity *= EDA_TEXT::Similarity( other );
802
803 return similarity;
804}
805
806
807static struct PCB_TEXTBOX_DESC
808{
810 {
812
813 if( lineStyleEnum.Choices().GetCount() == 0 )
814 {
815 lineStyleEnum.Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
816 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
817 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
818 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
819 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
820 }
821
828
829 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
830 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ) );
831 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ) );
832 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End X" ) );
833 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End Y" ) );
834 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Width" ) );
835 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Height" ) );
836 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Width" ) );
837 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Style" ) );
838 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Filled" ) );
839 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Color" ) );
840
841 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( PCB_SHAPE ), _HKI( "Soldermask" ) );
842 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( PCB_SHAPE ), _HKI( "Soldermask Margin Override" ) );
843
844 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, bool, BOARD_ITEM>( _HKI( "Knockout" ),
846 _HKI( "Text Properties" ) );
847
848 const wxString borderProps = _( "Border Properties" );
849
850 void ( PCB_TEXTBOX::*lineStyleSetter )( LINE_STYLE ) = &PCB_TEXTBOX::SetLineStyle;
851 LINE_STYLE ( PCB_TEXTBOX::*lineStyleGetter )() const = &PCB_TEXTBOX::GetLineStyle;
852
853 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, bool>( _HKI( "Border" ),
855 borderProps );
856
857 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TEXTBOX, LINE_STYLE>( _HKI( "Border Style" ),
858 lineStyleSetter, lineStyleGetter ),
859 borderProps );
860
861 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Border Width" ),
863 PROPERTY_DISPLAY::PT_SIZE ),
864 borderProps );
865
866 const wxString marginProps = _( "Margins" );
867
868 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Left" ),
870 PROPERTY_DISPLAY::PT_SIZE ),
871 marginProps );
872 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Top" ),
874 PROPERTY_DISPLAY::PT_SIZE ),
875 marginProps );
876 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Right" ),
878 PROPERTY_DISPLAY::PT_SIZE ),
879 marginProps );
880 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Bottom" ),
882 PROPERTY_DISPLAY::PT_SIZE ),
883 marginProps );
884
885 propMgr.Mask( TYPE_HASH( PCB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Hyperlink" ) );
886 }
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
Definition: approximation.h:32
@ ERROR_OUTSIDE
Definition: approximation.h:33
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:112
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition: box2.h:990
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
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:79
void SetLocked(bool aLocked) override
Definition: board_item.h:323
PCB_LAYER_ID m_layer
Definition: board_item.h:453
virtual bool IsKnockout() const
Definition: board_item.h:319
bool IsLocked() const override
Definition: board_item.cpp:103
virtual void SetIsKnockout(bool aKnockout)
Definition: board_item.h:320
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:79
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:97
const KIFONT::METRICS & GetFontMetrics() const
Definition: board_item.cpp:132
bool IsSideSpecific() const
Definition: board_item.cpp:190
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:180
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:317
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:500
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:558
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
bool IsHorizontal() const
Definition: eda_angle.h:142
EDA_ANGLE Normalized() const
Definition: eda_angle.h:240
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:98
const KIID m_Uuid
Definition: eda_item.h:516
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:110
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:401
void SetStartX(int x)
Definition: eda_shape.h:191
int GetStartY() const
Definition: eda_shape.h:174
void SetEndY(int aY)
Definition: eda_shape.h:226
int GetEndX() const
Definition: eda_shape.h:217
void SetLineStyle(const LINE_STYLE aStyle)
Definition: eda_shape.cpp:2382
void SetStartY(int y)
Definition: eda_shape.h:184
std::vector< VECTOR2I > GetCornersInSequence(EDA_ANGLE angle) const
Definition: eda_shape.cpp:1614
SHAPE_T GetShape() const
Definition: eda_shape.h:168
int GetEndY() const
Definition: eda_shape.h:216
void SetEndX(int aX)
Definition: eda_shape.h:233
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:215
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:177
LINE_STYLE GetLineStyle() const
Definition: eda_shape.cpp:2388
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:173
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:167
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1599
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:219
int GetStartX() const
Definition: eda_shape.h:175
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:513
STROKE_PARAMS m_stroke
Definition: eda_shape.h:490
void SetWidth(int aWidth)
Definition: eda_shape.cpp:2375
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
int GetTextHeight() const
Definition: eda_text.h:264
bool IsItalic() const
Definition: eda_text.h:166
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:144
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:533
bool IsMultilineAllowed() const
Definition: eda_text.h:194
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:97
bool IsKeepUpright() const
Definition: eda_text.h:203
KIFONT::FONT * GetFont() const
Definition: eda_text.h:244
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition: eda_text.cpp:433
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:393
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
Definition: eda_text.cpp:676
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:374
int GetTextWidth() const
Definition: eda_text.h:261
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:417
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:596
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:197
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
Definition: eda_text.cpp:641
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:116
double GetLineSpacing() const
Definition: eda_text.h:255
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1267
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:284
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:228
bool IsMirrored() const
Definition: eda_text.h:187
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:465
double GetTextAngleDegrees() const
Definition: eda_text.h:151
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:1108
bool IsBold() const
Definition: eda_text.h:181
void SetKeepUpright(bool aKeepUpright)
Definition: eda_text.cpp:425
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:200
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:108
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:270
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:299
int GetTextThickness() const
Definition: eda_text.h:125
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition: eda_text.cpp:307
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:393
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:401
VECTOR2I GetTextSize() const
Definition: eda_text.h:258
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:409
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:703
static ENUM_MAP< T > & Instance()
Definition: property.h:697
wxPGChoices & Choices()
Definition: property.h:746
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
Definition: footprint.cpp:1003
FONT is an abstract base class for both outline and stroke fonts.
Definition: font.h:131
static FONT * GetFont(const wxString &aFontName=wxEmptyString, bool aBold=false, bool aItalic=false, const std::vector< wxString > *aEmbeddedFiles=nullptr, bool aForDrawingSheet=false)
Definition: font.cpp:147
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:250
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:572
virtual void DrawGlyphs(const std::vector< std::unique_ptr< KIFONT::GLYPH > > &aGlyphs)
Draw polygons representing font glyphs.
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:182
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:187
PCB specific render settings.
Definition: pcb_painter.h:80
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
Definition: view_item.h:180
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition: view_item.h:185
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:66
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:422
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:220
Definition: kiid.h:49
std::string AsStdString() const
Definition: kiid.cpp:252
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.h:121
virtual void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
Definition: pcb_shape.cpp:578
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:564
int GetWidth() const override
Definition: pcb_shape.cpp:385
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_shape.h:123
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:775
void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_shape.h:78
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_shape.cpp:570
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_shape.cpp:176
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:91
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Definition: pcb_shape.cpp:395
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:471
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
Definition: pcb_shape.cpp:483
VECTOR2I GetPosition() const override
Definition: pcb_shape.h:79
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_shape.h:71
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
void SetBorderWidth(const int aSize)
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
int GetMarginBottom() const
Definition: pcb_textbox.h:92
PCB_TEXTBOX(BOARD_ITEM *aParent, KICAD_T aType=PCB_TEXTBOX_T)
Definition: pcb_textbox.cpp:46
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the shape to a closed polygon.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
bool m_borderEnabled
Controls drawing the border (as defined by the stroke members)
Definition: pcb_textbox.h:176
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
int m_marginLeft
Definition: pcb_textbox.h:179
int m_marginBottom
Definition: pcb_textbox.h:182
void SetBorderEnabled(bool enabled)
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
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...
int m_marginRight
Definition: pcb_textbox.h:181
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
EDA_ITEM * Clone() const override
Tests whether the border is disabled, as configured by the stroke.
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.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
VECTOR2I GetDrawPos() const override
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
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 SetMarginTop(int aTop)
Definition: pcb_textbox.h:85
void SetLeft(int aVal) override
int GetMarginLeft() const
Definition: pcb_textbox.h:89
void SetMarginLeft(int aLeft)
Definition: pcb_textbox.h:84
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
void SetMarginBottom(int aBottom)
Definition: pcb_textbox.h:87
int GetMarginRight() const
Definition: pcb_textbox.h:91
void SetRight(int aVal) override
std::vector< int > ViewGetLayers() const override
void SetTop(int aVal) override
int GetMarginTop() const
Definition: pcb_textbox.h:90
wxString GetShownText(bool aAllowExtraText, int aDepth=0) const override
Return the string actually shown after processing of the base text.
void SetTextAngle(const EDA_ANGLE &aAngle) override
bool operator==(const PCB_TEXTBOX &aOther) const
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_textbox.cpp:74
void SetMarginRight(int aRight)
Definition: pcb_textbox.h:86
void Move(const VECTOR2I &aMoveVector) override
Move this object.
int GetLegacyTextMargin() const
void SetBottom(int aVal) override
VECTOR2I GetTopLeft() const override
VECTOR2I GetBotRight() const override
void CopyFrom(const BOARD_ITEM *aOther) override
Definition: pcb_textbox.cpp:67
int GetBorderWidth() const
Definition: pcb_textbox.h:161
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
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.
Definition: seg.h:42
VECTOR2I A
Definition: seg.h:49
VECTOR2I B
Definition: seg.h:50
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual const VECTOR2I GetPoint(int aIndex) const override
int PointCount() const
Return the number of points (vertices) in this line chain.
virtual const SEG GetSegment(int aIndex) const override
int SegmentCount() const
Return the number of segments in this line chain.
Represent a set of closed polygons.
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()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
int NewOutline()
Creates a new empty polygon in the set and returns its index.
void BooleanSubtract(const SHAPE_POLY_SET &b)
Perform boolean polyset difference.
void SetWidth(int aWidth)
void GetMsgPanelInfo(UNITS_PROVIDER *aUnitsProvider, std::vector< MSG_PANEL_ITEM > &aList, bool aIncludeStyle=true, bool aIncludeWidth=true)
GR_TEXT_H_ALIGN_T m_Halign
GR_TEXT_V_ALIGN_T m_Valign
KIFONT::FONT * m_Font
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, int aFlags)
Definition: common.cpp:59
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:413
@ DEGREES_T
Definition: eda_angle.h:31
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:416
static constexpr EDA_ANGLE ANGLE_180
Definition: eda_angle.h:415
#define PCB_EDIT_FRAME_NAME
SHAPE_T
Definition: eda_shape.h:43
static FILENAME_RESOLVER * resolver
Definition: export_idf.cpp:53
a few functions useful in geometry calculations.
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:184
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:790
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition: layer_ids.h:306
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
This file contains miscellaneous commonly used macros and functions.
FLIP_DIRECTION
Definition: mirror.h:27
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:221
KICOMMON_API 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:203
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput)
Definition: api_utils.cpp:85
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput)
Definition: api_utils.cpp:78
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:400
static struct PCB_TEXTBOX_DESC _PCB_TEXTBOX_DESC
#define TYPE_HASH(x)
Definition: property.h:72
#define REGISTER_TYPE(x)
Definition: property_mgr.h:351
wxString UnescapeString(const wxString &aSource)
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
VECTOR2I center
int delta
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_INDETERMINATE
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
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:229
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:93
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695