50#define SHEET_NAME_CANONICAL "Sheetname"
51#define SHEET_FILE_CANONICAL "Sheetfile"
52#define USER_FIELD_CANONICAL "Field%d"
122 m_pins.back()->SetParent(
this );
126 field.SetParent(
this );
196 wxCHECK_MSG(
Schematic(),
false,
"Can't call IsRootSheet without setting a schematic" );
205 [&](
const wxString& aVar )
208 aVars->push_back( aVar );
212 add(
m_fields[i].GetCanonicalName().Upper() );
219 if( sheetPath.
size() >= 2 )
231 add( wxT(
"SHEETPATH" ) );
242 if( token->Contains(
':' ) )
244 if(
Schematic()->ResolveCrossReference( token, aDepth + 1 ) )
250 if( token->IsSameAs(
m_fields[i].GetCanonicalName().Upper() ) )
252 *token =
m_fields[i].GetShownText( aDepth + 1 );
259 if( token->IsSameAs(
m_fields[i].GetName() ) )
261 *token =
m_fields[i].GetShownText( aDepth + 1 );
275 if( token->IsSameAs( wxT(
"#" ) ) )
280 else if( token->IsSameAs( wxT(
"##" ) ) )
286 else if( token->IsSameAs( wxT(
"SHEETPATH" ) ) )
296 if( sheetPath.
size() >= 2 )
316 wxString::Format( wxT(
"SCH_SHEET object cannot swap data with %s object." ),
329 sheetPin->SetParent(
this );
335 field.SetParent(
this );
352 for(
int ii = 0; ii < int(
m_fields.size() ); )
371 wxASSERT( aSheetPin !=
nullptr );
375 m_pins.push_back( aSheetPin );
382 wxASSERT( aSheetPin !=
nullptr );
387 if( *i == aSheetPin )
401 if(
pin->GetText().CmpNoCase( aName ) == 0 )
413 if( sheetPin->GetPosition() == aPosition )
428 switch(
pin->GetSide() )
438 return topBottom > 0 && leftRight == 0;
458 if( HLabel ==
nullptr )
470 int base = aVal / gridSize;
471 int excess =
abs( aVal % gridSize );
475 return ( base + 1 ) * gridSize;
477 else if( excess > 0 )
479 return ( base ) * gridSize;
483 return ( base - 1 ) * gridSize;
493 for(
size_t i = 0; i <
m_pins.size(); i++ )
501 pinsLeft = std::min( pinsLeft, pinRect.
GetLeft() );
502 pinsRight = std::max( pinsRight, pinRect.
GetRight() );
511 if( pinsLeft >= pinsRight )
514 pinMinWidth = pinsRight -
m_pos.
x;
527 for(
size_t i = 0; i <
m_pins.size(); i++ )
535 pinsTop = std::min( pinsTop, pinRect.
GetTop() );
536 pinsBottom = std::max( pinsBottom, pinRect.
GetBottom() );
545 if( pinsTop >= pinsBottom )
548 pinMinHeight = pinsBottom -
m_pos.
y;
558 std::vector<SCH_SHEET_PIN*> pins =
m_pins;
586 if(
pin->HitTest( aPosition ) )
610 int margin = borderMargin +
KiROUND( std::max( textSize.
x, textSize.
y ) * 0.5 );
628 margin = borderMargin +
KiROUND( std::max( textSize.
x, textSize.
y ) * 0.4 );
670 end.
x = std::max(
m_size.x, textLength );
688 bbox.
Merge( field.GetBoundingBox() );
744 if( screen && screen->
GetFileName().Cmp( aFilename ) == 0 )
804 path.push_back(
this );
806 aList.emplace_back(
_(
"Hierarchical Path" ),
path.PathHumanReadable(
false,
true ) );
815 m_pos += aMoveVector;
818 pin->Move( aMoveVector );
821 field.Move( aMoveVector );
847 sheetPin->Rotate( aCenter );
861 field.SetTextPos( pos );
876 sheetPin->MirrorVertically( aCenter );
882 field.SetTextPos( pos );
896 sheetPin->MirrorHorizontally( aCenter );
902 field.SetTextPos( pos );
928 sheetPin->ConstrainOnEdge( sheetPin->GetPosition() );
945 pin->SetNumber(
id );
957 while( !sheetPath.
empty() && sheetPath.
Last() !=
this )
960 if( sheetPath.
empty() )
976 wxT(
"Invalid item in schematic sheet pin list. Bad programmer!" ) );
978 sheetPin->GetEndPoints( aItemList );
986 bool changed =
false;
989 changed |= sheetPin->UpdateDanglingState( aItemList );
997 std::vector<VECTOR2I> retval;
1000 retval.push_back( sheetPin->GetPosition() );
1007 const std::vector<KICAD_T>& aScanTypes )
1009 for(
KICAD_T scanType : aScanTypes )
1046 aFunction( &field );
1099 if(
override || borderColor == COLOR4D::UNSPECIFIED )
1102 if(
override || backgroundColor == COLOR4D::UNSPECIFIED )
1107 aPlotter->
SetColor( backgroundColor );
1119 std::vector<wxString> properties;
1127 field.GetShownText() ) );
1134 sheetPin->Plot( aPlotter, aBackground );
1138 field.Plot( aPlotter, aBackground );
1152 if(
override || border == COLOR4D::UNSPECIFIED )
1155 if(
override || background == COLOR4D::UNSPECIFIED )
1159 background = COLOR4D::UNSPECIFIED;
1161 if( background != COLOR4D::UNSPECIFIED )
1167 field.Print( aSettings, aOffset );
1170 sheetPin->Print( aSettings, aOffset );
1176 wxCHECK_MSG(
Type() == aItem.
Type(), *
this,
1177 wxT(
"Cannot assign object type " ) + aItem.
GetClass() + wxT(
" to type " ) +
1180 if( &aItem !=
this )
1193 m_pins.back()->SetParent(
this );
1209 auto sheet =
static_cast<const SCH_SHEET*
>( &aItem );
1229 if( instance.m_Path == aSheetPath.
Path() )
1248 bool aTestFromEnd )
const
1254 if( instance.m_Path == aSheetPath )
1256 aInstance = instance;
1260 else if( instance.m_Path.EndsWith( aSheetPath ) )
1262 aInstance = instance;
1275 if( instance.m_Path.size() == 0 )
1287 if( instance.m_Path.size() == 0 )
1301 wxCHECK( aSheetPath.
IsFullPath(), wxEmptyString );
1304 wxString pageNumber;
1309 if( instance.m_Path ==
path )
1311 pageNumber = instance.m_PageNumber;
1329 if( instance.m_Path ==
path )
1331 instance.m_PageNumber = aPageNumber;
1340 if( aPageNumberA == aPageNumberB )
1345 bool isIntegerPageA = aPageNumberA.ToLong( &pageA );
1346 bool isIntegerPageB = aPageNumberB.ToLong( &pageB );
1348 if( isIntegerPageA && isIntegerPageB )
1357 if( isIntegerPageA )
1359 else if( isIntegerPageB )
1363 int result =
StrNumCmp( aPageNumberA, aPageNumberB );
1366 wxCHECK( result != 0, 0 );
1368 result = result /
std::abs( result );
1376void SCH_SHEET::Show(
int nestLevel, std::ostream& os )
const
1381 NestedSpace( nestLevel, os ) <<
'<' << s.Lower().mb_str() <<
">" <<
" sheet_name=\""
1386 sheetPin->Show( nestLevel + 1, os );
1388 NestedSpace( nestLevel, os ) <<
"</" << s.Lower().mb_str() <<
">\n" << std::flush;
constexpr EDA_IU_SCALE schIUScale
BITMAPS
A list of all bitmap identifiers.
@ add_hierarchical_subsheet
const Vec GetCenter() const
bool Intersects(const BOX2< Vec > &aRect) const
coord_type GetTop() const
bool Contains(const Vec &aPoint) const
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
coord_type GetRight() const
coord_type GetLeft() const
coord_type GetBottom() const
void SetEnd(coord_type x, coord_type y)
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM * GetParent() const
virtual const wxString & GetText() const
Return the string associated with the text object.
static wxString GotoPageHref(const wxString &aDestination)
Generate a href to a page in the current schematic.
EE_TYPE OfType(KICAD_T aType) const
A color representation with 4 components: red, green, blue, alpha.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
int GetDefaultPenWidth() const
int GetMinPenWidth() const
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
Store schematic specific render settings.
bool m_OverrideItemColors
wxString AsString() const
Base plotter engine class.
RENDER_SETTINGS * RenderSettings()
bool GetColorMode() const
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
virtual void Rect(const VECTOR2I &p1, const VECTOR2I &p2, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
virtual void SetColor(const COLOR4D &color)=0
Container for project specific data.
SCH_SHEET_PATH & CurrentSheet() const override
SCHEMATIC_SETTINGS & Settings() const
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
void GetContextualTextVars(wxArrayString *aVars) const
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Schematic editor (Eeschema) main window.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM & operator=(const SCH_ITEM &aPin)
virtual wxString GetClass() const override
Return the class name.
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
FIELDS_AUTOPLACED m_fieldsAutoplaced
void AutoAutoplaceFields(SCH_SCREEN *aScreen)
Autoplace fields only if correct to do so automatically.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
const wxString & GetFileName() const
const TITLE_BLOCK & GetTitleBlock() const
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...
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.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
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.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
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.
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
friend class SCH_SHEET_PIN
void SetFileName(const wxString &aFilename)
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.
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
Test the schematic item to aItemList to check if it's dangling state has changed.
void setPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslated=true)
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.
wxString GetClass() const override
Return the class name.
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
int GetPenWidth() const override
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
SCH_SHEET_PATH findSelf() const
Get the sheetpath of this sheet.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
std::vector< SCH_FIELD > & GetFields()
KIGFX::COLOR4D m_borderColor
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...
SCH_SHEET(EDA_ITEM *aParent=nullptr, const VECTOR2I &aPos=VECTOR2I(0, 0), wxSize aSize=wxSize(schIUScale.MilsToIU(MIN_SHEET_WIDTH), schIUScale.MilsToIU(MIN_SHEET_HEIGHT)), FIELDS_AUTOPLACED aAutoplaceFields=FIELDS_AUTOPLACED_AUTO)
SCH_SHEET_PIN * GetPin(const VECTOR2I &aPosition)
Return the sheet pin item found at aPosition in the sheet.
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.
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
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
bool HasUndefinedPins() const
Check all sheet labels against schematic for undefined hierarchical labels.
void SetPosition(const VECTOR2I &aPosition) override
int SymbolCount() const
Count our own symbols, without the power symbols.
int GetMinWidth(bool aFromLeft) const
Return the minimum width of the sheet based on the widths of the sheet pin text.
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
std::vector< SCH_FIELD > m_fields
KIGFX::COLOR4D m_backgroundColor
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
const BOX2I GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
static int ComparePageNum(const wxString &aPageNumberA, const wxString &aPageNumberB)
Compares page numbers of schematic sheets.
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
void Plot(PLOTTER *aPlotter, bool aBackground) const override
Plot the schematic item to aPlotter.
wxString getPageNumber(const SCH_SHEET_PATH &aInstance) const
Return the sheet page number for aInstance.
void SetFields(const std::vector< SCH_FIELD > &aFields)
Set multiple schematic fields.
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)
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 AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
KIGFX::COLOR4D GetBorderColor() const
std::vector< SCH_SHEET_PIN * > m_pins
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...
bool addInstance(const SCH_SHEET_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
int GetMinHeight(bool aFromTop) const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
int GetBorderWidth() const
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 IsVerticalOrientation() const
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a schematic item.
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
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
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
bool TextVarResolver(wxString *aToken, const PROJECT *aProject) const
static void GetContextualTextVars(wxArrayString *aVars)
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
static constexpr EDA_ANGLE & ANGLE_HORIZONTAL
static constexpr EDA_ANGLE & ANGLE_VERTICAL
static constexpr EDA_ANGLE & ANGLE_90
const INSPECTOR_FUNC & INSPECTOR
void GRRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
bool GetGRForceBlackPenState(void)
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
@ LAYER_SELECTION_SHADOWS
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Message panel definition file.
wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
#define USER_FIELD_CANONICAL
#define SHEET_NAME_CANONICAL
int bumpToNextGrid(const int aVal, const int aDirection)
#define SHEET_FILE_CANONICAL
@ SHEET_MANDATORY_FIELDS
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
SHEET_SIDE
Define the edge of the sheet that the sheet pin is positioned.
std::vector< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
constexpr int MilsToIU(int mils) const
A simple container for sheet instance information.
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".