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