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 (C) 1992-2024 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, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26#include <cstdlib>
27
28#include <bitmaps.h>
29#include <core/mirror.h>
30#include <core/kicad_algo.h>
31#include <sch_draw_panel.h>
32#include <trigo.h>
33#include <sch_edit_frame.h>
34#include <plotters/plotter.h>
35#include <string_utils.h>
36#include <widgets/msgpanel.h>
37#include <math/util.h> // for KiROUND
38#include <sch_sheet.h>
39#include <sch_sheet_path.h>
40#include <sch_sheet_pin.h>
41#include <sch_symbol.h>
42#include <sch_painter.h>
43#include <schematic.h>
46#include <trace_helpers.h>
47#include <pgm_base.h>
48#include <wx/log.h>
49
50// N.B. Do not change these values without transitioning the file format
51#define SHEET_NAME_CANONICAL "Sheetname"
52#define SHEET_FILE_CANONICAL "Sheetfile"
53#define USER_FIELD_CANONICAL "Field%d"
54
55
56const wxString SCH_SHEET::GetDefaultFieldName( int aFieldNdx, bool aTranslated )
57{
58 if( !aTranslated )
59 {
60 switch( aFieldNdx )
61 {
64 default: return wxString::Format( USER_FIELD_CANONICAL, aFieldNdx );
65 }
66 }
67
68 // Fixed values for the mandatory fields
69 switch( aFieldNdx )
70 {
71 case SHEETNAME: return _( SHEET_NAME_CANONICAL );
72 case SHEETFILENAME: return _( SHEET_FILE_CANONICAL );
73 default: return wxString::Format( _( USER_FIELD_CANONICAL ), aFieldNdx );
74 }
75}
76
77
78SCH_SHEET::SCH_SHEET( EDA_ITEM* aParent, const VECTOR2I& aPos, VECTOR2I aSize,
79 FIELDS_AUTOPLACED aAutoplaceFields ) :
80 SCH_ITEM( aParent, SCH_SHEET_T ),
81 m_excludedFromSim( false ),
82 m_excludedFromBOM( false ),
83 m_excludedFromBoard( false ),
84 m_DNP( false )
85{
87 m_pos = aPos;
88 m_size = aSize;
89 m_screen = nullptr;
90
91 m_borderWidth = 0;
92 m_borderColor = COLOR4D::UNSPECIFIED;
93 m_backgroundColor = COLOR4D::UNSPECIFIED;
94 m_fieldsAutoplaced = aAutoplaceFields;
95
96 for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
97 {
98 m_fields.emplace_back( aPos, i, this, GetDefaultFieldName( i ) );
99 m_fields.back().SetVisible( true );
100
101 if( i == SHEETNAME )
102 m_fields.back().SetLayer( LAYER_SHEETNAME );
103 else if( i == SHEETFILENAME )
104 m_fields.back().SetLayer( LAYER_SHEETFILENAME );
105 else
106 m_fields.back().SetLayer( LAYER_SHEETFIELDS );
107 }
108
109 AutoAutoplaceFields( nullptr );
110}
111
112
114 SCH_ITEM( aSheet )
115{
116 m_pos = aSheet.m_pos;
117 m_size = aSheet.m_size;
118 m_layer = aSheet.m_layer;
119 const_cast<KIID&>( m_Uuid ) = aSheet.m_Uuid;
120 m_fields = aSheet.m_fields;
122 m_screen = aSheet.m_screen;
123
127 m_DNP = aSheet.m_DNP;
128
132 m_instances = aSheet.m_instances;
133
134 for( SCH_SHEET_PIN* pin : aSheet.m_pins )
135 {
136 m_pins.emplace_back( new SCH_SHEET_PIN( *pin ) );
137 m_pins.back()->SetParent( this );
138 }
139
140 for( SCH_FIELD& field : m_fields )
141 field.SetParent( this );
142
143 if( m_screen )
145}
146
147
149{
150 // also, look at the associated sheet & its reference count
151 // perhaps it should be deleted also.
152 if( m_screen )
153 {
155
156 if( m_screen->GetRefCount() == 0 )
157 delete m_screen;
158 }
159
160 // We own our pins; delete them
161 for( SCH_SHEET_PIN* pin : m_pins )
162 delete pin;
163}
164
165
167{
168 return new SCH_SHEET( *this );
169}
170
171
173{
174 if( aScreen == m_screen )
175 return;
176
177 if( m_screen != nullptr )
178 {
180
181 if( m_screen->GetRefCount() == 0 )
182 {
183 delete m_screen;
184 m_screen = nullptr;
185 }
186 }
187
188 m_screen = aScreen;
189
190 if( m_screen )
192}
193
194
196{
197 if( m_screen == nullptr )
198 return 0;
199
200 return m_screen->GetRefCount();
201}
202
203
205{
206 wxCHECK_MSG( Schematic(), false, "Can't call IsRootSheet without setting a schematic" );
207
208 return &Schematic()->Root() == this;
209}
210
211
212void SCH_SHEET::GetContextualTextVars( wxArrayString* aVars ) const
213{
214 auto add =
215 [&]( const wxString& aVar )
216 {
217 if( !alg::contains( *aVars, aVar ) )
218 aVars->push_back( aVar );
219 };
220
221 for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
222 add( m_fields[i].GetCanonicalName().Upper() );
223
224 for( size_t i = SHEET_MANDATORY_FIELDS; i < m_fields.size(); ++i )
225 add( m_fields[i].GetName() );
226
227 SCH_SHEET_PATH sheetPath = findSelf();
228
229 if( sheetPath.size() >= 2 )
230 {
231 sheetPath.pop_back();
232 sheetPath.Last()->GetContextualTextVars( aVars );
233 }
234 else if( Schematic() )
235 {
237 }
238
239 add( wxT( "#" ) );
240 add( wxT( "##" ) );
241 add( wxT( "SHEETPATH" ) );
242 add( wxT( "EXCLUDE_FROM_BOM" ) );
243 add( wxT( "EXCLUDE_FROM_BOARD" ) );
244 add( wxT( "EXCLUDE_FROM_SIM" ) );
245 add( wxT( "DNP" ) );
246
248}
249
250
251bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const
252{
253 wxCHECK( aPath, false );
254
255 SCHEMATIC* schematic = Schematic();
256
257 if( !schematic )
258 return false;
259
260 if( token->Contains( ':' ) )
261 {
262 if( schematic->ResolveCrossReference( token, aDepth + 1 ) )
263 return true;
264 }
265
266 for( int i = 0; i < SHEET_MANDATORY_FIELDS; ++i )
267 {
268 if( token->IsSameAs( m_fields[i].GetCanonicalName().Upper() ) )
269 {
270 *token = m_fields[i].GetShownText( aPath, false, aDepth + 1 );
271 return true;
272 }
273 }
274
275 for( size_t i = SHEET_MANDATORY_FIELDS; i < m_fields.size(); ++i )
276 {
277 if( token->IsSameAs( m_fields[i].GetName() ) )
278 {
279 *token = m_fields[i].GetShownText( aPath, false, aDepth + 1 );
280 return true;
281 }
282 }
283
284 PROJECT* project = &schematic->Prj();
285
286 // We cannot resolve text variables initially on load as we need to first load the screen and
287 // then parse the hierarchy. So skip the resolution if the screen isn't set yet
289 {
290 return true;
291 }
292
293 if( token->IsSameAs( wxT( "#" ) ) )
294 {
295 *token = wxString::Format( "%s", aPath->GetPageNumber() );
296 return true;
297 }
298 else if( token->IsSameAs( wxT( "##" ) ) )
299 {
300 *token = wxString::Format( wxT( "%d" ), (int) schematic->BuildUnorderedSheetList().size() );
301 return true;
302 }
303 else if( token->IsSameAs( wxT( "SHEETPATH" ) ) )
304 {
305 *token = aPath->PathHumanReadable();
306 return true;
307 }
308 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOM" ) ) )
309 {
310 *token = wxEmptyString;
311
312 if( aPath->GetExcludedFromBOM() || this->GetExcludedFromBOM() )
313 *token = _( "Excluded from BOM" );
314
315 return true;
316 }
317 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOARD" ) ) )
318 {
319 *token = wxEmptyString;
320
321 if( aPath->GetExcludedFromBoard() || this->GetExcludedFromBoard() )
322 *token = _( "Excluded from board" );
323
324 return true;
325 }
326 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_SIM" ) ) )
327 {
328 *token = wxEmptyString;
329
330 if( aPath->GetExcludedFromSim() || this->GetExcludedFromSim() )
331 *token = _( "Excluded from simulation" );
332
333 return true;
334 }
335 else if( token->IsSameAs( wxT( "DNP" ) ) )
336 {
337 *token = wxEmptyString;
338
339 if( aPath->GetDNP() || this->GetDNP() )
340 *token = _( "DNP" );
341
342 return true;
343 }
344
345 // See if parent can resolve it (these will recurse to ancestors)
346
347 if( aPath->size() >= 2 )
348 {
349 SCH_SHEET_PATH path = *aPath;
350 path.pop_back();
351
352 if( path.Last()->ResolveTextVar( &path, token, aDepth + 1 ) )
353 return true;
354 }
355 else
356 {
357 if( schematic->ResolveTextVar( aPath, token, aDepth + 1 ) )
358 return true;
359 }
360
361 return false;
362}
363
364
366{
367 SCH_ITEM::SwapFlags( aItem );
368
369 wxCHECK_RET( aItem->Type() == SCH_SHEET_T,
370 wxString::Format( wxT( "SCH_SHEET object cannot swap data with %s object." ),
371 aItem->GetClass() ) );
372
373 SCH_SHEET* sheet = ( SCH_SHEET* ) aItem;
374
375 std::swap( m_pos, sheet->m_pos );
376 std::swap( m_size, sheet->m_size );
377 m_fields.swap( sheet->m_fields );
378 std::swap( m_fieldsAutoplaced, sheet->m_fieldsAutoplaced );
379 m_pins.swap( sheet->m_pins );
380
381 // Update parent pointers after swapping.
382 for( SCH_SHEET_PIN* sheetPin : m_pins )
383 sheetPin->SetParent( this );
384
385 for( SCH_SHEET_PIN* sheetPin : sheet->m_pins )
386 sheetPin->SetParent( sheet );
387
388 for( SCH_FIELD& field : m_fields )
389 field.SetParent( this );
390
391 for( SCH_FIELD& field : sheet->m_fields )
392 field.SetParent( sheet );
393
394 std::swap( m_excludedFromSim, sheet->m_excludedFromSim );
395 std::swap( m_excludedFromBOM, sheet->m_excludedFromBOM );
396 std::swap( m_excludedFromBoard, sheet->m_excludedFromBoard );
397 std::swap( m_DNP, sheet->m_DNP );
398
399 std::swap( m_borderWidth, sheet->m_borderWidth );
400 std::swap( m_borderColor, sheet->m_borderColor );
401 std::swap( m_backgroundColor, sheet->m_backgroundColor );
402 std::swap( m_instances, sheet->m_instances );
403}
404
405
406void SCH_SHEET::SetFields( const std::vector<SCH_FIELD>& aFields )
407{
408 m_fields = aFields;
409
410 // Ensure that mandatory fields are at the beginning
411 std::sort( m_fields.begin(), m_fields.end(),
412 []( const SCH_FIELD& a, const SCH_FIELD& b )
413 {
414 return a.GetId() < b.GetId();
415 } );
416
417 // After mandatory fields, the rest should be sequential user fields
418 for( int ii = SHEET_MANDATORY_FIELDS; ii < static_cast<int>( m_fields.size() ); ++ii )
419 m_fields[ii].SetId( ii );
420
421 // Make sure that we get the UNIX variant of the file path
422 SetFileName( m_fields[SHEETFILENAME].GetText() );
423}
424
425
427{
428 wxASSERT( aSheetPin != nullptr );
429 wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
430
431 aSheetPin->SetParent( this );
432 m_pins.push_back( aSheetPin );
433 renumberPins();
434}
435
436
437void SCH_SHEET::RemovePin( const SCH_SHEET_PIN* aSheetPin )
438{
439 wxASSERT( aSheetPin != nullptr );
440 wxASSERT( aSheetPin->Type() == SCH_SHEET_PIN_T );
441
442 for( auto i = m_pins.begin(); i < m_pins.end(); ++i )
443 {
444 if( *i == aSheetPin )
445 {
446 m_pins.erase( i );
447 renumberPins();
448 return;
449 }
450 }
451}
452
453
454bool SCH_SHEET::HasPin( const wxString& aName ) const
455{
456 for( SCH_SHEET_PIN* pin : m_pins )
457 {
458 if( pin->GetText().Cmp( aName ) == 0 )
459 return true;
460 }
461
462 return false;
463}
464
465
466bool SCH_SHEET::doIsConnected( const VECTOR2I& aPosition ) const
467{
468 for( SCH_SHEET_PIN* sheetPin : m_pins )
469 {
470 if( sheetPin->GetPosition() == aPosition )
471 return true;
472 }
473
474 return false;
475}
476
477
479{
480 int leftRight = 0;
481 int topBottom = 0;
482
483 for( SCH_SHEET_PIN* pin : m_pins )
484 {
485 switch( pin->GetSide() )
486 {
487 case SHEET_SIDE::LEFT: leftRight++; break;
488 case SHEET_SIDE::RIGHT: leftRight++; break;
489 case SHEET_SIDE::TOP: topBottom++; break;
490 case SHEET_SIDE::BOTTOM: topBottom++; break;
491 default: break;
492 }
493 }
494
495 return topBottom > 0 && leftRight == 0;
496}
497
498
500{
501 for( SCH_SHEET_PIN* pin : m_pins )
502 {
503 /* Search the schematic for a hierarchical label corresponding to this sheet label. */
504 const SCH_HIERLABEL* HLabel = nullptr;
505
506 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) )
507 {
508 if( !pin->GetText().Cmp( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) )
509 {
510 HLabel = static_cast<SCH_HIERLABEL*>( aItem );
511 break;
512 }
513 }
514
515 if( HLabel == nullptr ) // Corresponding hierarchical label not found.
516 return true;
517 }
518
519 return false;
520}
521
522
523int bumpToNextGrid( const int aVal, const int aDirection )
524{
525 constexpr int gridSize = schIUScale.MilsToIU( 50 );
526
527 int base = aVal / gridSize;
528 int excess = abs( aVal % gridSize );
529
530 if( aDirection > 0 )
531 {
532 return ( base + 1 ) * gridSize;
533 }
534 else if( excess > 0 )
535 {
536 return ( base ) * gridSize;
537 }
538 else
539 {
540 return ( base - 1 ) * gridSize;
541 }
542}
543
544
545int SCH_SHEET::GetMinWidth( bool aFromLeft ) const
546{
547 int pinsLeft = m_pos.x + m_size.x;
548 int pinsRight = m_pos.x;
549
550 for( size_t i = 0; i < m_pins.size(); i++ )
551 {
552 SHEET_SIDE edge = m_pins[i]->GetSide();
553
554 if( edge == SHEET_SIDE::TOP || edge == SHEET_SIDE::BOTTOM )
555 {
556 BOX2I pinRect = m_pins[i]->GetBoundingBox();
557
558 pinsLeft = std::min( pinsLeft, pinRect.GetLeft() );
559 pinsRight = std::max( pinsRight, pinRect.GetRight() );
560 }
561 }
562
563 pinsLeft = bumpToNextGrid( pinsLeft, -1 );
564 pinsRight = bumpToNextGrid( pinsRight, 1 );
565
566 int pinMinWidth;
567
568 if( pinsLeft >= pinsRight )
569 pinMinWidth = 0;
570 else if( aFromLeft )
571 pinMinWidth = pinsRight - m_pos.x;
572 else
573 pinMinWidth = m_pos.x + m_size.x - pinsLeft;
574
575 return std::max( pinMinWidth, schIUScale.MilsToIU( MIN_SHEET_WIDTH ) );
576}
577
578
579int SCH_SHEET::GetMinHeight( bool aFromTop ) const
580{
581 int pinsTop = m_pos.y + m_size.y;
582 int pinsBottom = m_pos.y;
583
584 for( size_t i = 0; i < m_pins.size(); i++ )
585 {
586 SHEET_SIDE edge = m_pins[i]->GetSide();
587
588 if( edge == SHEET_SIDE::RIGHT || edge == SHEET_SIDE::LEFT )
589 {
590 BOX2I pinRect = m_pins[i]->GetBoundingBox();
591
592 pinsTop = std::min( pinsTop, pinRect.GetTop() );
593 pinsBottom = std::max( pinsBottom, pinRect.GetBottom() );
594 }
595 }
596
597 pinsTop = bumpToNextGrid( pinsTop, -1 );
598 pinsBottom = bumpToNextGrid( pinsBottom, 1 );
599
600 int pinMinHeight;
601
602 if( pinsTop >= pinsBottom )
603 pinMinHeight = 0;
604 else if( aFromTop )
605 pinMinHeight = pinsBottom - m_pos.y;
606 else
607 pinMinHeight = m_pos.y + m_size.y - pinsTop;
608
609 return std::max( pinMinHeight, schIUScale.MilsToIU( MIN_SHEET_HEIGHT ) );
610}
611
612
614{
615 std::vector<SCH_SHEET_PIN*> pins = m_pins;
616
617 m_pins.clear();
618
619 for( SCH_SHEET_PIN* pin : pins )
620 {
621 /* Search the schematic for a hierarchical label corresponding to this sheet label. */
622 const SCH_HIERLABEL* HLabel = nullptr;
623
624 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_HIER_LABEL_T ) )
625 {
626 if( pin->GetText().CmpNoCase( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) == 0 )
627 {
628 HLabel = static_cast<SCH_HIERLABEL*>( aItem );
629 break;
630 }
631 }
632
633 if( HLabel )
634 m_pins.push_back( pin );
635 }
636}
637
638
640{
641 for( SCH_SHEET_PIN* pin : m_pins )
642 {
643 if( pin->HitTest( aPosition ) )
644 return pin;
645 }
646
647 return nullptr;
648}
649
650
652{
653 if( GetBorderWidth() > 0 )
654 return GetBorderWidth();
655
656 if( Schematic() )
658
660}
661
662
663void SCH_SHEET::AutoplaceFields( SCH_SCREEN* aScreen, bool /* aManual */ )
664{
665 VECTOR2I textSize = m_fields[SHEETNAME].GetTextSize();
666 int borderMargin = KiROUND( GetPenWidth() / 2.0 ) + 4;
667 int margin = borderMargin + KiROUND( std::max( textSize.x, textSize.y ) * 0.5 );
668
670 {
671 m_fields[SHEETNAME].SetTextPos( m_pos + VECTOR2I( -margin, m_size.y ) );
672 m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
673 m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
674 m_fields[ SHEETNAME ].SetTextAngle( ANGLE_VERTICAL );
675 }
676 else
677 {
678 m_fields[SHEETNAME].SetTextPos( m_pos + VECTOR2I( 0, -margin ) );
679 m_fields[ SHEETNAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
680 m_fields[ SHEETNAME ].SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
681 m_fields[ SHEETNAME ].SetTextAngle( ANGLE_HORIZONTAL );
682 }
683
684 textSize = m_fields[ SHEETFILENAME ].GetTextSize();
685 margin = borderMargin + KiROUND( std::max( textSize.x, textSize.y ) * 0.4 );
686
688 {
689 m_fields[SHEETFILENAME].SetTextPos( m_pos + VECTOR2I( m_size.x + margin, m_size.y ) );
690 m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
691 m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
692 m_fields[ SHEETFILENAME ].SetTextAngle( ANGLE_VERTICAL );
693 }
694 else
695 {
696 m_fields[SHEETFILENAME].SetTextPos( m_pos + VECTOR2I( 0, m_size.y + margin ) );
697 m_fields[ SHEETFILENAME ].SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
698 m_fields[ SHEETFILENAME ].SetVertJustify( GR_TEXT_V_ALIGN_TOP );
699 m_fields[ SHEETFILENAME ].SetTextAngle( ANGLE_HORIZONTAL );
700 }
701
703}
704
705
706void SCH_SHEET::ViewGetLayers( int aLayers[], int& aCount ) const
707{
708 aCount = 8;
709 aLayers[0] = LAYER_DANGLING; // Sheet pins are drawn by their parent sheet, so the
710 // parent needs to draw to LAYER_DANGLING
711 aLayers[1] = LAYER_HIERLABEL;
712 aLayers[2] = LAYER_SHEETNAME;
713 aLayers[3] = LAYER_SHEETFILENAME;
714 aLayers[4] = LAYER_SHEETFIELDS;
715 aLayers[5] = LAYER_SHEET;
716 aLayers[6] = LAYER_SHEET_BACKGROUND;
717 aLayers[7] = LAYER_SELECTION_SHADOWS;
718}
719
720
722{
723 VECTOR2I end;
724 BOX2I box( m_pos, m_size );
725 int lineWidth = GetPenWidth();
726 int textLength = 0;
727
728 // Calculate bounding box X size:
729 end.x = std::max( m_size.x, textLength );
730
731 // Calculate bounding box pos:
732 end.y = m_size.y;
733 end += m_pos;
734
735 box.SetEnd( end );
736 box.Inflate( lineWidth / 2 );
737
738 return box;
739}
740
741
743{
744 BOX2I bbox = GetBodyBoundingBox();
745
746 for( const SCH_FIELD& field : m_fields )
747 bbox.Merge( field.GetBoundingBox() );
748
749 return bbox;
750}
751
752
754{
755 BOX2I box( m_pos, m_size );
756 return box.GetCenter();
757}
758
759
761{
762 int n = 0;
763
764 if( m_screen )
765 {
766 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SYMBOL_T ) )
767 {
768 SCH_SYMBOL* symbol = (SCH_SYMBOL*) aItem;
769
770 if( symbol->GetField( VALUE_FIELD )->GetText().GetChar( 0 ) != '#' )
771 n++;
772 }
773
774 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
775 n += static_cast<const SCH_SHEET*>( aItem )->SymbolCount();
776 }
777
778 return n;
779}
780
781
782bool SCH_SHEET::SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen )
783{
784 if( m_screen )
785 {
786 // Only check the root sheet once and don't recurse.
787 if( !GetParent() )
788 {
789 if( m_screen && m_screen->GetFileName().Cmp( aFilename ) == 0 )
790 {
791 *aScreen = m_screen;
792 return true;
793 }
794 }
795
796 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
797 {
798 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
799 SCH_SCREEN* screen = sheet->m_screen;
800
801 // Must use the screen's path (which is always absolute) rather than the
802 // sheet's (which could be relative).
803 if( screen && screen->GetFileName().Cmp( aFilename ) == 0 )
804 {
805 *aScreen = screen;
806 return true;
807 }
808
809 if( sheet->SearchHierarchy( aFilename, aScreen ) )
810 return true;
811 }
812 }
813
814 return false;
815}
816
817
819{
820 if( m_screen )
821 {
822 aList->push_back( this );
823
824 if( m_screen == aScreen )
825 return true;
826
827 for( EDA_ITEM* item : m_screen->Items().OfType( SCH_SHEET_T ) )
828 {
829 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
830
831 if( sheet->LocatePathOfScreen( aScreen, aList ) )
832 return true;
833 }
834
835 aList->pop_back();
836 }
837
838 return false;
839}
840
841
843{
844 int count = 1; //1 = this!!
845
846 if( m_screen )
847 {
848 for( SCH_ITEM* aItem : m_screen->Items().OfType( SCH_SHEET_T ) )
849 count += static_cast<SCH_SHEET*>( aItem )->CountSheets();
850 }
851
852 return count;
853}
854
855
856void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
857{
858 // Don't use GetShownText(); we want to see the variable references here
859 aList.emplace_back( _( "Sheet Name" ),
860 KIUI::EllipsizeStatusText( aFrame, m_fields[ SHEETNAME ].GetText() ) );
861
862 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
863 {
864 SCH_SHEET_PATH path = schframe->GetCurrentSheet();
865 path.push_back( this );
866
867 aList.emplace_back( _( "Hierarchical Path" ), path.PathHumanReadable( false, true ) );
868 }
869
870 // Don't use GetShownText(); we want to see the variable references here
871 aList.emplace_back( _( "File Name" ),
872 KIUI::EllipsizeStatusText( aFrame, m_fields[ SHEETFILENAME ].GetText() ) );
873
874 wxArrayString msgs;
875 wxString msg;
876
877 if( GetExcludedFromSim() )
878 msgs.Add( _( "Simulation" ) );
879
880 if( GetExcludedFromBOM() )
881 msgs.Add( _( "BOM" ) );
882
884 msgs.Add( _( "Board" ) );
885
886 if( GetDNP() )
887 msgs.Add( _( "DNP" ) );
888
889 msg = wxJoin( msgs, '|' );
890 msg.Replace( '|', wxS( ", " ) );
891
892 if( !msg.empty() )
893 aList.emplace_back( _( "Exclude from" ), msg );
894}
895
896
898{
899 VECTOR2I delta = aPosition - m_pos;
900
901 m_pos = aPosition;
902
903 for( SCH_FIELD& field : m_fields )
904 field.Move( delta );
905}
906
907
908void SCH_SHEET::Move( const VECTOR2I& aMoveVector )
909{
910 m_pos += aMoveVector;
911
912 for( SCH_SHEET_PIN* pin : m_pins )
913 pin->Move( aMoveVector );
914
915 for( SCH_FIELD& field : m_fields )
916 field.Move( aMoveVector );
917}
918
919
920void SCH_SHEET::Rotate( const VECTOR2I& aCenter, bool aRotateCCW )
921{
922 VECTOR2I prev = m_pos;
923
924 RotatePoint( m_pos, aCenter, aRotateCCW ? ANGLE_90 : ANGLE_270 );
925 RotatePoint( &m_size.x, &m_size.y, aRotateCCW ? ANGLE_90 : ANGLE_270 );
926
927 if( m_size.x < 0 )
928 {
929 m_pos.x += m_size.x;
930 m_size.x = -m_size.x;
931 }
932
933 if( m_size.y < 0 )
934 {
935 m_pos.y += m_size.y;
936 m_size.y = -m_size.y;
937 }
938
939 // Pins must be rotated first as that's how we determine vertical vs horizontal
940 // orientation for auto-placement
941 for( SCH_SHEET_PIN* sheetPin : m_pins )
942 sheetPin->Rotate( aCenter, aRotateCCW );
943
945 {
946 AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
947 }
948 else
949 {
950 // Move the fields to the new position because the parent itself has moved.
951 for( SCH_FIELD& field : m_fields )
952 {
953 VECTOR2I pos = field.GetTextPos();
954 pos.x -= prev.x - m_pos.x;
955 pos.y -= prev.y - m_pos.y;
956 field.SetTextPos( pos );
957 }
958 }
959}
960
961
963{
964 int dy = m_pos.y;
965
966 MIRROR( m_pos.y, aCenter );
967 m_pos.y -= m_size.y;
968 dy -= m_pos.y; // 0,dy is the move vector for this transform
969
970 for( SCH_SHEET_PIN* sheetPin : m_pins )
971 sheetPin->MirrorVertically( aCenter );
972
973 for( SCH_FIELD& field : m_fields )
974 {
975 VECTOR2I pos = field.GetTextPos();
976 pos.y -= dy;
977 field.SetTextPos( pos );
978 }
979}
980
981
983{
984 int dx = m_pos.x;
985
986 MIRROR( m_pos.x, aCenter );
987 m_pos.x -= m_size.x;
988 dx -= m_pos.x; // dx,0 is the move vector for this transform
989
990 for( SCH_SHEET_PIN* sheetPin : m_pins )
991 sheetPin->MirrorHorizontally( aCenter );
992
993 for( SCH_FIELD& field : m_fields )
994 {
995 VECTOR2I pos = field.GetTextPos();
996 pos.x -= dx;
997 field.SetTextPos( pos );
998 }
999}
1000
1001
1002void SCH_SHEET::SetPosition( const VECTOR2I& aPosition )
1003{
1004 // Remember the sheet and all pin sheet positions must be
1005 // modified. So use Move function to do that.
1006 Move( aPosition - m_pos );
1007}
1008
1009
1010void SCH_SHEET::Resize( const VECTOR2I& aSize )
1011{
1012 if( aSize == m_size )
1013 return;
1014
1015 m_size = aSize;
1016
1017 // Move the fields if we're in autoplace mode
1019 AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
1020
1021 // Move the sheet labels according to the new sheet size.
1022 for( SCH_SHEET_PIN* sheetPin : m_pins )
1023 sheetPin->ConstrainOnEdge( sheetPin->GetPosition(), false );
1024}
1025
1026
1027bool SCH_SHEET::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
1028{
1029 // Sheets are searchable via the child field and pin item text.
1030 return false;
1031}
1032
1033
1035{
1036 int id = 2;
1037
1038 for( SCH_SHEET_PIN* pin : m_pins )
1039 {
1040 pin->SetNumber( id );
1041 id++;
1042 }
1043}
1044
1045
1047{
1048 wxCHECK_MSG( Schematic(), SCH_SHEET_PATH(), "Can't call findSelf without a schematic" );
1049
1050 SCH_SHEET_PATH sheetPath = Schematic()->CurrentSheet();
1051
1052 while( !sheetPath.empty() && sheetPath.Last() != this )
1053 sheetPath.pop_back();
1054
1055 if( sheetPath.empty() )
1056 {
1057 // If we weren't in the hierarchy, then we must be a child of the current sheet.
1058 sheetPath = Schematic()->CurrentSheet();
1059 sheetPath.push_back( const_cast<SCH_SHEET*>( this ) );
1060 }
1061
1062 return sheetPath;
1063}
1064
1065
1066void SCH_SHEET::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
1067{
1068 for( SCH_SHEET_PIN* sheetPin : m_pins )
1069 {
1070 wxCHECK2_MSG( sheetPin->Type() == SCH_SHEET_PIN_T, continue,
1071 wxT( "Invalid item in schematic sheet pin list. Bad programmer!" ) );
1072
1073 sheetPin->GetEndPoints( aItemList );
1074 }
1075}
1076
1077
1078bool SCH_SHEET::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
1079 std::vector<DANGLING_END_ITEM>& aItemListByPos,
1080 const SCH_SHEET_PATH* aPath )
1081{
1082 bool changed = false;
1083
1084 for( SCH_SHEET_PIN* sheetPin : m_pins )
1085 changed |= sheetPin->UpdateDanglingState( aItemListByType, aItemListByPos );
1086
1087 return changed;
1088}
1089
1090
1092 const SCH_SHEET_PATH* aInstance ) const
1093{
1094 // Do not compare to ourself.
1095 if( aItem == this )
1096 return false;
1097
1098 const SCH_SHEET* sheet = dynamic_cast<const SCH_SHEET*>( aItem );
1099
1100 // Don't compare against a different SCH_ITEM.
1101 wxCHECK( sheet, false );
1102
1103 if( GetPosition() != sheet->GetPosition() )
1104 return true;
1105
1106 // Technically this cannot happen because undo/redo does not support reloading sheet
1107 // file association changes. This was just added so that it doesn't get missed should
1108 // we ever fix the undo/redo issue.
1109 if( ( GetFileName() != sheet->GetFileName() ) || ( GetName() != sheet->GetName() ) )
1110 return true;
1111
1112 if( m_pins.size() != sheet->m_pins.size() )
1113 return true;
1114
1115 for( size_t i = 0; i < m_pins.size(); i++ )
1116 {
1117 if( m_pins[i]->HasConnectivityChanges( sheet->m_pins[i] ) )
1118 return true;
1119 }
1120
1121 return false;
1122}
1123
1124
1125std::vector<VECTOR2I> SCH_SHEET::GetConnectionPoints() const
1126{
1127 std::vector<VECTOR2I> retval;
1128
1129 for( SCH_SHEET_PIN* sheetPin : m_pins )
1130 retval.push_back( sheetPin->GetPosition() );
1131
1132 return retval;
1133}
1134
1135
1136INSPECT_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData,
1137 const std::vector<KICAD_T>& aScanTypes )
1138{
1139 for( KICAD_T scanType : aScanTypes )
1140 {
1141 // If caller wants to inspect my type
1142 if( scanType == SCH_LOCATE_ANY_T || scanType == Type() )
1143 {
1144 if( INSPECT_RESULT::QUIT == aInspector( this, nullptr ) )
1145 return INSPECT_RESULT::QUIT;
1146 }
1147
1148 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_FIELD_T )
1149 {
1150 // Test the sheet fields.
1151 for( SCH_FIELD& field : m_fields )
1152 {
1153 if( INSPECT_RESULT::QUIT == aInspector( &field, this ) )
1154 return INSPECT_RESULT::QUIT;
1155 }
1156 }
1157
1158 if( scanType == SCH_LOCATE_ANY_T || scanType == SCH_SHEET_PIN_T )
1159 {
1160 // Test the sheet labels.
1161 for( SCH_SHEET_PIN* sheetPin : m_pins )
1162 {
1163 if( INSPECT_RESULT::QUIT == aInspector( sheetPin, this ) )
1164 return INSPECT_RESULT::QUIT;
1165 }
1166 }
1167 }
1168
1169 return INSPECT_RESULT::CONTINUE;
1170}
1171
1172
1173void SCH_SHEET::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction )
1174{
1175 for( SCH_FIELD& field : m_fields )
1176 aFunction( &field );
1177
1178 for( SCH_SHEET_PIN* pin : m_pins )
1179 aFunction( pin );
1180}
1181
1182
1183wxString SCH_SHEET::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
1184{
1185 return wxString::Format( _( "Hierarchical Sheet %s" ),
1186 aFull ? m_fields[ SHEETNAME ].GetShownText( false )
1187 : KIUI::EllipsizeMenuText( m_fields[ SHEETNAME ].GetText() ) );
1188}
1189
1190
1192{
1193 return BITMAPS::add_hierarchical_subsheet;
1194}
1195
1196
1197bool SCH_SHEET::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1198{
1199 BOX2I rect = GetBodyBoundingBox();
1200
1201 rect.Inflate( aAccuracy );
1202
1203 return rect.Contains( aPosition );
1204}
1205
1206
1207bool SCH_SHEET::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1208{
1209 BOX2I rect = aRect;
1210
1211 rect.Inflate( aAccuracy );
1212
1213 if( aContained )
1214 return rect.Contains( GetBodyBoundingBox() );
1215
1216 return rect.Intersects( GetBodyBoundingBox() );
1217}
1218
1219
1220void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
1221 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
1222{
1223 if( aBackground && !aPlotter->GetColorMode() )
1224 return;
1225
1226 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
1227 COLOR4D borderColor = GetBorderColor();
1228 COLOR4D backgroundColor = GetBackgroundColor();
1229
1230 if( renderSettings->m_OverrideItemColors || borderColor == COLOR4D::UNSPECIFIED )
1231 borderColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET );
1232
1233 if( renderSettings->m_OverrideItemColors || backgroundColor == COLOR4D::UNSPECIFIED )
1234 backgroundColor = aPlotter->RenderSettings()->GetLayerColor( LAYER_SHEET_BACKGROUND );
1235
1236 if( aBackground && backgroundColor.a > 0.0 )
1237 {
1238 aPlotter->SetColor( backgroundColor );
1239 aPlotter->Rect( m_pos, m_pos + m_size, FILL_T::FILLED_SHAPE, 1 );
1240 }
1241 else
1242 {
1243 aPlotter->SetColor( borderColor );
1244
1245 int penWidth = GetEffectivePenWidth( getRenderSettings( aPlotter ) );
1246 aPlotter->Rect( m_pos, m_pos + m_size, FILL_T::NO_FILL, penWidth );
1247 }
1248
1249 // Make the sheet object a clickable hyperlink (e.g. for PDF plotter)
1250 std::vector<wxString> properties;
1251
1252 properties.emplace_back( EDA_TEXT::GotoPageHref( findSelf().GetPageNumber() ) );
1253
1254 for( const SCH_FIELD& field : GetFields() )
1255 {
1256 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
1257 field.GetName(),
1258 field.GetShownText( false ) ) );
1259 }
1260
1261 aPlotter->HyperlinkMenu( GetBoundingBox(), properties );
1262
1263 // Plot sheet pins
1264 for( SCH_SHEET_PIN* sheetPin : m_pins )
1265 sheetPin->Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1266
1267 // Plot the fields
1268 for( SCH_FIELD& field : m_fields )
1269 field.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
1270
1271 if( GetDNP() )
1272 {
1274 BOX2I bbox = GetBodyBoundingBox();
1275 BOX2I pins = GetBoundingBox();
1276 VECTOR2D margins( std::max( bbox.GetX() - pins.GetX(),
1277 pins.GetEnd().x - bbox.GetEnd().x ),
1278 std::max( bbox.GetY() - pins.GetY(),
1279 pins.GetEnd().y - bbox.GetEnd().y ) );
1280 int strokeWidth = 3.0 * schIUScale.MilsToIU( DEFAULT_LINE_WIDTH_MILS );
1281
1282 margins.x = std::max( margins.x * 0.6, margins.y * 0.3 );
1283 margins.y = std::max( margins.y * 0.6, margins.x * 0.3 );
1284 bbox.Inflate( KiROUND( margins.x ), KiROUND( margins.y ) );
1285
1286 aPlotter->SetColor( colors->GetColor( LAYER_DNP_MARKER ) );
1287
1288 aPlotter->ThickSegment( bbox.GetOrigin(), bbox.GetEnd(), strokeWidth, FILLED, nullptr );
1289
1290 aPlotter->ThickSegment( bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ),
1291 bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ),
1292 strokeWidth, FILLED, nullptr );
1293 }
1294}
1295
1296
1297void SCH_SHEET::Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
1298 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed )
1299{
1300 wxDC* DC = aSettings->GetPrintDC();
1301 VECTOR2I pos = m_pos + aOffset;
1302 int lineWidth = GetEffectivePenWidth( aSettings );
1303 COLOR4D border = GetBorderColor();
1304 COLOR4D background = GetBackgroundColor();
1305
1306 if( aSettings->m_OverrideItemColors || border == COLOR4D::UNSPECIFIED )
1307 border = aSettings->GetLayerColor( LAYER_SHEET );
1308
1309 if( aSettings->m_OverrideItemColors || background == COLOR4D::UNSPECIFIED )
1310 background = aSettings->GetLayerColor( LAYER_SHEET_BACKGROUND );
1311
1312 if( GetGRForceBlackPenState() ) // printing in black & white
1313 background = COLOR4D::UNSPECIFIED;
1314
1315 if( background.a > 0.0 )
1316 GRFilledRect( DC, pos, pos + m_size, 0, background, background );
1317
1318 GRRect( DC, pos, pos + m_size, lineWidth, border );
1319
1320 for( SCH_FIELD& field : m_fields )
1321 field.Print( aSettings, aUnit, aBodyStyle, aOffset, aForceNoFill, aDimmed );
1322
1323 for( SCH_SHEET_PIN* sheetPin : m_pins )
1324 sheetPin->Print( aSettings, aUnit, aBodyStyle, aOffset, aForceNoFill, aDimmed );
1325
1326 if( GetDNP() )
1327 {
1328 BOX2I bbox = GetBodyBoundingBox();
1329 BOX2I pins = GetBoundingBox();
1330 COLOR4D dnp_color = aSettings->GetLayerColor( LAYER_DNP_MARKER );
1331 VECTOR2D margins( std::max( bbox.GetX() - pins.GetX(), pins.GetEnd().x - bbox.GetEnd().x ),
1332 std::max( bbox.GetY() - pins.GetY(), pins.GetEnd().y - bbox.GetEnd().y ) );
1333
1334 margins.x = std::max( margins.x * 0.6, margins.y * 0.3 );
1335 margins.y = std::max( margins.y * 0.6, margins.x * 0.3 );
1336 bbox.Inflate( KiROUND( margins.x ), KiROUND( margins.y ) );
1337
1338 GRFilledSegment( DC, bbox.GetOrigin(), bbox.GetEnd(),
1340 dnp_color );
1341
1342 GRFilledSegment( DC, bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ),
1343 bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ),
1345 dnp_color );
1346 }
1347}
1348
1349
1351{
1352 wxCHECK_MSG( Type() == aItem.Type(), *this,
1353 wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
1354 GetClass() );
1355
1356 if( &aItem != this )
1357 {
1358 SCH_ITEM::operator=( aItem );
1359
1360 SCH_SHEET* sheet = (SCH_SHEET*) &aItem;
1361
1362 m_pos = sheet->m_pos;
1363 m_size = sheet->m_size;
1364 m_fields = sheet->m_fields;
1365
1366 for( SCH_SHEET_PIN* pin : sheet->m_pins )
1367 {
1368 m_pins.emplace_back( new SCH_SHEET_PIN( *pin ) );
1369 m_pins.back()->SetParent( this );
1370 }
1371
1372 for( const SCH_SHEET_INSTANCE& instance : sheet->m_instances )
1373 m_instances.emplace_back( instance );
1374 }
1375
1376 return *this;
1377}
1378
1379
1380bool SCH_SHEET::operator <( const SCH_ITEM& aItem ) const
1381{
1382 if( Type() != aItem.Type() )
1383 return Type() < aItem.Type();
1384
1385 auto sheet = static_cast<const SCH_SHEET*>( &aItem );
1386
1387 if (m_fields[ SHEETNAME ].GetText() != sheet->m_fields[ SHEETNAME ].GetText() )
1388 return m_fields[ SHEETNAME ].GetText() < sheet->m_fields[ SHEETNAME ].GetText();
1389
1390 if (m_fields[ SHEETFILENAME ].GetText() != sheet->m_fields[ SHEETFILENAME ].GetText() )
1391 return m_fields[ SHEETFILENAME ].GetText() < sheet->m_fields[ SHEETFILENAME ].GetText();
1392
1393 return false;
1394}
1395
1396
1397void SCH_SHEET::RemoveInstance( const KIID_PATH& aInstancePath )
1398{
1399 // Search for an existing path and remove it if found (should not occur)
1400 for( unsigned ii = 0; ii < m_instances.size(); ii++ )
1401 {
1402 if( m_instances[ii].m_Path == aInstancePath )
1403 {
1404 wxLogTrace( traceSchSheetPaths, "Removing sheet instance:\n"
1405 " sheet path %s\n"
1406 " page %s, from project %s.",
1407 aInstancePath.AsString(),
1408 m_instances[ii].m_PageNumber,
1409 m_instances[ii].m_ProjectName );
1410
1411 m_instances.erase( m_instances.begin() + ii );
1412 ii--;
1413 }
1414 }
1415}
1416
1417
1419{
1420 SCH_SHEET_INSTANCE oldInstance;
1421
1422 if( getInstance( oldInstance, aInstance.m_Path ) )
1423 RemoveInstance( aInstance.m_Path );
1424
1425 m_instances.emplace_back( aInstance );
1426
1427}
1428
1429
1431{
1432 for( const SCH_SHEET_INSTANCE& instance : m_instances )
1433 {
1434 // if aSheetPath is found, nothing to do:
1435 if( instance.m_Path == aPath )
1436 return false;
1437 }
1438
1439 wxLogTrace( traceSchSheetPaths, wxT( "Adding instance `%s` to sheet `%s`." ),
1440 aPath.AsString(),
1441 ( GetName().IsEmpty() ) ? wxString( wxT( "root" ) ) : GetName() );
1442
1443 SCH_SHEET_INSTANCE instance;
1444
1445 instance.m_Path = aPath;
1446
1447 // This entry does not exist: add it with an empty page number.
1448 m_instances.emplace_back( instance );
1449 return true;
1450}
1451
1452
1453bool SCH_SHEET::getInstance( SCH_SHEET_INSTANCE& aInstance, const KIID_PATH& aSheetPath,
1454 bool aTestFromEnd ) const
1455{
1456 for( const SCH_SHEET_INSTANCE& instance : m_instances )
1457 {
1458 if( !aTestFromEnd )
1459 {
1460 if( instance.m_Path == aSheetPath )
1461 {
1462 aInstance = instance;
1463 return true;
1464 }
1465 }
1466 else if( instance.m_Path.EndsWith( aSheetPath ) )
1467 {
1468 aInstance = instance;
1469 return true;
1470 }
1471 }
1472
1473 return false;
1474}
1475
1476
1478{
1479 for( const SCH_SHEET_INSTANCE& instance : m_instances )
1480 {
1481 if( instance.m_Path.size() == 0 )
1482 return true;
1483 }
1484
1485 return false;
1486}
1487
1488
1490{
1491 for( const SCH_SHEET_INSTANCE& instance : m_instances )
1492 {
1493 if( instance.m_Path.size() == 0 )
1494 return instance;
1495 }
1496
1497 wxFAIL;
1498
1500
1501 return dummy;
1502}
1503
1504
1505wxString SCH_SHEET::getPageNumber( const KIID_PATH& aPath ) const
1506{
1507 wxString pageNumber;
1508
1509 for( const SCH_SHEET_INSTANCE& instance : m_instances )
1510 {
1511 if( instance.m_Path == aPath )
1512 {
1513 pageNumber = instance.m_PageNumber;
1514 break;
1515 }
1516 }
1517
1518 return pageNumber;
1519}
1520
1521
1522void SCH_SHEET::setPageNumber( const KIID_PATH& aPath, const wxString& aPageNumber )
1523{
1524 for( SCH_SHEET_INSTANCE& instance : m_instances )
1525 {
1526 if( instance.m_Path == aPath )
1527 {
1528 instance.m_PageNumber = aPageNumber;
1529 break;
1530 }
1531 }
1532}
1533
1534
1535int SCH_SHEET::ComparePageNum( const wxString& aPageNumberA, const wxString& aPageNumberB )
1536{
1537 if( aPageNumberA == aPageNumberB )
1538 return 0; // A == B
1539
1540 // First sort numerically if the page numbers are integers
1541 long pageA, pageB;
1542 bool isIntegerPageA = aPageNumberA.ToLong( &pageA );
1543 bool isIntegerPageB = aPageNumberB.ToLong( &pageB );
1544
1545 if( isIntegerPageA && isIntegerPageB )
1546 {
1547 if( pageA < pageB )
1548 return -1; //A < B
1549 else
1550 return 1; // A > B
1551 }
1552
1553 // Numerical page numbers always before strings
1554 if( isIntegerPageA )
1555 return -1; //A < B
1556 else if( isIntegerPageB )
1557 return 1; // A > B
1558
1559 // If not numeric, then sort as strings using natural sort
1560 int result = StrNumCmp( aPageNumberA, aPageNumberB );
1561
1562 // Divide by zero bad.
1563 wxCHECK( result != 0, 0 );
1564
1565 result = result / std::abs( result );
1566
1567 return result;
1568}
1569
1570
1571bool SCH_SHEET::operator==( const SCH_ITEM& aOther ) const
1572{
1573 if( Type() != aOther.Type() )
1574 return false;
1575
1576 const SCH_SHEET* other = static_cast<const SCH_SHEET*>( &aOther );
1577
1578 if( m_pos != other->m_pos )
1579 return false;
1580
1581 if( m_size != other->m_size )
1582 return false;
1583
1584 if( GetExcludedFromSim() != other->GetExcludedFromSim() )
1585 return false;
1586
1587 if( GetExcludedFromBOM() != other->GetExcludedFromBOM() )
1588 return false;
1589
1590 if( GetExcludedFromBoard() != other->GetExcludedFromBoard() )
1591 return false;
1592
1593 if( GetDNP() != other->GetDNP() )
1594 return false;
1595
1596 if( GetBorderColor() != other->GetBorderColor() )
1597 return false;
1598
1599 if( GetBackgroundColor() != other->GetBackgroundColor() )
1600 return false;
1601
1602 if( GetBorderWidth() != other->GetBorderWidth() )
1603 return false;
1604
1605 if( GetFields().size() != other->GetFields().size() )
1606 return false;
1607
1608 for( size_t i = 0; i < GetFields().size(); ++i )
1609 {
1610 if( !( GetFields()[i] == other->GetFields()[i] ) )
1611 return false;
1612 }
1613
1614 return true;
1615}
1616
1617
1618double SCH_SHEET::Similarity( const SCH_ITEM& aOther ) const
1619{
1620 if( Type() != aOther.Type() )
1621 return 0.0;
1622
1623 const SCH_SHEET* other = static_cast<const SCH_SHEET*>( &aOther );
1624
1625 if( m_screen->GetFileName() == other->m_screen->GetFileName() )
1626 return 1.0;
1627
1628 return 0.0;
1629}
1630
1631
1632#if defined(DEBUG)
1633
1634void SCH_SHEET::Show( int nestLevel, std::ostream& os ) const
1635{
1636 // XML output:
1637 wxString s = GetClass();
1638
1639 NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str() << ">" << " sheet_name=\""
1640 << TO_UTF8( m_fields[ SHEETNAME ].GetText() ) << '"' << ">\n";
1641
1642 // show all the pins, and check the linked list integrity
1643 for( SCH_SHEET_PIN* sheetPin : m_pins )
1644 sheetPin->Show( nestLevel + 1, os );
1645
1646 NestedSpace( nestLevel, os ) << "</" << s.Lower().mb_str() << ">\n" << std::flush;
1647}
1648
1649#endif
1650
1651static struct SCH_SHEET_DESC
1652{
1654 {
1658
1659 propMgr.AddProperty( new PROPERTY<SCH_SHEET, wxString>( _HKI( "Sheet Name" ),
1661
1662 propMgr.AddProperty( new PROPERTY<SCH_SHEET, int>( _HKI( "Border Width" ),
1664 PROPERTY_DISPLAY::PT_SIZE ) );
1665
1666 propMgr.AddProperty( new PROPERTY<SCH_SHEET, COLOR4D>( _HKI( "Border Color" ),
1668
1669 propMgr.AddProperty( new PROPERTY<SCH_SHEET, COLOR4D>( _HKI( "Background Color" ),
1671
1672 const wxString groupAttributes = _HKI( "Attributes" );
1673
1674 propMgr.AddProperty( new PROPERTY<SCH_SHEET, bool>( _HKI( "Exclude From Board" ),
1676 groupAttributes );
1677 propMgr.AddProperty( new PROPERTY<SCH_SHEET, bool>( _HKI( "Exclude From Simulation" ),
1679 groupAttributes );
1680 propMgr.AddProperty( new PROPERTY<SCH_SHEET, bool>( _HKI( "Exclude From Bill of Materials" ),
1682 groupAttributes );
1683 propMgr.AddProperty( new PROPERTY<SCH_SHEET, bool>( _HKI( "Do not Populate" ),
1685 groupAttributes );
1686 }
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
const Vec & GetOrigin() const
Definition: box2.h:200
size_type GetHeight() const
Definition: box2.h:205
const Vec GetCenter() const
Definition: box2.h:220
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:294
coord_type GetTop() const
Definition: box2.h:219
size_type GetWidth() const
Definition: box2.h:204
coord_type GetY() const
Definition: box2.h:198
const Vec GetEnd() const
Definition: box2.h:202
bool Contains(const Vec &aPoint) const
Definition: box2.h:158
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:541
coord_type GetX() const
Definition: box2.h:197
coord_type GetRight() const
Definition: box2.h:207
coord_type GetLeft() const
Definition: box2.h:218
coord_type GetBottom() const
Definition: box2.h:212
void SetEnd(coord_type x, coord_type y)
Definition: box2.h:280
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:623
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
EDA_ITEM * GetParent() const
Definition: eda_item.h:103
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
static wxString GotoPageHref(const wxString &aDestination)
Generate a href to a page in the current schematic.
Definition: eda_text.cpp:1164
EE_TYPE OfType(KICAD_T aType) const
Definition: sch_rtree.h:238
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double a
Alpha component.
Definition: color4d.h:395
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
wxString AsString() const
Definition: kiid.cpp:356
Definition: kiid.h:49
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
Base plotter engine class.
Definition: plotter.h:105
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:553
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:136
bool GetColorMode() const
Definition: plotter.h:133
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Definition: plotter.h:465
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetColor(const COLOR4D &color)=0
Container for project specific data.
Definition: project.h:62
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:87
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
Holds all the data relating to one schematic.
Definition: schematic.h:76
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:144
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:297
SCH_SHEET_LIST BuildUnorderedSheetList() const
Definition: schematic.h:101
bool ResolveTextVar(const SCH_SHEET_PATH *aSheetPath, wxString *token, int aDepth) const
Definition: schematic.cpp:238
void GetContextualTextVars(wxArrayString *aVars) const
Definition: schematic.cpp:213
SCH_SHEET & Root() const
Definition: schematic.h:113
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:91
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Definition: schematic.cpp:427
Schematic editor (Eeschema) main window.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition: sch_item.cpp:101
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:670
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:727
void SwapFlags(SCH_ITEM *aItem)
Swap the non-temp and non-edit flags.
Definition: sch_item.cpp:354
wxString GetClass() const override
Return the class name.
Definition: sch_item.h:176
int GetEffectivePenWidth(const SCH_RENDER_SETTINGS *aSettings) const
Definition: sch_item.cpp:475
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
Definition: sch_item.h:560
SCH_LAYER_ID m_layer
Definition: sch_item.h:723
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:108
const wxString & GetFileName() const
Definition: sch_screen.h:143
void DecRefCount()
Definition: sch_screen.cpp:131
void IncRefCount()
Definition: sch_screen.cpp:125
const TITLE_BLOCK & GetTitleBlock() const
Definition: sch_screen.h:154
int GetRefCount() const
Definition: sch_screen.h:160
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.
wxString PathHumanReadable(bool aUseShortRootName=true, bool aStripTrailingSeparator=false) const
Return the sheet path in a human readable form made from the sheet names.
wxString GetPageNumber() const
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.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
Definition: sch_sheet.cpp:1066
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this sheet.
Definition: sch_sheet.cpp:212
friend SCH_SHEET_PATH
Definition: sch_sheet.h:462
bool GetExcludedFromBOM() const
Definition: sch_sheet.h:376
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:119
friend class SCH_SHEET_PIN
Definition: sch_sheet.h:527
VECTOR2I m_size
Definition: sch_sheet.h:544
void SetFileName(const wxString &aFilename)
Definition: sch_sheet.h:312
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
Definition: sch_sheet.cpp:1091
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:306
bool IsRootSheet() const
Definition: sch_sheet.cpp:204
bool getInstance(SCH_SHEET_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
Definition: sch_sheet.cpp:1453
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_sheet.cpp:1191
void RemoveInstance(const KIID_PATH &aInstancePath)
Definition: sch_sheet.cpp:1397
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
Definition: sch_sheet.cpp:56
bool addInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
Definition: sch_sheet.cpp:1430
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
Definition: sch_sheet.cpp:426
bool HasRootInstance() const
Check to see if this sheet has a root sheet instance.
Definition: sch_sheet.cpp:1477
wxString GetClass() const override
Return the class name.
Definition: sch_sheet.h:77
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
Definition: sch_sheet.cpp:1173
int GetPenWidth() const override
Definition: sch_sheet.cpp:651
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_sheet.cpp:166
SCH_SHEET_PATH findSelf() const
Get the sheetpath of this sheet.
Definition: sch_sheet.cpp:1046
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_sheet.cpp:1027
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: sch_sheet.cpp:1618
VECTOR2I m_pos
Definition: sch_sheet.h:543
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:93
KIGFX::COLOR4D m_borderColor
Definition: sch_sheet.h:546
bool m_excludedFromBOM
Definition: sch_sheet.h:539
wxString GetName() const
Definition: sch_sheet.h:107
void renumberPins()
Renumber the sheet pins in the sheet.
Definition: sch_sheet.cpp:1034
void SetExcludedFromBOM(bool aExcludeFromBOM)
Set or clear the exclude from schematic bill of materials flag.
Definition: sch_sheet.h:375
VECTOR2I GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
Definition: sch_sheet.cpp:753
SCH_SHEET_PIN * GetPin(const VECTOR2I &aPosition)
Return the sheet pin item found at aPosition in the sheet.
Definition: sch_sheet.cpp:639
bool operator<(const SCH_ITEM &aItem) const override
Definition: sch_sheet.cpp:1380
bool GetExcludedFromBoard() const
Definition: sch_sheet.h:382
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
Definition: sch_sheet.cpp:613
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print an item.
Definition: sch_sheet.cpp:1297
void RemovePin(const SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Definition: sch_sheet.cpp:437
void SetPositionIgnoringPins(const VECTOR2I &aPosition)
Definition: sch_sheet.cpp:897
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:782
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Definition: sch_sheet.cpp:818
std::vector< SCH_SHEET_INSTANCE > m_instances
Definition: sch_sheet.h:549
bool HasUndefinedPins() const
Check all sheet labels against schematic for undefined hierarchical labels.
Definition: sch_sheet.cpp:499
bool m_excludedFromSim
Definition: sch_sheet.h:538
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_sheet.cpp:1002
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition: sch_sheet.h:122
int SymbolCount() const
Count our own symbols, without the power symbols.
Definition: sch_sheet.cpp:760
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.
Definition: sch_sheet.cpp:1220
void AddInstance(const SCH_SHEET_INSTANCE &aInstance)
Definition: sch_sheet.cpp:1418
int GetMinWidth(bool aFromLeft) const
Return the minimum width of the sheet based on the widths of the sheet pin text.
Definition: sch_sheet.cpp:545
bool operator==(const SCH_ITEM &aOther) const override
Definition: sch_sheet.cpp:1571
SCH_SCREEN * m_screen
Definition: sch_sheet.h:531
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_sheet.cpp:706
std::vector< SCH_FIELD > m_fields
Definition: sch_sheet.h:536
void SetDNP(bool aDNP)
Definition: sch_sheet.h:388
KIGFX::COLOR4D m_backgroundColor
Definition: sch_sheet.h:547
void SetName(const wxString &aName)
Definition: sch_sheet.h:108
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
Definition: sch_sheet.cpp:842
VECTOR2I GetPosition() const override
Definition: sch_sheet.h:400
const BOX2I GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
Definition: sch_sheet.cpp:721
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
Definition: sch_sheet.cpp:454
static int ComparePageNum(const wxString &aPageNumberA, const wxString &aPageNumberB)
Compares page numbers of schematic sheets.
Definition: sch_sheet.cpp:1535
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)), FIELDS_AUTOPLACED aAutoplaceFields=FIELDS_AUTOPLACED_AUTO)
Definition: sch_sheet.cpp:78
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_sheet.cpp:982
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
Definition: sch_sheet.cpp:406
int GetScreenCount() const
Return the number of times the associated screen for the sheet is being used.
Definition: sch_sheet.cpp:195
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
Definition: sch_sheet.cpp:172
SCH_SHEET & operator=(const SCH_ITEM &aSheet)
Definition: sch_sheet.cpp:1350
const SCH_SHEET_INSTANCE & GetRootInstance() const
Return the root sheet instance data.
Definition: sch_sheet.cpp:1489
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_sheet.cpp:466
bool m_excludedFromBoard
Definition: sch_sheet.h:540
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Definition: sch_sheet.cpp:663
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_sheet.cpp:742
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
Definition: sch_sheet.cpp:1125
KIGFX::COLOR4D GetBorderColor() const
Definition: sch_sheet.h:118
std::vector< SCH_SHEET_PIN * > m_pins
Definition: sch_sheet.h:535
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...
Definition: sch_sheet.cpp:1136
void SetBorderWidth(int aWidth)
Definition: sch_sheet.h:116
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_sheet.cpp:962
void setPageNumber(const KIID_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
Definition: sch_sheet.cpp:1522
bool GetExcludedFromSim() const override
Definition: sch_sheet.h:370
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_sheet.cpp:365
int GetMinHeight(bool aFromTop) const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
Definition: sch_sheet.cpp:579
int m_borderWidth
Definition: sch_sheet.h:545
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_sheet.cpp:1183
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.
Definition: sch_sheet.cpp:1078
void Resize(const VECTOR2I &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
Definition: sch_sheet.cpp:1010
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_sheet.cpp:908
int GetBorderWidth() const
Definition: sch_sheet.h:115
void SetExcludedFromBoard(bool aExcludeFromBoard)
Set or clear exclude from board netlist flag.
Definition: sch_sheet.h:381
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: sch_sheet.cpp:856
bool m_DNP
Definition: sch_sheet.h:541
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_sheet.cpp:920
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
Definition: sch_sheet.cpp:251
bool IsVerticalOrientation() const
Definition: sch_sheet.cpp:478
void SetExcludedFromSim(bool aExcludeFromSim) override
Set or clear the exclude from simulation flag.
Definition: sch_sheet.h:369
bool GetDNP() const
Set or clear the 'Do Not Populate' flaga.
Definition: sch_sheet.h:387
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_sheet.cpp:1197
KIGFX::COLOR4D GetBackgroundColor() const
Definition: sch_sheet.h:121
wxString getPageNumber(const KIID_PATH &aInstance) const
Return the sheet page number for aInstance.
Definition: sch_sheet.cpp:1505
Schematic symbol object.
Definition: sch_symbol.h:105
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:919
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
bool TextVarResolver(wxString *aToken, const PROJECT *aProject) const
Definition: title_block.cpp:96
static void GetContextualTextVars(wxArrayString *aVars)
Definition: title_block.cpp:74
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
#define _HKI(x)
#define _(s)
static constexpr EDA_ANGLE ANGLE_90
Definition: eda_angle.h:403
static constexpr EDA_ANGLE ANGLE_VERTICAL
Definition: eda_angle.h:398
static constexpr EDA_ANGLE ANGLE_HORIZONTAL
Definition: eda_angle.h:397
static constexpr EDA_ANGLE ANGLE_270
Definition: eda_angle.h:406
INSPECT_RESULT
Definition: eda_item.h:43
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:82
void GRRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:396
void GRFilledSegment(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:278
static const bool FILLED
Definition: gr_basic.cpp:30
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition: gr_basic.cpp:403
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:165
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
@ LAYER_DANGLING
Definition: layer_ids.h:382
@ LAYER_SHEETNAME
Definition: layer_ids.h:377
@ LAYER_SHEET_BACKGROUND
Definition: layer_ids.h:389
@ LAYER_HIERLABEL
Definition: layer_ids.h:362
@ LAYER_SHEETFIELDS
Definition: layer_ids.h:379
@ LAYER_SHEET
Definition: layer_ids.h:376
@ LAYER_SELECTION_SHADOWS
Definition: layer_ids.h:397
@ LAYER_SHEETFILENAME
Definition: layer_ids.h:378
@ LAYER_DNP_MARKER
Definition: layer_ids.h:383
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
Message panel definition file.
KICOMMON_API wxString EllipsizeMenuText(const wxString &aString)
Ellipsize text (at the end) to be no more than 36 characters.
Definition: ui_common.cpp:213
KICOMMON_API wxString EllipsizeStatusText(wxWindow *aWindow, const wxString &aString)
Ellipsize text (at the end) to be no more than 1/3 of the window width.
Definition: ui_common.cpp:195
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:100
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:390
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: pgm_base.cpp:1059
see class PGM_BASE
#define TYPE_HASH(x)
Definition: property.h:71
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
FIELDS_AUTOPLACED
Definition: sch_item.h:68
@ FIELDS_AUTOPLACED_AUTO
Definition: sch_item.h:70
#define USER_FIELD_CANONICAL
Definition: sch_sheet.cpp:53
#define SHEET_NAME_CANONICAL
Definition: sch_sheet.cpp:51
int bumpToNextGrid(const int aVal, const int aDirection)
Definition: sch_sheet.cpp:523
static struct SCH_SHEET_DESC _SCH_SHEET_DESC
#define SHEET_FILE_CANONICAL
Definition: sch_sheet.cpp:52
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition: sch_sheet.h:49
@ SHEETNAME
Definition: sch_sheet.h:45
@ SHEETFILENAME
Definition: sch_sheet.h:46
#define MIN_SHEET_HEIGHT
Definition: sch_sheet.h:40
#define MIN_SHEET_WIDTH
Definition: sch_sheet.h:39
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.
Definition: sch_sheet_pin.h:46
std::vector< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:391
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
A simple container for sheet instance information.
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
constexpr 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:228
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_LOCATE_ANY_T
Definition: typeinfo.h:198
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:173
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:121
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:673