46 static void* locale =
nullptr;
47 static wxString sheetnameDefault;
48 static wxString sheetfilenameDefault;
49 static wxString fieldDefault;
53 if(
Pgm().GetLocale() != locale )
55 sheetnameDefault =
_(
"Sheet name" );
56 sheetfilenameDefault =
_(
"Sheet file" );
57 fieldDefault =
_(
"Field%d" );
58 locale =
Pgm().GetLocale();
114 m_pins.back()->SetParent(
this );
118 field.SetParent(
this );
188 wxCHECK_MSG(
Schematic(),
false,
"Can't call IsRootSheet without setting a schematic" );
197 aVars->push_back(
m_fields[i].GetCanonicalName().Upper() );
200 aVars->push_back(
m_fields[i].GetName() );
202 aVars->push_back( wxT(
"#" ) );
203 aVars->push_back( wxT(
"##" ) );
212 if( token->IsSameAs(
m_fields[i].GetCanonicalName().Upper() ) )
214 *token =
m_fields[i].GetShownText( aDepth + 1 );
221 if( token->IsSameAs(
m_fields[i].GetName() ) )
223 *token =
m_fields[i].GetShownText( aDepth + 1 );
235 if( token->IsSameAs( wxT(
"#" ) ) )
239 if( sheet.Last() == this )
246 else if( token->IsSameAs( wxT(
"##" ) ) )
266 wxString::Format( wxT(
"SCH_SHEET object cannot swap data with %s object." ),
279 sheetPin->SetParent(
this );
285 field.SetParent(
this );
299 wxASSERT( aSheetPin !=
NULL );
303 m_pins.push_back( aSheetPin );
310 wxASSERT( aSheetPin !=
NULL );
315 if( *i == aSheetPin )
329 if( pin->GetText().CmpNoCase( aName ) == 0 )
341 if( sheetPin->GetPosition() == aPosition )
356 switch( pin->GetEdge() )
366 return topBottom > 0 && leftRight == 0;
378 if( !pin->GetText().CmpNoCase( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) )
380 HLabel = static_cast<SCH_HIERLABEL*>( aItem );
385 if( HLabel ==
nullptr )
397 for(
size_t i = 0; i <
m_pins.size(); i++ )
399 int edge =
m_pins[i]->GetEdge();
414 for(
size_t j = 0; j <
m_pins.size(); j++ )
417 if( (i == j) || (
m_pins[i]->GetPosition().y !=
m_pins[j]->GetPosition().y) )
420 if( width < pinRect.
GetWidth() +
m_pins[j]->GetBoundingBox().GetWidth() )
422 width = pinRect.
GetWidth() +
m_pins[j]->GetBoundingBox().GetWidth();
437 for(
size_t i = 0; i <
m_pins.size(); i++ )
439 int edge =
m_pins[i]->GetEdge();
453 for(
size_t j = 0; j <
m_pins.size(); j++ )
456 if( (i == j) || (
m_pins[i]->GetPosition().x !=
m_pins[j]->GetPosition().x) )
459 if( height < pinRect.
GetHeight() +
m_pins[j]->GetBoundingBox().GetHeight() )
461 height = pinRect.
GetHeight() +
m_pins[j]->GetBoundingBox().GetHeight();
476 while( i !=
m_pins.end() )
483 if( (*i)->GetText().CmpNoCase( static_cast<SCH_HIERLABEL*>( aItem )->GetText() ) == 0 )
485 HLabel = static_cast<SCH_HIERLABEL*>( aItem );
502 if( pin->HitTest( aPosition ) )
520 int margin = borderMargin +
KiROUND( std::max( textSize.x, textSize.y ) * 0.5 );
538 margin = borderMargin +
KiROUND( std::max( textSize.x, textSize.y ) * 0.4 );
577 end.x = std::max(
m_size.x, textLength );
595 box.
Merge( field.GetBoundingBox() );
623 n += static_cast<const SCH_SHEET*>( aItem )->SymbolCount();
646 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
651 if( screen && screen->
GetFileName().Cmp( aFilename ) == 0 )
677 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( item );
699 count += static_cast<SCH_SHEET*>( aItem )->CountSheets();
710 if(
SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
724 wxPoint prev =
m_pos;
744 sheetPin->Rotate( aPosition );
755 wxPoint pos = field.GetTextPos();
756 pos.x -= prev.x -
m_pos.x;
757 pos.y -= prev.y -
m_pos.y;
758 field.SetTextPos( pos );
770 sheetPin->MirrorVertically( aCenter );
780 sheetPin->MirrorHorizontally( aCenter );
805 sheetPin->ConstrainOnEdge( sheetPin->GetPosition() );
824 pin->SetNumber(
id );
835 wxT(
"Invalid item in schematic sheet pin list. Bad programmer!" ) );
837 sheetPin->GetEndPoints( aItemList );
845 bool changed =
false;
848 changed |= sheetPin->UpdateDanglingState( aItemList );
856 std::vector<wxPoint> retval;
859 retval.push_back( sheetPin->GetPosition() );
869 for(
const KICAD_T* p = aFilterTypes; (stype = *p) !=
EOT; ++p )
953 auto* settings = dynamic_cast<KIGFX::SCH_RENDER_SETTINGS*>( aPlotter->
RenderSettings() );
954 bool override = settings ? settings->m_OverrideItemColors :
false;
958 if(
override || borderColor == COLOR4D::UNSPECIFIED )
961 if(
override || backgroundColor == COLOR4D::UNSPECIFIED )
964 aPlotter->
SetColor( backgroundColor );
991 field.Plot( aPlotter );
995 sheetPin->Plot( aPlotter );
1002 wxPoint pos =
m_pos + aOffset;
1004 const auto* settings = dynamic_cast<const KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
1005 bool override = settings && settings->m_OverrideItemColors;
1009 if(
override || border == COLOR4D::UNSPECIFIED )
1012 if(
override || background == COLOR4D::UNSPECIFIED )
1016 background = COLOR4D::UNSPECIFIED;
1018 if( background != COLOR4D::UNSPECIFIED )
1021 background, background );
1024 GRRect(
nullptr, DC, pos.x, pos.y, pos.x +
m_size.x, pos.y +
m_size.y, lineWidth, border );
1027 field.Print( aSettings, aOffset );
1031 sheetPin->Print( aSettings, aOffset );
1037 wxCHECK_MSG(
Type() == aItem.
Type(), *
this,
1038 wxT(
"Cannot assign object type " ) + aItem.
GetClass() + wxT(
" to type " ) +
1041 if( &aItem !=
this )
1054 m_pins.back()->SetParent(
this );
1070 auto sheet = static_cast<const SCH_SHEET*>( &aItem );
1085 wxCHECK( aSheetPath.size() > 0, false );
1092 if( instance.m_Path == aSheetPath )
1098 instance.
m_Path = aSheetPath;
1108 wxString pageNumber;
1113 if( instance.m_Path == path )
1115 pageNumber = instance.m_PageNumber;
1130 if( instance.m_Path == path )
1132 instance.m_PageNumber = aPageNumber;
1141 if( aPageNumberA == aPageNumberB )
1146 bool isIntegerPageA = aPageNumberA.ToLong( &pageA );
1147 bool isIntegerPageB = aPageNumberB.ToLong( &pageB );
1149 if( isIntegerPageA && isIntegerPageB )
1153 else if( pageA == pageB )
1160 if( isIntegerPageA )
1162 else if( isIntegerPageB )
1166 int result = aPageNumberA.Cmp( aPageNumberB );
1170 else if( result > 0 )
1179 void SCH_SHEET::Show(
int nestLevel, std::ostream& os )
const 1184 NestedSpace( nestLevel, os ) <<
'<' << s.Lower().mb_str() <<
">" <<
" sheet_name=\"" 1189 sheetPin->Show( nestLevel + 1, os );
1191 NestedSpace( nestLevel, os ) <<
"</" << s.Lower().mb_str() <<
">\n" << std::flush;
void FinishTo(const wxPoint &pos)
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
EE_TYPE OfType(KICAD_T aType) const
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
const wxString & GetFileName() const
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Plot settings, and plotting engines (PostScript, Gerber, HPGL and DXF)
bool SearchHierarchy(const wxString &aFilename, SCH_SCREEN **aScreen)
Search the existing hierarchy for an instance of screen loaded from aFileName.
SCH_SHEET_PIN * GetPin(const wxPoint &aPosition)
Return the sheet pin item found at aPosition in the sheet.
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Container for project specific data.
PNG memory record (file in memory).
KIGFX::COLOR4D m_borderColor
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
The first 2 are mandatory, and must be instantiated in SCH_SHEET.
virtual void SetColor(COLOR4D color)=0
virtual void Rect(const wxPoint &p1, const wxPoint &p2, FILL_TYPE fill, int width=USE_DEFAULT_LINE_WIDTH)=0
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet names.
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
friend class SCH_SHEET_PIN
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
void SetScreen(SCH_SCREEN *aScreen)
Set the SCH_SCREEN associated with this sheet to aScreen.
void MirrorVertically(int aXaxis_position) override
Mirror item vertically about aCenter.
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this sheet.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
bool doIsConnected(const wxPoint &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
bool HasUndefinedPins() const
Check all sheet labels against schematic for undefined hierarchical labels.
const TITLE_BLOCK & GetTitleBlock() const
KIGFX::COLOR4D GetBorderColor() const
bool UsesDefaultStroke() const
Test this sheet to see if the default stroke is used to draw the outline.
Schematic editor (Eeschema) main window.
static int ComparePageNum(const wxString &aPageNumberA, const wxString aPageNumberB)
Compares page numbers of schematic sheets.
void RotatePoint(int *pX, int *pY, double angle)
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
bool operator<(const SCH_ITEM &aItem) const override
The base class for create windows for drawing purpose.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
void AddPin(SCH_SHEET_PIN *aSheetPin)
Add aSheetPin to the sheet.
static void GetContextualTextVars(wxArrayString *aVars)
bool Contains(const wxPoint &aPoint) const
FIELDS_AUTOPLACED m_fieldsAutoplaced
void SetPageNumber(const SCH_SHEET_PATH &aInstance, const wxString &aPageNumber)
Set the page number for the sheet instance aInstance.
const INSPECTOR_FUNC & INSPECTOR
search types array terminator (End Of Types)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
std::vector< SCH_SHEET_INSTANCE > m_instances
virtual void SetParent(EDA_ITEM *aParent)
Field Value of part, i.e. "3.3K".
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
void pop_back()
Forwarded method from std::vector.
KIGFX::COLOR4D GetBackgroundColor() const
int GetScreenCount() const
Return the number of times the associated screen for the sheet is being used.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
void LineTo(const wxPoint &pos)
void renumberPins()
Renumber the sheet pins in the sheet.
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.
wxString GetClass() const override
Return the class name.
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
int GetBorderWidth() const
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
SCH_SHEET(EDA_ITEM *aParent=nullptr, const wxPoint &pos=wxPoint(0, 0))
const BITMAP_OPAQUE add_hierarchical_subsheet_xpm[1]
void SetEnd(int x, int y)
int GetPenWidth() const override
std::vector< SCH_SHEET_PIN * > m_pins
int GetMinHeight() const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
EDA_ITEM * GetParent() const
const EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the sheet body but not the fields.
wxLogTrace helper definitions.
wxDC * GetPrintDC() const
static const wxString GetDefaultFieldName(int aFieldNdx)
Define a sheet pin (label) used in sheets to create hierarchical schematics.
int SymbolCount() const
Count our own components, without the power components.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::vector< wxPoint > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
void CleanupSheet()
Delete sheet label which do not have a corresponding hierarchical label.
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
void MirrorHorizontally(int aYaxis_position) override
Mirror item horizontally about aCenter.
void RemovePin(const SCH_SHEET_PIN *aSheetPin)
Remove aSheetPin from the sheet.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
void MoveTo(const wxPoint &pos)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
std::vector< SCH_FIELD > m_fields
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
int GetMinWidth() const
Return the minimum width of the sheet based on the widths of the sheet pin text.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
bool LocatePathOfScreen(SCH_SCREEN *aScreen, SCH_SHEET_PATH *aList)
Search the existing hierarchy for an instance of screen loaded from aFileName.
Base plotter engine class.
A simple container for sheet instance information.
RENDER_SETTINGS * RenderSettings()
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void Plot(PLOTTER *aPlotter) override
Plot the schematic item to aPlotter.
const wxChar *const traceFindItem
Flag to enable find debug tracing.
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.
bool IsVerticalOrientation() const
void SetPosition(const wxPoint &aPosition) override
KIGFX::COLOR4D m_backgroundColor
Handle the component boundary box.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
A base class for most all the KiCad significant classes used in schematics and boards.
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
virtual wxString GetClass() const override
Return the class name.
BITMAP_DEF GetMenuImage() const override
Return a pointer to an image to be used in menus.
int GetDefaultPenWidth() const
wxPoint GetRotationCenter() const
Rotating around the boundingBox's center can cause walking when the sheetname or filename is longer t...
bool TextVarResolver(wxString *aToken, const PROJECT *aProject) const
int GetMinPenWidth() const
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the sheet.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
const wxPoint GetCenter() const
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
bool Matches(const wxFindReplaceData &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
bool HasPin(const wxString &aName) const
Checks if the sheet already has a sheet pin named aName.
Message panel definition file.
Base class for any item which can be embedded within the SCHEMATIC container class,...
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
virtual const wxString & GetText() const
Return the string associated with the text object.
wxString GetPageNumber(const SCH_SHEET_PATH &aInstance) const
Return the sheet page number for aInstance.
SCH_SHEET & operator=(const SCH_ITEM &aSheet)
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
bool AddInstance(const KIID_PATH &aInstance)
Add a new instance aSheetPath to the instance list.
KICAD_T Type() const
Returns the type of object.
void Resize(const wxSize &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
A color representation with 4 components: red, green, blue, alpha.
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Test if aPosition is contained within or on the bounding box of an item.
bool GetColorMode() const