KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_sheet.h
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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef SCH_SHEEET_H
22#define SCH_SHEEET_H
23
24#include <map>
25#include <memory>
26#include <functional>
27#include <set>
28
29#include <sch_field.h>
30
31class KIID_PATH;
32class SCH_SCREEN;
34class SCH_SHEET_LIST;
35class SCH_SHEET_PIN;
36class SCH_SHEET_PATH;
37class EDA_DRAW_FRAME;
38class SCH_NO_CONNECT;
40
41
42#define MIN_SHEET_WIDTH 500 // Units are mils.
43#define MIN_SHEET_HEIGHT 150 // Units are mils.
44
45
49class SCH_SHEET : public SCH_ITEM
50{
51public:
52 SCH_SHEET( EDA_ITEM* aParent = nullptr, const VECTOR2I& aPos = VECTOR2I( 0, 0 ),
53 VECTOR2I aSize = VECTOR2I( schIUScale.MilsToIU( MIN_SHEET_WIDTH ),
54 schIUScale.MilsToIU( MIN_SHEET_HEIGHT ) ) );
55
56 void Serialize( google::protobuf::Any& aContainer ) const override;
57 bool Deserialize( const google::protobuf::Any& aContainer ) override;
58
65 SCH_SHEET( const SCH_SHEET& aSheet );
66
67 ~SCH_SHEET();
68
69 static inline bool ClassOf( const EDA_ITEM* aItem )
70 {
71 return aItem && SCH_SHEET_T == aItem->Type();
72 }
73
74 wxString GetClass() const override
75 {
76 return wxT( "SCH_SHEET" );
77 }
78
88 bool IsMovableFromAnchorPoint() const override { return false; }
89
93 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
94 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
95
100 SCH_FIELD* GetField( FIELD_T aFieldType );
101 const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
102
110 SCH_FIELD* GetField( const wxString& aFieldName );
111 const SCH_FIELD* GetField( const wxString& aFieldName ) const;
112
113 std::vector<PROPERTY_BASE*> GetDynamicProperties() const override;
114
118 int GetNextFieldOrdinal() const;
119
125 void SetFields( const std::vector<SCH_FIELD>& aFields );
126
132 SCH_FIELD* AddField( const SCH_FIELD& aField );
133
134 void SetFieldText( SCH_FIELD* aField, const wxString& aFieldName, const wxString& aFieldText,
135 const SCH_SHEET_PATH* aPath, const wxString& aVariantName );
136
137 void SetFieldText( const wxString& aFieldName, const wxString& aFieldText, const SCH_SHEET_PATH* aPath = nullptr,
138 const wxString& aVariantName = wxEmptyString );
139
140 wxString GetFieldText( const SCH_FIELD* aField, const wxString& aFieldName, const SCH_SHEET_PATH* aPath,
141 const wxString& aVariantName ) const;
142
143 wxString GetFieldText( const wxString& aFieldName, const SCH_SHEET_PATH* aPath = nullptr,
144 const wxString& aVariantName = wxEmptyString ) const;
145
146 wxString GetShownName( RESOLUTION_CONTEXT aContext ) const
147 {
148 return GetField( FIELD_T::SHEET_NAME )->GetShownText( aContext );
149 }
150 wxString GetName() const { return GetField( FIELD_T::SHEET_NAME )->GetText(); }
151
160 wxString GetRefSuffix( const SCH_SHEET_PATH& aParentPath ) const;
161
165 wxString ResolveRefSuffix( const wxString& aText, const SCH_SHEET_PATH& aParentPath ) const;
166
170 wxString GetFullRefSuffixProp() const;
171
183 static wxString NextRefSuffix( const wxString& aSuffix, const std::set<wxString>& aInUse,
184 const std::function<bool( const wxString& )>& aIsTaken = nullptr );
185 void SetName( const wxString& aName ) { GetField( FIELD_T::SHEET_NAME )->SetText( aName ); }
186
187 SCH_SCREEN* GetScreen() const { return m_screen; }
188
189 VECTOR2I GetSize() const { return m_size; }
190 void SetSize( const VECTOR2I& aSize ) { m_size = aSize; }
191
192 int GetBorderWidth() const { return m_borderWidth; }
193 void SetBorderWidth( int aWidth ) { m_borderWidth = aWidth; }
194
196 void SetBorderColor( KIGFX::COLOR4D aColor ) { m_borderColor = aColor; }
197
200
206 bool IsVirtualRootSheet() const;
207
215 bool IsTopLevelSheet() const;
216
228 void SetScreen( SCH_SCREEN* aScreen );
229
236 void SyncUuidToScreen();
237
243 int GetScreenCount() const;
244
248 void GetContextualTextVars( wxArrayString* aVars ) const;
249
257 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth = 0 ) const;
258
259 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
260
261 /* there is no member for orientation in sch_sheet, to preserve file
262 * format, we detect orientation based on pin edges
263 */
264 bool IsVerticalOrientation() const;
265
270 std::map<SCH_SHEET_PIN*, SCH_NO_CONNECT*> GetNoConnects() const;
271
272 void SetPositionIgnoringPins( const VECTOR2I& aPosition );
273
283 void AddPin( SCH_SHEET_PIN* aSheetPin );
284
285 std::vector<SCH_SHEET_PIN*>& GetPins() { return m_pins; }
286 const std::vector<SCH_SHEET_PIN*>& GetPins() const { return m_pins; }
287
293 void RemovePin( const SCH_SHEET_PIN* aSheetPin );
294
301 void CleanupSheet();
302
310 SCH_SHEET_PIN* GetPin( const VECTOR2I& aPosition );
311
318 bool HasPin( const wxString& aName ) const;
319
320 bool HasPins() const { return !m_pins.empty(); }
321
327 bool HasUndefinedPins() const;
328
340 int GetMinWidth( bool aFromLeft ) const;
341
352 int GetMinHeight( bool aFromTop ) const;
353
354 int GetPenWidth() const override;
355
359 const BOX2I GetBodyBoundingBox() const;
360
361 const BOX2I GetBoundingBox() const override;
362
370
371 void swapData( SCH_ITEM* aItem ) override;
372
376 int SymbolCount() const;
377
385 bool SearchHierarchy( const wxString& aFilename, SCH_SCREEN** aScreen );
386
397 bool LocatePathOfScreen( SCH_SCREEN* aScreen, SCH_SHEET_PATH* aList );
398
404 int CountSheets() const;
405
413 int CountActiveSheets() const;
414
421 int CountSheets( const wxString& aFileName ) const;
422
428 wxString GetFileName() const
429 {
431 }
432
433 // Set a new filename without changing anything else
434 void SetFileName( const wxString& aFilename )
435 {
436 // Filenames are stored using unix notation
437 wxString tmp = aFilename;
438 tmp.Replace( wxT( "\\" ), wxT( "/" ) );
440 }
441
442 // Geometric transforms (used in block operations):
443
444 void Move( const VECTOR2I& aMoveVector ) override;
445 void MirrorHorizontally( int aCenter ) override;
446 void MirrorVertically( int aCenter ) override;
447 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
448
449 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
450
451 bool IsReplaceable() const override { return true; }
452
458 void Resize( const VECTOR2I& aSize );
459
460 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
461
462 void GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) override;
463
464 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
465 std::vector<DANGLING_END_ITEM>& aItemListByPos,
466 const SCH_SHEET_PATH* aPath = nullptr ) override;
467
468 bool IsConnectable() const override { return true; }
469
470 bool HasConnectivityChanges( const SCH_ITEM* aItem,
471 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
472
473 bool CanConnect( const SCH_ITEM* aItem ) const override
474 {
475 return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE )
476 || ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS )
477 || ( aItem->Type() == SCH_NO_CONNECT_T )
478 || ( aItem->Type() == SCH_SYMBOL_T );
479 }
480
481 std::vector<VECTOR2I> GetConnectionPoints() const override;
482
483 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
484 const std::vector<KICAD_T>& aScanTypes ) override;
485
486 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
487
491 void SetExcludedFromSim( bool aExcludeFromSim, const SCH_SHEET_PATH* aInstance = nullptr,
492 const wxString& aVariantName = wxEmptyString ) override;
493 bool GetExcludedFromSim( const SCH_SHEET_PATH* aInstance = nullptr,
494 const wxString& aVariantName = wxEmptyString ) const override;
495
496 bool GetExcludedFromSimProp() const;
497 void SetExcludedFromSimProp( bool aEnable );
498
502 void SetExcludedFromBOM( bool aExcludeFromBOM, const SCH_SHEET_PATH* aInstance = nullptr,
503 const wxString& aVariantName = wxEmptyString ) override;
504 bool GetExcludedFromBOM( const SCH_SHEET_PATH* aInstance = nullptr,
505 const wxString& aVariantName = wxEmptyString ) const override;
506
507 bool GetExcludedFromBOMProp() const;
508 void SetExcludedFromBOMProp( bool aEnable );
509
513 void SetExcludedFromBoard( bool aExclude, const SCH_SHEET_PATH* aInstance = nullptr,
514 const wxString& aVariantName = wxEmptyString ) override
515 {
516 m_excludedFromBoard = aExclude;
517 }
518
519 bool GetExcludedFromBoard( const SCH_SHEET_PATH* aInstance = nullptr,
520 const wxString& aVariantName = wxEmptyString ) const override
521 {
522 return m_excludedFromBoard;
523 }
524
526 void SetExcludedFromBoardProp( bool aExclude ) { SetExcludedFromBoard( aExclude ); }
527
531 bool GetDNP( const SCH_SHEET_PATH* aInstance = nullptr,
532 const wxString& aVariantName = wxEmptyString ) const override;
533 void SetDNP( bool aDNP, const SCH_SHEET_PATH* aInstance = nullptr,
534 const wxString& aVariantName = wxEmptyString ) override;
535 bool GetDNPProp() const;
536 void SetDNPProp( bool aEnable );
537
538 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
539
540 BITMAPS GetMenuImage() const override;
541
542 SCH_SHEET& operator=( const SCH_ITEM& aSheet );
543
544 bool operator <( const SCH_ITEM& aItem ) const override;
545
546 std::vector<int> ViewGetLayers() const override;
547
548 VECTOR2I GetPosition() const override { return m_pos; }
549 void SetPosition( const VECTOR2I& aPosition ) override;
550
551 bool HitTest( const VECTOR2I& aPosition, int aAccuracy ) const override;
552 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
553 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override;
554
555 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
556 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
557
558 EDA_ITEM* Clone() const override;
559
563 const std::vector<SCH_SHEET_INSTANCE>& GetInstances() const { return m_instances; }
564
566 const SCH_SHEET_INSTANCE* GetInstance( const KIID_PATH& aParentPath ) const
567 {
568 return getInstance( aParentPath );
569 }
570
580 bool HasRootInstance() const;
581
590 const SCH_SHEET_INSTANCE& GetRootInstance() const;
591
592 void RemoveInstance( const KIID_PATH& aInstancePath );
593
594 void AddInstance( const SCH_SHEET_INSTANCE& aInstance );
595
596 void DeleteVariant( const KIID_PATH& aPath, const wxString& aVariantName );
597
598 // Remove a variant's override of one field
599 void ClearVariantField( const KIID_PATH& aPath, const wxString& aVariantName,
600 const wxString& aFieldName );
601
602 void RenameVariant( const KIID_PATH& aPath, const wxString& aOldName, const wxString& aNewName );
603
604 void CopyVariant( const KIID_PATH& aPath, const wxString& aSourceVariant,
605 const wxString& aNewVariant );
606
607 void AddVariant( const SCH_SHEET_PATH& aInstance, const SCH_SHEET_VARIANT& aVariant );
608 void DeleteVariant( const SCH_SHEET_PATH& aInstance, const wxString& aVariantName )
609 {
610 DeleteVariant( aInstance.Path(), aVariantName );
611 }
612
613 void RenameVariant( const SCH_SHEET_PATH& aInstance, const wxString& aOldName,
614 const wxString& aNewName )
615 {
616 RenameVariant( aInstance.Path(), aOldName, aNewName );
617 }
618
619 void CopyVariant( const SCH_SHEET_PATH& aInstance, const wxString& aSourceVariant,
620 const wxString& aNewVariant )
621 {
622 CopyVariant( aInstance.Path(), aSourceVariant, aNewVariant );
623 }
624
631 bool HasPageNumberChanges( const SCH_SHEET& aOther ) const;
632
633 bool HasHierarchyChanges( const SCH_SHEET& aOther ) const;
634
636 bool HasRefSuffixChanges( const SCH_SHEET& aOther ) const;
637
644
645 bool HasPinIdentityChanges( const SCH_SHEET& aOther ) const;
646
652 static int ComparePageNum( const wxString& aPageNumberA, const wxString& aPageNumberB );
653
654 double Similarity( const SCH_ITEM& aOther ) const override;
655
656 bool operator==( const SCH_ITEM& aOther ) const override;
657
658#if defined(DEBUG)
659 void Show( int nestLevel, std::ostream& os ) const override;
660#endif
661
662protected:
665 friend SCHEMATIC; // Only to swap a staged screen in, see SCHEMATIC::AdoptContent().
666
667 void setInstances( const std::vector<SCH_SHEET_INSTANCE>& aInstances )
668 {
669 m_instances = aInstances;
670 }
671
685 bool addInstance( const KIID_PATH& aInstance );
686
696 wxString getPageNumber( const KIID_PATH& aParentPath ) const;
697
707 void setPageNumber( const KIID_PATH& aInstance, const wxString& aPageNumber );
708
709 bool getInstance( SCH_SHEET_INSTANCE& aInstance, const KIID_PATH& aSheetPath,
710 bool aTestFromEnd = false ) const;
711
712 void setVariantAttribute( bool aEnable, const SCH_SHEET_PATH* aInstance, const wxString& aVariantName,
713 bool SCH_SHEET::*aBase, bool SCH_SHEET_VARIANT::*aOverride );
714
716 const SCH_SHEET_INSTANCE* getInstance( const KIID_PATH& aPath ) const;
717
718 SCH_SHEET_INSTANCE* getInstance( const SCH_SHEET_PATH& aPath ) { return getInstance( aPath.Path() ); }
719 const SCH_SHEET_INSTANCE* getInstance( const SCH_SHEET_PATH& aPath ) const { return getInstance( aPath.Path() ); }
720
728 void renumberPins();
729
737 SCH_SHEET_PATH findSelf() const;
738
739private:
740 bool doIsConnected( const VECTOR2I& aPosition ) const override;
741
742 friend class SCH_SHEET_PIN;
743 friend class SCH_SHEET_LIST;
744
745private:
746 SCH_SCREEN* m_screen; // Screen that contains the physical data for the
747 // sheet. In complex hierarchies multiple sheets
748 // can share a common screen.
749
750 std::vector<SCH_SHEET_PIN*> m_pins; // The list of sheet connection points.
751 std::vector<SCH_FIELD> m_fields;
752
756 bool m_DNP;
757
758 VECTOR2I m_pos; // The position of the sheet.
759 VECTOR2I m_size; // The size of the sheet.
763
764 std::vector<SCH_SHEET_INSTANCE> m_instances;
765
766 mutable std::map<wxString, std::unique_ptr<SCH_SHEET_FIELD_PROPERTY>> m_dynamicPropertyCache;
767};
768
769
770#endif // SCH_SHEEET_H
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:130
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
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
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Base plotter engine class.
Definition plotter.h:138
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:139
wxString GetShownText(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString, int aDepth=0) const
void SetText(const wxString &aText) override
Object to parser s-expression symbol library and schematic file formats.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition sch_item.h:353
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:65
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Variant information for a schematic sheet.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:50
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this sheet.
friend SCH_SHEET_PATH
Definition sch_sheet.h:663
bool HasPinIdentityChanges(const SCH_SHEET &aOther) const
void SetBorderColor(KIGFX::COLOR4D aColor)
Definition sch_sheet.h:196
const std::vector< SCH_SHEET_PIN * > & GetPins() const
Definition sch_sheet.h:286
wxString GetFieldText(const SCH_FIELD *aField, const wxString &aFieldName, const SCH_SHEET_PATH *aPath, const wxString &aVariantName) const
friend class SCH_SHEET_PIN
Definition sch_sheet.h:742
wxString GetRefSuffix(const SCH_SHEET_PATH &aParentPath) const
Return this sheet's own reference suffix with text variables resolved.
void ClearVariantField(const KIID_PATH &aPath, const wxString &aVariantName, const wxString &aFieldName)
VECTOR2I m_size
Definition sch_sheet.h:759
void SetFileName(const wxString &aFilename)
Definition sch_sheet.h:434
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition sch_sheet.h:428
void SetFieldText(SCH_FIELD *aField, const wxString &aFieldName, const wxString &aFieldText, const SCH_SHEET_PATH *aPath, const wxString &aVariantName)
bool getInstance(SCH_SHEET_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
void CopyVariant(const KIID_PATH &aPath, const wxString &aSourceVariant, const wxString &aNewVariant)
const SCH_SHEET_INSTANCE * GetInstance(const KIID_PATH &aParentPath) const
Return this sheet's placement record under aParentPath, or nullptr if it has none.
Definition sch_sheet.h:566
void SetSize(const VECTOR2I &aSize)
Definition sch_sheet.h:190
void RemoveInstance(const KIID_PATH &aInstancePath)
void SetDNP(bool aDNP, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
bool addInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
bool HasRootInstance() const
Check to see if this sheet has a root sheet instance.
void SyncUuidToScreen()
Take the identity of the screen this sheet owns.
void setVariantAttribute(bool aEnable, const SCH_SHEET_PATH *aInstance, const wxString &aVariantName, bool SCH_SHEET::*aBase, bool SCH_SHEET_VARIANT::*aOverride)
wxString GetClass() const override
Return the class name.
Definition sch_sheet.h:74
wxString getPageNumber(const KIID_PATH &aParentPath) const
Return the sheet page number for aParentPath.
static wxString NextRefSuffix(const wxString &aSuffix, const std::set< wxString > &aInUse, const std::function< bool(const wxString &)> &aIsTaken=nullptr)
Return the suffix a pasted copy of a sheet should take.
void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
int GetPenWidth() const override
std::map< SCH_SHEET_PIN *, SCH_NO_CONNECT * > GetNoConnects() const
wxString GetFullRefSuffixProp() const
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool IsConnectable() const override
Definition sch_sheet.h:468
bool IsTopLevelSheet() const
Check if this sheet is a top-level sheet.
SCH_SHEET_PATH findSelf() const
Get the sheetpath of this sheet.
bool GetDNPProp() const
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
bool GetExcludedFromBoardProp() const
Definition sch_sheet.h:525
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
bool GetExcludedFromBOMProp() const
VECTOR2I m_pos
Definition sch_sheet.h:758
void CopyVariant(const SCH_SHEET_PATH &aInstance, const wxString &aSourceVariant, const wxString &aNewVariant)
Definition sch_sheet.h:619
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the sheet's fields.
Definition sch_sheet.h:93
KIGFX::COLOR4D m_borderColor
Definition sch_sheet.h:761
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this sheet.
bool m_excludedFromBOM
Definition sch_sheet.h:754
wxString GetName() const
Definition sch_sheet.h:150
void renumberPins()
Renumber the sheet pins in the sheet.
VECTOR2I GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
bool HasHierarchyChanges(const SCH_SHEET &aOther) const
SCH_SHEET_PIN * GetPin(const VECTOR2I &aPosition)
Return the sheet pin item found at aPosition in the sheet.
bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool operator<(const SCH_ITEM &aItem) const override
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
void RemovePin(const SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
void SetPositionIgnoringPins(const VECTOR2I &aPosition)
friend SCHEMATIC
Definition sch_sheet.h:665
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
std::vector< SCH_SHEET_INSTANCE > m_instances
Definition sch_sheet.h:764
bool HasUndefinedPins() const
Check all sheet labels against schematic for undefined hierarchical labels.
bool m_excludedFromSim
Definition sch_sheet.h:753
void SetPosition(const VECTOR2I &aPosition) override
void SetBackgroundColor(KIGFX::COLOR4D aColor)
Definition sch_sheet.h:199
int SymbolCount() const
Count our own symbols, without the power symbols.
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition sch_sheet.h:451
void SetDNPProp(bool aEnable)
void AddInstance(const SCH_SHEET_INSTANCE &aInstance)
int GetMinWidth(bool aFromLeft) const
Return the minimum width of the sheet based on the widths of the sheet pin text.
bool operator==(const SCH_ITEM &aOther) const override
SCH_SCREEN * m_screen
Definition sch_sheet.h:746
std::vector< int > ViewGetLayers() const override
Return the layers the item is drawn on (which may be more than its "home" layer)
std::vector< SCH_FIELD > m_fields
Definition sch_sheet.h:751
void RenameVariant(const KIID_PATH &aPath, const wxString &aOldName, const wxString &aNewName)
VECTOR2I GetSize() const
Definition sch_sheet.h:189
KIGFX::COLOR4D m_backgroundColor
Definition sch_sheet.h:762
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
Definition sch_sheet.h:513
void DeleteVariant(const KIID_PATH &aPath, const wxString &aVariantName)
SCH_SHEET(EDA_ITEM *aParent=nullptr, const VECTOR2I &aPos=VECTOR2I(0, 0), VECTOR2I aSize=VECTOR2I(schIUScale.MilsToIU(MIN_SHEET_WIDTH), schIUScale.MilsToIU(MIN_SHEET_HEIGHT)))
void SetName(const wxString &aName)
Definition sch_sheet.h:185
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this sheet.
SCH_SCREEN * GetScreen() const
Definition sch_sheet.h:187
void SetExcludedFromSimProp(bool aEnable)
bool HasPins() const
Definition sch_sheet.h:320
VECTOR2I GetPosition() const override
Definition sch_sheet.h:548
const BOX2I GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
bool HasPin(const wxString &aName) const
Check if the sheet already has a sheet pin named aName.
static int ComparePageNum(const wxString &aPageNumberA, const wxString &aPageNumberB)
Compare page numbers of schematic sheets.
std::vector< PROPERTY_BASE * > GetDynamicProperties() const override
Return dynamically-computed properties specific to this object instance (e.g.
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
wxString ResolveRefSuffix(const wxString &aText, const SCH_SHEET_PATH &aParentPath) const
Resolve aText as if it were this sheet's reference suffix, with the same rules as GetRefSuffix.
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
int CountActiveSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
wxString GetShownName(RESOLUTION_CONTEXT aContext) const
Definition sch_sheet.h:146
int GetScreenCount() const
Return the number of times the associated screen for the sheet is being used.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
SCH_SHEET & operator=(const SCH_ITEM &aSheet)
bool HasPageNumberChanges(const SCH_SHEET &aOther) const
Check if the instance data of this sheet has any changes compared to aOther.
const SCH_SHEET_INSTANCE & GetRootInstance() const
Return the root sheet instance data.
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
bool m_excludedFromBoard
Definition sch_sheet.h:755
void SetDescendantsModified()
Flag every screen at or below this sheet as modified.
void setInstances(const std::vector< SCH_SHEET_INSTANCE > &aInstances)
Definition sch_sheet.h:667
bool HasRefSuffixChanges(const SCH_SHEET &aOther) const
True when an edit may change the reference suffix this sheet adds to the paths below it.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
const std::vector< SCH_FIELD > & GetFields() const
Definition sch_sheet.h:94
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
KIGFX::COLOR4D GetBorderColor() const
Definition sch_sheet.h:195
std::vector< SCH_SHEET_PIN * > m_pins
Definition sch_sheet.h:750
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
Definition sch_sheet.h:88
bool CanConnect(const SCH_ITEM *aItem) const override
Definition sch_sheet.h:473
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...
friend class SCH_SHEET_LIST
Definition sch_sheet.h:743
void SetBorderWidth(int aWidth)
Definition sch_sheet.h:193
std::map< wxString, std::unique_ptr< SCH_SHEET_FIELD_PROPERTY > > m_dynamicPropertyCache
Definition sch_sheet.h:766
static bool ClassOf(const EDA_ITEM *aItem)
Definition sch_sheet.h:69
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add aFieldName to the list of fields.
void setPageNumber(const KIID_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
bool IsVirtualRootSheet() const
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
int GetMinHeight(bool aFromTop) const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
bool GetDNP(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Set or clear the 'Do Not Populate' flags.
bool GetExcludedFromSimProp() const
void SetExcludedFromBoardProp(bool aExclude)
Definition sch_sheet.h:526
int m_borderWidth
Definition sch_sheet.h:760
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition sch_sheet.h:519
void Resize(const VECTOR2I &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
int GetBorderWidth() const
Definition sch_sheet.h:192
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
bool m_DNP
Definition sch_sheet.h:756
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition sch_sheet.h:285
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
void SetExcludedFromBOMProp(bool aEnable)
void DeleteVariant(const SCH_SHEET_PATH &aInstance, const wxString &aVariantName)
Definition sch_sheet.h:608
friend SCH_IO_KICAD_SEXPR_PARSER
Definition sch_sheet.h:664
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void AddVariant(const SCH_SHEET_PATH &aInstance, const SCH_SHEET_VARIANT &aVariant)
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
const std::vector< SCH_SHEET_INSTANCE > & GetInstances() const
Definition sch_sheet.h:563
void RenameVariant(const SCH_SHEET_PATH &aInstance, const wxString &aOldName, const wxString &aNewName)
Definition sch_sheet.h:613
SCH_SHEET_INSTANCE * getInstance(const SCH_SHEET_PATH &aPath)
Definition sch_sheet.h:718
bool IsVerticalOrientation() const
const SCH_SHEET_INSTANCE * getInstance(const SCH_SHEET_PATH &aPath) const
Definition sch_sheet.h:719
bool HitTest(const VECTOR2I &aPosition, int aAccuracy) const override
Test if aPosition is inside or on the boundary of this item.
KIGFX::COLOR4D GetBackgroundColor() const
Definition sch_sheet.h:198
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
RESOLUTION_CONTEXT
Definition common.h:91
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
@ LAYER_WIRE
Definition layer_ids.h:483
@ LAYER_BUS
Definition layer_ids.h:484
AUTOPLACE_ALGO
Definition sch_item.h:73
#define MIN_SHEET_HEIGHT
Definition sch_sheet.h:43
#define MIN_SHEET_WIDTH
Definition sch_sheet.h:42
A simple container for sheet instance information.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ SCH_LINE_T
Definition typeinfo.h:159
@ SCH_NO_CONNECT_T
Definition typeinfo.h:156
@ SCH_SYMBOL_T
Definition typeinfo.h:168
@ SCH_SHEET_T
Definition typeinfo.h:171
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708