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 aContainer.PackFrom( boardText );
144}
145
146
147bool PCB_TEXT::Deserialize( const kiapi::board::types::BoardText& boardText )
148{
149 using namespace kiapi::common;
150
152 SetUuidDirect( KIID( boardText.id().value() ) );
153 SetIsKnockout( boardText.knockout() );
154 SetLocked( boardText.locked() == types::LockedState::LS_LOCKED );
155
156 EDA_TEXT::Deserialize( boardText.text(), pcbIUScale );
157
158 const types::Text& text = boardText.text();
159
160 SetPosition( UnpackVector2( text.position() ) );
161 kiapi::common::UnpackCustomProperties( boardText.custom_properties(), *this );
162
163 return true;
164}
165
166
167bool PCB_TEXT::Deserialize( const google::protobuf::Any& aContainer )
168{
169 kiapi::board::types::BoardText boardText;
170
171 if( !aContainer.UnpackTo( &boardText ) )
172 return false;
173
174 return Deserialize( boardText );
175}
176
177
178wxString PCB_TEXT::GetShownText( RESOLUTION_CONTEXT aContext, int aDepth ) const
179{
180 const FOOTPRINT* parentFootprint = GetParentFootprint();
181 const BOARD* board = GetBoard();
182
183 std::function<bool( wxString* )> resolver =
184 [&]( wxString* token ) -> bool
185 {
186 if( token->IsSameAs( wxT( "LAYER" ) ) )
187 {
188 *token = GetLayerName();
189 return true;
190 }
191
192 if( parentFootprint && parentFootprint->ResolveTextVar( token, aDepth + 1 ) )
193 return true;
194
195 // board can be null in some cases when saving a footprint in FP editor
196 if( board && board->ResolveTextVar( token, aDepth + 1 ) )
197 return true;
198
199 return false;
200 };
201
202 wxString text = EDA_TEXT::GetShownText( aContext, aDepth );
203
204 if( HasTextVars() && aContext != RAW_VALUE )
205 {
206 text = ResolveTextVars( text, &resolver, aDepth );
207 FinalizeTextVarExpansion( text, aContext );
208 }
209
210 return text;
211}
212
213
214bool PCB_TEXT::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
215{
216 return BOARD_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
217}
218
219
221{
222 EDA_ANGLE rotation = GetTextAngle();
223
225 {
226 // Keep angle between ]-90..90] deg. Otherwise the text is not easy to read
227 while( rotation > ANGLE_90 )
228 rotation -= ANGLE_180;
229
230 while( rotation <= -ANGLE_90 )
231 rotation += ANGLE_180;
232 }
233 else
234 {
235 rotation.Normalize();
236 }
237
238 return rotation;
239}
240
241
243{
244 return GetBoundingBox();
245}
246
247
248std::vector<int> PCB_TEXT::ViewGetLayers() const
249{
252
253 return { GetLayer() };
254}
255
256
257double PCB_TEXT::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
258{
259 if( !aView )
260 return LOD_SHOW;
261
262 KIGFX::PCB_PAINTER& painter = static_cast<KIGFX::PCB_PAINTER&>( *aView->GetPainter() );
263 KIGFX::PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
264
265 if( !aView->IsLayerVisibleCached( GetLayer() ) )
266 return LOD_HIDE;
267
268 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
269 {
270 // Hide shadow on dimmed tracks
271 if( renderSettings.GetHighContrast() )
272 {
273 if( m_layer != renderSettings.GetPrimaryHighContrastLayer() )
274 return LOD_HIDE;
275 }
276 }
277
278 if( FOOTPRINT* parentFP = GetParentFootprint() )
279 {
280 // Handle Render tab switches
281 if( GetText() == wxT( "${VALUE}" ) )
282 {
284 return LOD_HIDE;
285 }
286
287 if( GetText() == wxT( "${REFERENCE}" ) )
288 {
290 return LOD_HIDE;
291 }
292
293 PCB_LAYER_ID checkLayer = GetLayer();
294
295 if( !IsFrontLayer( checkLayer ) && !IsBackLayer( checkLayer ) )
296 checkLayer = parentFP->GetLayer();
297
298 if( IsFrontLayer( checkLayer ) && !aView->IsLayerVisibleCached( LAYER_FOOTPRINTS_FR ) )
299 return LOD_HIDE;
300
301 if( IsBackLayer( checkLayer ) && !aView->IsLayerVisibleCached( LAYER_FOOTPRINTS_BK ) )
302 return LOD_HIDE;
303
304 if( !aView->IsLayerVisibleCached( LAYER_FP_TEXT ) )
305 return LOD_HIDE;
306 }
307
308 return LOD_SHOW;
309}
310
311
312void PCB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
313{
314 FOOTPRINT* parentFP = GetParentFootprint();
315
316 if( parentFP && aFrame->GetName() == PCB_EDIT_FRAME_NAME )
317 aList.emplace_back( _( "Footprint" ), parentFP->GetReference() );
318
319 // Don't use GetShownText() here; we want to show the user the variable references
320 wxString value = GetText();
321
322 if( parentFP )
323 {
324 if( PCB_FIELD* field = dynamic_cast<PCB_FIELD*>( this ) )
325 {
326 wxString variant;
327
328 if( BOARD* board = parentFP->GetBoard() )
329 variant = board->GetCurrentVariant();
330
331 value = parentFP->GetFieldValueForVariant( variant, field->GetName() );
332 }
333
334 aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, value ) );
335 }
336 else
337 {
338 aList.emplace_back( _( "PCB Text" ), KIUI::EllipsizeStatusText( aFrame, value ) );
339 }
340
341 if( parentFP )
342 aList.emplace_back( _( "Type" ), GetTextTypeDescription() );
343
344 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
345 aList.emplace_back( _( "Status" ), _( "Locked" ) );
346
347 aList.emplace_back( _( "Layer" ), GetLayerName() );
348
349 aList.emplace_back( _( "Mirror" ), IsMirrored() ? _( "Yes" ) : _( "No" ) );
350
351 aList.emplace_back( _( "Angle" ), wxString::Format( wxT( "%g" ), GetTextAngle().AsDegrees() ) );
352
353 aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
354
355 if( GetTextThickness() )
356 aList.emplace_back( _( "Text Thickness" ), aFrame->MessageTextFromValue( GetEffectiveTextPenWidth() ) );
357 else
358 aList.emplace_back( _( "Text Thickness" ), _( "Auto" ) );
359
360 aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( GetTextWidth() ) );
361 aList.emplace_back( _( "Height" ), aFrame->MessageTextFromValue( GetTextHeight() ) );
362}
363
364
369
370
371void PCB_TEXT::StyleFromSettings( const BOARD_DESIGN_SETTINGS& settings, bool aCheckSide )
372{
373 SetTextSize( settings.GetTextSize( GetLayer() ) );
375 SetItalic( settings.GetTextItalic( GetLayer() ) );
376
377 if( GetParentFootprint() )
378 SetKeepUpright( settings.GetTextUpright( GetLayer() ) );
379
380 if( aCheckSide )
381 {
382 if( BOARD* board = GetBoard() )
383 SetMirrored( board->IsBackLayer( GetLayer() ) );
384 else
386 }
387}
388
389
391{
392 if( !IsKeepUpright() )
393 return;
394
395 EDA_ANGLE newAngle = GetTextAngle();
396 newAngle.Normalize();
397
398 bool needsFlipped = newAngle >= ANGLE_180;
399
400 if( needsFlipped )
401 {
403 SetVertJustify( static_cast<GR_TEXT_V_ALIGN_T>( -GetVertJustify() ) );
404 newAngle += ANGLE_180;
405 newAngle.Normalize();
406 SetTextAngle( newAngle );
407 }
408}
409
410
412{
413 EDA_ANGLE angle = GetDrawRotation();
414 BOX2I rect = GetTextBox( nullptr );
415
416 if( IsKnockout() )
417 rect.Inflate( getKnockoutMargin() );
418
419 if( !angle.IsZero() )
420 rect = rect.GetBoundingBoxRotated( GetTextPos(), angle );
421
422 return rect;
423}
424
425
426bool PCB_TEXT::TextHitTest( const VECTOR2I& aPoint, int aAccuracy ) const
427{
428 int accuracy = aAccuracy;
429
430 if( IsKnockout() )
432
433 return EDA_TEXT::TextHitTest( aPoint, accuracy );
434}
435
436
437bool PCB_TEXT::TextHitTest( const BOX2I& aRect, bool aContains, int aAccuracy ) const
438{
439 BOX2I rect = aRect;
440
441 rect.Inflate( aAccuracy );
442
443 if( aContains )
444 return rect.Contains( GetBoundingBox() );
445
446 return rect.Intersects( GetBoundingBox() );
447}
448
449
450bool PCB_TEXT::TextHitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
451{
452 BOX2I rect = GetTextBox( nullptr );
453
454 if( IsKnockout() )
455 rect.Inflate( getKnockoutMargin() );
456
457 return KIGEOM::BoxHitTest( aPoly, rect, GetDrawRotation(), GetDrawPos(), aContained );
458}
459
460
462{
463 if( const FOOTPRINT* fp = GetParentFootprint() )
464 return fp->GetTransform().Apply( EDA_TEXT::GetTextPos() );
465
466 return EDA_TEXT::GetTextPos();
467}
468
469
471{
473
474 if( const FOOTPRINT* fp = GetParentFootprint() )
475 {
476 const TRANSFORM_TRS& xf = fp->GetTransform();
477 return { KiROUND( libSize.x * std::abs( xf.GetScaleX() ) ), KiROUND( libSize.y * std::abs( xf.GetScaleY() ) ) };
478 }
479
480 return libSize;
481}
482
483
484void PCB_TEXT::SetTextSize( VECTOR2I aNewSize, bool aEnforceMinTextSize )
485{
486 if( const FOOTPRINT* fp = GetParentFootprint() )
487 {
488 const TRANSFORM_TRS& xf = fp->GetTransform();
489 aNewSize = { KiROUND( aNewSize.x / std::abs( xf.GetScaleX() ) ),
490 KiROUND( aNewSize.y / std::abs( xf.GetScaleY() ) ) };
491 }
492
493 EDA_TEXT::SetTextSize( aNewSize, aEnforceMinTextSize );
494}
495
496
498{
499 int libThickness = EDA_TEXT::GetTextThickness();
500
501 if( const FOOTPRINT* fp = GetParentFootprint() )
502 {
503 const TRANSFORM_TRS& xf = fp->GetTransform();
504 const double factor = ( std::abs( xf.GetScaleX() ) + std::abs( xf.GetScaleY() ) ) * 0.5;
505 return KiROUND( libThickness * factor );
506 }
507
508 return libThickness;
509}
510
511
513{
514 if( const FOOTPRINT* fp = GetParentFootprint() )
515 {
516 const TRANSFORM_TRS& xf = fp->GetTransform();
517 const double factor = ( std::abs( xf.GetScaleX() ) + std::abs( xf.GetScaleY() ) ) * 0.5;
518 aWidth = KiROUND( aWidth / factor );
519 }
520
522}
523
524
525void PCB_TEXT::Offset( const VECTOR2I& aOffset )
526{
527 if( const FOOTPRINT* fp = GetParentFootprint() )
528 {
529 VECTOR2I curBoardPos = fp->GetTransform().Apply( EDA_TEXT::GetTextPos() );
530 VECTOR2I newLibPos = fp->GetTransform().InverseApply( curBoardPos + aOffset );
531 VECTOR2I libDelta = newLibPos - EDA_TEXT::GetTextPos();
533 EDA_TEXT::Offset( libDelta );
534 }
535 else
536 {
537 EDA_TEXT::Offset( aOffset );
538 }
539}
540
541
543{
545}
546
547
549{
550 EDA_TEXT::SetTextSize( aSize );
551}
552
553
555{
557}
558
559
561{
562 if( const FOOTPRINT* fp = GetParentFootprint() )
563 return m_libTextAngle + fp->GetOrientation();
564
565 return m_libTextAngle;
566}
567
568
570{
571 if( const FOOTPRINT* fp = GetParentFootprint() )
572 m_libTextAngle = aAngle - fp->GetOrientation();
573 else
574 m_libTextAngle = aAngle;
575
576 m_libTextAngle.Normalize();
577 EDA_TEXT::SetTextAngle( aAngle );
578}
579
580
581void PCB_TEXT::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
582{
583 VECTOR2I pt = GetTextPos();
584 RotatePoint( pt, aRotCentre, aAngle );
585 SetTextPos( pt );
586
587 EDA_ANGLE new_angle = GetTextAngle() + aAngle;
588 new_angle.Normalize();
589 SetTextAngle( new_angle );
590}
591
592
593void PCB_TEXT::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
594{
595 // the position and justification are mirrored, but not the text itself
596
597 if( aFlipDirection == FLIP_DIRECTION::TOP_BOTTOM )
598 {
601
602 SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
603 }
604 else
605 {
608
609 SetTextX( MIRRORVAL( GetTextPos().x, aCentre.x ) );
610 }
611}
612
613
614void PCB_TEXT::OnFootprintRescaled( double /* aRatioX */, double /* aRatioY */, double /* aLinearFactor */,
615 const VECTOR2I& /* aAnchor */, const EDA_ANGLE& /* aParentRotate */ )
616{
618}
619
620
627
628
629void PCB_TEXT::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
630{
631 if( const FOOTPRINT* fp = GetParentFootprint() )
632 {
633 // Mirror the library-frame position (rotation-independent).
634 const VECTOR2I libAxis = fp->GetTransform().InverseApply( aCentre );
636
637 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
638 libPos.x = 2 * libAxis.x - libPos.x;
639 else
640 libPos.y = 2 * libAxis.y - libPos.y;
641
642 SetLibTextPos( libPos );
643 }
644 else if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
645 {
646 SetTextX( MIRRORVAL( GetTextPos().x, aCentre.x ) );
647 }
648 else
649 {
650 SetTextY( MIRRORVAL( GetTextPos().y, aCentre.y ) );
651 }
652
653 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
655 else
657
658 m_libTextAngle.Normalize();
660
662
663 if( IsSideSpecific() )
665}
666
667
669{
670 return _( "Text" );
671}
672
673
674wxString PCB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
675{
676 wxString content = aFull ? GetShownText( FOR_GUI ) : KIUI::EllipsizeMenuText( GetText() );
677
678 if( FOOTPRINT* parentFP = GetParentFootprint() )
679 {
680 wxString ref = parentFP->GetReference();
681 return wxString::Format( _( "Footprint text of %s (%s)" ), ref, content );
682 }
683
684 return wxString::Format( _( "PCB text '%s' on %s" ), content, GetLayerName() );
685}
686
687
689{
690 return BITMAPS::text;
691}
692
693
695{
696 return new PCB_TEXT( *this );
697}
698
699
701{
702 wxASSERT( aImage->Type() == PCB_TEXT_T );
703
704 std::swap( *( (PCB_TEXT*) this ), *( (PCB_TEXT*) aImage ) );
705}
706
707
709{
710 if( IsKnockout() )
711 {
712 SHAPE_POLY_SET poly;
713
715
716 return std::make_shared<SHAPE_POLY_SET>( std::move( poly ) );
717 }
718
719 return GetEffectiveTextShape();
720}
721
722
723const SHAPE_POLY_SET& PCB_TEXT::GetKnockoutCache( const KIFONT::FONT* aFont, const wxString& forResolvedText,
724 int aMaxError ) const
725{
727 attrs.m_Size = GetTextSize();
728 EDA_ANGLE drawAngle = GetDrawRotation();
729 VECTOR2I drawPos = GetDrawPos();
730
731 if( !m_knockout_cache )
732 m_knockout_cache = std::make_unique<PCB_TEXT_KNOCKOUT_CACHE_DATA>();
733
734 if( m_knockout_cache->cache.IsEmpty() || m_knockout_cache->text_attrs != attrs
735 || m_knockout_cache->text != forResolvedText
736 || m_knockout_cache->angle != drawAngle )
737 {
738 m_knockout_cache->cache.RemoveAllContours();
739
741 m_knockout_cache->cache.Fracture();
742
743 m_knockout_cache->text_attrs = attrs;
744 m_knockout_cache->angle = drawAngle;
745 m_knockout_cache->text = forResolvedText;
746 m_knockout_cache->pos = drawPos;
747 }
748 else if( m_knockout_cache->pos != drawPos )
749 {
750 m_knockout_cache->cache.Move( drawPos - m_knockout_cache->pos );
751 m_knockout_cache->pos = drawPos;
752 }
753
754 return m_knockout_cache->cache;
755}
756
757
758void PCB_TEXT::buildBoundingHull( SHAPE_POLY_SET* aBuffer, const SHAPE_POLY_SET& aRenderedText, int aClearance ) const
759{
760 SHAPE_POLY_SET poly( aRenderedText );
761
762 poly.Rotate( -GetDrawRotation(), GetDrawPos() );
763
764 BOX2I rect = poly.BBox( aClearance );
765 VECTOR2I corners[4];
766
767 corners[0].x = rect.GetOrigin().x;
768 corners[0].y = rect.GetOrigin().y;
769 corners[1].y = corners[0].y;
770 corners[1].x = rect.GetRight();
771 corners[2].x = corners[1].x;
772 corners[2].y = rect.GetBottom();
773 corners[3].y = corners[2].y;
774 corners[3].x = corners[0].x;
775
776 aBuffer->NewOutline();
777
778 for( VECTOR2I& corner : corners )
779 {
780 RotatePoint( corner, GetDrawPos(), GetDrawRotation() );
781 aBuffer->Append( corner.x, corner.y );
782 }
783}
784
785
786void PCB_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, int aClearance, int aMaxError,
787 ERROR_LOC aErrorLoc ) const
788{
790 KIFONT::FONT* font = GetDrawFont( nullptr );
791 int penWidth = GetEffectiveTextPenWidth();
793 wxString shownText = GetShownText( FOR_CANVAS );
794
795 attrs.m_Angle = GetDrawRotation();
796 attrs.m_Size = GetTextSize();
797
798 // The polygonal shape of a text can have many basic shapes, so combining these shapes can
799 // be very useful to create a final shape with a lot less vertices to speedup calculations.
800 // Simplify shapes is not usually always efficient, but in this case it is.
801 SHAPE_POLY_SET textShape;
802
803 CALLBACK_GAL callback_gal(
804 empty_opts,
805 // Stroke callback
806 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
807 {
808 TransformOvalToPolygon( textShape, aPt1, aPt2, penWidth, aMaxError, aErrorLoc );
809 },
810 // Triangulation callback
811 [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 )
812 {
813 textShape.NewOutline();
814
815 for( const VECTOR2I& point : { aPt1, aPt2, aPt3 } )
816 textShape.Append( point.x, point.y );
817 } );
818
819 if( auto* cache = GetRenderCache( font, shownText ) )
820 callback_gal.DrawGlyphs( *cache );
821 else
822 font->Draw( &callback_gal, shownText, GetTextPos(), attrs, GetFontMetrics() );
823
824 textShape.Simplify();
825
826 if( IsKnockout() )
827 {
828 SHAPE_POLY_SET finalPoly;
829 int margin = GetKnockoutTextMargin( attrs.m_Size, penWidth );
830
831 buildBoundingHull( &finalPoly, textShape, margin + aClearance );
832 finalPoly.BooleanSubtract( textShape );
833
834 aBuffer.Append( finalPoly );
835 }
836 else
837 {
838 if( aClearance > 0 || aErrorLoc == ERROR_OUTSIDE )
839 {
840 if( aErrorLoc == ERROR_OUTSIDE )
841 aClearance += aMaxError;
842
843 textShape.Inflate( aClearance, CORNER_STRATEGY::ROUND_ALL_CORNERS, aMaxError );
844 }
845
846 aBuffer.Append( textShape );
847 }
848}
849
850
851void PCB_TEXT::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError,
852 ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const
853{
854 SHAPE_POLY_SET poly;
855
856 TransformTextToPolySet( poly, 0, aMaxError, aErrorLoc );
857
858 buildBoundingHull( &aBuffer, poly, aClearance );
859}
860
861
862bool PCB_TEXT::operator==( const BOARD_ITEM& aBoardItem ) const
863{
864 if( aBoardItem.Type() != Type() )
865 return false;
866
867 const PCB_TEXT& other = static_cast<const PCB_TEXT&>( aBoardItem );
868
869 return *this == other;
870}
871
872
873bool PCB_TEXT::operator==( const PCB_TEXT& aOther ) const
874{
875 return EDA_TEXT::operator==( aOther );
876}
877
878
879double PCB_TEXT::Similarity( const BOARD_ITEM& aOther ) const
880{
881 if( aOther.Type() != Type() )
882 return 0.0;
883
884 const PCB_TEXT& other = static_cast<const PCB_TEXT&>( aOther );
885
886 return EDA_TEXT::Similarity( other );
887}
888
889
891{
892 wxString msg =
893#include "pcb_text_help_md.h"
894 ;
895
896 HTML_MESSAGE_BOX* dlg = new HTML_MESSAGE_BOX( aParentWindow, _( "Syntax Help" ) );
897 wxSize sz( 320, 320 );
898
899 dlg->SetMinSize( dlg->ConvertDialogToPixels( sz ) );
900 dlg->SetDialogSizeInDU( sz.x, sz.y );
901
902 wxString html_txt;
903 ConvertMarkdown2Html( wxGetTranslation( msg ), html_txt );
904 dlg->AddHTML_Text( html_txt );
905 dlg->ShowModeless();
906
907 return dlg;
908}
909
910
911static struct PCB_TEXT_DESC
912{
914 {
921
922 propMgr.Mask( TYPE_HASH( PCB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Color" ) );
923
924 propMgr.AddProperty( new PROPERTY<PCB_TEXT, bool, BOARD_ITEM>( _HKI( "Knockout" ),
926 _HKI( "Text Properties" ) ).SetIsCopyable();
927
928 propMgr.AddProperty( new PROPERTY<PCB_TEXT, bool, EDA_TEXT>( _HKI( "Keep Upright" ),
930 _HKI( "Text Properties" ) ).SetIsCopyable();
931
932 auto isFootprintText =
933 []( INSPECTABLE* aItem ) -> bool
934 {
935 if( PCB_TEXT* text = dynamic_cast<PCB_TEXT*>( aItem ) )
936 return text->GetParentFootprint();
937
938 return false;
939 };
940
941 propMgr.OverrideAvailability( TYPE_HASH( PCB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Keep Upright" ),
942 isFootprintText );
943
944 propMgr.Mask( TYPE_HASH( PCB_TEXT ), TYPE_HASH( EDA_TEXT ), _HKI( "Hyperlink" ) );
945 }
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:55
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:121
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:995
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:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
friend class BOARD
Definition board_item.h:578
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
Definition board_item.h:417
PCB_LAYER_ID m_layer
Definition board_item.h:571
virtual bool IsKnockout() const
Definition board_item.h:413
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:414
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition board_item.h:374
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:103
bool IsSideSpecific() const
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
int GetMaxError() const
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:553
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:165
constexpr const Vec & GetOrigin() const
Definition box2.h:207
const BOX2< Vec > GetBoundingBoxRotated(const VECTOR2I &aRotCenter, const EDA_ANGLE &aAngle) const
Useful to calculate bounding box of rotated items, when rotation is not cardinal.
Definition box2.h:715
constexpr coord_type GetRight() const
Definition box2.h:214
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition box2.h:308
constexpr coord_type GetBottom() const
Definition box2.h:219
EDA_ANGLE Normalize()
Definition eda_angle.h:229
bool IsZero() const
Definition eda_angle.h:136
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:597
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:482
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:165
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:495
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:539
virtual void SetTextX(int aX)
Definition eda_text.cpp:546
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:195
KIFONT::FONT * GetFont() const
Definition eda_text.h:286
void SetMirrored(bool isMirrored)
Definition eda_text.cpp:349
virtual void SetTextY(int aY)
Definition eda_text.cpp:552
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:666
virtual VECTOR2I GetDrawPos() const
Definition eda_text.h:420
EDA_TEXT & operator=(const EDA_TEXT &aItem)
Definition eda_text.cpp:138
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:737
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:373
virtual void Offset(const VECTOR2I &aOffset)
Definition eda_text.cpp:558
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:630
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:658
double Similarity(const EDA_TEXT &aOther) const
virtual void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition eda_text.cpp:245
virtual bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const
Test if aPoint is within the bounds of this object.
Definition eda_text.cpp:873
virtual void ClearRenderCache()
Definition eda_text.cpp:652
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:422
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:381
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:263
void SetItalic(bool aItalic)
Set the text to be italic - this will also update the font if needed.
Definition eda_text.cpp:285
bool operator==(const EDA_TEXT &aRhs) const
Definition eda_text.h:438
void SetMultilineAllowed(bool aAllow)
Definition eda_text.cpp:357
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:365
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the component.
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition footprint.h:449
wxString GetFieldValueForVariant(const wxString &aVariantName, const wxString &aFieldName) const
Get a field value for a specific variant.
const wxString & GetReference() const
Definition footprint.h:901
VECTOR2I GetPosition() const override
Definition footprint.h:435
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:240
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:84
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:63
bool IsLayerVisibleCached(int aLayer) const
Definition view.h:439
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition view.h:225
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:312
void StyleFromSettings(const BOARD_DESIGN_SETTINGS &settings, bool aCheckSide) override
Definition pcb_text.cpp:371
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:879
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:851
void SetTextThickness(int aWidth) override
The TextThickness is that set by the user.
Definition pcb_text.cpp:512
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition pcb_text.cpp:674
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition pcb_text.cpp:242
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition pcb_text.cpp:629
EDA_ANGLE GetTextAngle() const override
Definition pcb_text.cpp:560
void swapData(BOARD_ITEM *aImage) override
Definition pcb_text.cpp:700
void KeepUpright()
Called when rotating the parent footprint.
Definition pcb_text.cpp:390
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition pcb_text.cpp:214
void Offset(const VECTOR2I &aOffset) override
Definition pcb_text.cpp:525
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:723
void SetLibTextThickness(int aWidth)
Definition pcb_text.cpp:554
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:593
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition pcb_text.cpp:257
void SetTextSize(VECTOR2I aNewSize, bool aEnforceMinTextSize=true) override
Definition pcb_text.cpp:484
void SetLibTextSize(const VECTOR2I &aSize)
Definition pcb_text.cpp:548
VECTOR2I GetTextPos() const override
Definition pcb_text.cpp:461
VECTOR2I GetPosition() const override
Definition pcb_text.h:100
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:242
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_text.h:102
bool operator==(const PCB_TEXT &aOther) const
Definition pcb_text.cpp:873
int getKnockoutMargin() const
Definition pcb_text.cpp:365
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:614
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...
Definition pcb_text.cpp:786
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition pcb_text.cpp:411
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:708
virtual wxString GetTextTypeDescription() const
Definition pcb_text.cpp:668
std::vector< int > ViewGetLayers() const override
Definition pcb_text.cpp:248
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:758
bool TextHitTest(const VECTOR2I &aPoint, int aAccuracy=0) const override
Test if aPoint is within the bounds of this object.
Definition pcb_text.cpp:426
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pcb_text.cpp:694
int GetTextThickness() const override
Definition pcb_text.cpp:497
EDA_ANGLE m_libTextAngle
Definition pcb_text.h:244
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
Definition pcb_text.cpp:621
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
Display a syntax help window for text variables and expressions.
Definition pcb_text.cpp:890
EDA_ANGLE GetDrawRotation() const override
Definition pcb_text.cpp:220
void SetTextAngle(const EDA_ANGLE &aAngle) override
Definition pcb_text.cpp:569
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:178
VECTOR2I GetTextSize() const override
Definition pcb_text.cpp:470
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition pcb_text.cpp:167
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition pcb_text.cpp:581
void SetLibTextPos(const VECTOR2I &aPos)
Definition pcb_text.cpp:542
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:688
PROPERTY_BASE & SetIsCopyable(bool aIsCopyable=true)
Definition property.h:359
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 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.
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.
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:87
@ FOR_GUI
Definition common.h:89
@ FOR_CANVAS
Definition common.h:88
@ RAW_VALUE
Definition common.h:94
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.
DRC_CONSTRAINT_T
Definition drc_rule.h:49
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:422
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:424
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:419
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:418
static constexpr EDA_ANGLE ANGLE_180
Definition eda_angle.h:426
#define PCB_EDIT_FRAME_NAME
static FILENAME_RESOLVER * resolver
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
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition layer_id.cpp:179
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition layer_ids.h:806
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:829
@ 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 T MIRRORVAL(T aPoint, T aMirrorRef)
Returns the mirror of aPoint relative to the aMirrorRef.
Definition mirror.h:32
FLIP_DIRECTION
Definition mirror.h:23
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:24
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:25
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:411
#define _HKI(x)
Definition page_info.cpp:40
static struct PCB_TEXT_DESC _PCB_TEXT_DESC
#define TYPE_HASH(x)
Definition property.h:74
#define REGISTER_TYPE(x)
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:225
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:683