KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_text.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) 2012 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <google/protobuf/any.pb.h>
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 <core/mirror.h>
32#include <footprint.h>
33#include <pcb_text.h>
34#include <pcb_painter.h>
35#include <trigo.h>
36#include <string_utils.h>
40#include <callback_gal.h>
42#include <api/api_enums.h>
43#include <api/api_utils.h>
44#include <api/board/board_types.pb.h>
45#include <properties/property.h>
47
48
50 BOARD_ITEM( parent, idtype ),
53{
54 SetMultilineAllowed( true );
55}
56
57
59 BOARD_ITEM( aParent, idtype ),
62{
63 SetKeepUpright( true );
64
65 // N.B. Do not automatically set text effects
66 // These are optional in the file format and so need to be defaulted to off.
67
69
70 if( aParent )
71 {
72 SetTextPos( aParent->GetPosition() );
73
74 if( IsBackLayer( aParent->GetLayer() ) )
76 }
77}
78
79
80PCB_TEXT::PCB_TEXT( const PCB_TEXT& aOther ) :
81 BOARD_ITEM( aOther ),
82 EDA_TEXT( aOther ),
84{
85}
86
87
89{
90 if( this == &aOther )
91 return *this;
92
93 BOARD_ITEM::operator=( aOther );
94 EDA_TEXT::operator=( aOther );
95 m_knockout_cache.reset();
97
98 return *this;
99}
100
101
105
106
107void PCB_TEXT::CopyFrom( const BOARD_ITEM* aOther )
108{
109 wxCHECK( aOther && aOther->Type() == PCB_TEXT_T, /* void */ );
110 *this = *static_cast<const PCB_TEXT*>( aOther );
111}
112
113
114void PCB_TEXT::Serialize( kiapi::board::types::BoardText& boardText ) const
115{
116 using namespace kiapi::common;
117
118 boardText.mutable_id()->set_value( m_Uuid.AsStdString() );
120 boardText.set_knockout( IsKnockout() );
121 boardText.set_locked( IsLocked() ? types::LockedState::LS_LOCKED : types::LockedState::LS_UNLOCKED );
122
123 EDA_TEXT::Serialize( *boardText.mutable_text(), pcbIUScale );
124
125 // Some of the common Text message fields are not stored in EDA_TEXT
126 types::Text* text = boardText.mutable_text();
127
128 PackVector2( *text->mutable_position(), GetPosition() );
129
130 if( FOOTPRINT* parent = GetParentFootprint() )
131 boardText.mutable_parent()->set_value( parent->m_Uuid.AsStdString() );
132 else if( const BOARD* board = GetBoard() )
133 boardText.mutable_parent()->set_value( board->m_Uuid.AsStdString() );
134
135 kiapi::common::PackCustomProperties( boardText.mutable_custom_properties(), *this );
136}
137
138
139void PCB_TEXT::Serialize( google::protobuf::Any& aContainer ) const
140{
141 kiapi::board::types::BoardText boardText;
142 Serialize( boardText );
143
144 if( !aContainer.PackFrom( boardText ) )
145 wxFAIL_MSG( wxT( "Failed to pack PCB_TEXT" ) );
146}
147
148
149bool PCB_TEXT::Deserialize( const kiapi::board::types::BoardText& boardText )
150{
151 using namespace kiapi::common;
152
154 SetUuidDirect( KIID( boardText.id().value() ) );
155 SetIsKnockout( boardText.knockout() );
156 SetLocked( boardText.locked() == types::LockedState::LS_LOCKED );
157
158 EDA_TEXT::Deserialize( boardText.text(), pcbIUScale );
159
160 const types::Text& text = boardText.text();
161
162 SetPosition( UnpackVector2( text.position() ) );
163 kiapi::common::UnpackCustomProperties( boardText.custom_properties(), *this );
164
165 return true;
166}
167
168
169bool PCB_TEXT::Deserialize( const google::protobuf::Any& aContainer )
170{
171 kiapi::board::types::BoardText boardText;
172
173 if( !aContainer.UnpackTo( &boardText ) )
174 return false;
175
176 return Deserialize( boardText );
177}
178
179
180wxString PCB_TEXT::GetShownText( RESOLUTION_CONTEXT aContext, int aDepth ) const
181{
182 const FOOTPRINT* parentFootprint = GetParentFootprint();
183 const BOARD* board = GetBoard();
184
185 std::function<bool( wxString* )> resolver =
186 [&]( wxString* token ) -> bool
187 {
188 if( token->IsSameAs( wxT( "LAYER" ) ) )
189 {
190 *token = GetLayerName();
191 return true;
192 }
193
194 if( parentFootprint && parentFootprint->ResolveTextVar( token, aDepth + 1 ) )
195 return true;
196
197 // board can be null in some cases when saving a footprint in FP editor
198 if( board && board->ResolveTextVar( token, aDepth + 1 ) )
199 return true;
200
201 return false;
202 };
203
204 wxString text = EDA_TEXT::GetShownText( aContext, aDepth );
205
206 if( HasTextVars() && aContext != RAW_VALUE )
207 {
208 text = ResolveTextVars( text, &resolver, aDepth );
209 FinalizeTextVarExpansion( text, aContext );
210 }
211
212 return text;
213}
214
215
216bool PCB_TEXT::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
217{
218 return BOARD_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
219}
220
221
223{
224 EDA_ANGLE rotation = GetTextAngle();
225
227 {
228 // Keep angle between ]-90..90] deg. Otherwise the text is not easy to read
229 while( rotation > ANGLE_90 )
230 rotation -= ANGLE_180;
231
232 while( rotation <= -ANGLE_90 )
233 rotation += ANGLE_180;
234 }
235 else
236 {
237 rotation.Normalize();
238 }
239
240 return rotation;
241}
242
243
245{
246 return GetBoundingBox();
247}
248
249
250std::vector<int> PCB_TEXT::ViewGetLayers() const
251{
254
255 return { GetLayer() };
256}
257
258
259double PCB_TEXT::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
260{
261 if( !aView )
262 return LOD_SHOW;
263
264 KIGFX::PCB_PAINTER& painter = static_cast<KIGFX::PCB_PAINTER&>( *aView->GetPainter() );
265 KIGFX::PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
266
267 if( !aView->IsLayerVisibleCached( GetLayer() ) )
268 return LOD_HIDE;
269
270 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
271 {
272 // Hide shadow on dimmed tracks
273 if( renderSettings.GetHighContrast() )
274 {
275 if( m_layer != renderSettings.GetPrimaryHighContrastLayer() )
276 return LOD_HIDE;
277 }
278 }
279
280 if( FOOTPRINT* parentFP = GetParentFootprint() )
281 {
282 // Handle Render tab switches
283 if( GetText() == wxT( "${VALUE}" ) )
284 {
286 return LOD_HIDE;
287 }
288
289 if( GetText() == wxT( "${REFERENCE}" ) )
290 {
292 return LOD_HIDE;
293 }
294
295 PCB_LAYER_ID checkLayer = GetLayer();
296
297 if( !IsFrontLayer( checkLayer ) && !IsBackLayer( checkLayer ) )
298 checkLayer = parentFP->GetLayer();
299
300 if( IsFrontLayer( checkLayer ) && !aView->IsLayerVisibleCached( LAYER_FOOTPRINTS_FR ) )
301 return LOD_HIDE;
302
303 if( IsBackLayer( checkLayer ) && !aView->IsLayerVisibleCached( LAYER_FOOTPRINTS_BK ) )
304 return LOD_HIDE;
305
306 if( !aView->IsLayerVisibleCached( LAYER_FP_TEXT ) )
307 return LOD_HIDE;
308 }
309
310 return LOD_SHOW;
311}
312
313
314void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
315{
316 FOOTPRINT* parentFP = GetParentFootprint();
317
318 if( parentFP && aFrame->GetName() == PCB_EDIT_FRAME_NAME )
319 aList.emplace_back( _( "Footprint" ), parentFP->GetReference() );
320
321 // Don't use GetShownText() here; we want to show the user the variable references
322 wxString value = GetText();
323
324 if( parentFP )
325 {
326 if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( this ) )
327 {
328 wxString variant;
329
330 if( BOARD* board = parentFP->GetBoard() )
331 variant = board->GetCurrentVariant();
332
333 value = parentFP->GetFieldValueForVariant( variant, field->GetName() );
334 }
335
336 aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, value ) );
337 }
338 else
339 {
340 aList.emplace_back( _( "PCB Text" ), KIUI::EllipsizeStatusText( aFrame, value ) );
341 }
342
343 if( parentFP )
344 aList.emplace_back( _( "Type" ), GetTextTypeDescription() );
345
346 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
347 aList.emplace_back( _( "Status" ), _( "Locked" ) );
348
349 aList.emplace_back( _( "Layer" ), GetLayerName() );
350
351 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
352
353 aList.emplace_back( _( "Angle" ), wxString::Format( wxT( "%g" ), GetTextAngle().AsDegrees() ) );
354
355 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
356
357 if( GetTextThickness() )
358 aList.emplace_back( _( "Text Thickness" ), aFrame->MessageTextFromValue( GetEffectiveTextPenWidth() ) );
359 else
360 aList.emplace_back( _( "Text Thickness" ), _( "Auto" ) );
361
362 aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
363 aList.emplace_back( _( "Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
364}
365
366
371
372
373void PCB_TEXT::StyleFromSettings( const BOARD_DESIGN_SETTINGS& aSettings, bool aCheckSide )
374{
375 SetTextSize( aSettings.GetTextSize( GetLayer() ) );
377 SetItalic( aSettings.GetTextItalic( GetLayer() ) );
378
379 if( GetParentFootprint() )
380 SetKeepUpright( aSettings.GetTextUpright( GetLayer() ) );
381
382 if( aCheckSide )
383 {
384 if( BOARD* board = GetBoard() )
385 SetMirrored( board->IsBackLayer( GetLayer() ) );
386 else
388 }
389}
390
391
393{
394 if( !IsKeepUpright() )
395 return;
396
397 EDA_ANGLE newAngle = GetTextAngle();
398 newAngle.Normalize();
399
400 bool needsFlipped = newAngle >= ANGLE_180;
401
402 if( needsFlipped )
403 {
405 SetVertJustify( static_cast<GR_TEXT_V_ALIGN_T>( -GetVertJustify() ) );
406 newAngle += ANGLE_180;
407 newAngle.Normalize();
408 SetTextAngle( newAngle );
409 }
410}
411
412
414{
415 EDA_ANGLE angle = GetDrawRotation();
416 BOX2I rect = GetTextBox( nullptr );
417
418 if( IsKnockout() )
419 rect.Inflate( getKnockoutMargin() );
420
421 if( !angle.IsZero() )
422 rect = rect.GetBoundingBoxRotated( GetTextPos(), angle );
423
424 return rect;
425}
426
427
428bool PCB_TEXT::TextHitTest( const VECTOR2I& aPoint, int aAccuracy ) const
429{
430 int accuracy = aAccuracy;
431
432 if( IsKnockout() )
434
435 return EDA_TEXT::TextHitTest( aPoint, accuracy );
436}
437
438
439bool PCB_TEXT::TextHitTest( const BOX2I& aRect, bool aContains, int aAccuracy ) const
440{
441 BOX2I rect = aRect;
442
443 rect.Inflate( aAccuracy );
444
445 if( aContains )
446 return rect.Contains( GetBoundingBox() );
447
448 return rect.Intersects( GetBoundingBox() );
449}
450
451
452bool PCB_TEXT::TextHitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
453{
454 BOX2I rect = GetTextBox( nullptr );
455
456 if( IsKnockout() )
457 rect.Inflate( getKnockoutMargin() );
458
459 return KIGEOM::BoxHitTest( aPoly, rect, GetDrawRotation(), GetDrawPos(), aContained );
460}
461
462
464{
465 if( const FOOTPRINT* fp = GetParentFootprint() )
466 return fp->GetTransform().Apply( EDA_TEXT::GetTextPos() );
467
468 return EDA_TEXT::GetTextPos();
469}
470
471
473{
475
476 if( const FOOTPRINT* fp = GetParentFootprint() )
477 {
478 const TRANSFORM_TRS& xf = fp->GetTransform();
479 return { KiROUND( libSize.x * std::abs( xf.GetScaleX() ) ), KiROUND( libSize.y * std::abs( xf.GetScaleY() ) ) };
480 }
481
482 return libSize;
483}
484
485
486void PCB_TEXT::SetTextSize( VECTOR2I aNewSize, bool aEnforceMinTextSize )
487{
488 if( const FOOTPRINT* fp = GetParentFootprint() )
489 {
490 const TRANSFORM_TRS& xf = fp->GetTransform();
491 aNewSize = { KiROUND( aNewSize.x / std::abs( xf.GetScaleX() ) ),
492 KiROUND( aNewSize.y / std::abs( xf.GetScaleY() ) ) };
493 }
494
495 EDA_TEXT::SetTextSize( aNewSize, aEnforceMinTextSize );
496}
497
498
500{
501 int libThickness = EDA_TEXT::GetTextThickness();
502
503 if( const FOOTPRINT* fp = GetParentFootprint() )
504 {
505 const TRANSFORM_TRS& xf = fp->GetTransform();
506 const double factor = ( std::abs( xf.GetScaleX() ) + std::abs( xf.GetScaleY() ) ) * 0.5;
507 return KiROUND( libThickness * factor );
508 }
509
510 return libThickness;
511}
512
513
515{
516 if( const FOOTPRINT* fp = GetParentFootprint() )
517 {
518 const TRANSFORM_TRS& xf = fp->GetTransform();
519 const double factor = ( std::abs( xf.GetScaleX() ) + std::abs( xf.GetScaleY() ) ) * 0.5;
520 aWidth = KiROUND( aWidth / factor );
521 }
522
524}
525
526
527void PCB_TEXT::Offset( const VECTOR2I& aOffset )
528{
529 if( const FOOTPRINT* fp = GetParentFootprint() )
530 {
531 VECTOR2I curBoardPos = fp->GetTransform().Apply( EDA_TEXT::GetTextPos() );
532 VECTOR2I newLibPos = fp->GetTransform().InverseApply( curBoardPos + aOffset );
533 VECTOR2I libDelta = newLibPos - EDA_TEXT::GetTextPos();
535 EDA_TEXT::Offset( libDelta );
536 }
537 else
538 {
539 EDA_TEXT::Offset( aOffset );
540 }
541}
542
543
545{
547}
548
549
551{
552 EDA_TEXT::SetTextSize( aSize );
553}
554
555
557{
559}
560
561
563{
564 if( const FOOTPRINT* fp = GetParentFootprint() )
565 {
566 EDA_ANGLE angle = m_libTextAngle.GetAngle() + fp->GetOrientation();
567 return angle.Normalize();
568 }
569
570 return m_libTextAngle.GetAngle();
571}
572
573
575{
576 if( const FOOTPRINT* fp = GetParentFootprint() )
577 m_libTextAngle = aAngle - fp->GetOrientation();
578 else
579 m_libTextAngle = aAngle;
580
581 EDA_TEXT::SetTextAngle( aAngle );
582}
583
584
585void PCB_TEXT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
586{
587 VECTOR2I pt = GetTextPos();
588 RotatePoint( pt, aRotCentre, aAngle );
589 SetTextPos( pt );
590
591 EDA_ANGLE new_angle = GetTextAngle() + aAngle;
592 new_angle.Normalize();
593 SetTextAngle( new_angle );
594}
595
596
597void PCB_TEXT::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
598{
599 Mirror( MIRROR_AXIS( aCentre, aFlipDirection ) );
600}
601
602
603void PCB_TEXT::Mirror( const SEG& aAxis )
604{
605 // the position and justification are mirrored, but not the text itself
606
607 const VECTOR2I newPos = aAxis.ReflectPoint( GetTextPos() );
608
609 if( const FOOTPRINT* fp = GetParentFootprint() )
610 SetLibTextPos( fp->GetTransform().InverseApply( newPos ) );
611 else
612 SetTextPos( newPos );
613
614 const EDA_ANGLE axisAngle = -EDA_ANGLE( aAxis.B - aAxis.A );
615 EDA_ANGLE newAngle = GetTextAngle().Reflect( axisAngle ).Normalized();
616
617 // If we're mirroring "left-right-ish", swap the justification and fix the text orientation.
618 if( newAngle > ANGLE_90 && newAngle <= ANGLE_270 )
619 {
620 newAngle -= ANGLE_180;
622 }
623
624 SetTextAngle( newAngle );
625}
626
627
628void PCB_TEXT::OnFootprintRescaled( double /* aRatioX */, double /* aRatioY */, double /* aLinearFactor */,
629 const VECTOR2I& /* aAnchor */, const EDA_ANGLE& /* aParentRotate */ )
630{
632}
633
634
641
642
643void PCB_TEXT::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
644{
645 // The position mirrors in the library or board frame depending on if this is in a FP.
646 const FOOTPRINT* fp = GetParentFootprint();
647 const VECTOR2I libCentre = fp ? fp->GetTransform().InverseApply( aCentre ) : aCentre;
648 const EDA_ANGLE axis = MIRROR_AXIS( aFlipDirection );
649
651 MIRROR( libPos, libCentre, aFlipDirection );
652 SetLibTextPos( libPos );
653
654 // A flip changes the side it is read from, so add a half turn on top of the reflection.
655 m_libTextAngle = m_libTextAngle.Reflect( axis ) + ANGLE_180;
656
658
660
661 if( IsSideSpecific() )
663}
664
665
667{
668 return _( "Text" );
669}
670
671
672wxString PCB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
673{
674 wxString content = aFull ? GetShownText( FOR_GUI ) : KIUI::EllipsizeMenuText( GetText() );
675
676 if( FOOTPRINT* parentFP = GetParentFootprint() )
677 {
678 wxString ref = parentFP->GetReference();
679 return wxString::Format( _( "Footprint text of %s (%s)" ), ref, content );
680 }
681
682 return wxString::Format( _( "PCB text '%s' on %s" ), content, GetLayerName() );
683}
684
685
687{
688 return BITMAPS::text;
689}
690
691
693{
694 return new PCB_TEXT( *this );
695}
696
697
699{
700 wxASSERT( aImage->Type() == PCB_TEXT_T );
701
702 std::swap( *( (PCB_TEXT*) this ), *( (PCB_TEXT*) aImage ) );
703}
704
705
707{
708 if( IsKnockout() )
709 {
710 SHAPE_POLY_SET poly;
711
713
714 return std::make_shared<SHAPE_POLY_SET>( std::move( poly ) );
715 }
716
717 return GetEffectiveTextShape();
718}
719
720
721const SHAPE_POLY_SET& PCB_TEXT::GetKnockoutCache( const KIFONT::FONT* aFont, const wxString& forResolvedText,
722 int aMaxError ) const
723{
725 attrs.m_Size = GetTextSize();
726 EDA_ANGLE drawAngle = GetDrawRotation();
727 VECTOR2I drawPos = GetDrawPos();
728
729 if( !m_knockout_cache )
730 m_knockout_cache = std::make_unique<PCB_TEXT_KNOCKOUT_CACHE_DATA>();
731
732 if( m_knockout_cache->cache.IsEmpty() || m_knockout_cache->text_attrs != attrs
733 || m_knockout_cache->text != forResolvedText
734 || m_knockout_cache->angle != drawAngle )
735 {
736 m_knockout_cache->cache.RemoveAllContours();
737
739 m_knockout_cache->cache.Fracture();
740
741 m_knockout_cache->text_attrs = attrs;
742 m_knockout_cache->angle = drawAngle;
743 m_knockout_cache->text = forResolvedText;
744 m_knockout_cache->pos = drawPos;
745 }
746 else if( m_knockout_cache->pos != drawPos )
747 {
748 m_knockout_cache->cache.Move( drawPos - m_knockout_cache->pos );
749 m_knockout_cache->pos = drawPos;
750 }
751
752 return m_knockout_cache->cache;
753}
754
755
756void PCB_TEXT::buildBoundingHull( SHAPE_POLY_SET* aBuffer, const SHAPE_POLY_SET& aRenderedText, int aClearance ) const
757{
758 SHAPE_POLY_SET poly( aRenderedText );
759
760 poly.Rotate( -GetDrawRotation(), GetDrawPos() );
761
762 BOX2I rect = poly.BBox( aClearance );
763 VECTOR2I corners[4];
764
765 corners[0].x = rect.GetOrigin().x;
766 corners[0].y = rect.GetOrigin().y;
767 corners[1].y = corners[0].y;
768 corners[1].x = rect.GetRight();
769 corners[2].x = corners[1].x;
770 corners[2].y = rect.GetBottom();
771 corners[3].y = corners[2].y;
772 corners[3].x = corners[0].x;
773
774 aBuffer->NewOutline();
775
776 for( VECTOR2I& corner : corners )
777 {
778 RotatePoint( corner, GetDrawPos(), GetDrawRotation() );
779 aBuffer->Append( corner.x, corner.y );
780 }
781}
782
783
784void PCB_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, int aMaxError,
785 ERROR_LOC aErrorLoc ) const
786{
788 KIFONT::FONT* font = GetDrawFont( nullptr );
789 int penWidth = GetEffectiveTextPenWidth();
791 wxString shownText = GetShownText( FOR_CANVAS );
792
793 attrs.m_Angle = GetDrawRotation();
794 attrs.m_Size = GetTextSize();
795
796 // The polygonal shape of a text can have many basic shapes, so combining these shapes can
797 // be very useful to create a final shape with a lot less vertices to speedup calculations.
798 // Simplify shapes is not usually always efficient, but in this case it is.
799 SHAPE_POLY_SET textShape;
800
801 CALLBACK_GAL callback_gal(
802 empty_opts,
803 // Stroke callback
804 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
805 {
806 TransformOvalToPolygon( textShape, aPt1, aPt2, penWidth, aMaxError, aErrorLoc );
807 },
808 // Triangulation callback
809 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
810 {
811 textShape.NewOutline();
812
813 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
814 textShape.Append( point.x, point.y );
815 } );
816
817 if( auto* cache = GetRenderCache( font, shownText ) )
818 callback_gal.DrawGlyphs( *cache );
819 else
820 font->Draw( &callback_gal, shownText, GetTextPos(), attrs, GetFontMetrics() );
821
822 textShape.Simplify();
823
824 if( IsKnockout() )
825 {
826 SHAPE_POLY_SET finalPoly;
827 int margin = GetKnockoutTextMargin( attrs.m_Size, penWidth );
828
829 buildBoundingHull( &finalPoly, textShape, margin + aClearance );
830 finalPoly.BooleanSubtract( textShape );
831
832 aBuffer.Append( finalPoly );
833 }
834 else
835 {
836 if( aClearance > 0 || aErrorLoc == ERROR_OUTSIDE )
837 {
838 if( aErrorLoc == ERROR_OUTSIDE )
839 aClearance += aMaxError;
840
841 textShape.Inflate( aClearance, CORNER_STRATEGY::ROUND_ALL_CORNERS, aMaxError );
842 }
843
844 aBuffer.Append( textShape );
845 }
846}
847
848
849double PCB_TEXT::GetCoverageArea( int aTextMargin ) const
850{
851 SHAPE_POLY_SET poly;
852 TransformTextToPolySet( poly, aTextMargin, ARC_LOW_DEF, ERROR_INSIDE );
853 return polygonArea( poly );
854}
855
856
857void PCB_TEXT::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError,
858 ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const
859{
860 SHAPE_POLY_SET poly;
861
862 TransformTextToPolySet( poly, 0, aMaxError, aErrorLoc );
863
864 buildBoundingHull( &aBuffer, poly, aClearance );
865}
866
867
868bool PCB_TEXT::operator==( const BOARD_ITEM& aBoardItem ) const
869{
870 if( aBoardItem.Type() != Type() )
871 return false;
872
873 const PCB_TEXT& other = static_cast<const PCB_TEXT&>( aBoardItem );
874
875 return *this == other;
876}
877
878
879bool PCB_TEXT::operator==( const PCB_TEXT& aOther ) const
880{
881 return EDA_TEXT::operator==( aOther );
882}
883
884
885double PCB_TEXT::Similarity( const BOARD_ITEM& aOther ) const
886{
887 if( aOther.Type() != Type() )
888 return 0.0;
889
890 const PCB_TEXT& other = static_cast<const PCB_TEXT&>( aOther );
891
892 return EDA_TEXT::Similarity( other );
893}
894
895
897{
898 wxString msg =
899#include "pcb_text_help_md.h"
900 ;
901
902 HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( aParentWindow, _( "Syntax Help" ) );
903 wxSize sz( 320, 320 );
904
905 dlg->SetMinSize( dlg->ConvertDialogToPixels( sz ) );
906 dlg->SetDialogSizeInDU( sz.x, sz.y );
907
908 wxString html_txt;
909 ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt );
910 dlg->AddHTML_Text( html_txt );
911 dlg->ShowModeless();
912
913 return dlg;
914}
915
916
917static struct PCB_TEXT_DESC
918{
920 {
927
928 propMgr.Mask( TYPE_HASH( PCB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Color" ) );
929
930 propMgr.AddProperty( new PROPERTY<PCB_TEXT, bool, BOARD_ITEM>( _HKI( "Knockout" ),
932 _HKI( "Text Properties" ) )
933 .SetIsCopyable();
934
935 propMgr.AddProperty( new PROPERTY<PCB_TEXT, bool, EDA_TEXT>( _HKI( "Keep Upright" ),
937 _HKI( "Text Properties" ) )
938 .SetIsCopyable();
939
940 auto isFootprintText =
941 []( INSPECTABLE* aItem ) -> bool
942 {
943 if( PCB_TEXT* text = dynamic_cast<PCB_TEXT*>( aItem ) )
944 return text->GetParentFootprint();
945
946 return false;
947 };
948
949 propMgr.OverrideAvailability( TYPE_HASH( PCB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Keep Upright" ),
950 isFootprintText );
951
952 propMgr.Mask( TYPE_HASH( PCB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Hyperlink" ) );
953 }
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:56
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_OUTSIDE
@ ERROR_INSIDE
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
constexpr int ARC_LOW_DEF
Definition base_units.h:143
BITMAPS
A list of all bitmap identifiers.
SEG MIRROR_AXIS(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Definition board_item.h:85
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
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:99
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:101
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
Definition board_item.h:441
PCB_LAYER_ID GetFlippedLayer(PCB_LAYER_ID aLayer) const
Return the layer paired with aLayer on the opposite side of the board.
static double polygonArea(SHAPE_POLY_SET &aPolySet)
Area of aPolySet with every contour closed first, holes subtracted.
PCB_LAYER_ID m_layer
Definition board_item.h:625
virtual bool IsKnockout() const
Definition board_item.h:437
bool IsLocked() const override
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
virtual void SetIsKnockout(bool aKnockout)
Definition board_item.h:438
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:397
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
BOARD_ITEM & operator=(const BOARD_ITEM &aOther)
Definition board_item.h:118
bool IsSideSpecific() const
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
int GetMaxError() const
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
EDA_ANGLE Normalize()
Definition eda_angle.h:228
bool IsZero() const
Definition eda_angle.h:135
EDA_ANGLE Reflect(const EDA_ANGLE &aAxisAngle) const
Reflection, over a line with direction aAxisAngle, of the turn this angle stores.
Definition eda_angle.h:331
EDA_ANGLE Normalized() const
Definition eda_angle.h:241
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:599
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:484
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition eda_text.cpp:170
virtual VECTOR2I GetTextSize() const
Definition eda_text.h:301
virtual VECTOR2I GetTextPos() const
Definition eda_text.h:313
virtual void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true)
Definition eda_text.cpp:513
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:118
bool IsKeepUpright() const
Definition eda_text.h:245
virtual void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:557
virtual int GetTextHeight() const
Definition eda_text.h:307
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition eda_text.cpp:201
KIFONT::FONT * GetFont() const
Definition eda_text.h:286
void SetMirrored(bool isMirrored)
Definition eda_text.cpp:355
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:684
virtual VECTOR2I GetDrawPos() const
Definition eda_text.h:426
EDA_TEXT & operator=(const EDA_TEXT &aItem)
Definition eda_text.cpp:140
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
virtual wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition eda_text.h:128
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:379
virtual void Offset(const VECTOR2I &aOffset)
Definition eda_text.cpp:576
virtual int GetTextWidth() const
Definition eda_text.h:304
GR_TEXT_H_ALIGN_T GetHorizJustify() const
Definition eda_text.h:239
virtual KIFONT::FONT * GetDrawFont(const RENDER_SETTINGS *aSettings) const
Definition eda_text.cpp:648
bool HasTextVars() const
Indicates the ShownText has text var references which need to be processed.
Definition eda_text.h:139
EDA_TEXT(const EDA_IU_SCALE &aIuScale, const wxString &aText=wxEmptyString)
Definition eda_text.cpp:98
virtual void ClearBoundingBoxCache()
Definition eda_text.cpp:676
double Similarity(const EDA_TEXT &aOther) const
virtual void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition eda_text.cpp:251
virtual bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition eda_text.cpp:891
virtual void ClearRenderCache()
Definition eda_text.cpp:670
const TEXT_ATTRIBUTES & GetAttributes() const
Definition eda_text.h:270
bool IsMirrored() const
Definition eda_text.h:229
int GetEffectiveTextPenWidth(int aDefaultPenWidth=0) const
The EffectiveTextPenWidth uses the text thickness if > 1 or aDefaultPenWidth.
Definition eda_text.cpp:428
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.
void SetKeepUpright(bool aKeepUpright)
Definition eda_text.cpp:387
GR_TEXT_V_ALIGN_T GetVertJustify() const
Definition eda_text.h:242
virtual int GetTextThickness() const
Definition eda_text.h:159
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:269
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:291
bool operator==(const EDA_TEXT &aRhs) const
Definition eda_text.h:444
void SetMultilineAllowed(bool aAllow)
Definition eda_text.cpp:363
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:371
const TRANSFORM_TRS & GetTransform() const
Definition footprint.h:395
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition footprint.h:393
bool ResolveTextVar(wxString *aToken, int aDepth=0) const
Resolve any references to system tokens supported by the component.
wxString GetFieldValueForVariant(const wxString &aVariantName, const wxString &aFieldName) const
Get a field value for a specific variant.
const wxString & GetReference() const
Definition footprint.h:793
VECTOR2I GetPosition() const override
Definition footprint.h:379
void SetDialogSizeInDU(int aWidth, int aHeight)
Set the dialog size, using a "logical" value.
void AddHTML_Text(const wxString &message)
Add HTML text (without any change) to message list.
void ShowModeless()
Show a modeless version of the dialog (without an OK button).
Class that other classes need to inherit from, in order to be inspectable.
Definition inspectable.h:39
FONT is an abstract base class for both outline and stroke fonts.
Definition font.h:94
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:243
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:94
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:176
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition view_item.h:181
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
bool IsLayerVisibleCached(int aLayer) const
Definition view.h:472
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
Definition view.h:242
Definition kiid.h:46
void CopyFrom(const BOARD_ITEM *aOther) override
Definition pcb_text.cpp:107
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition pcb_text.cpp:314
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
Definition pcb_text.cpp:885
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth=false) const override
Convert the item shape to a closed polygon.
Definition pcb_text.cpp:857
void SetTextThickness(int aWidth) override
The TextThickness is that set by the user.
Definition pcb_text.cpp:514
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition pcb_text.cpp:672
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &aSettings, bool aCheckSide) override
Definition pcb_text.cpp:373
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition pcb_text.cpp:244
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition pcb_text.cpp:643
EDA_ANGLE GetTextAngle() const override
Definition pcb_text.cpp:562
void swapData(BOARD_ITEM *aImage) override
Definition pcb_text.cpp:698
void KeepUpright()
Called when rotating the parent footprint.
Definition pcb_text.cpp:392
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition pcb_text.cpp:216
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
Definition pcb_text.cpp:849
void Offset(const VECTOR2I &aOffset) override
Definition pcb_text.cpp:527
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition pcb_text.cpp:139
const SHAPE_POLY_SET & GetKnockoutCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, int aMaxError) const
Definition pcb_text.cpp:721
void SetLibTextThickness(int aWidth)
Definition pcb_text.cpp:556
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_text.cpp:597
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition pcb_text.cpp:259
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true) override
Definition pcb_text.cpp:486
EDA_ORIENTATION m_libTextAngle
Definition pcb_text.h:245
void SetLibTextSize(const VECTOR2I &aSize)
Definition pcb_text.cpp:550
VECTOR2I GetTextPos() const override
Definition pcb_text.cpp:463
VECTOR2I GetPosition() const override
Definition pcb_text.h:101
PCB_TEXT(BOARD_ITEM *parent, KICAD_T idtype=PCB_TEXT_T)
Definition pcb_text.cpp:49
std::unique_ptr< PCB_TEXT_KNOCKOUT_CACHE_DATA > m_knockout_cache
Definition pcb_text.h:243
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_text.h:103
bool operator==(const PCB_TEXT &aOther) const
Definition pcb_text.cpp:879
int getKnockoutMargin() const
Definition pcb_text.cpp:367
void OnFootprintRescaled(double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I &aAnchor, const EDA_ANGLE &aParentRotate) override
Apply a parent footprint scale to this item.
Definition pcb_text.cpp:628
void TransformTextToPolySet(SHAPE_POLY_SET &aBuffer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc) const
Convert the text to a polygonSet describing the actual character strokes (one per segment).
Definition pcb_text.cpp:784
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition pcb_text.cpp:413
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition pcb_text.cpp:706
virtual wxString GetTextTypeDescription() const
Definition pcb_text.cpp:666
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition pcb_text.cpp:250
void buildBoundingHull(SHAPE_POLY_SET *aBuffer, const SHAPE_POLY_SET &aRenderedText, int aClearance) const
Build a nominally rectangular bounding box for the rendered text.
Definition pcb_text.cpp:756
bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const override
Test if aPoint is within the bounds of this object.
Definition pcb_text.cpp:428
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pcb_text.cpp:692
int GetTextThickness() const override
Definition pcb_text.cpp:499
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
Definition pcb_text.cpp:635
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
Display a syntax help window for text variables and expressions.
Definition pcb_text.cpp:896
EDA_ANGLE GetDrawRotation() const override
Definition pcb_text.cpp:222
void SetTextAngle(const EDA_ANGLE &aAngle) override
Definition pcb_text.cpp:574
wxString GetShownText(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition pcb_text.cpp:180
VECTOR2I GetTextSize() const override
Definition pcb_text.cpp:472
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition pcb_text.cpp:169
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition pcb_text.cpp:585
void SetLibTextPos(const VECTOR2I &aPos)
Definition pcb_text.cpp:544
PCB_TEXT & operator=(const PCB_TEXT &aOther)
Definition pcb_text.cpp:88
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition pcb_text.cpp:686
PROPERTY_BASE & SetIsCopyable(bool aIsCopyable=true)
Definition property.h:388
Provide class metadata.
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 OverrideAvailability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override availability functor for a base class property of a given derived class.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
Definition seg.h:38
const VECTOR2I ReflectPoint(const VECTOR2I &aP) const
Reflect a point using this segment as axis.
Definition seg.cpp:630
VECTOR2I A
Definition seg.h:45
VECTOR2I B
Definition seg.h:46
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
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.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
EDA_ORIENTATION m_Angle
VECTOR2I InverseApply(const VECTOR2I &aPoint) const
double GetScaleX() const
double GetScaleY() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
void FinalizeTextVarExpansion(wxString &aText, RESOLUTION_CONTEXT aContext)
Definition common.cpp:88
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:333
RESOLUTION_CONTEXT
Definition common.h:91
@ FOR_GUI
Definition common.h:93
@ FOR_CANVAS
Definition common.h:92
@ RAW_VALUE
Definition common.h:98
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_0
Definition eda_angle.h:472
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:474
static constexpr EDA_ANGLE ANGLE_270
Definition eda_angle.h:477
static constexpr EDA_ANGLE ANGLE_180
Definition eda_angle.h:476
#define PCB_EDIT_FRAME_NAME
a few functions useful in geometry calculations.
int GetKnockoutTextMargin(const VECTOR2I &aSize, int aThickness)
Return the margin for knocking out text.
Definition gr_text.h:88
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition layer_ids.h:847
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition layer_ids.h:870
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition layer_ids.h:303
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
Definition layer_ids.h:255
@ LAYER_FP_REFERENCES
Show footprints references (when texts are visible).
Definition layer_ids.h:262
@ LAYER_FP_TEXT
Definition layer_ids.h:236
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
Definition layer_ids.h:256
@ LAYER_FP_VALUES
Show footprints values (when texts are visible).
Definition layer_ids.h:259
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ F_SilkS
Definition layer_ids.h:96
@ B_SilkS
Definition layer_ids.h:97
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition mirror.h:44
FLIP_DIRECTION
Definition mirror.h:26
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
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 void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:461
#define _HKI(x)
Definition page_info.cpp:40
static struct PCB_TEXT_DESC _PCB_TEXT_DESC
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
wxString UnescapeString(const wxString &aSource)
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
const int accuracy
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
GR_TEXT_V_ALIGN_T
This is API surface mapped to common.types.VertialAlignment.
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:227
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition typeinfo.h:84
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)