KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_sheet.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2023 CERN
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 <cstdlib>
23#include <optional>
24
25#include <bitmaps.h>
26#include <core/mirror.h>
27#include <core/kicad_algo.h>
28#include <sch_draw_panel.h>
29#include <trigo.h>
30#include <sch_edit_frame.h>
31#include <plotters/plotter.h>
32#include <sch_plotter.h>
33#include <string_utils.h>
34#include <common.h>
35#include <advanced_config.h>
36#include <widgets/msgpanel.h>
37#include <math/util.h> // for KiROUND
39#include <increment.h>
40#include <api/api_enums.h>
41#include <api/api_utils.h>
42#include <api/schematic/schematic_types.pb.h>
43#include <sch_sheet.h>
44#include <sch_sheet_path.h>
45#include <sch_sheet_pin.h>
46#include <sch_no_connect.h>
47#include <sch_symbol.h>
48#include <sch_painter.h>
49#include <schematic.h>
51#include <trace_helpers.h>
52#include <validators.h>
54#include <properties/property.h>
56#include <pgm_base.h>
57#include <wx/log.h>
58
59
61{
62public:
63 SCH_SHEET_FIELD_PROPERTY( const wxString& aName ) :
64 PROPERTY_BASE( aName ),
65 m_name( aName )
66 {
67 SetGroup( _HKI( "Fields" ) );
68
70 {
71 SetValidator( []( const wxAny&& aValue, EDA_ITEM* ) -> VALIDATOR_RESULT
72 {
73 wxString value;
74
75 if( !aValue.GetAs( &value ) )
76 return {};
77
79
80 if( msg.empty() )
81 return {};
82
83 return std::make_unique<VALIDATION_ERROR_MSG>( msg );
84 } );
85 }
86 }
87
88 size_t OwnerHash() const override { return TYPE_HASH( SCH_SHEET ); }
89 size_t BaseHash() const override { return TYPE_HASH( SCH_SHEET ); }
90 size_t TypeHash() const override { return TYPE_HASH( wxString ); }
91
92private:
93 void setter( void* obj, wxAny& v ) override
94 {
95 wxString value;
96
97 if( !v.GetAs( &value ) )
98 return;
99
100 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( obj );
101 SCH_FIELD* field = sheet->GetField( m_name );
102
103 wxString variantName;
104 const SCH_SHEET_PATH* sheetPath = nullptr;
105
106 if( sheet->Schematic() )
107 {
108 variantName = sheet->Schematic()->GetCurrentVariant();
109 sheetPath = &sheet->Schematic()->CurrentSheet();
110 }
111
112 if( !field )
113 field = sheet->AddField( SCH_FIELD( sheet, FIELD_T::SHEET_USER, m_name ) );
114
115 field->SetText( value, sheetPath, variantName );
116 }
117
118 wxAny getter( const void* obj ) const override
119 {
120 const SCH_SHEET* sheet = static_cast<const SCH_SHEET*>( obj );
121 const SCH_FIELD* field = sheet->GetField( m_name );
122
123 if( !field )
124 return wxAny();
125
126 wxString variantName;
127 const SCH_SHEET_PATH* sheetPath = nullptr;
128
129 if( sheet->Schematic() )
130 {
131 variantName = sheet->Schematic()->GetCurrentVariant();
132 sheetPath = &sheet->Schematic()->CurrentSheet();
133 }
134
135 wxString text;
136
137 if( !variantName.IsEmpty() && sheetPath )
138 text = field->GetText( sheetPath, variantName );
139 else
140 text = field->GetText();
141
142 return wxAny( text );
143 }
144
145private:
146 wxString m_name;
147};
148
149
150SCH_SHEET::SCH_SHEET( EDA_ITEM* aParent, const VECTOR2I& aPos, VECTOR2I aSize ) :
151 SCH_ITEM( aParent, SCH_SHEET_T ),
152 m_excludedFromSim( false ),
153 m_excludedFromBOM( false ),
154 m_excludedFromBoard( false ),
155 m_DNP( false )
156{
158 m_pos = aPos;
159 m_size = aSize;
160 m_screen = nullptr;
161
162 m_borderWidth = 0;
166
169
171}
172
173
174void SCH_SHEET::Serialize( google::protobuf::Any& aContainer ) const
175{
176 using namespace kiapi::common;
177 using namespace kiapi::common::types;
178 using namespace kiapi::schematic::types;
179
180 SheetSymbol sheet;
181
182 sheet.mutable_id()->set_value( m_Uuid.AsStdString() );
183 PackVector2( *sheet.mutable_position(), GetPosition(), schIUScale );
184 PackVector2( *sheet.mutable_size(), GetSize(), schIUScale );
185 sheet.set_locked( IsLocked() ? LockedState::LS_LOCKED : LockedState::LS_UNLOCKED );
186 sheet.set_fields_autoplaced( GetFieldsAutoplaced() != AUTOPLACE_NONE );
187 sheet.set_exclude_from_sim( GetExcludedFromSim() );
188 sheet.set_exclude_from_bom( GetExcludedFromBOM() );
189 sheet.set_exclude_from_board( GetExcludedFromBoard() );
190 sheet.set_dnp( GetDNP() );
191
192 StrokeAttributes* borderStroke = sheet.mutable_border_stroke();
193 PackDistance( *borderStroke->mutable_width(), GetBorderWidth(), schIUScale );
195
197 PackColor( *borderStroke->mutable_color(), GetBorderColor() );
198
199 GraphicFillAttributes* fill = sheet.mutable_fill();
200 fill->set_fill_type( GetBackgroundColor() == COLOR4D::UNSPECIFIED ? GraphicFillType::GFT_UNFILLED
201 : GraphicFillType::GFT_FILLED_WITH_COLOR );
202
204 PackColor( *fill->mutable_color(), GetBackgroundColor() );
205
206 GetField( FIELD_T::SHEET_NAME )->Serialize( *sheet.mutable_name_field(), schIUScale );
207 GetField( FIELD_T::SHEET_FILENAME )->Serialize( *sheet.mutable_filename_field(), schIUScale );
208
209 for( const SCH_FIELD& field : GetFields() )
210 {
211 if( field.IsMandatory() )
212 continue;
213
214 field.Serialize( *sheet.add_user_fields(), schIUScale );
215 }
216
217 for( const SCH_SHEET_PIN* pin : GetPins() )
218 pin->Serialize( *sheet.add_pins() );
219
220 kiapi::common::PackCustomProperties( sheet.mutable_custom_properties(), *this );
221
222 if( !aContainer.PackFrom( sheet ) )
223 wxFAIL_MSG( wxT( "Failed to pack SCH_SHEET" ) );
224}
225
226
227bool SCH_SHEET::Deserialize( const google::protobuf::Any& aContainer )
228{
229 using namespace kiapi::common;
230 using namespace kiapi::common::types;
231 using namespace kiapi::schematic::types;
232
233 SheetSymbol sheet;
234
235 if( !aContainer.UnpackTo( &sheet ) )
236 return false;
237
238 if( SCH_SCREEN* screen = GetParentScreen() )
239 screen->BumpConnectivityRevision();
240
241 const_cast<::KIID&>( m_Uuid ) = ::KIID( sheet.id().value() );
242 SetPosition( UnpackVector2( sheet.position(), schIUScale ) );
243 SetSize( UnpackVector2( sheet.size(), schIUScale ) );
244 SetLocked( sheet.locked() == LockedState::LS_LOCKED );
245 SetFieldsAutoplaced( sheet.fields_autoplaced() ? AUTOPLACE_AUTO : AUTOPLACE_NONE );
246 SetExcludedFromSim( sheet.exclude_from_sim() );
247 SetExcludedFromBOM( sheet.exclude_from_bom() );
248 SetExcludedFromBoard( sheet.exclude_from_board() );
249 SetDNP( sheet.dnp() );
250 kiapi::common::UnpackCustomProperties( sheet.custom_properties(), *this );
251
252 SetBorderWidth( UnpackDistance( sheet.border_stroke().width(), schIUScale ) );
253 SetBorderColor( sheet.border_stroke().has_color() ? UnpackColor( sheet.border_stroke().color() )
255
256 if( sheet.fill().fill_type() == GraphicFillType::GFT_UNFILLED || !sheet.fill().has_color() )
258 else
259 SetBackgroundColor( UnpackColor( sheet.fill().color() ) );
260
261 for( SCH_SHEET_PIN* pin : m_pins )
262 delete pin;
263
264 m_pins.clear();
265
266 m_fields.clear();
269
270 GetField( FIELD_T::SHEET_NAME )->Deserialize( sheet.name_field(), schIUScale );
271 GetField( FIELD_T::SHEET_FILENAME )->Deserialize( sheet.filename_field(), schIUScale );
272
273 for( const auto& field : sheet.user_fields() )
274 {
275 m_fields.emplace_back( this, FIELD_T::SHEET_USER );
276 m_fields.back().Deserialize( field, schIUScale );
277 }
278
279 for( const auto& pinProto : sheet.pins() )
280 {
281 std::unique_ptr<SCH_SHEET_PIN> pin = std::make_unique<SCH_SHEET_PIN>( this );
282
283 if( !pin->Deserialize( pinProto ) )
284 return false;
285
286 AddPin( pin.release() );
287 }
288
289 kiapi::common::UnpackCustomProperties( sheet.custom_properties(), *this );
290 return true;
291}
292
293
295 SCH_ITEM( aSheet )
296{
297 m_pos = aSheet.m_pos;
298 m_size = aSheet.m_size;
299 m_layer = aSheet.m_layer;
300 const_cast<KIID&>( m_Uuid ) = aSheet.m_Uuid;
301 m_fields = aSheet.m_fields;
303 m_screen = aSheet.m_screen;
304
308 m_DNP = aSheet.m_DNP;
309
313 m_instances = aSheet.m_instances;
314
315 for( SCH_SHEET_PIN* pin : aSheet.m_pins )
316 {
317 m_pins.emplace_back( new SCH_SHEET_PIN( *pin ) );
318 m_pins.back()->SetParent( this );
319 }
320
321 for( SCH_FIELD& field : m_fields )
322 field.SetParent( this );
323
324 if( m_screen )
325 m_screen->IncRefCount();
326}
327
328
330{
331 // also, look at the associated sheet & its reference count
332 // perhaps it should be deleted also.
333 if( m_screen )
334 {
335 m_screen->DecRefCount();
336
337 if( m_screen->GetRefCount() == 0 )
338 delete m_screen;
339 }
340
341 // We own our pins; delete them
342 for( SCH_SHEET_PIN* pin : m_pins )
343 delete pin;
344}
345
346
347std::vector<PROPERTY_BASE*> SCH_SHEET::GetDynamicProperties() const
348{
349 std::vector<PROPERTY_BASE*> props;
350
351 auto getOrCreate = [&]( const wxString& aName )
352 {
353 auto it = m_dynamicPropertyCache.find( aName );
354
355 if( it == m_dynamicPropertyCache.end() )
356 {
357 auto prop = std::make_unique<SCH_SHEET_FIELD_PROPERTY>( aName );
358 it = m_dynamicPropertyCache.emplace( aName, std::move( prop ) ).first;
359 }
360
361 return it->second.get();
362 };
363
364
365 for( const SCH_FIELD& field : GetFields() )
366 {
367 if( field.IsMandatory() )
368 {
369 if( field.IsPrivate() )
370 continue;
371
372 const wxString& name = field.GetUntranslatedName();
373
374 if( PROPERTY_MANAGER::Instance().GetProperty( TYPE_HASH( SCH_SHEET ), name ) )
375 continue;
376
377 props.push_back( getOrCreate( name ) );
378 }
379 }
380
381 std::vector<const SCH_FIELD*> userFields;
382
383 for( const SCH_FIELD& field : GetFields() )
384 {
385 if( field.IsMandatory() )
386 continue;
387
388 if( field.IsPrivate() )
389 continue;
390
391 userFields.push_back( &field );
392 }
393
394 std::ranges::sort( userFields,
395 []( const SCH_FIELD* a, const SCH_FIELD* b )
396 {
397 return a->GetUntranslatedName().CmpNoCase( b->GetUntranslatedName() ) < 0;
398 } );
399
400 for( const SCH_FIELD* field : userFields )
401 {
402 const wxString& name = field->GetUntranslatedName();
403 props.push_back( getOrCreate( name ) );
404 }
405
407 props.push_back( prop );
408
409 return props;
410}
411
412
414{
415 return new SCH_SHEET( *this );
416}
417
418
420{
421 if( aScreen == m_screen )
422 return;
423
424 if( m_screen != nullptr )
425 {
426 m_screen->DecRefCount();
427
428 if( m_screen->GetRefCount() == 0 )
429 {
430 delete m_screen;
431 m_screen = nullptr;
432 }
433 }
434
435 m_screen = aScreen;
436
437 if( m_screen )
438 m_screen->IncRefCount();
439}
440
441
443{
444 wxCHECK_RET( m_screen, wxS( "Cannot sync a sheet UUID without a screen" ) );
445
446 const_cast<KIID&>( m_Uuid ) = m_screen->GetUuid();
447}
448
449
451{
452 if( m_screen == nullptr )
453 return 0;
454
455 return m_screen->GetRefCount();
456}
457
458
460{
461 wxCHECK_MSG( Schematic(), false, "Can't call IsVirtualRootSheet without setting a schematic" );
462
463 return m_Uuid == niluuid;
464}
465
466
468{
469 wxCHECK_MSG( Schematic(), false, "Can't call IsTopLevelSheet without setting a schematic" );
470
471 return Schematic()->IsTopLevelSheet( this );
472}
473
474
475void SCH_SHEET::GetContextualTextVars( wxArrayString* aVars ) const
476{
477 auto add =
478 [&]( const wxString& aVar )
479 {
480 if( !alg::contains( *aVars, aVar ) )
481 aVars->push_back( aVar );
482 };
483
484 for( const SCH_FIELD& field : m_fields )
485 {
486 if( field.IsMandatory() )
487 add( field.GetUntranslatedName().Upper() );
488 else
489 add( field.GetName() );
490 }
491
492 SCH_SHEET_PATH sheetPath = findSelf();
493
494 if( sheetPath.size() >= 2 )
495 {
496 sheetPath.pop_back();
497 sheetPath.Last()->GetContextualTextVars( aVars );
498 }
499 else if( Schematic() )
500 {
502 }
503
504 add( wxT( "#" ) );
505 add( wxT( "##" ) );
506 add( wxT( "SHEETPATH" ) );
507 add( wxT( "EXCLUDE_FROM_BOM" ) );
508 add( wxT( "EXCLUDE_FROM_BOARD" ) );
509 add( wxT( "EXCLUDE_FROM_SIM" ) );
510 add( wxT( "DNP" ) );
511 add( wxT( "ERC_ERROR <message_text>" ) );
512 add( wxT( "ERC_WARNING <message_text>" ) );
513
514 m_screen->GetTitleBlock().GetContextualTextVars( aVars );
515}
516
517
518bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const
519{
520 wxCHECK( aPath, false );
521
523
524 if( !schematic )
525 return false;
526
527 if( token->Contains( ':' ) )
528 {
529 if( schematic->ResolveCrossReference( token, aDepth + 1 ) )
530 return true;
531 }
532
533 for( const SCH_FIELD& field : m_fields )
534 {
535 wxString fieldName = field.IsMandatory() ? field.GetUntranslatedName().Upper()
536 : field.GetName();
537
538 if( token->IsSameAs( fieldName ) )
539 {
540 // Sheet instances (and their variant fields) are keyed by the parent path
541 SCH_SHEET_PATH parentPath = *aPath;
542
543 if( !parentPath.empty() && parentPath.Last() == this )
544 parentPath.pop_back();
545
546 *token = field.GetShownText( &parentPath, INTERNAL, schematic->GetCurrentVariant(), aDepth + 1 );
547 return true;
548 }
549 }
550
551 PROJECT* project = &schematic->Project();
552 wxString variant = schematic->GetCurrentVariant();
553
554 // We cannot resolve text variables initially on load as we need to first load the screen and
555 // then parse the hierarchy. So skip the resolution if the screen isn't set yet
556 if( m_screen && m_screen->GetTitleBlock().TextVarResolver( token, project, INTERNAL ) )
557 return true;
558
559 if( token->IsSameAs( wxT( "#" ) ) )
560 {
561 *token = wxString::Format( "%s", aPath->GetPageNumber() );
562 return true;
563 }
564 else if( token->IsSameAs( wxT( "##" ) ) )
565 {
566 *token = wxString::Format( wxT( "%d" ), (int) schematic->Hierarchy().size() );
567 return true;
568 }
569 else if( token->IsSameAs( wxT( "SHEETPATH" ) ) )
570 {
571 *token = aPath->PathHumanReadable();
572 return true;
573 }
574 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOM" ) ) )
575 {
576 *token = wxEmptyString;
577
578 if( aPath->GetExcludedFromBOM( variant ) || this->ResolveExcludedFromBOM( aPath, variant ) )
579 *token = wxS( "Excluded from BOM" );
580
581 return true;
582 }
583 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOARD" ) ) )
584 {
585 *token = wxEmptyString;
586
587 if( aPath->GetExcludedFromBoard( variant ) || this->ResolveExcludedFromBoard( aPath, variant ) )
588 *token = wxS( "Excluded from board" );
589
590 return true;
591 }
592 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_SIM" ) ) )
593 {
594 *token = wxEmptyString;
595
596 if( aPath->GetExcludedFromSim( variant ) || this->ResolveExcludedFromSim( aPath, variant ) )
597 *token = wxS( "Excluded from simulation" );
598
599 return true;
600 }
601 else if( token->IsSameAs( wxT( "DNP" ) ) )
602 {
603 *token = wxEmptyString;
604
605 if( aPath->GetDNP( variant ) || this->ResolveDNP( aPath, variant ) )
606 *token = wxS( "DNP" );
607
608 return true;
609 }
610
611 // See if parent can resolve it (these will recurse to ancestors)
612
613 if( aPath->size() >= 2 )
614 {
615 SCH_SHEET_PATH path = *aPath;
616 path.pop_back();
617
618 if( path.Last()->ResolveTextVar( &path, token, aDepth + 1 ) )
619 return true;
620 }
621 else
622 {
623 if( schematic->ResolveTextVar( aPath, token, aDepth + 1 ) )
624 return true;
625 }
626
627 return false;
628}
629
630
632{
633 wxCHECK_RET( aItem->Type() == SCH_SHEET_T,
634 wxString::Format( wxT( "SCH_SHEET object cannot swap data with %s object." ),
635 aItem->GetClass() ) );
636
637 SCH_SHEET* sheet = ( SCH_SHEET* ) aItem;
638
639 std::swap( m_pos, sheet->m_pos );
640 std::swap( m_size, sheet->m_size );
641 m_fields.swap( sheet->m_fields );
642 m_pins.swap( sheet->m_pins );
643
644 // Update parent pointers after swapping.
645 for( SCH_SHEET_PIN* sheetPin : m_pins )
646 sheetPin->SetParent( this );
647
648 for( SCH_SHEET_PIN* sheetPin : sheet->m_pins )
649 sheetPin->SetParent( sheet );
650
651 for( SCH_FIELD& field : m_fields )
652 field.SetParent( this );
653
654 for( SCH_FIELD& field : sheet->m_fields )
655 field.SetParent( sheet );
656
657 std::swap( m_excludedFromSim, sheet->m_excludedFromSim );
658 std::swap( m_excludedFromBOM, sheet->m_excludedFromBOM );
659 std::swap( m_excludedFromBoard, sheet->m_excludedFromBoard );
660 std::swap( m_DNP, sheet->m_DNP );
661
662 std::swap( m_borderWidth, sheet->m_borderWidth );
663 std::swap( m_borderColor, sheet->m_borderColor );
664 std::swap( m_backgroundColor, sheet->m_backgroundColor );
665 std::swap( m_instances, sheet->m_instances );
666}
667
668
670{
671 if( SCH_FIELD* field = FindField( m_fields, aFieldType ) )
672 return field;
673
674 m_fields.emplace_back( this, aFieldType );
675 return &m_fields.back();
676}
677
678
679const SCH_FIELD* SCH_SHEET::GetField( FIELD_T aFieldType ) const
680{
681 return FindField( m_fields, aFieldType );
682}
683
684
685wxString SCH_SHEET::GetRefSuffix( const SCH_SHEET_PATH& aParentPath ) const
686{
687 const SCH_FIELD* suffixField = GetField( FIELD_T::SHEET_REF_SUFFIX );
688
689 if( !suffixField )
690 return wxEmptyString;
691
692 return ResolveRefSuffix( suffixField->GetText(), aParentPath );
693}
694
695
696wxString SCH_SHEET::ResolveRefSuffix( const wxString& aText, const SCH_SHEET_PATH& aParentPath ) const
697{
698 if( aText.IsEmpty() )
699 return wxEmptyString;
700
701 const SCH_FIELD* suffixField = GetField( FIELD_T::SHEET_REF_SUFFIX );
703 int depth = 0;
704
705 // Only base user fields on this path resolve, so every input reaches the cache through a commit
706 std::function<bool( wxString* )> resolver =
707 [&]( wxString* aToken ) -> bool
708 {
709 const SCH_FIELD* field = GetField( *aToken );
710
711 for( size_t ii = aParentPath.size(); !field && ii > 0; --ii )
712 field = std::as_const( *aParentPath.at( ii - 1 ) ).GetField( *aToken );
713
714 // Saves rewrite the mandatory file name field without a commit
715 if( !field || field == suffixField || field->IsMandatory() )
716 return false;
717
718 wxString value = UnescapeString( field->GetText() );
719
720 if( value.Contains( wxS( "${" ) ) && depth < maxDepth )
721 {
722 ++depth;
723 value = ExpandTextVars( value, &resolver, FOR_ERC_DRC, depth );
724 --depth;
725 }
726
727 *aToken = value;
728 return true;
729 };
730
731 // INTERNAL would drop fields named like ERC_WARNING*, which are ordinary fields here
732 wxString suffix = ExpandTextVars( UnescapeString( aText ), &resolver, FOR_ERC_DRC );
734 return suffix;
735}
736
737
738wxString SCH_SHEET::NextRefSuffix( const wxString& aSuffix, const std::set<wxString>& aInUse,
739 const std::function<bool( const wxString& )>& aIsTaken )
740{
741 auto taken =
742 [&]( const wxString& aCandidate )
743 {
744 return aInUse.contains( aCandidate ) || ( aIsTaken && aIsTaken( aCandidate ) );
745 };
746
747 if( aSuffix.IsEmpty() || !taken( aSuffix ) )
748 return aSuffix;
749
750 auto splitTail =
751 []( const wxString& aText, auto aIsTailChar ) -> size_t
752 {
753 size_t stem = aText.length();
754
755 while( stem > 0 && aIsTailChar( aText[stem - 1] ) )
756 --stem;
757
758 return stem;
759 };
760
761 auto isDigit = []( wxUniChar c ) { return c >= '0' && c <= '9'; };
762 auto isUpper = []( wxUniChar c ) { return c >= 'A' && c <= 'Z'; };
763 auto isLower = []( wxUniChar c ) { return c >= 'a' && c <= 'z'; };
764
765 size_t digitStem = splitTail( aSuffix, isDigit );
766
767 if( digitStem < aSuffix.length() )
768 {
769 wxString stem = aSuffix.Left( digitStem );
770 size_t width = aSuffix.length() - digitStem;
771 wxULongLong_t highest = 0;
772
773 for( const wxString& used : aInUse )
774 {
775 wxULongLong_t value = 0;
776
777 if( used.StartsWith( stem ) && used.length() > stem.length()
778 && splitTail( used, isDigit ) == stem.length()
779 && used.Mid( stem.length() ).ToULongLong( &value ) )
780 {
781 highest = std::max( highest, value );
782 }
783 }
784
785 // A wrapped counter restarts at zero, so it still needs the in-use check
786 for( wxULongLong_t next = highest + 1; ; ++next )
787 {
788 wxString candidate = stem + wxString::Format( wxS( "%0*" wxLongLongFmtSpec "u" ), (int) width, next );
789
790 if( !taken( candidate ) )
791 return candidate;
792 }
793 }
794
795 // Longer letter runs are words such as _LEFT, not a series
796 auto letterSeries =
797 [&]( auto aIsLetter, bool aLower ) -> std::optional<wxString>
798 {
799 static const wxString alphabet = wxS( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
800
801 size_t stem = splitTail( aSuffix, aIsLetter );
802 size_t run = aSuffix.length() - stem;
803
804 if( run == 0 || run > 2 )
805 return std::nullopt;
806
807 wxString prefix = aSuffix.Left( stem );
808 int highest = -1;
809
810 for( const wxString& used : aInUse )
811 {
812 size_t usedStem = splitTail( used, aIsLetter );
813
814 if( usedStem == stem && used.length() - usedStem <= 2 && used.StartsWith( prefix ) )
815 highest = std::max( highest, IndexFromAlphabetic( used.Mid( stem ).Upper(), alphabet ) );
816 }
817
818 // Overflow such as _ZZ to _AAA leaves the series, so skip what it already holds
819 for( int next = highest + 1; ; ++next )
820 {
821 wxString letters = AlphabeticFromIndex( next, alphabet, true );
822
823 if( aLower )
824 letters.MakeLower();
825
826 if( !taken( prefix + letters ) )
827 return prefix + letters;
828 }
829 };
830
831 if( std::optional<wxString> next = letterSeries( isUpper, false ) )
832 return *next;
833
834 if( std::optional<wxString> next = letterSeries( isLower, true ) )
835 return *next;
836
837 return aSuffix;
838}
839
840
842{
843 const SCHEMATIC* schematic = Schematic();
844
845 if( !schematic )
846 return wxEmptyString;
847
848 SCH_SHEET_PATH path = schematic->CurrentSheet();
849 path.push_back( const_cast<SCH_SHEET*>( this ) );
850 return schematic->GetRefSuffix( path );
851}
852
853
854SCH_FIELD* SCH_SHEET::GetField( const wxString& aFieldName )
855{
856 return FindField( m_fields, aFieldName );
857}
858
859
860const SCH_FIELD* SCH_SHEET::GetField( const wxString& aFieldName ) const
861{
862 return FindField( m_fields, aFieldName );
863}
864
865
867{
868 return NextFieldOrdinal( m_fields );
869}
870
871
872void SCH_SHEET::SetFields( const std::vector<SCH_FIELD>& aFields )
873{
874 m_fields = aFields;
875
876 // Make sure that we get the UNIX variant of the file path
878}
879
880
882{
883 m_fields.emplace_back( aField );
884
886
887 return &m_fields.back();
888}
889
890
891void SCH_SHEET::SetFieldText( SCH_FIELD* aField, const wxString& aFieldName, const wxString& aFieldText,
892 const SCH_SHEET_PATH* aPath, const wxString& aVariantName )
893{
894 switch( aField->GetId() )
895 {
897 {
898 // File names are stored using unix separators.
899 wxString tmp = aFieldText;
900 tmp.Replace( wxT( "\\" ), wxT( "/" ) );
902 break;
903 }
904
907 aField->SetText( aFieldText );
908 break;
909
910 default:
911 {
912 wxString defaultText = aField->GetText( aPath );
913
914 if( aVariantName.IsEmpty() )
915 {
916 if( aFieldText != defaultText )
917 aField->SetText( aFieldText );
918 }
919 else
920 {
921 SCH_SHEET_INSTANCE* instance = getInstance( *aPath );
922
923 wxCHECK( instance, /* void */ );
924
925 bool changed = false;
926
927 if( instance->m_Variants.contains( aVariantName ) )
928 {
929 auto& fields = instance->m_Variants[aVariantName].m_Fields;
930
931 if( aFieldText != defaultText )
932 {
933 auto [entry, inserted] = fields.try_emplace( aFieldName, aFieldText );
934 changed = inserted || std::exchange( entry->second, aFieldText ) != aFieldText;
935 }
936 else
937 {
938 changed = fields.erase( aFieldName ) != 0;
939 }
940 }
941 else if( aFieldText != defaultText )
942 {
943 SCH_SHEET_VARIANT newVariant( aVariantName );
944
945 newVariant.InitializeAttributes( *this );
946 newVariant.m_Fields[aFieldName] = aFieldText;
947 instance->m_Variants.insert( std::make_pair( aVariantName, newVariant ) );
948 changed = true;
949 }
950
951 if( changed )
953 }
954
955 break;
956 }
957 }
958}
959
960
961void SCH_SHEET::SetFieldText( const wxString& aFieldName, const wxString& aFieldText, const SCH_SHEET_PATH* aPath,
962 const wxString& aVariantName )
963{
964 wxCHECK_MSG( !aFieldName.IsEmpty(), /* void */, wxT( "Can't set text on a field with no name!" ) );
965
966 SCH_FIELD* field = GetField( aFieldName );
967
968 wxCHECK_MSG( field, /* void */, wxT( "Can't set text on a field not yet added to the sheet!" ) );
969
970 SetFieldText( field, aFieldName, aFieldText, aPath, aVariantName );
971}
972
973
974wxString SCH_SHEET::GetFieldText( const SCH_FIELD* aField, const wxString& aFieldName, const SCH_SHEET_PATH* aPath,
975 const wxString& aVariantName ) const
976{
977 switch( aField->GetId() )
978 {
982 return aField->GetText();
983 break;
984
985 default:
986 if( aVariantName.IsEmpty() )
987 {
988 return aField->GetText();
989 }
990 else
991 {
992 const SCH_SHEET_INSTANCE* instance = getInstance( *aPath );
993
994 if( instance->m_Variants.contains( aVariantName )
995 && instance->m_Variants.at( aVariantName ).m_Fields.contains( aFieldName ) )
996 {
997 return instance->m_Variants.at( aVariantName ).m_Fields.at( aFieldName );
998 }
999 }
1000
1001 break;
1002 }
1003
1004 return aField->GetText();
1005}
1006
1007
1008wxString SCH_SHEET::GetFieldText( const wxString& aFieldName, const SCH_SHEET_PATH* aPath,
1009 const wxString& aVariantName ) const
1010{
1011 wxCHECK_MSG( !aFieldName.IsEmpty(), wxEmptyString, wxT( "Can't get text from a field with no name!" ) );
1012
1013 const SCH_FIELD* field = GetField( aFieldName );
1014
1015 wxCHECK_MSG( field, wxEmptyString, wxT( "Can't get text from a field not yet added to the sheet!" ) );
1016
1017 return GetFieldText( field, aFieldName, aPath, aVariantName );
1018}
1019
1020
1022{
1023 wxASSERT( aSheetPin != nullptr );
1024 wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
1025
1026 if( SCH_SCREEN* screen = GetParentScreen() )
1027 screen->BumpConnectivityRevision();
1028
1029 aSheetPin->SetParent( this );
1030 m_pins.push_back( aSheetPin );
1031 renumberPins();
1032}
1033
1034
1035void SCH_SHEET::RemovePin( const SCH_SHEET_PIN* aSheetPin )
1036{
1037 wxASSERT( aSheetPin != nullptr );
1038 wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
1039
1040 for( auto i = m_pins.begin(); i < m_pins.end(); ++i )
1041 {
1042 if( *i == aSheetPin )
1043 {
1044 if( SCH_SCREEN* screen = GetParentScreen() )
1045 screen->BumpConnectivityRevision();
1046
1047 m_pins.erase( i );
1048 delete aSheetPin;
1049
1050 renumberPins();
1051 return;
1052 }
1053 }
1054}
1055
1056
1057bool SCH_SHEET::HasPin( const wxString& aName ) const
1058{
1059 for( SCH_SHEET_PIN* pin : m_pins )
1060 {
1061 if( pin->GetText().Cmp( aName ) == 0 )
1062 return true;
1063 }
1064
1065 return false;
1066}
1067
1068
1069bool SCH_SHEET::doIsConnected( const VECTOR2I& aPosition ) const
1070{
1071 for( SCH_SHEET_PIN* sheetPin : m_pins )
1072 {
1073 if( sheetPin->GetPosition() == aPosition )
1074 return true;
1075 }
1076
1077 return false;
1078}
1079
1080
1082{
1083 int leftRight = 0;
1084 int topBottom = 0;
1085
1086 for( SCH_SHEET_PIN* pin : m_pins )
1087 {
1088 switch( pin->GetSide() )
1089 {
1090 case SHEET_SIDE::LEFT: leftRight++; break;
1091 case SHEET_SIDE::RIGHT: leftRight++; break;
1092 case SHEET_SIDE::TOP: topBottom++; break;
1093 case SHEET_SIDE::BOTTOM: topBottom++; break;
1094 default: break;
1095 }
1096 }
1097
1098 return topBottom > 0 && leftRight == 0;
1099}
1100
1101
1103{
1104 for( SCH_SHEET_PIN* pin : m_pins )
1105 {
1106 /* Search the schematic for a hierarchical label corresponding to this sheet label. */
1107 const SCH_HIERLABEL* HLabel = nullptr;
1108
1109 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) )
1110 {
1111 if( !pin->GetText().Cmp( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) )
1112 {
1113 HLabel = static_cast<SCH_HIERLABEL*>( aItem );
1114 break;
1115 }
1116 }
1117
1118 if( HLabel == nullptr ) // Corresponding hierarchical label not found.
1119 return true;
1120 }
1121
1122 return false;
1123}
1124
1125
1126int bumpToNextGrid( const int aVal, const int aDirection )
1127{
1128 constexpr int gridSize = schIUScale.MilsToIU( 50 );
1129
1130 int base = aVal / gridSize;
1131 int excess = abs( aVal % gridSize );
1132
1133 // Use floor division for negative coordinates between grid lines.
1134 if( aVal < 0 && excess > 0 )
1135 --base;
1136
1137 if( aDirection > 0 )
1138 {
1139 return ( base + 1 ) * gridSize;
1140 }
1141 else if( excess > 0 )
1142 {
1143 return ( base ) * gridSize;
1144 }
1145 else
1146 {
1147 return ( base - 1 ) * gridSize;
1148 }
1149}
1150
1151
1152int SCH_SHEET::GetMinWidth( bool aFromLeft ) const
1153{
1154 int pinsLeft = m_pos.x + m_size.x;
1155 int pinsRight = m_pos.x;
1156
1157 for( SCH_SHEET_PIN* pin : m_pins)
1158 {
1159 SHEET_SIDE edge = pin->GetSide();
1160
1161 if( edge == SHEET_SIDE::TOP || edge == SHEET_SIDE::BOTTOM )
1162 {
1163 BOX2I pinRect = pin->GetBoundingBox();
1164
1165 pinsLeft = std::min( pinsLeft, pinRect.GetLeft() );
1166 pinsRight = std::max( pinsRight, pinRect.GetRight() );
1167 }
1168 }
1169
1170 pinsLeft = bumpToNextGrid( pinsLeft, -1 );
1171 pinsRight = bumpToNextGrid( pinsRight, 1 );
1172
1173 int pinMinWidth;
1174
1175 if( pinsLeft >= pinsRight )
1176 pinMinWidth = 0;
1177 else if( aFromLeft )
1178 pinMinWidth = pinsRight - m_pos.x;
1179 else
1180 pinMinWidth = m_pos.x + m_size.x - pinsLeft;
1181
1182 return std::max( pinMinWidth, schIUScale.MilsToIU( MIN_SHEET_WIDTH ) );
1183}
1184
1185
1186int SCH_SHEET::GetMinHeight( bool aFromTop ) const
1187{
1188 int pinsTop = m_pos.y + m_size.y;
1189 int pinsBottom = m_pos.y;
1190
1191 for( SCH_SHEET_PIN* pin : m_pins )
1192 {
1193 SHEET_SIDE edge = pin->GetSide();
1194
1195 if( edge == SHEET_SIDE::RIGHT || edge == SHEET_SIDE::LEFT )
1196 {
1197 BOX2I pinRect = pin->GetBoundingBox();
1198
1199 pinsTop = std::min( pinsTop, pinRect.GetTop() );
1200 pinsBottom = std::max( pinsBottom, pinRect.GetBottom() );
1201 }
1202 }
1203
1204 pinsTop = bumpToNextGrid( pinsTop, -1 );
1205 pinsBottom = bumpToNextGrid( pinsBottom, 1 );
1206
1207 int pinMinHeight;
1208
1209 if( pinsTop >= pinsBottom )
1210 pinMinHeight = 0;
1211 else if( aFromTop )
1212 pinMinHeight = pinsBottom - m_pos.y;
1213 else
1214 pinMinHeight = m_pos.y + m_size.y - pinsTop;
1215
1216 return std::max( pinMinHeight, schIUScale.MilsToIU( MIN_SHEET_HEIGHT ) );
1217}
1218
1219
1221{
1222 if( SCH_SCREEN* screen = GetParentScreen() )
1223 screen->BumpConnectivityRevision();
1224
1225 std::vector<SCH_SHEET_PIN*> pins = m_pins;
1226
1227 m_pins.clear();
1228
1229 for( SCH_SHEET_PIN* pin : pins )
1230 {
1231 /* Search the schematic for a hierarchical label corresponding to this sheet label. */
1232 const SCH_HIERLABEL* HLabel = nullptr;
1233
1234 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) )
1235 {
1236 if( pin->GetText().CmpNoCase( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) == 0 )
1237 {
1238 HLabel = static_cast<SCH_HIERLABEL*>( aItem );
1239 break;
1240 }
1241 }
1242
1243 if( HLabel )
1244 m_pins.push_back( pin );
1245 else
1246 delete pin;
1247 }
1248}
1249
1250
1252{
1253 for( SCH_SHEET_PIN* pin : m_pins )
1254 {
1255 if( pin->HitTest( aPosition ) )
1256 return pin;
1257 }
1258
1259 return nullptr;
1260}
1261
1262
1264{
1265 if( GetBorderWidth() > 0 )
1266 return GetBorderWidth();
1267
1268 if( Schematic() )
1270
1271 return schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS );
1272}
1273
1274
1276{
1277 SCH_FIELD* sheetNameField = GetField( FIELD_T::SHEET_NAME );
1278 VECTOR2I textSize = sheetNameField->GetTextSize();
1279 int borderMargin = KiROUND( GetPenWidth() / 2.0 ) + 4;
1280 int margin = borderMargin + KiROUND( std::max( textSize.x, textSize.y ) * 0.5 );
1281
1282 if( IsVerticalOrientation() )
1283 {
1284 sheetNameField->SetTextPos( m_pos + VECTOR2I( -margin, m_size.y ) );
1285 sheetNameField->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1286 sheetNameField->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
1287 sheetNameField->SetTextAngle( ANGLE_VERTICAL );
1288 }
1289 else
1290 {
1291 sheetNameField->SetTextPos( m_pos + VECTOR2I( 0, -margin ) );
1292 sheetNameField->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1293 sheetNameField->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
1294 sheetNameField->SetTextAngle( ANGLE_HORIZONTAL );
1295 }
1296
1297 SCH_FIELD* sheetFilenameField = GetField( FIELD_T::SHEET_FILENAME );
1298
1299 textSize = sheetFilenameField->GetTextSize();
1300 margin = borderMargin + KiROUND( std::max( textSize.x, textSize.y ) * 0.4 );
1301
1302 if( IsVerticalOrientation() )
1303 {
1304 sheetFilenameField->SetTextPos( m_pos + VECTOR2I( m_size.x + margin, m_size.y ) );
1305 sheetFilenameField->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1306 sheetFilenameField->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
1307 sheetFilenameField->SetTextAngle( ANGLE_VERTICAL );
1308 }
1309 else
1310 {
1311 sheetFilenameField->SetTextPos( m_pos + VECTOR2I( 0, m_size.y + margin ) );
1312 sheetFilenameField->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
1313 sheetFilenameField->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
1314 sheetFilenameField->SetTextAngle( ANGLE_HORIZONTAL );
1315 }
1316
1317 if( aAlgo == AUTOPLACE_AUTO || aAlgo == AUTOPLACE_MANUAL )
1318 m_fieldsAutoplaced = aAlgo;
1319}
1320
1321
1322std::vector<int> SCH_SHEET::ViewGetLayers() const
1323{
1324 // Sheet pins are drawn by their parent sheet, so the parent needs to draw to LAYER_DANGLING
1327}
1328
1329
1331{
1332 VECTOR2I end;
1333 BOX2I box( m_pos, m_size );
1334 int lineWidth = GetPenWidth();
1335 int textLength = 0;
1336
1337 // Calculate bounding box X size:
1338 end.x = std::max( m_size.x, textLength );
1339
1340 // Calculate bounding box pos:
1341 end.y = m_size.y;
1342 end += m_pos;
1343
1344 box.SetEnd( end );
1345 box.Inflate( lineWidth / 2 );
1346
1347 return box;
1348}
1349
1350
1352{
1353 BOX2I bbox = GetBodyBoundingBox();
1354
1355 for( const SCH_FIELD& field : m_fields )
1356 if( field.IsVisible() )
1357 bbox.Merge( field.GetBoundingBox() );
1358
1359 for( const SCH_SHEET_PIN* pin : m_pins )
1360 bbox.Merge( pin->GetBoundingBox() );
1361
1362 return bbox;
1363}
1364
1365
1367{
1368 BOX2I box( m_pos, m_size );
1369 return box.GetCenter();
1370}
1371
1372
1374{
1375 int n = 0;
1376
1377 if( m_screen )
1378 {
1379 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SYMBOL_T ) )
1380 {
1381 SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
1382
1383 if( !symbol->IsPower() )
1384 n++;
1385 }
1386
1387 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
1388 n += static_cast<const SCH_SHEET*>( aItem )->SymbolCount();
1389 }
1390
1391 return n;
1392}
1393
1394
1395bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen )
1396{
1397 if( m_screen )
1398 {
1399 // Only check the root sheet once and don't recurse.
1400 if( !GetParent() )
1401 {
1402 if( m_screen && m_screen->GetFileName().Cmp( aFilename ) == 0 )
1403 {
1404 *aScreen = m_screen;
1405 return true;
1406 }
1407 }
1408
1409 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
1410 {
1411 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
1412 SCH_SCREEN* screen = sheet->m_screen;
1413
1414 // Must use the screen's path (which is always absolute) rather than the
1415 // sheet's (which could be relative).
1416 if( screen && screen->GetFileName().Cmp( aFilename ) == 0 )
1417 {
1418 *aScreen = screen;
1419 return true;
1420 }
1421
1422 if( sheet->SearchHierarchy( aFilename, aScreen ) )
1423 return true;
1424 }
1425 }
1426
1427 return false;
1428}
1429
1430
1432{
1433 if( m_screen )
1434 {
1435 aList->push_back( this );
1436
1437 if( m_screen == aScreen )
1438 return true;
1439
1440 for( EDA_ITEM* item : m_screen->Items().OfType( SCH_SHEET_T ) )
1441 {
1442 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
1443
1444 if( sheet->LocatePathOfScreen( aScreen, aList ) )
1445 return true;
1446 }
1447
1448 aList->pop_back();
1449 }
1450
1451 return false;
1452}
1453
1454
1455int SCH_SHEET::CountSheets( const wxString& aFilename ) const
1456{
1457 int count = 0;
1458
1459 if( m_screen )
1460 {
1461 if( m_screen->GetFileName().Cmp( aFilename ) == 0 )
1462 count++;
1463
1464 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
1465 count += static_cast<SCH_SHEET*>( aItem )->CountSheets( aFilename );
1466 }
1467
1468 return count;
1469}
1470
1471
1473{
1474 int count = 1; //1 = this!!
1475
1476 if( m_screen )
1477 {
1478 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
1479 count += static_cast<SCH_SHEET*>( aItem )->CountSheets();
1480 }
1481
1482 return count;
1483}
1484
1485
1487{
1488 int count = CountSheets();
1489
1490 if( IsVirtualRootSheet() )
1491 count--;
1492
1493 return count;
1494}
1495
1496
1497void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1498{
1499 // Don't use GetShownText(); we want to see the variable references here
1500 aList.emplace_back( _( "Sheet Name" ), KIUI::EllipsizeStatusText( aFrame, GetName() ) );
1501
1502 SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
1503 SCH_SHEET_PATH* currentSheet = nullptr;
1504 wxString currentVariant;
1505
1506 if( schframe )
1507 {
1508 SCH_SHEET_PATH path = schframe->GetCurrentSheet();
1509 path.push_back( this );
1510 currentSheet = &schframe->GetCurrentSheet();
1511 currentVariant = Schematic() ? Schematic()->GetCurrentVariant() : wxString();
1512
1513 aList.emplace_back( _( "Hierarchical Path" ), path.PathHumanReadable( false, true ) );
1514 }
1515
1516 // Don't use GetShownText(); we want to see the variable references here
1517 aList.emplace_back( _( "File Name" ), KIUI::EllipsizeStatusText( aFrame, GetFileName() ) );
1518
1519 wxArrayString msgs;
1520 wxString msg;
1521
1522 if( GetExcludedFromSim() )
1523 msgs.Add( _( "Simulation" ) );
1524
1525 if( GetExcludedFromBOM() )
1526 msgs.Add( _( "BOM" ) );
1527
1528 if( GetExcludedFromBoard() )
1529 msgs.Add( _( "Board" ) );
1530
1531 if( GetDNP( currentSheet, currentVariant ) )
1532 msgs.Add( _( "DNP" ) );
1533
1534 msg = wxJoin( msgs, '|' );
1535 msg.Replace( '|', wxS( ", " ) );
1536
1537 if( !msg.empty() )
1538 aList.emplace_back( _( "Exclude from" ), msg );
1539}
1540
1541
1542std::map<SCH_SHEET_PIN*, SCH_NO_CONNECT*> SCH_SHEET::GetNoConnects() const
1543{
1544 std::map<SCH_SHEET_PIN*, SCH_NO_CONNECT*> noConnects;
1545
1546 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( GetParent() );
1547
1548 // A top level sheet is parented to the root sheet rather than to the root screen, so reach
1549 // the screen that holds this sheet through the parent sheet instead
1550 if( !screen )
1551 {
1552 if( SCH_SHEET* parentSheet = dynamic_cast<SCH_SHEET*>( GetParent() ) )
1553 screen = parentSheet->GetScreen();
1554 }
1555
1556 if( screen )
1557 {
1558 for( SCH_SHEET_PIN* sheetPin : m_pins )
1559 {
1560 for( SCH_ITEM* noConnect : screen->Items().Overlapping( SCH_NO_CONNECT_T, sheetPin->GetTextPos() ) )
1561 noConnects[sheetPin] = static_cast<SCH_NO_CONNECT*>( noConnect );
1562 }
1563 }
1564
1565 return noConnects;
1566}
1567
1568
1570{
1571 VECTOR2I delta = aPosition - m_pos;
1572
1573 m_pos = aPosition;
1574
1575 for( SCH_FIELD& field : m_fields )
1576 field.Move( delta );
1577}
1578
1579
1580void SCH_SHEET::Move( const VECTOR2I& aMoveVector )
1581{
1582 m_pos += aMoveVector;
1583
1584 for( SCH_SHEET_PIN* pin : m_pins )
1585 pin->Move( aMoveVector );
1586
1587 for( SCH_FIELD& field : m_fields )
1588 field.Move( aMoveVector );
1589}
1590
1591
1592void SCH_SHEET::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
1593{
1594 VECTOR2I prev = m_pos;
1595
1596 RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
1597 RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_90 : ANGLE_270 );
1598
1599 if( m_size.x < 0 )
1600 {
1601 m_pos.x += m_size.x;
1602 m_size.x = -m_size.x;
1603 }
1604
1605 if( m_size.y < 0 )
1606 {
1607 m_pos.y += m_size.y;
1608 m_size.y = -m_size.y;
1609 }
1610
1611 // Pins must be rotated first as that's how we determine vertical vs horizontal
1612 // orientation for auto-placement
1613 for( SCH_SHEET_PIN* sheetPin : m_pins )
1614 sheetPin->Rotate( aCenter, aRotateCCW );
1615
1617 {
1619 }
1620 else
1621 {
1622 // Move the fields to the new position because the parent itself has moved.
1623 for( SCH_FIELD& field : m_fields )
1624 {
1625 VECTOR2I pos = field.GetTextPos();
1626 pos.x -= prev.x - m_pos.x;
1627 pos.y -= prev.y - m_pos.y;
1628 field.SetTextPos( pos );
1629 }
1630 }
1631}
1632
1633
1635{
1636 int dy = m_pos.y;
1637
1638 MIRROR( m_pos.y, aCenter );
1639 m_pos.y -= m_size.y;
1640 dy -= m_pos.y; // 0,dy is the move vector for this transform
1641
1642 for( SCH_SHEET_PIN* sheetPin : m_pins )
1643 sheetPin->MirrorVertically( aCenter );
1644
1645 for( SCH_FIELD& field : m_fields )
1646 {
1647 VECTOR2I pos = field.GetTextPos();
1648 pos.y -= dy;
1649 field.SetTextPos( pos );
1650 }
1651}
1652
1653
1655{
1656 int dx = m_pos.x;
1657
1658 MIRROR( m_pos.x, aCenter );
1659 m_pos.x -= m_size.x;
1660 dx -= m_pos.x; // dx,0 is the move vector for this transform
1661
1662 for( SCH_SHEET_PIN* sheetPin : m_pins )
1663 sheetPin->MirrorHorizontally( aCenter );
1664
1665 for( SCH_FIELD& field : m_fields )
1666 {
1667 VECTOR2I pos = field.GetTextPos();
1668 pos.x -= dx;
1669 field.SetTextPos( pos );
1670 }
1671}
1672
1673
1674void SCH_SHEET::SetPosition( const VECTOR2I& aPosition )
1675{
1676 // Remember the sheet and all pin sheet positions must be
1677 // modified. So use Move function to do that.
1678 Move( aPosition - m_pos );
1679}
1680
1681
1682void SCH_SHEET::Resize( const VECTOR2I& aSize )
1683{
1684 if( aSize == m_size )
1685 return;
1686
1687 m_size = aSize;
1688
1689 // Move the fields if we're in autoplace mode
1692
1693 // Move the sheet labels according to the new sheet size.
1694 for( SCH_SHEET_PIN* sheetPin : m_pins )
1695 sheetPin->ConstrainOnEdge( sheetPin->GetPosition(), false );
1696}
1697
1698
1699bool SCH_SHEET::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
1700{
1701 // Sheets are searchable via the child field and pin item text.
1702 return false;
1703}
1704
1705
1707{
1708 int id = 2;
1709
1710 for( SCH_SHEET_PIN* pin : m_pins )
1711 {
1712 pin->SetNumber( id );
1713 id++;
1714 }
1715}
1716
1717
1719{
1720 wxCHECK_MSG( Schematic(), SCH_SHEET_PATH(), "Can't call findSelf without a schematic" );
1721
1722 SCH_SHEET_PATH sheetPath = Schematic()->CurrentSheet();
1723
1724 while( !sheetPath.empty() && sheetPath.Last() != this )
1725 sheetPath.pop_back();
1726
1727 if( sheetPath.empty() )
1728 {
1729 // If we weren't in the hierarchy, then we must be a child of the current sheet.
1730 sheetPath = Schematic()->CurrentSheet();
1731 sheetPath.push_back( const_cast<SCH_SHEET*>( this ) );
1732 }
1733
1734 return sheetPath;
1735}
1736
1737
1738void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
1739{
1740 for( SCH_SHEET_PIN* sheetPin : m_pins )
1741 {
1742 wxCHECK2_MSG( sheetPin->Type() == SCH_SHEET_PIN_T, continue,
1743 wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) );
1744
1745 sheetPin->GetEndPoints( aItemList );
1746 }
1747}
1748
1749
1750bool SCH_SHEET::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
1751 std::vector<DANGLING_END_ITEM>& aItemListByPos,
1752 const SCH_SHEET_PATH* aPath )
1753{
1754 bool changed = false;
1755
1756 for( SCH_SHEET_PIN* sheetPin : m_pins )
1757 changed |= sheetPin->UpdateDanglingState( aItemListByType, aItemListByPos );
1758
1759 return changed;
1760}
1761
1762
1763bool SCH_SHEET::HasConnectivityChanges( const SCH_ITEM* aItem, const SCH_SHEET_PATH* aInstance ) const
1764{
1765 // Do not compare to ourself.
1766 if( aItem == this )
1767 return false;
1768
1769 const SCH_SHEET* sheet = dynamic_cast<const SCH_SHEET*>( aItem );
1770
1771 // Don't compare against a different SCH_ITEM.
1772 wxCHECK( sheet, false );
1773
1774 if( GetPosition() != sheet->GetPosition() )
1775 return true;
1776
1777 // Technically this cannot happen because undo/redo does not support reloading sheet
1778 // file association changes. This was just added so that it doesn't get missed should
1779 // we ever fix the undo/redo issue.
1780 if( ( GetFileName() != sheet->GetFileName() ) || ( GetName() != sheet->GetName() ) )
1781 return true;
1782
1783 if( m_pins.size() != sheet->m_pins.size() )
1784 return true;
1785
1786 for( size_t i = 0; i < m_pins.size(); i++ )
1787 {
1788 if( m_pins[i]->HasConnectivityChanges( sheet->m_pins[i] ) )
1789 return true;
1790 }
1791
1792 return false;
1793}
1794
1795
1796std::vector<VECTOR2I> SCH_SHEET::GetConnectionPoints() const
1797{
1798 std::vector<VECTOR2I> retval;
1799
1800 for( SCH_SHEET_PIN* sheetPin : m_pins )
1801 retval.push_back( sheetPin->GetPosition() );
1802
1803 return retval;
1804}
1805
1806
1807INSPECT_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData, const std::vector<KICAD_T>& aScanTypes )
1808{
1809 for( KICAD_T scanType : aScanTypes )
1810 {
1811 // If caller wants to inspect my type
1812 if( scanType == SCH_LOCATE_ANY_T || scanType == Type() )
1813 {
1814 if( INSPECT_RESULT::QUIT == aInspector( this, nullptr ) )
1815 return INSPECT_RESULT::QUIT;
1816 }
1817
1818 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_FIELD_T )
1819 {
1820 // Test the sheet fields.
1821 for( SCH_FIELD& field : m_fields )
1822 {
1823 if( INSPECT_RESULT::QUIT == aInspector( &field, this ) )
1824 return INSPECT_RESULT::QUIT;
1825 }
1826 }
1827
1828 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_SHEET_PIN_T )
1829 {
1830 // Test the sheet labels.
1831 for( SCH_SHEET_PIN* sheetPin : m_pins )
1832 {
1833 if( INSPECT_RESULT::QUIT == aInspector( sheetPin, this ) )
1834 return INSPECT_RESULT::QUIT;
1835 }
1836 }
1837 }
1838
1840}
1841
1842
1843void SCH_SHEET::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode )
1844{
1845 for( SCH_FIELD& field : m_fields )
1846 aFunction( &field );
1847
1848 for( SCH_SHEET_PIN* pin : m_pins )
1849 aFunction( pin );
1850}
1851
1852
1853wxString SCH_SHEET::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
1854{
1855 const SCH_FIELD* sheetnameField = GetField( FIELD_T::SHEET_NAME );
1856
1857 return wxString::Format( _( "Hierarchical Sheet '%s'" ),
1858 aFull ? sheetnameField->GetShownText( FOR_GUI )
1859 : KIUI::EllipsizeMenuText( sheetnameField->GetText() ) );
1860}
1861
1862
1867
1868
1869bool SCH_SHEET::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1870{
1872
1873 rect.Inflate( aAccuracy );
1874
1875 return rect.Contains( aPosition );
1876}
1877
1878
1879bool SCH_SHEET::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1880{
1881 BOX2I rect = aRect;
1882
1883 rect.Inflate( aAccuracy );
1884
1885 if( aContained )
1886 return rect.Contains( GetBodyBoundingBox() );
1887
1888 return rect.Intersects( GetBodyBoundingBox() );
1889}
1890
1891
1892bool SCH_SHEET::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
1893{
1894 return KIGEOM::BoxHitTest( aPoly, GetBodyBoundingBox(), aContained );
1895}
1896
1897
1898void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
1899 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
1900{
1901 if( aBackground && !aPlotter->GetColorMode() )
1902 return;
1903
1904 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
1905 COLOR4D borderColor = GetBorderColor();
1906 COLOR4D backgroundColor = GetBackgroundColor();
1907 SCH_SHEET_PATH instance;
1908 wxString variantName;
1909
1910 if( Schematic() )
1911 {
1912 instance = Schematic()->CurrentSheet();
1913 variantName = Schematic()->GetCurrentVariant();
1914 }
1915
1916 bool dnp = GetDNP( &instance, variantName );
1917
1918 if( renderSettings->m_OverrideItemColors || borderColor == COLOR4D::UNSPECIFIED )
1919 borderColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET );
1920
1921 if( renderSettings->m_OverrideItemColors || backgroundColor == COLOR4D::UNSPECIFIED )
1922 backgroundColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET_BACKGROUND );
1923
1924 if( borderColor.m_text && Schematic() )
1925 borderColor = COLOR4D( ResolveText( *borderColor.m_text, &Schematic()->CurrentSheet() ) );
1926
1927 if( backgroundColor.m_text && Schematic() )
1928 backgroundColor = COLOR4D( ResolveText( *backgroundColor.m_text, &Schematic()->CurrentSheet() ) );
1929
1930 if( aDimmed || dnp )
1931 {
1932 borderColor.Desaturate();
1933 borderColor = borderColor.Mix( backgroundColor, 0.5f );
1934 }
1935
1936 if( aBackground && backgroundColor.a > 0.0 )
1937 {
1938 aPlotter->SetColor( backgroundColor );
1939 aPlotter->Rect( m_pos, m_pos + m_size, FILL_T::FILLED_SHAPE, 1, 0 );
1940 }
1941 else
1942 {
1943 aPlotter->SetColor( borderColor );
1944
1945 int penWidth = GetEffectivePenWidth( getRenderSettings( aPlotter ) );
1946 aPlotter->Rect( m_pos, m_pos + m_size, FILL_T::NO_FILL, penWidth, 0 );
1947 }
1948
1949 // Make the sheet object a clickable hyperlink (e.g. for PDF plotter)
1950 if( aPlotOpts.m_PDFHierarchicalLinks )
1951 {
1952 aPlotter->HyperlinkBox( GetBoundingBox(), EDA_TEXT::GotoPageHref( findSelf().GetPageNumber() ) );
1953 }
1954 else if( aPlotOpts.m_PDFPropertyPopups )
1955 {
1956 std::vector<wxString> properties;
1957
1958 properties.emplace_back( EDA_TEXT::GotoPageHref( findSelf().GetPageNumber() ) );
1959
1960 for( const SCH_FIELD& field : GetFields() )
1961 {
1962 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
1963 field.GetName(),
1964 field.GetShownText( FOR_GUI ) ) );
1965 }
1966
1967 aPlotter->HyperlinkMenu( GetBoundingBox(), properties );
1968 }
1969
1970 // Plot sheet pins
1971 for( SCH_SHEET_PIN* sheetPin : m_pins )
1972 sheetPin->Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed || dnp );
1973
1974 // Plot the fields
1975 for( SCH_FIELD& field : m_fields )
1976 field.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed || dnp );
1977
1978 if( dnp && renderSettings->m_ShowDNPMarkers )
1979 {
1980 BOX2I bbox = GetBodyBoundingBox();
1981 BOX2I pins = GetBoundingBox();
1982 VECTOR2D margins( std::max( bbox.GetX() - pins.GetX(), pins.GetEnd().x - bbox.GetEnd().x ),
1983 std::max( bbox.GetY() - pins.GetY(), pins.GetEnd().y - bbox.GetEnd().y ) );
1984 int strokeWidth = 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS );
1985
1986 margins.x = std::max( margins.x * 0.6, margins.y * 0.3 );
1987 margins.y = std::max( margins.y * 0.6, margins.x * 0.3 );
1988 bbox.Inflate( KiROUND( margins.x ), KiROUND( margins.y ) );
1989
1990 aPlotter->SetColor( renderSettings->GetLayerColor( LAYER_DNP_MARKER ) );
1991
1992 aPlotter->ThickSegment( bbox.GetOrigin(), bbox.GetEnd(), strokeWidth, nullptr );
1993
1994 aPlotter->ThickSegment( bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ),
1995 bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ),
1996 strokeWidth, nullptr );
1997 }
1998}
1999
2000
2002{
2003 wxCHECK_MSG( Type() == aItem.Type(), *this,
2004 wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) + GetClass() );
2005
2006 if( &aItem != this )
2007 {
2008 SCH_ITEM::operator=( aItem );
2009
2010 SCH_SHEET* sheet = (SCH_SHEET*) &aItem;
2011
2012 m_pos = sheet->m_pos;
2013 m_size = sheet->m_size;
2014 m_fields = sheet->m_fields;
2015
2016 // Reparent fields after assignment to new sheet.
2017 for( SCH_FIELD& field : m_fields )
2018 field.SetParent( this );
2019
2020 for( SCH_SHEET_PIN* pin : m_pins )
2021 delete pin;
2022
2023 m_pins.clear();
2024
2025 for( SCH_SHEET_PIN* pin : sheet->m_pins )
2026 {
2027 m_pins.emplace_back( new SCH_SHEET_PIN( *pin ) );
2028 m_pins.back()->SetParent( this );
2029 }
2030
2031 m_instances.clear();
2032
2033 for( const SCH_SHEET_INSTANCE& instance : sheet->m_instances )
2034 m_instances.emplace_back( instance );
2035 }
2036
2037 return *this;
2038}
2039
2040
2041bool SCH_SHEET::operator <( const SCH_ITEM& aItem ) const
2042{
2043 if( Type() != aItem.Type() )
2044 return Type() < aItem.Type();
2045
2046 const SCH_SHEET* otherSheet = static_cast<const SCH_SHEET*>( &aItem );
2047
2048 if( GetName() != otherSheet->GetName() )
2049 return GetName() < otherSheet->GetName();
2050
2051 if( GetFileName() != otherSheet->GetFileName() )
2052 return GetFileName() < otherSheet->GetFileName();
2053
2054 return false;
2055}
2056
2057
2058void SCH_SHEET::RemoveInstance( const KIID_PATH& aInstancePath )
2059{
2060 // Search for an existing path and remove it if found (should not occur)
2061 // (search from back to avoid invalidating iterator on remove)
2062 for( int ii = (int) m_instances.size() - 1; ii >= 0; --ii )
2063 {
2064 if( m_instances[ii].m_Path == aInstancePath )
2065 {
2066 wxLogTrace( traceSchSheetPaths, "Removing sheet instance:\n"
2067 " sheet path %s\n"
2068 " page %s, from project %s.",
2069 aInstancePath.AsString(),
2070 m_instances[ii].m_PageNumber,
2071 m_instances[ii].m_ProjectName );
2072
2073 m_instances.erase( m_instances.begin() + ii );
2074 }
2075 }
2076}
2077
2078
2080{
2081 SCH_SHEET_INSTANCE oldInstance;
2082
2083 if( getInstance( oldInstance, aInstance.m_Path ) )
2084 RemoveInstance( aInstance.m_Path );
2085
2086 m_instances.emplace_back( aInstance );
2087
2088}
2089
2090
2092{
2093 for( const SCH_SHEET_INSTANCE& instance : m_instances )
2094 {
2095 // if aSheetPath is found, nothing to do:
2096 if( instance.m_Path == aPath )
2097 return false;
2098 }
2099
2100 wxLogTrace( traceSchSheetPaths, wxT( "Adding instance `%s` to sheet `%s`." ), aPath.AsString(),
2101 GetName().IsEmpty() ? wxString( wxT( "root" ) ) : GetName() );
2102
2103 SCH_SHEET_INSTANCE instance;
2104
2105 instance.m_Path = aPath;
2106
2107 // This entry does not exist: add it with an empty page number.
2108 m_instances.emplace_back( instance );
2109 return true;
2110}
2111
2112
2113bool SCH_SHEET::getInstance( SCH_SHEET_INSTANCE& aInstance, const KIID_PATH& aSheetPath, bool aTestFromEnd ) const
2114{
2115 for( const SCH_SHEET_INSTANCE& instance : m_instances )
2116 {
2117 if( !aTestFromEnd )
2118 {
2119 if( instance.m_Path == aSheetPath )
2120 {
2121 aInstance = instance;
2122 return true;
2123 }
2124 }
2125 else if( instance.m_Path.EndsWith( aSheetPath ) )
2126 {
2127 aInstance = instance;
2128 return true;
2129 }
2130 }
2131
2132 return false;
2133}
2134
2135
2137{
2138 for( SCH_SHEET_INSTANCE& instance : m_instances )
2139 {
2140 if( instance.m_Path == aSheetPath )
2141 return &instance;
2142 }
2143
2144 return nullptr;
2145}
2146
2147
2148const SCH_SHEET_INSTANCE* SCH_SHEET::getInstance( const KIID_PATH& aSheetPath ) const
2149{
2150 for( const SCH_SHEET_INSTANCE& instance : m_instances )
2151 {
2152 if( instance.m_Path == aSheetPath )
2153 return &instance;
2154 }
2155
2156 return nullptr;
2157}
2158
2159
2161{
2162 for( const SCH_SHEET_INSTANCE& instance : m_instances )
2163 {
2164 if( instance.m_Path.size() == 0 )
2165 return true;
2166 }
2167
2168 return false;
2169}
2170
2171
2173{
2174 for( const SCH_SHEET_INSTANCE& instance : m_instances )
2175 {
2176 if( instance.m_Path.size() == 0 )
2177 return instance;
2178 }
2179
2180 wxFAIL;
2181
2183
2184 return dummy;
2185}
2186
2187
2188wxString SCH_SHEET::getPageNumber( const KIID_PATH& aParentPath ) const
2189{
2190 wxString pageNumber;
2191
2192 for( const SCH_SHEET_INSTANCE& instance : m_instances )
2193 {
2194 if( instance.m_Path == aParentPath )
2195 {
2196 pageNumber = instance.m_PageNumber;
2197 break;
2198 }
2199 }
2200
2201 return pageNumber;
2202}
2203
2204
2205void SCH_SHEET::setPageNumber( const KIID_PATH& aPath, const wxString& aPageNumber )
2206{
2207 for( SCH_SHEET_INSTANCE& instance : m_instances )
2208 {
2209 if( instance.m_Path == aPath )
2210 {
2211 instance.m_PageNumber = aPageNumber;
2212 break;
2213 }
2214 }
2215}
2216
2217
2219{
2220 return GetName() != aOther.GetName()
2221 || GetFileName() != aOther.GetFileName()
2222 || GetScreen() != aOther.GetScreen()
2223 || HasPageNumberChanges( aOther )
2224 || HasRefSuffixChanges( aOther );
2225}
2226
2227
2229{
2230 const SCHEMATIC* schematic = Schematic() ? Schematic() : aOther.Schematic();
2231
2233 && !( schematic && schematic->HasRefSuffixFields() ) )
2234 {
2235 return false;
2236 }
2237
2238 // A suffix can resolve any sheet field on its path, so every field edit may move one
2239 return !std::ranges::equal( m_fields, aOther.m_fields,
2240 []( const SCH_FIELD& a, const SCH_FIELD& b )
2241 {
2242 return a.GetName() == b.GetName() && a.GetText() == b.GetText();
2243 } );
2244}
2245
2246
2248{
2249 SCH_SCREENS screens( this );
2250
2251 for( SCH_SCREEN* screen = screens.GetFirst(); screen; screen = screens.GetNext() )
2252 screen->SetContentModified();
2253}
2254
2255
2257{
2258 return !std::ranges::equal( m_pins, aOther.m_pins, {}, &SCH_SHEET_PIN::m_Uuid, &SCH_SHEET_PIN::m_Uuid );
2259}
2260
2261
2263{
2264 // Avoid self comparison.
2265 if( &aOther == this )
2266 return false;
2267
2268 // A difference in the instance data count implies a page numbering change.
2269 if( GetInstances().size() != aOther.GetInstances().size() )
2270 return true;
2271
2272 std::vector<SCH_SHEET_INSTANCE> instances = GetInstances();
2273 std::vector<SCH_SHEET_INSTANCE> otherInstances = aOther.GetInstances();
2274
2275 // Sorting may not be necessary but there is no guarantee that sheet
2276 // instance data will be in the correct KIID_PATH order. We should
2277 // probably use a std::map instead of a std::vector to store the sheet
2278 // instance data.
2279 std::sort( instances.begin(), instances.end(),
2280 []( const SCH_SHEET_INSTANCE& aLhs, const SCH_SHEET_INSTANCE& aRhs )
2281 {
2282 if( aLhs.m_Path > aRhs.m_Path )
2283 return true;
2284
2285 return false;
2286 } );
2287 std::sort( otherInstances.begin(), otherInstances.end(),
2288 []( const SCH_SHEET_INSTANCE& aLhs, const SCH_SHEET_INSTANCE& aRhs )
2289 {
2290 if( aLhs.m_Path > aRhs.m_Path )
2291 return true;
2292
2293 return false;
2294 } );
2295
2296 auto itThis = instances.begin();
2297 auto itOther = otherInstances.begin();
2298
2299 while( itThis != instances.end() )
2300 {
2301 if( itThis->m_Path == itOther->m_Path
2302 && itThis->m_PageNumber != itOther->m_PageNumber )
2303 {
2304 return true;
2305 }
2306
2307 itThis++;
2308 itOther++;
2309 }
2310
2311 return false;
2312}
2313
2314
2315int SCH_SHEET::ComparePageNum( const wxString& aPageNumberA, const wxString& aPageNumberB )
2316{
2317 if( aPageNumberA == aPageNumberB )
2318 return 0; // A == B
2319
2320 // First sort numerically if the page numbers are integers
2321 long pageA, pageB;
2322 bool isIntegerPageA = aPageNumberA.ToLong( &pageA );
2323 bool isIntegerPageB = aPageNumberB.ToLong( &pageB );
2324
2325 if( isIntegerPageA && isIntegerPageB )
2326 {
2327 if( pageA < pageB )
2328 return -1; //A < B
2329 else
2330 return 1; // A > B
2331 }
2332
2333 // Numerical page numbers always before strings
2334 if( isIntegerPageA )
2335 return -1; //A < B
2336 else if( isIntegerPageB )
2337 return 1; // A > B
2338
2339 // If not numeric, then sort as strings using natural sort
2340 int result = StrNumCmp( aPageNumberA, aPageNumberB );
2341
2342 // Divide by zero bad.
2343 wxCHECK( result != 0, 0 );
2344
2346
2347 return result;
2348}
2349
2350
2351bool SCH_SHEET::operator==( const SCH_ITEM& aOther ) const
2352{
2353 if( Type() != aOther.Type() )
2354 return false;
2355
2356 const SCH_SHEET* other = static_cast<const SCH_SHEET*>( &aOther );
2357
2358 if( m_pos != other->m_pos )
2359 return false;
2360
2361 if( m_size != other->m_size )
2362 return false;
2363
2364 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
2365 return false;
2366
2367 if( GetExcludedFromBOM() != other->GetExcludedFromBOM() )
2368 return false;
2369
2370 if( GetExcludedFromBoard() != other->GetExcludedFromBoard() )
2371 return false;
2372
2373 if( GetDNP() != other->GetDNP() )
2374 return false;
2375
2376 if( GetBorderColor() != other->GetBorderColor() )
2377 return false;
2378
2379 if( GetBackgroundColor() != other->GetBackgroundColor() )
2380 return false;
2381
2382 if( GetBorderWidth() != other->GetBorderWidth() )
2383 return false;
2384
2385 if( GetFields().size() != other->GetFields().size() )
2386 return false;
2387
2388 for( size_t i = 0; i < GetFields().size(); ++i )
2389 {
2390 if( GetFields()[i] != other->GetFields()[i] )
2391 return false;
2392 }
2393
2394 if( GetPins().size() != other->GetPins().size() )
2395 return false;
2396
2397 for( size_t ii = 0; ii < GetPins().size(); ++ii )
2398 {
2399 if( !GetPins()[ii]->operator==( other->GetPins()[ii] ) )
2400 return false;
2401 }
2402
2403 return true;
2404}
2405
2406
2407double SCH_SHEET::Similarity( const SCH_ITEM& aOther ) const
2408{
2409 if( Type() != aOther.Type() )
2410 return 0.0;
2411
2412 const SCH_SHEET* other = static_cast<const SCH_SHEET*>( &aOther );
2413
2414 if( m_screen->GetFileName() == other->m_screen->GetFileName() )
2415 return 1.0;
2416
2417 return 0.0;
2418}
2419
2420
2421void SCH_SHEET::AddVariant( const SCH_SHEET_PATH& aInstance, const SCH_SHEET_VARIANT& aVariant )
2422{
2423 SCH_SHEET_INSTANCE* instance = getInstance( aInstance );
2424
2425 // The instance path must already exist.
2426 if( !instance )
2427 return;
2428
2429 if( instance->m_Variants.insert( std::make_pair( aVariant.m_Name, aVariant ) ).second )
2431}
2432
2433
2434void SCH_SHEET::DeleteVariant( const KIID_PATH& aPath, const wxString& aVariantName )
2435{
2436 SCH_SHEET_INSTANCE* instance = getInstance( aPath );
2437
2438 // The instance path must already exist.
2439 if( !instance || !instance->m_Variants.contains( aVariantName ) )
2440 return;
2441
2442 instance->m_Variants.erase( aVariantName );
2443
2445}
2446
2447
2448void SCH_SHEET::ClearVariantField( const KIID_PATH& aPath, const wxString& aVariantName,
2449 const wxString& aFieldName )
2450{
2451 SCH_SHEET_INSTANCE* instance = getInstance( aPath );
2452
2453 if( !instance || !instance->m_Variants.contains( aVariantName ) )
2454 return;
2455
2456 if( instance->m_Variants[aVariantName].m_Fields.erase( aFieldName ) )
2458}
2459
2460
2461void SCH_SHEET::RenameVariant( const KIID_PATH& aPath, const wxString& aOldName, const wxString& aNewName )
2462{
2463 SCH_SHEET_INSTANCE* instance = getInstance( aPath );
2464
2465 // The instance path must already exist and contain the old variant.
2466 if( aOldName == aNewName || !instance || !instance->m_Variants.contains( aOldName ) )
2467 return;
2468
2469 // Get the variant data, update the name, and re-insert with new key
2470 SCH_SHEET_VARIANT variant = instance->m_Variants[aOldName];
2471 variant.m_Name = aNewName;
2472 instance->m_Variants.erase( aOldName );
2473 instance->m_Variants.insert( std::make_pair( aNewName, variant ) );
2474
2476}
2477
2478
2479void SCH_SHEET::CopyVariant( const KIID_PATH& aPath, const wxString& aSourceVariant, const wxString& aNewVariant )
2480{
2481 SCH_SHEET_INSTANCE* instance = getInstance( aPath );
2482
2483 // The instance path must already exist and contain the source variant.
2484 if( !instance || !instance->m_Variants.contains( aSourceVariant ) )
2485 return;
2486
2487 // Copy the variant data with a new name
2488 SCH_SHEET_VARIANT variant = instance->m_Variants[aSourceVariant];
2489 variant.m_Name = aNewVariant;
2490
2491 if( instance->m_Variants.insert( std::make_pair( aNewVariant, variant ) ).second )
2493}
2494
2495
2496void SCH_SHEET::setVariantAttribute( bool aEnable, const SCH_SHEET_PATH* aInstance, const wxString& aVariantName,
2497 bool SCH_SHEET::*aBase, bool SCH_SHEET_VARIANT::*aOverride )
2498{
2499 bool* attribute = &( this->*aBase );
2500
2501 if( aInstance && !aVariantName.IsEmpty() )
2502 {
2503 SCH_SHEET_INSTANCE* instance = getInstance( *aInstance );
2504
2505 wxCHECK_MSG( instance, /* void */,
2506 wxString::Format( wxS( "Cannot set attribute for invalid sheet path '%s'." ),
2507 aInstance->PathHumanReadable() ) );
2508
2509 auto variant = instance->m_Variants.find( aVariantName );
2510
2511 if( variant == instance->m_Variants.end() )
2512 {
2513 if( aEnable == this->*aBase )
2514 return;
2515
2516 SCH_SHEET_VARIANT newVariant( aVariantName );
2517 newVariant.InitializeAttributes( *this );
2518 newVariant.*aOverride = aEnable;
2519 AddVariant( *aInstance, newVariant );
2520 return;
2521 }
2522
2523 attribute = &( variant->second.*aOverride );
2524 }
2525
2526 if( *attribute == aEnable )
2527 return;
2528
2529 *attribute = aEnable;
2531}
2532
2533
2534void SCH_SHEET::SetDNP( bool aEnable, const SCH_SHEET_PATH* aInstance, const wxString& aVariantName )
2535{
2536 setVariantAttribute( aEnable, aInstance, aVariantName, &SCH_SHEET::m_DNP, &SCH_SHEET_VARIANT::m_DNP );
2537}
2538
2539
2540bool SCH_SHEET::GetDNP( const SCH_SHEET_PATH* aInstance, const wxString& aVariantName ) const
2541{
2542 if( !aInstance || aVariantName.IsEmpty() )
2543 return m_DNP;
2544
2545 SCH_SHEET_INSTANCE instance;
2546
2547 if( !getInstance( instance, aInstance->Path() ) )
2548 return m_DNP;
2549
2550 if( instance.m_Variants.contains( aVariantName ) )
2551 return instance.m_Variants[aVariantName].m_DNP;
2552
2553 // If the variant has not been defined, return the default DNP setting.
2554 return m_DNP;
2555}
2556
2557
2559{
2560 return GetDNP( &Schematic()->CurrentSheet(), Schematic()->GetCurrentVariant() );
2561}
2562
2563
2564void SCH_SHEET::SetDNPProp( bool aEnable )
2565{
2566 SetDNP( aEnable, &Schematic()->CurrentSheet(), Schematic()->GetCurrentVariant() );
2567}
2568
2569
2570void SCH_SHEET::SetExcludedFromSim( bool aEnable, const SCH_SHEET_PATH* aInstance, const wxString& aVariantName )
2571{
2572 setVariantAttribute( aEnable, aInstance, aVariantName, &SCH_SHEET::m_excludedFromSim,
2574}
2575
2576
2577bool SCH_SHEET::GetExcludedFromSim( const SCH_SHEET_PATH* aInstance, const wxString& aVariantName ) const
2578{
2579 if( !aInstance || aVariantName.IsEmpty() )
2580 return m_excludedFromSim;
2581
2582 SCH_SHEET_INSTANCE instance;
2583
2584 if( !getInstance( instance, aInstance->Path() ) )
2585 return m_excludedFromSim;
2586
2587 if( instance.m_Variants.contains( aVariantName ) )
2588 return instance.m_Variants[aVariantName].m_ExcludedFromSim;
2589
2590 // If the variant has not been defined, return the default DNP setting.
2591 return m_excludedFromSim;
2592}
2593
2594
2596{
2597 return GetExcludedFromSim( &Schematic()->CurrentSheet(), Schematic()->GetCurrentVariant() );
2598}
2599
2600
2602{
2603 SetExcludedFromSim( aEnable, &Schematic()->CurrentSheet(), Schematic()->GetCurrentVariant() );
2604}
2605
2606
2607void SCH_SHEET::SetExcludedFromBOM( bool aEnable, const SCH_SHEET_PATH* aInstance, const wxString& aVariantName )
2608{
2609 setVariantAttribute( aEnable, aInstance, aVariantName, &SCH_SHEET::m_excludedFromBOM,
2611}
2612
2613
2614bool SCH_SHEET::GetExcludedFromBOM( const SCH_SHEET_PATH* aInstance, const wxString& aVariantName ) const
2615{
2616 if( !aInstance || aVariantName.IsEmpty() )
2617 return m_excludedFromBOM;
2618
2619 SCH_SHEET_INSTANCE instance;
2620
2621 if( !getInstance( instance, aInstance->Path() ) )
2622 return m_excludedFromBOM;
2623
2624 if( instance.m_Variants.contains( aVariantName ) )
2625 return instance.m_Variants[aVariantName].m_ExcludedFromBOM;
2626
2627 // If the variant has not been defined, return the default DNP setting.
2628 return m_excludedFromBOM;
2629}
2630
2631
2633{
2634 return GetExcludedFromBOM( &Schematic()->CurrentSheet(), Schematic()->GetCurrentVariant() );
2635}
2636
2637
2639{
2640 SetExcludedFromBOM( aEnable, &Schematic()->CurrentSheet(), Schematic()->GetCurrentVariant() );
2641}
2642
2643
2644#if defined(DEBUG)
2645
2646void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const
2647{
2648 // XML output:
2649 wxString s = GetClass();
2650
2651 NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" << " sheet_name=\""
2652 << TO_UTF8( GetName() ) << '"' << ">\n";
2653
2654 // show all the pins, and check the linked list integrity
2655 for( SCH_SHEET_PIN* sheetPin : m_pins )
2656 sheetPin->Show( nestLevel + 1, os );
2657
2658 NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" << std::flush;
2659}
2660
2661#endif
2662
2663static struct SCH_SHEET_DESC
2664{
2666 {
2670
2671 propMgr.AddProperty( new PROPERTY<SCH_SHEET, wxString>( _HKI( "Sheet Name" ),
2673 .SetValidator( []( const wxAny&& aValue, EDA_ITEM* ) -> VALIDATOR_RESULT
2674 {
2675 wxString value;
2676
2677 if( !aValue.GetAs( &value ) )
2678 return {};
2679
2680 wxString msg = GetFieldValidationErrorMessage( FIELD_T::SHEET_NAME, value );
2681
2682 if( msg.empty() )
2683 return {};
2684
2685 return std::make_unique<VALIDATION_ERROR_MSG>( msg );
2686 } );
2687
2688 propMgr.AddProperty( new PROPERTY<SCH_SHEET, wxString>( _HKI( "Full Suffix" ),
2690 .SetAvailableFunc( []( INSPECTABLE* aObject )
2691 {
2692 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( aObject );
2693 return sheet && !sheet->GetFullRefSuffixProp().IsEmpty();
2694 } );
2695
2696 propMgr.AddProperty( new PROPERTY<SCH_SHEET, int>( _HKI( "Border Width" ),
2698
2699 propMgr.AddProperty( new PROPERTY<SCH_SHEET, COLOR4D>( _HKI( "Border Color" ),
2701
2702 propMgr.AddProperty( new PROPERTY<SCH_SHEET, COLOR4D>( _HKI( "Background Color" ),
2704
2705 const wxString groupAttributes = _HKI( "Attributes" );
2706
2707 propMgr.AddProperty( new PROPERTY<SCH_SHEET, bool>( _HKI( "Exclude From Board" ),
2709 groupAttributes );
2710 propMgr.AddProperty( new PROPERTY<SCH_SHEET, bool>( _HKI( "Exclude From Simulation" ),
2712 groupAttributes );
2713 propMgr.AddProperty( new PROPERTY<SCH_SHEET, bool>( _HKI( "Exclude From Bill of Materials" ),
2715 groupAttributes );
2716 propMgr.AddProperty( new PROPERTY<SCH_SHEET, bool>( _HKI( "Do not Populate" ),
2718 groupAttributes );
2719 }
const char * name
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:130
BITMAPS
A list of all bitmap identifiers.
@ add_hierarchical_subsheet
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:556
constexpr const Vec GetEnd() const
Definition box2.h:215
constexpr coord_type GetY() const
Definition box2.h:211
constexpr size_type GetWidth() const
Definition box2.h:217
constexpr coord_type GetX() const
Definition box2.h:210
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:597
constexpr const Vec GetCenter() const
Definition box2.h:233
constexpr size_type GetHeight() const
Definition box2.h:218
constexpr coord_type GetLeft() const
Definition box2.h:231
constexpr const Vec & GetOrigin() const
Definition box2.h:213
constexpr coord_type GetRight() const
Definition box2.h:220
constexpr void SetEnd(coord_type x, coord_type y)
Definition box2.h:300
constexpr coord_type GetTop() const
Definition box2.h:232
constexpr coord_type GetBottom() const
Definition box2.h:225
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
Definition color4d.h:400
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
std::vector< PROPERTY_BASE * > GetCustomPropertiesAsInspectables() const
Definition eda_item.cpp:210
const KIID m_Uuid
Definition eda_item.h:599
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM * GetParent() const
Definition eda_item.h:112
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
virtual VECTOR2I GetTextSize() const
Definition eda_text.h:301
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:118
virtual void SetTextPos(const VECTOR2I &aPoint)
Definition eda_text.cpp:557
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition eda_text.cpp:379
static wxString GotoPageHref(const wxString &aDestination)
Generate a href to a page in the current schematic.
virtual void SetTextAngle(const EDA_ANGLE &aAngle)
Definition eda_text.cpp:269
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition eda_text.cpp:371
EE_TYPE Overlapping(const BOX2I &aRect) const
Definition sch_rtree.h:253
Class that other classes need to inherit from, in order to be inspectable.
Definition inspectable.h:39
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
std::shared_ptr< wxString > m_text
Definition color4d.h:397
double a
Alpha component.
Definition color4d.h:394
COLOR4D & Desaturate()
Removes color (in HSL model)
Definition color4d.cpp:530
COLOR4D Mix(const COLOR4D &aColor, double aFactor) const
Return a color that is mixed with the input by a factor.
Definition color4d.h:293
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxString AsString() const
Definition kiid.cpp:423
Definition kiid.h:46
Base plotter engine class.
Definition plotter.h:138
RENDER_SETTINGS * RenderSettings()
Definition plotter.h:169
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width, int aCornerRadius=0)=0
virtual void HyperlinkBox(const BOX2I &aBox, const wxString &aDestinationURL)
Create a clickable hyperlink with a rectangular click area.
Definition plotter.h:527
bool GetColorMode() const
Definition plotter.h:166
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, void *aData)
Definition plotter.cpp:442
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Definition plotter.h:538
virtual void SetColor(const COLOR4D &color)=0
Container for project specific data.
Definition project.h:63
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition property.h:275
PROPERTY_BASE(const wxString &aName, PROPERTY_DISPLAY aDisplay=PT_DEFAULT, ORIGIN_TRANSFORMS::COORD_TYPES_T aCoordType=ORIGIN_TRANSFORMS::NOT_A_COORD)
Used to generate unique IDs. Must come up front so it's initialized before ctor.
Definition property.h:201
PROPERTY_BASE & SetGroup(const wxString &aGroup)
Definition property.h:395
PROPERTY_BASE & SetValidator(PROPERTY_VALIDATOR_FN &&aValidator)
Definition property.h:397
Provide class metadata.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
bool IsTopLevelSheet(const SCH_SHEET *aSheet) const
Check if a sheet is a top-level sheet (direct child of virtual root).
SCHEMATIC_SETTINGS & Settings() const
wxString GetCurrentVariant() const
Return the current variant being edited.
void GetContextualTextVars(wxArrayString *aVars) const
SCH_SHEET_PATH & CurrentSheet() const
Definition schematic.h:399
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
bool IsMandatory() const
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:139
FIELD_T GetId() const
Definition sch_field.h:143
wxString GetUntranslatedName() const
Get the untranslated field name for storage, variable look-up, etc.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString, int aDepth=0) const
void SetText(const wxString &aText) override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
void SetLocked(bool aLocked) override
Definition sch_item.h:262
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition sch_item.cpp:91
SCH_SCREEN * GetParentScreen() const
Definition sch_item.cpp:308
void invalidateConnectivity(KICAD_T aChangedType=TYPE_NOT_INIT)
Bump the parent screen's connectivity revision when this item, or the item owning it as a child,...
Definition sch_item.cpp:323
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition sch_item.cpp:46
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition sch_item.cpp:302
bool IsLocked() const override
Definition sch_item.cpp:179
void SetFieldsAutoplaced(AUTOPLACE_ALGO aAlgo)
Definition sch_item.h:679
AUTOPLACE_ALGO m_fieldsAutoplaced
Definition sch_item.h:847
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:65
AUTOPLACE_ALGO GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition sch_item.h:678
wxString ResolveText(const wxString &aText, const SCH_SHEET_PATH *aPath, int aDepth=0) const
Definition sch_item.cpp:464
wxString GetClass() const override
Return the class name.
Definition sch_item.h:180
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
SCH_LAYER_ID m_layer
Definition sch_item.h:843
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
Definition sch_screen.h:826
SCH_SCREEN * GetNext()
SCH_SCREEN * GetFirst()
EE_RTREE & Items()
Get the full RTree, usually for iterating.
Definition sch_screen.h:122
const wxString & GetFileName() const
Definition sch_screen.h:157
size_t BaseHash() const override
Return type-id of the Base class.
Definition sch_sheet.cpp:89
SCH_SHEET_FIELD_PROPERTY(const wxString &aName)
Definition sch_sheet.cpp:63
wxAny getter(const void *obj) const override
void setter(void *obj, wxAny &v) override
Definition sch_sheet.cpp:93
size_t OwnerHash() const override
Return type-id of the Owner class.
Definition sch_sheet.cpp:88
size_t TypeHash() const override
Return type-id of the property type.
Definition sch_sheet.cpp:90
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool GetExcludedFromBOM() const
bool empty() const
Forwarded method from std::vector.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
wxString GetPageNumber() const
SCH_SHEET * at(size_t aIndex) const
Forwarded method from std::vector.
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false, bool aEscapeSheetNames=false) const
Return the sheet path in a human readable form made from the sheet names.
bool GetExcludedFromSim() const
bool GetExcludedFromBoard() const
bool GetDNP() const
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
size_t size() const
Forwarded method from std::vector.
void pop_back()
Forwarded method from std::vector.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Variant information for a schematic sheet.
void InitializeAttributes(const SCH_SHEET &aSheet)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:50
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this sheet.
friend SCH_SHEET_PATH
Definition sch_sheet.h:663
bool HasPinIdentityChanges(const SCH_SHEET &aOther) const
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition sch_sheet.h:196
wxString GetFieldText(const SCH_FIELD *aField, const wxString &aFieldName, const SCH_SHEET_PATH *aPath, const wxString &aVariantName) const
friend class SCH_SHEET_PIN
Definition sch_sheet.h:742
wxString GetRefSuffix(const SCH_SHEET_PATH &aParentPath) const
Return this sheet's own reference suffix with text variables resolved.
void ClearVariantField(const KIID_PATH &aPath, const wxString &aVariantName, const wxString &aFieldName)
VECTOR2I m_size
Definition sch_sheet.h:759
void SetFileName(const wxString &aFilename)
Definition sch_sheet.h:434
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition sch_sheet.h:428
void SetFieldText(SCH_FIELD *aField, const wxString &aFieldName, const wxString &aFieldText, const SCH_SHEET_PATH *aPath, const wxString &aVariantName)
bool getInstance(SCH_SHEET_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
void CopyVariant(const KIID_PATH &aPath, const wxString &aSourceVariant, const wxString &aNewVariant)
void SetSize(const VECTOR2I &aSize)
Definition sch_sheet.h:190
void RemoveInstance(const KIID_PATH &aInstancePath)
void SetDNP(bool aDNP, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
bool addInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
bool HasRootInstance() const
Check to see if this sheet has a root sheet instance.
void SyncUuidToScreen()
Take the identity of the screen this sheet owns.
void setVariantAttribute(bool aEnable, const SCH_SHEET_PATH *aInstance, const wxString &aVariantName, bool SCH_SHEET::*aBase, bool SCH_SHEET_VARIANT::*aOverride)
wxString GetClass() const override
Return the class name.
Definition sch_sheet.h:74
wxString getPageNumber(const KIID_PATH &aParentPath) const
Return the sheet page number for aParentPath.
static wxString NextRefSuffix(const wxString &aSuffix, const std::set< wxString > &aInUse, const std::function< bool(const wxString &)> &aIsTaken=nullptr)
Return the suffix a pasted copy of a sheet should take.
void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
int GetPenWidth() const override
std::map< SCH_SHEET_PIN *, SCH_NO_CONNECT * > GetNoConnects() const
wxString GetFullRefSuffixProp() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool IsTopLevelSheet() const
Check if this sheet is a top-level sheet.
SCH_SHEET_PATH findSelf() const
Get the sheetpath of this sheet.
bool GetDNPProp() const
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
bool GetExcludedFromBoardProp() const
Definition sch_sheet.h:525
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
bool GetExcludedFromBOMProp() const
VECTOR2I m_pos
Definition sch_sheet.h:758
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
Definition sch_sheet.h:93
KIGFX::COLOR4D m_borderColor
Definition sch_sheet.h:761
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
bool m_excludedFromBOM
Definition sch_sheet.h:754
wxString GetName() const
Definition sch_sheet.h:150
void renumberPins()
Renumber the sheet pins in the sheet.
VECTOR2I GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
bool HasHierarchyChanges(const SCH_SHEET &aOther) const
SCH_SHEET_PIN * GetPin(const VECTOR2I &aPosition)
Return the sheet pin item found at aPosition in the sheet.
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool operator<(const SCH_ITEM &aItem) const override
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
void RemovePin(const SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
void SetPositionIgnoringPins(const VECTOR2I &aPosition)
friend SCHEMATIC
Definition sch_sheet.h:665
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
std::vector< SCH_SHEET_INSTANCE > m_instances
Definition sch_sheet.h:764
bool HasUndefinedPins() const
Check all sheet labels against schematic for undefined hierarchical labels.
bool m_excludedFromSim
Definition sch_sheet.h:753
void SetPosition(const VECTOR2I &aPosition) override
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition sch_sheet.h:199
int SymbolCount() const
Count our own symbols, without the power symbols.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
void SetDNPProp(bool aEnable)
void AddInstance(const SCH_SHEET_INSTANCE &aInstance)
int GetMinWidth(bool aFromLeft) const
Return the minimum width of the sheet based on the widths of the sheet pin text.
bool operator==(const SCH_ITEM &aOther) const override
SCH_SCREEN * m_screen
Definition sch_sheet.h:746
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
std::vector< SCH_FIELD > m_fields
Definition sch_sheet.h:751
void RenameVariant(const KIID_PATH &aPath, const wxString &aOldName, const wxString &aNewName)
VECTOR2I GetSize() const
Definition sch_sheet.h:189
KIGFX::COLOR4D m_backgroundColor
Definition sch_sheet.h:762
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
Definition sch_sheet.h:513
void DeleteVariant(const KIID_PATH &aPath, const wxString &aVariantName)
SCH_SHEET(EDA_ITEM *aParent=nullptr, const VECTOR2I &aPos=VECTOR2I(0, 0), VECTOR2I aSize=VECTOR2I(schIUScale.MilsToIU(MIN_SHEET_WIDTH), schIUScale.MilsToIU(MIN_SHEET_HEIGHT)))
void SetName(const wxString &aName)
Definition sch_sheet.h:185
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this sheet.
SCH_SCREEN * GetScreen() const
Definition sch_sheet.h:187
void SetExcludedFromSimProp(bool aEnable)
VECTOR2I GetPosition() const override
Definition sch_sheet.h:548
const BOX2I GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
bool HasPin(const wxString &aName) const
Check if the sheet already has a sheet pin named aName.
static int ComparePageNum(const wxString &aPageNumberA, const wxString &aPageNumberB)
Compare page numbers of schematic sheets.
std::vector< PROPERTY_BASE * > GetDynamicProperties() const override
Return dynamically-computed properties specific to this object instance (e.g.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
wxString ResolveRefSuffix(const wxString &aText, const SCH_SHEET_PATH &aParentPath) const
Resolve aText as if it were this sheet's reference suffix, with the same rules as GetRefSuffix.
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
int CountActiveSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
int GetScreenCount() const
Return the number of times the associated screen for the sheet is being used.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
SCH_SHEET & operator=(const SCH_ITEM &aSheet)
bool HasPageNumberChanges(const SCH_SHEET &aOther) const
Check if the instance data of this sheet has any changes compared to aOther.
const SCH_SHEET_INSTANCE & GetRootInstance() const
Return the root sheet instance data.
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
bool m_excludedFromBoard
Definition sch_sheet.h:755
void SetDescendantsModified()
Flag every screen at or below this sheet as modified.
bool HasRefSuffixChanges(const SCH_SHEET &aOther) const
True when an edit may change the reference suffix this sheet adds to the paths below it.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
KIGFX::COLOR4D GetBorderColor() const
Definition sch_sheet.h:195
std::vector< SCH_SHEET_PIN * > m_pins
Definition sch_sheet.h:750
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
void SetBorderWidth(int aWidth)
Definition sch_sheet.h:193
std::map< wxString, std::unique_ptr< SCH_SHEET_FIELD_PROPERTY > > m_dynamicPropertyCache
Definition sch_sheet.h:766
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add aFieldName to the list of fields.
void setPageNumber(const KIID_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
bool IsVirtualRootSheet() const
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
int GetMinHeight(bool aFromTop) const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flags.
bool GetExcludedFromSimProp() const
void SetExcludedFromBoardProp(bool aExclude)
Definition sch_sheet.h:526
int m_borderWidth
Definition sch_sheet.h:760
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition sch_sheet.h:519
void Resize(const VECTOR2I &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
int GetBorderWidth() const
Definition sch_sheet.h:192
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.
bool m_DNP
Definition sch_sheet.h:756
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition sch_sheet.h:285
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
void SetExcludedFromBOMProp(bool aEnable)
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void AddVariant(const SCH_SHEET_PATH &aInstance, const SCH_SHEET_VARIANT &aVariant)
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
Definition sch_sheet.h:563
bool IsVerticalOrientation() const
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
KIGFX::COLOR4D GetBackgroundColor() const
Definition sch_sheet.h:198
Schematic symbol object.
Definition sch_symbol.h:76
bool IsPower() const override
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
wxString m_Name
bool m_ExcludedFromBOM
std::map< wxString, wxString > m_Fields
bool m_ExcludedFromSim
void FinalizeTextVarExpansion(wxString &aText, RESOLUTION_CONTEXT aContext)
Definition common.cpp:88
wxString ExpandTextVars(const wxString &aSource, const PROJECT *aProject, RESOLUTION_CONTEXT aContext)
Definition common.cpp:60
@ FOR_ERC_DRC
Definition common.h:95
@ FOR_GUI
Definition common.h:93
@ INTERNAL
Definition common.h:96
#define DEFAULT_LINE_WIDTH_MILS
The default line width in mils. (can be changed in preference menu)
bool isDigit(char cc)
Definition dsnlexer.cpp:482
#define _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:474
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition eda_angle.h:469
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition eda_angle.h:468
static constexpr EDA_ANGLE ANGLE_270
Definition eda_angle.h:477
@ NO_FILL
Definition eda_fill.h:30
@ FILLED_SHAPE
Fill with object color.
Definition eda_fill.h:31
RECURSE_MODE
Definition eda_item.h:50
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
a few functions useful in geometry calculations.
int m_ResolveTextRecursionDepth
The number of recursions to resolve text variables.
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
KICOMMON_API int IndexFromAlphabetic(const wxString &aStr, const wxString &aAlphabet)
Attempt to convert a string to an integer, assuming it is an alphabetic string like "A",...
wxString KICOMMON_API AlphabeticFromIndex(size_t aN, const wxString &aAlphabet, bool aZeroBasedNonUnitCols)
Get an alphabetic string like A, B, ... Z, AA, AB, ... ZZ, AAA, ...
KIID niluuid(0)
@ LAYER_DANGLING
Definition layer_ids.h:508
@ LAYER_SHEETNAME
Definition layer_ids.h:503
@ LAYER_SHEET_BACKGROUND
Definition layer_ids.h:516
@ LAYER_HIERLABEL
Definition layer_ids.h:488
@ LAYER_SHEETFIELDS
Definition layer_ids.h:505
@ LAYER_SHEET
Definition layer_ids.h:502
@ LAYER_SELECTION_SHADOWS
Definition layer_ids.h:526
@ LAYER_SHEETFILENAME
Definition layer_ids.h:504
@ LAYER_DNP_MARKER
Definition layer_ids.h:509
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition mirror.h:44
Message panel definition file.
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.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition kicad_algo.h:96
KICOMMON_API void PackColor(types::Color &aOutput, const KIGFX::COLOR4D &aInput)
KICOMMON_API int UnpackDistance(const types::Distance &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API KIGFX::COLOR4D UnpackColor(const types::Color &aInput)
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 PackDistance(types::Distance &aOutput, int 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
see class PGM_BASE
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
#define NO_SETTER(owner, type)
Macro to define read-only fields (no setter method available)
Definition property.h:923
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition property.h:63
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
std::optional< std::unique_ptr< VALIDATION_ERROR > > VALIDATOR_RESULT
Null optional means validation succeeded.
CITER next(CITER it)
Definition ptree.cpp:120
const SCH_FIELD * FindField(const std::vector< SCH_FIELD > &aFields, FIELD_T aFieldId)
Definition sch_field.h:390
int NextFieldOrdinal(const std::vector< SCH_FIELD > &aFields)
Definition sch_field.h:379
AUTOPLACE_ALGO
Definition sch_item.h:73
@ AUTOPLACE_MANUAL
Definition sch_item.h:76
@ AUTOPLACE_NONE
Definition sch_item.h:74
@ AUTOPLACE_AUTO
Definition sch_item.h:75
int bumpToNextGrid(const int aVal, const int aDirection)
static struct SCH_SHEET_DESC _SCH_SHEET_DESC
#define MIN_SHEET_HEIGHT
Definition sch_sheet.h:43
#define MIN_SHEET_WIDTH
Definition sch_sheet.h:42
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
std::vector< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, CMP_T aCaseSensitivity)
Compare two strings with alphanumerical content.
wxString UnescapeString(const wxString &aSource)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool m_PDFPropertyPopups
Definition sch_plotter.h:66
bool m_PDFHierarchicalLinks
Definition sch_plotter.h:67
A simple container for sheet instance information.
std::map< wxString, SCH_SHEET_VARIANT > m_Variants
A list of sheet variants.
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ SHEET_REF_SUFFIX
Optional sheet field appended to the references of the sheet's symbols.
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ UNTRANSLATED
@ TRANSLATED
std::string path
KIBIS_PIN * pin
VECTOR2I end
wxString result
Test unit parsing edge cases and error handling.
int delta
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_TOP
wxLogTrace helper definitions.
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
@ SCH_NO_CONNECT_T
Definition typeinfo.h:156
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_FIELD_T
Definition typeinfo.h:146
@ SCH_LOCATE_ANY_T
Definition typeinfo.h:195
@ SCH_SHEET_T
Definition typeinfo.h:171
@ SCH_HIER_LABEL_T
Definition typeinfo.h:165
@ SCH_SHEET_PIN_T
Definition typeinfo.h:170
wxString GetFieldValidationErrorMessage(FIELD_T aFieldId, const wxString &aValue)
Return the error message if aValue is invalid for aFieldId.
Custom text control validator definitions.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)