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 (C) 2022-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <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 <callback_gal.h>
38#include <macros.h>
39#include <core/ignore.h>
40#include <api/api_enums.h>
41#include <api/api_utils.h>
42#include <api/board/board_types.pb.h>
43
44
46 PCB_SHAPE( aParent, aType, SHAPE_T::RECTANGLE ),
48 m_borderEnabled( true )
49{
52 SetMultilineAllowed( true );
53
54 int defaultMargin = GetLegacyTextMargin();
55 m_marginLeft = defaultMargin;
56 m_marginTop = defaultMargin;
57 m_marginRight = defaultMargin;
58 m_marginBottom = defaultMargin;
59}
60
61
63{
64}
65
66
67void PCB_TEXTBOX::Serialize( google::protobuf::Any &aContainer ) const
68{
69 using namespace kiapi::common::types;
70 using namespace kiapi::board;
71 types::BoardTextBox boardText;
72 boardText.set_layer( ToProtoEnum<PCB_LAYER_ID, types::BoardLayer>( GetLayer() ) );
73 boardText.mutable_id()->set_value( m_Uuid.AsStdString() );
74 boardText.set_locked( IsLocked() ? LockedState::LS_LOCKED : LockedState::LS_UNLOCKED );
75
76 TextBox& text = *boardText.mutable_textbox();
77
78 kiapi::common::PackVector2( *text.mutable_top_left(), GetPosition() );
79 kiapi::common::PackVector2( *text.mutable_bottom_right(), GetEnd() );
80 text.set_text( GetText().ToStdString() );
81 //text.set_hyperlink( GetHyperlink().ToStdString() );
82
83 TextAttributes* attrs = text.mutable_attributes();
84
85 if( GetFont() )
86 attrs->set_font_name( GetFont()->GetName().ToStdString() );
87
88 attrs->set_horizontal_alignment(
89 ToProtoEnum<GR_TEXT_H_ALIGN_T, HorizontalAlignment>( GetHorizJustify() ) );
90
91 attrs->set_vertical_alignment(
92 ToProtoEnum<GR_TEXT_V_ALIGN_T, VerticalAlignment>( GetVertJustify() ) );
93
94 attrs->mutable_angle()->set_value_degrees( GetTextAngleDegrees() );
95 attrs->set_line_spacing( GetLineSpacing() );
96 attrs->mutable_stroke_width()->set_value_nm( GetTextThickness() );
97 attrs->set_italic( IsItalic() );
98 attrs->set_bold( IsBold() );
99 attrs->set_underlined( GetAttributes().m_Underlined );
100 attrs->set_visible( IsVisible() );
101 attrs->set_mirrored( IsMirrored() );
102 attrs->set_multiline( IsMultilineAllowed() );
103 attrs->set_keep_upright( IsKeepUpright() );
104 kiapi::common::PackVector2( *attrs->mutable_size(), GetTextSize() );
105
106 aContainer.PackFrom( boardText );
107}
108
109
110bool PCB_TEXTBOX::Deserialize( const google::protobuf::Any &aContainer )
111{
112 using namespace kiapi::board;
113 types::BoardTextBox boardText;
114
115 if( !aContainer.UnpackTo( &boardText ) )
116 return false;
117
118 const_cast<KIID&>( m_Uuid ) = KIID( boardText.id().value() );
119 SetLayer( FromProtoEnum<PCB_LAYER_ID, types::BoardLayer>( boardText.layer() ) );
120 SetLocked( boardText.locked() == kiapi::common::types::LockedState::LS_LOCKED );
121
122 const kiapi::common::types::TextBox& text = boardText.textbox();
123
125 SetEnd( kiapi::common::UnpackVector2( text.bottom_right() ) );
126 SetText( wxString( text.text().c_str(), wxConvUTF8 ) );
127 //SetHyperlink( wxString::FromUTF8( text.hyperlink() );
128
129 if( text.has_attributes() )
130 {
132
133 attrs.m_Bold = text.attributes().bold();
134 attrs.m_Italic = text.attributes().italic();
135 attrs.m_Underlined = text.attributes().underlined();
136 attrs.m_Visible = text.attributes().visible();
137 attrs.m_Mirrored = text.attributes().mirrored();
138 attrs.m_Multiline = text.attributes().multiline();
139 attrs.m_KeepUpright = text.attributes().keep_upright();
140 attrs.m_Size = kiapi::common::UnpackVector2( text.attributes().size() );
141
142 if( !text.attributes().font_name().empty() )
143 {
145 wxString( text.attributes().font_name().c_str(), wxConvUTF8 ), attrs.m_Bold,
146 attrs.m_Italic );
147 }
148
149 attrs.m_Angle = EDA_ANGLE( text.attributes().angle().value_degrees(), DEGREES_T );
150 attrs.m_LineSpacing = text.attributes().line_spacing();
151 attrs.m_StrokeWidth = text.attributes().stroke_width().value_nm();
152 attrs.m_Halign =
153 FromProtoEnum<GR_TEXT_H_ALIGN_T, kiapi::common::types::HorizontalAlignment>(
154 text.attributes().horizontal_alignment() );
155
156 attrs.m_Valign = FromProtoEnum<GR_TEXT_V_ALIGN_T, kiapi::common::types::VerticalAlignment>(
157 text.attributes().vertical_alignment() );
158
159 SetAttributes( attrs );
160 }
161
162 return true;
163}
164
165
167{
169
170 SetTextSize( settings.GetTextSize( GetLayer() ) );
172 SetItalic( settings.GetTextItalic( GetLayer() ) );
173 SetKeepUpright( settings.GetTextUpright( GetLayer() ) );
175}
176
177
179{
180 return KiROUND( GetStroke().GetWidth() / 2.0 ) + KiROUND( GetTextSize().y * 0.75 );
181}
182
183
185{
186 EDA_ANGLE rotation = GetDrawRotation();
187
188 if( rotation == ANGLE_90 )
189 return VECTOR2I( GetStartX(), GetEndY() );
190 else if( rotation == ANGLE_180 )
191 return GetEnd();
192 else if( rotation == ANGLE_270 )
193 return VECTOR2I( GetEndX(), GetStartY() );
194 else
195 return GetStart();
196}
197
198
200{
201 EDA_ANGLE rotation = GetDrawRotation();
202
203 if( rotation == ANGLE_90 )
204 return VECTOR2I( GetEndX(), GetStartY() );
205 else if( rotation == ANGLE_180 )
206 return GetStart();
207 else if( rotation == ANGLE_270 )
208 return VECTOR2I( GetStartX(), GetEndY() );
209 else
210 return GetEnd();
211}
212
213
214void PCB_TEXTBOX::SetTop( int aVal )
215{
216 EDA_ANGLE rotation = GetDrawRotation();
217
218 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
219 SetEndY( aVal );
220 else
221 SetStartY( aVal );
222}
223
224
226{
227 EDA_ANGLE rotation = GetDrawRotation();
228
229 if( rotation == ANGLE_90 || rotation == ANGLE_180 )
230 SetStartY( aVal );
231 else
232 SetEndY( aVal );
233}
234
235
236void PCB_TEXTBOX::SetLeft( int aVal )
237{
238 EDA_ANGLE rotation = GetDrawRotation();
239
240 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
241 SetEndX( aVal );
242 else
243 SetStartX( aVal );
244}
245
246
247void PCB_TEXTBOX::SetRight( int aVal )
248{
249 EDA_ANGLE rotation = GetDrawRotation();
250
251 if( rotation == ANGLE_180 || rotation == ANGLE_270 )
252 SetStartX( aVal );
253 else
254 SetEndX( aVal );
255}
256
257
259{
260 EDA_ANGLE delta = aAngle.Normalized() - GetTextAngle();
262}
263
264
265std::vector<VECTOR2I> PCB_TEXTBOX::GetAnchorAndOppositeCorner() const
266{
267 std::vector<VECTOR2I> pts;
268 EDA_ANGLE textAngle( GetDrawRotation() );
269
270 textAngle.Normalize();
271
272 if( textAngle.IsCardinal() )
273 {
275 bbox.Normalize();
276
277 if( textAngle == ANGLE_0 )
278 {
279 pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetTop() ) );
280 pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetTop() ) );
281 }
282 else if( textAngle == ANGLE_90 )
283 {
284 pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetBottom() ) );
285 pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetTop() ) );
286 }
287 else if( textAngle == ANGLE_180 )
288 {
289 pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetBottom() ) );
290 pts.emplace_back( VECTOR2I( bbox.GetLeft(), bbox.GetBottom() ) );
291 }
292 else if( textAngle == ANGLE_270 )
293 {
294 pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetTop() ) );
295 pts.emplace_back( VECTOR2I( bbox.GetRight(), bbox.GetBottom() ) );
296 }
297 }
298 else
299 {
300 std::vector<VECTOR2I> corners = GetCorners();
301
302 VECTOR2I minX = corners[0];
303 VECTOR2I maxX = corners[0];
304 VECTOR2I minY = corners[0];
305 VECTOR2I maxY = corners[0];
306
307 for( const VECTOR2I& corner : corners )
308 {
309 if( corner.x < minX.x )
310 minX = corner;
311
312 if( corner.x > maxX.x )
313 maxX = corner;
314
315 if( corner.y < minY.y )
316 minY = corner;
317
318 if( corner.y > maxY.y )
319 maxY = corner;
320 }
321
322 if( textAngle < ANGLE_90 )
323 {
324 pts.emplace_back( minX );
325 pts.emplace_back( minY );
326 }
327 else if( textAngle < ANGLE_180 )
328 {
329 pts.emplace_back( maxY );
330 pts.emplace_back( minX );
331 }
332 else if( textAngle < ANGLE_270 )
333 {
334 pts.emplace_back( maxX );
335 pts.emplace_back( maxY );
336 }
337 else
338 {
339 pts.emplace_back( minY );
340 pts.emplace_back( maxX );
341 }
342 }
343
344 return pts;
345}
346
347
349{
350 return GetDrawPos( false );
351}
352
353
354VECTOR2I PCB_TEXTBOX::GetDrawPos( bool aIsFlipped ) const
355{
356 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
357 GR_TEXT_H_ALIGN_T effectiveAlignment = GetHorizJustify();
358 VECTOR2I textAnchor;
359 VECTOR2I offset;
360
361 if( IsMirrored() != aIsFlipped )
362 {
363 switch( GetHorizJustify() )
364 {
365 case GR_TEXT_H_ALIGN_LEFT: effectiveAlignment = GR_TEXT_H_ALIGN_RIGHT; break;
366 case GR_TEXT_H_ALIGN_CENTER: effectiveAlignment = GR_TEXT_H_ALIGN_CENTER; break;
367 case GR_TEXT_H_ALIGN_RIGHT: effectiveAlignment = GR_TEXT_H_ALIGN_LEFT; break;
368 case GR_TEXT_H_ALIGN_INDETERMINATE: wxFAIL_MSG( wxT( "Legal only in dialogs" ) ); break;
369 }
370 }
371
372 switch( effectiveAlignment )
373 {
375 textAnchor = corners[0];
376 offset = VECTOR2I( GetMarginLeft(), GetMarginTop() );
377 break;
379 textAnchor = ( corners[0] + corners[1] ) / 2;
380 offset = VECTOR2I( 0, GetMarginTop() );
381 break;
383 textAnchor = corners[1];
384 offset = VECTOR2I( -GetMarginRight(), GetMarginTop() );
385 break;
387 wxFAIL_MSG( wxT( "Indeterminate state legal only in dialogs." ) );
388 break;
389 }
390
391 RotatePoint( offset, GetDrawRotation() );
392 return textAnchor + offset;
393}
394
395
396double PCB_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
397{
398 constexpr double HIDE = std::numeric_limits<double>::max();
399
400 KIGFX::PCB_PAINTER* painter = static_cast<KIGFX::PCB_PAINTER*>( aView->GetPainter() );
401 KIGFX::PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
402
403 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
404 {
405 // Hide shadow if the main layer is not shown
406 if( !aView->IsLayerVisible( m_layer ) )
407 return HIDE;
408
409 // Hide shadow on dimmed tracks
410 if( renderSettings->GetHighContrast() )
411 {
412 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
413 return HIDE;
414 }
415 }
416
417 return 0.0;
418}
419
420
421std::vector<int> PCB_TEXTBOX::ViewGetLayers() const
422{
423 if( IsLocked() )
425
426 return { GetLayer() };
427}
428
429
430wxString PCB_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const
431{
432 const FOOTPRINT* parentFootprint = GetParentFootprint();
433 const BOARD* board = GetBoard();
434
435 std::function<bool( wxString* )> resolver = [&]( wxString* token ) -> bool
436 {
437 if( parentFootprint && parentFootprint->ResolveTextVar( token, aDepth + 1 ) )
438 return true;
439
440 if( token->IsSameAs( wxT( "LAYER" ) ) )
441 {
442 *token = GetLayerName();
443 return true;
444 }
445
446 if( board->ResolveTextVar( token, aDepth + 1 ) )
447 return true;
448
449 return false;
450 };
451
452 wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
453
454 if( HasTextVars() )
455 {
456 if( aDepth < ADVANCED_CFG::GetCfg().m_ResolveTextRecursionDepth )
458 }
459
460 KIFONT::FONT* font = getDrawFont();
461 std::vector<VECTOR2I> corners = GetAnchorAndOppositeCorner();
462 int colWidth = ( corners[1] - corners[0] ).EuclideanNorm();
463
464 if( GetTextAngle().IsHorizontal() )
465 colWidth -= ( GetMarginLeft() + GetMarginRight() );
466 else
467 colWidth -= ( GetMarginTop() + GetMarginBottom() );
468
469 font->LinebreakText( text, colWidth, GetTextSize(), GetTextThickness(), IsBold(), IsItalic() );
470
471 return text;
472}
473
474
475bool PCB_TEXTBOX::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
476{
477 return BOARD_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
478}
479
480
481void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
482{
483 // Don't use GetShownText() here; we want to show the user the variable references
484 aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
485
486 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
487 aList.emplace_back( _( "Status" ), _( "Locked" ) );
488
489 aList.emplace_back( _( "Layer" ), GetLayerName() );
490 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
491 aList.emplace_back( _( "Angle" ), wxString::Format( "%g", GetTextAngle().AsDegrees() ) );
492
493 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
494 aList.emplace_back( _( "Text Thickness" ), aFrame->MessageTextFromValue( GetTextThickness() ) );
495 aList.emplace_back( _( "Text Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
496 aList.emplace_back( _( "Text Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
497
498 aList.emplace_back( _( "Box Width" ),
499 aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) );
500
501 aList.emplace_back( _( "Box Height" ),
502 aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ));
503
504 m_stroke.GetMsgPanelInfo( aFrame, aList );
505}
506
507
508void PCB_TEXTBOX::Move( const VECTOR2I& aMoveVector )
509{
510 PCB_SHAPE::Move( aMoveVector );
511 EDA_TEXT::Offset( aMoveVector );
512}
513
514
515void PCB_TEXTBOX::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
516{
517 PCB_SHAPE::Rotate( aRotCentre, aAngle );
518 EDA_TEXT::SetTextAngle( ( GetTextAngle() + aAngle ).Normalize90() );
519
520 if( GetTextAngle().IsCardinal() && GetShape() != SHAPE_T::RECTANGLE )
521 {
522 std::vector<VECTOR2I> corners = GetCorners();
523 VECTOR2I diag = corners[2] - corners[0];
524 EDA_ANGLE angle = GetTextAngle();
525
526 SetShape( SHAPE_T::RECTANGLE );
527 SetStart( corners[0] );
528
529 angle.Normalize();
530
531 if( angle == ANGLE_90 )
532 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y - abs( diag.y ) ) );
533 else if( angle == ANGLE_180 )
534 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y - abs( diag.y ) ) );
535 else if( angle == ANGLE_270 )
536 SetEnd( VECTOR2I( corners[0].x - abs( diag.x ), corners[0].y + abs( diag.y ) ) );
537 else
538 SetEnd( VECTOR2I( corners[0].x + abs( diag.x ), corners[0].y + abs( diag.y ) ) );
539 }
540}
541
542
543void PCB_TEXTBOX::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
544{
545 // the position and angle are mirrored, but not the text (or its justification)
546 PCB_SHAPE::Mirror( aCentre, aFlipDirection );
547
548 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
550 else
552}
553
554
555void PCB_TEXTBOX::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
556{
557 PCB_SHAPE::Flip( aCentre, aFlipDirection );
558
560
561 if( IsSideSpecific() )
563}
564
565
566bool PCB_TEXTBOX::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
567{
568 BOX2I rect = GetBoundingBox();
569
570 rect.Inflate( aAccuracy );
571
572 return rect.Contains( aPosition );
573}
574
575
576bool PCB_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
577{
578 BOX2I rect = aRect;
579
580 rect.Inflate( aAccuracy );
581
582 if( aContained )
583 return rect.Contains( GetBoundingBox() );
584
585 return rect.Intersects( GetBoundingBox() );
586}
587
588
589wxString PCB_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
590{
591 return wxString::Format( _( "PCB Text Box '%s' on %s" ),
592 aFull ? GetShownText( false ) : KIUI::EllipsizeMenuText( GetText() ),
593 GetLayerName() );
594}
595
596
598{
599 return BITMAPS::add_textbox;
600}
601
602
604{
605 return new PCB_TEXTBOX( *this );
606}
607
608
610{
611 wxASSERT( aImage->Type() == PCB_TEXTBOX_T );
612
613 std::swap( *((PCB_TEXTBOX*) this), *((PCB_TEXTBOX*) aImage) );
614}
615
616
617std::shared_ptr<SHAPE> PCB_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
618{
619 std::shared_ptr<SHAPE_COMPOUND> shape = GetEffectiveTextShape();
620
621 if( PCB_SHAPE::GetStroke().GetWidth() >= 0 )
622 shape->AddShape( PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ) );
623
624 return shape;
625}
626
627
628void PCB_TEXTBOX::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, int aMaxError,
629 ERROR_LOC aErrorLoc ) const
630{
632 KIFONT::FONT* font = getDrawFont();
633 int penWidth = GetEffectiveTextPenWidth();
634
635 // Note: this function is mainly used in 3D viewer.
636 // the polygonal shape of a text can have many basic shapes,
637 // so combining these shapes can be very useful to create a final shape
638 // swith a lot less vertices to speedup calculations using this final shape
639 // Simplify shapes is not usually always efficient, but in this case it is.
640 SHAPE_POLY_SET buffer;
641
642 CALLBACK_GAL callback_gal( empty_opts,
643 // Stroke callback
644 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
645 {
646 TransformOvalToPolygon( buffer, aPt1, aPt2, penWidth, aMaxError, aErrorLoc );
647 },
648 // Triangulation callback
649 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
650 {
651 buffer.NewOutline();
652
653 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
654 buffer.Append( point.x, point.y );
655 } );
656
657 font->Draw( &callback_gal, GetShownText( true ), GetDrawPos(), GetAttributes(), GetFontMetrics() );
658
659 if( aClearance > 0 || aErrorLoc == ERROR_OUTSIDE )
660 {
661 if( aErrorLoc == ERROR_OUTSIDE )
662 aClearance += aMaxError;
663
664 buffer.Inflate( aClearance, CORNER_STRATEGY::ROUND_ALL_CORNERS, aMaxError, true );
665 }
666 else
667 {
669 }
670
671 aBuffer.Append( buffer );
672}
673
674
676 int aClearance, int aMaxError, ERROR_LOC aErrorLoc,
677 bool aIgnoreLineWidth ) const
678{
679 // Don't use PCB_SHAPE::TransformShapeToPolygon. We want to treat the textbox as filled even
680 // if there's no background colour.
681
682 int width = GetWidth() + ( 2 * aClearance );
683
684 if( GetShape() == SHAPE_T::RECTANGLE )
685 {
686 std::vector<VECTOR2I> pts = GetRectCorners();
687
688 aBuffer.NewOutline();
689
690 for( const VECTOR2I& pt : pts )
691 aBuffer.Append( pt );
692
693 if( m_borderEnabled && width > 0 )
694 {
695 // Add in segments
696 TransformOvalToPolygon( aBuffer, pts[0], pts[1], width, aMaxError, aErrorLoc );
697 TransformOvalToPolygon( aBuffer, pts[1], pts[2], width, aMaxError, aErrorLoc );
698 TransformOvalToPolygon( aBuffer, pts[2], pts[3], width, aMaxError, aErrorLoc );
699 TransformOvalToPolygon( aBuffer, pts[3], pts[0], width, aMaxError, aErrorLoc );
700 }
701 }
702 else if( GetShape() == SHAPE_T::POLY ) // Non-cardinally-rotated rect
703 {
704 aBuffer.NewOutline();
705
706 const SHAPE_LINE_CHAIN& poly = m_poly.Outline( 0 );
707
708 for( int ii = 0; ii < poly.PointCount(); ++ii )
709 aBuffer.Append( poly.GetPoint( ii ) );
710
711 if( m_borderEnabled && width > 0 )
712 {
713 for( int ii = 0; ii < poly.SegmentCount(); ++ii )
714 {
715 const SEG& seg = poly.GetSegment( ii );
716 TransformOvalToPolygon( aBuffer, seg.A, seg.B, width, aMaxError, aErrorLoc );
717 }
718 }
719 }
720}
721
722
724{
725 return m_borderEnabled;
726}
727
728
730{
731 m_borderEnabled = enabled;
732}
733
734
735void PCB_TEXTBOX::SetBorderWidth( const int aSize )
736{
737 m_stroke.SetWidth( aSize );
738}
739
740
741bool PCB_TEXTBOX::operator==( const BOARD_ITEM& aBoardItem ) const
742{
743 if( aBoardItem.Type() != Type() )
744 return false;
745
746 const PCB_TEXTBOX& other = static_cast<const PCB_TEXTBOX&>( aBoardItem );
747
748 return *this == other;
749}
750
751
752bool PCB_TEXTBOX::operator==( const PCB_TEXTBOX& aOther ) const
753{
754 return m_borderEnabled == aOther.m_borderEnabled
755 && EDA_TEXT::operator==( aOther );
756}
757
758
759double PCB_TEXTBOX::Similarity( const BOARD_ITEM& aBoardItem ) const
760{
761 if( aBoardItem.Type() != Type() )
762 return 0.0;
763
764 const PCB_TEXTBOX& other = static_cast<const PCB_TEXTBOX&>( aBoardItem );
765
766 double similarity = 1.0;
767
768 if( m_borderEnabled != other.m_borderEnabled )
769 similarity *= 0.9;
770
771 if( GetMarginLeft() != other.GetMarginLeft() )
772 similarity *= 0.9;
773
774 if( GetMarginTop() != other.GetMarginTop() )
775 similarity *= 0.9;
776
777 if( GetMarginRight() != other.GetMarginRight() )
778 similarity *= 0.9;
779
780 if( GetMarginBottom() != other.GetMarginBottom() )
781 similarity *= 0.9;
782
783 similarity *= EDA_TEXT::Similarity( other );
784
785 return similarity;
786}
787
788
789static struct PCB_TEXTBOX_DESC
790{
792 {
794
795 if( plotDashTypeEnum.Choices().GetCount() == 0 )
796 {
797 plotDashTypeEnum.Map( LINE_STYLE::DEFAULT, _HKI( "Default" ) )
798 .Map( LINE_STYLE::SOLID, _HKI( "Solid" ) )
799 .Map( LINE_STYLE::DASH, _HKI( "Dashed" ) )
800 .Map( LINE_STYLE::DOT, _HKI( "Dotted" ) )
801 .Map( LINE_STYLE::DASHDOT, _HKI( "Dash-Dot" ) )
802 .Map( LINE_STYLE::DASHDOTDOT, _HKI( "Dash-Dot-Dot" ) );
803 }
804
811
812 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Shape" ) );
813 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start X" ) );
814 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Start Y" ) );
815 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End X" ) );
816 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "End Y" ) );
817 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Width" ) );
818 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Height" ) );
819 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Width" ) );
820 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Line Style" ) );
821 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_SHAPE ), _HKI( "Filled" ) );
822 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Visible" ) );
823 propMgr.Mask( TYPE_HASH( PCB_TEXTBOX ), TYPE_HASH( EDA_TEXT ), _HKI( "Color" ) );
824
825 const wxString borderProps = _( "Border Properties" );
826
827 void ( PCB_TEXTBOX::*lineStyleSetter )( LINE_STYLE ) = &PCB_TEXTBOX::SetLineStyle;
828 LINE_STYLE ( PCB_TEXTBOX::*lineStyleGetter )() const = &PCB_TEXTBOX::GetLineStyle;
829
830 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, bool>( _HKI( "Border" ),
832 borderProps );
833
834 propMgr.AddProperty( new PROPERTY_ENUM<PCB_TEXTBOX, LINE_STYLE>( _HKI( "Border Style" ),
835 lineStyleSetter, lineStyleGetter ),
836 borderProps );
837
838 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Border Width" ),
840 PROPERTY_DISPLAY::PT_SIZE ),
841 borderProps );
842
843 const wxString marginProps = _( "Margins" );
844
845 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Left" ),
847 PROPERTY_DISPLAY::PT_SIZE ),
848 marginProps );
849 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Top" ),
851 PROPERTY_DISPLAY::PT_SIZE ),
852 marginProps );
853 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Right" ),
855 PROPERTY_DISPLAY::PT_SIZE ),
856 marginProps );
857 propMgr.AddProperty( new PROPERTY<PCB_TEXTBOX, int>( _HKI( "Margin Bottom" ),
859 PROPERTY_DISPLAY::PT_SIZE ),
860 marginProps );
861
862 }
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:108
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
virtual void SetLocked(bool aLocked)
Definition: board_item.h:328
PCB_LAYER_ID m_layer
Definition: board_item.h:436
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:47
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:298
const KIFONT::METRICS & GetFontMetrics() const
Definition: board_item.cpp:100
virtual bool IsLocked() const
Definition: board_item.cpp:75
bool IsSideSpecific() const
Definition: board_item.cpp:149
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:139
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
bool ResolveTextVar(wxString *token, int aDepth) const
Definition: board.cpp:433
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 BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:146
constexpr coord_type GetLeft() const
Definition: box2.h:228
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr coord_type GetRight() const
Definition: box2.h:217
constexpr coord_type GetTop() const
Definition: box2.h:229
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
constexpr coord_type GetBottom() const
Definition: box2.h:222
EDA_ANGLE Normalize()
Definition: eda_angle.h:221
bool IsHorizontal() const
Definition: eda_angle.h:138
bool IsCardinal() const
Definition: eda_angle.cpp:40
EDA_ANGLE Normalized() const
Definition: eda_angle.h:232
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:89
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition: eda_item.h:377
void SetStartX(int x)
Definition: eda_shape.h:153
int GetStartY() const
Definition: eda_shape.h:138
void SetEndY(int aY)
Definition: eda_shape.h:184
int GetEndX() const
Definition: eda_shape.h:176
void SetLineStyle(const LINE_STYLE aStyle)
Definition: eda_shape.cpp:2035
void SetStartY(int y)
Definition: eda_shape.h:147
SHAPE_T GetShape() const
Definition: eda_shape.h:132
int GetEndY() const
Definition: eda_shape.h:175
void SetEndX(int aX)
Definition: eda_shape.h:190
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:174
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:141
LINE_STYLE GetLineStyle() const
Definition: eda_shape.cpp:2041
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:137
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:131
std::vector< VECTOR2I > GetRectCorners() const
Definition: eda_shape.cpp:1386
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:178
int GetStartX() const
Definition: eda_shape.h:139
SHAPE_POLY_SET m_poly
Definition: eda_shape.h:442
STROKE_PARAMS m_stroke
Definition: eda_shape.h:422
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:251
bool IsItalic() const
Definition: eda_text.h:156
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:134
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition: eda_text.cpp:506
bool IsMultilineAllowed() const
Definition: eda_text.h:184
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:193
KIFONT::FONT * GetFont() const
Definition: eda_text.h:234
void SetAttributes(const EDA_TEXT &aSrc, bool aSetPosition=true)
Set the text attributes from another instance.
Definition: eda_text.cpp:424
void SetMirrored(bool isMirrored)
Definition: eda_text.cpp:384
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:362
int GetTextWidth() const
Definition: eda_text.h:248
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:408
void Offset(const VECTOR2I &aOffset)
Definition: eda_text.cpp:569
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition: eda_text.h:187
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition: eda_text.h:117
virtual KIFONT::FONT * getDrawFont() const
Definition: eda_text.cpp:614
double GetLineSpacing() const
Definition: eda_text.h:242
double Similarity(const EDA_TEXT &aOther) const
Definition: eda_text.cpp:1269
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.cpp:283
const TEXT_ATTRIBUTES & GetAttributes() const
Definition: eda_text.h:218
bool IsMirrored() const
Definition: eda_text.h:177
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition: eda_text.cpp:456
double GetTextAngleDegrees() const
Definition: eda_text.h:141
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:1110
bool IsBold() const
Definition: eda_text.h:171
void SetKeepUpright(bool aKeepUpright)
Definition: eda_text.cpp:416
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition: eda_text.h:190
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:269
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition: eda_text.cpp:291
int GetTextThickness() const
Definition: eda_text.h:126
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition: eda_text.cpp:299
bool operator==(const EDA_TEXT &aRhs) const
Definition: eda_text.h:379
void SetMultilineAllowed(bool aAllow)
Definition: eda_text.cpp:392
VECTOR2I GetTextSize() const
Definition: eda_text.h:245
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:400
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:669
static ENUM_MAP< T > & Instance()
Definition: property.h:663
wxPGChoices & Choices()
Definition: property.h:712
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
Definition: footprint.cpp:948
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:146
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:258
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:589
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:180
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:185
PCB specific render settings.
Definition: pcb_painter.h:78
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:419
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:217
Definition: kiid.h:49
std::string AsStdString() const
Definition: kiid.cpp:244
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.h:119
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:494
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:480
int GetWidth() const override
Definition: pcb_shape.cpp:301
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:726
void SetPosition(const VECTOR2I &aPos) override
Definition: pcb_shape.h:76
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_shape.cpp:486
virtual std::vector< VECTOR2I > GetCorners() const
Return 4 corners for a rectangle or rotated rectangle (stored as a poly).
Definition: pcb_shape.cpp:359
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_shape.cpp:170
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:89
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Definition: pcb_shape.cpp:311
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:387
VECTOR2I GetPosition() const override
Definition: pcb_shape.h:77
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_shape.h:69
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:90
PCB_TEXTBOX(BOARD_ITEM *aParent, KICAD_T aType=PCB_TEXTBOX_T)
Definition: pcb_textbox.cpp:45
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:171
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:178
int m_marginBottom
Definition: pcb_textbox.h:181
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:180
std::vector< VECTOR2I > GetAnchorAndOppositeCorner() const
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:83
void SetLeft(int aVal) override
int GetMarginLeft() const
Definition: pcb_textbox.h:87
void SetMarginLeft(int aLeft)
Definition: pcb_textbox.h:82
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
void SetMarginBottom(int aBottom)
Definition: pcb_textbox.h:85
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
int GetMarginRight() const
Definition: pcb_textbox.h:89
void SetRight(int aVal) override
std::vector< int > ViewGetLayers() const override
void SetTop(int aVal) override
int GetMarginTop() const
Definition: pcb_textbox.h:88
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:67
void SetMarginRight(int aRight)
Definition: pcb_textbox.h:84
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
bool IsVisible() const override
Definition: pcb_textbox.h:101
int GetBorderWidth() const
Definition: pcb_textbox.h:163
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings) override
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
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:87
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(POLYGON_MODE aFastMode)
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections) For aFastMo...
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 SetWidth(int aWidth)
Definition: stroke_params.h:90
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_0
Definition: eda_angle.h:401
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:403
@ DEGREES_T
Definition: eda_angle.h:31
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:406
static constexpr EDA_ANGLE ANGLE_180
Definition: eda_angle.h:405
#define PCB_EDIT_FRAME_NAME
SHAPE_T
Definition: eda_shape.h:43
static FILENAME_RESOLVER * resolver
Definition: export_idf.cpp:53
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:147
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:655
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:240
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:213
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:195
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput)
Definition: api_utils.cpp:84
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput)
Definition: api_utils.cpp:77
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:390
static struct PCB_TEXTBOX_DESC _PCB_TEXTBOX_DESC
#define TYPE_HASH(x)
Definition: property.h:71
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
wxString UnescapeString(const wxString &aSource)
LINE_STYLE
Dashed line types.
Definition: stroke_params.h:46
constexpr int delta
GR_TEXT_H_ALIGN_T
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_H_ALIGN_INDETERMINATE
@ 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:691