diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index b1a6ba4925..0e38794709 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -63,6 +63,7 @@ SCH_CONNECTION::SCH_CONNECTION( SCH_ITEM* aParent, SCH_SHEET_PATH aPath ) : m_sheet( aPath ), + m_local_sheet( aPath ), m_parent( aParent ), m_driver( nullptr ), m_graph( nullptr ) @@ -73,6 +74,7 @@ SCH_CONNECTION::SCH_CONNECTION( SCH_ITEM* aParent, SCH_SHEET_PATH aPath ) : SCH_CONNECTION::SCH_CONNECTION( CONNECTION_GRAPH* aGraph ) : m_sheet( SCH_SHEET_PATH() ), + m_local_sheet( SCH_SHEET_PATH() ), m_parent( nullptr ), m_driver( nullptr ), m_graph( aGraph ) @@ -109,7 +111,8 @@ void SCH_CONNECTION::SetDriver( SCH_ITEM* aItem ) void SCH_CONNECTION::SetSheet( SCH_SHEET_PATH aSheet ) { - m_sheet = aSheet; + m_sheet = aSheet; + m_local_sheet = aSheet; recacheName(); @@ -230,6 +233,7 @@ void SCH_CONNECTION::Clone( const SCH_CONNECTION& aOther ) // Note: m_lastDriver is not cloned as it needs to be the last driver of *this* connection m_driver = aOther.Driver(); m_sheet = aOther.Sheet(); + // Note: m_local_sheet is not cloned m_name = aOther.m_name; // Note: m_local_name is not cloned if not set yet if( m_local_name.IsEmpty() ) diff --git a/eeschema/sch_connection.h b/eeschema/sch_connection.h index e58259472c..f4f3d79bce 100644 --- a/eeschema/sch_connection.h +++ b/eeschema/sch_connection.h @@ -109,6 +109,8 @@ public: SCH_SHEET_PATH Sheet() const { return m_sheet; } void SetSheet( SCH_SHEET_PATH aSheet ); + SCH_SHEET_PATH LocalSheet() const { return m_local_sheet; } + /** * Checks if the SCH_ITEM this connection is attached to can drive connections * Drivers can be labels, sheet pins, or symbol pins. @@ -240,6 +242,14 @@ private: SCH_SHEET_PATH m_sheet; ///< The hierarchical sheet this connection is on + /** + * When a connection is overridden by one on a different hierarchical sheet, it will be cloned + * and m_sheet will point to the parent sheet. This member stores the original sheet so that it + * can be used for applications such as net highlighting to retrieve the sheet of the parent + * item from the highlighted connection. + */ + SCH_SHEET_PATH m_local_sheet; + SCH_ITEM* m_parent; ///< The SCH_ITEM this connection is owned by void* m_lastDriver; ///< WEAK POINTER (there is no guarantee it is still allocated) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index a255857c1c..6254bd6cc4 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1285,7 +1285,7 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags ) SCH_SHEET_PATH highlightPath; if( highlight ) - highlightPath = highlight->Sheet(); + highlightPath = highlight->LocalSheet(); SCHEMATIC_SETTINGS& settings = Schematic().Settings(); SCH_SHEET_LIST list = Schematic().GetSheets();