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