From 75d750a3cb7facc8a415da672bf2b0c840d62ee7 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 28 Nov 2021 17:08:30 +0000 Subject: [PATCH] Copy lastResolved stuff when pasting. This of course assumes the paste came from the same document. If not then pasted items will get default lastResolved stuff. --- eeschema/sch_bus_entry.cpp | 14 -------------- eeschema/sch_bus_entry.h | 12 ++++++++++++ eeschema/sch_item.h | 2 ++ eeschema/sch_junction.cpp | 7 ------- eeschema/sch_junction.h | 11 +++++++++++ eeschema/sch_line.cpp | 14 -------------- eeschema/sch_line.h | 12 ++++++++++++ eeschema/tools/sch_editor_control.cpp | 16 ++++++++++++++-- 8 files changed, 51 insertions(+), 37 deletions(-) diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index a6b936f3cd..d9364d4c8c 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -184,13 +184,6 @@ COLOR4D SCH_BUS_ENTRY_BASE::GetStrokeColor() const if( netclass ) m_lastResolvedColor = netclass->GetSchematicColor(); } - else - { - wxASSERT_MSG( !IsConnectable() - || !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity - || !Schematic() || !Schematic()->ConnectionGraph()->m_allowRealTime, - "Connectivity shouldn't be dirty if realtime connectivity is on!" ); - } return m_lastResolvedColor; } @@ -209,13 +202,6 @@ PLOT_DASH_TYPE SCH_BUS_ENTRY_BASE::GetStrokeStyle() const if( netclass ) m_lastResolvedLineStyle = static_cast( netclass->GetLineStyle() ); } - else - { - wxASSERT_MSG( !IsConnectable() - || !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity - || !Schematic() || !Schematic()->ConnectionGraph()->m_allowRealTime, - "Connectivity shouldn't be dirty if realtime connectivity is on!" ); - } return m_lastResolvedLineStyle; } diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index bb0c97954b..9f9fddf6f3 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -51,6 +51,18 @@ public: ~SCH_BUS_ENTRY_BASE() { } + void SetLastResolvedState( const SCH_ITEM* aItem ) override + { + const SCH_BUS_ENTRY_BASE* aEntry = dynamic_cast( aItem ); + + if( aEntry ) + { + m_lastResolvedWidth = aEntry->m_lastResolvedWidth; + m_lastResolvedLineStyle = aEntry->m_lastResolvedLineStyle; + m_lastResolvedColor = aEntry->m_lastResolvedColor; + } + } + /** * Return true for items which are moved with the anchor point at mouse cursor * and false for items moved with no reference to anchor diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index a8e0f7ed2e..e628e2d09c 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -414,6 +414,8 @@ public: void SetConnectivityDirty( bool aDirty = true ) { m_connectivity_dirty = aDirty; } + virtual void SetLastResolvedState( const SCH_ITEM* aItem ) { } + NETCLASSPTR NetClass( const SCH_SHEET_PATH* aSheet = nullptr ) const; /** diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index 08c9b27be9..f7e0a8dcc8 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -187,13 +187,6 @@ COLOR4D SCH_JUNCTION::GetJunctionColor() const if( netclass ) m_lastResolvedColor = netclass->GetSchematicColor(); } - else - { - wxASSERT_MSG( !IsConnectable() - || !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity - || !Schematic() || !Schematic()->ConnectionGraph()->m_allowRealTime, - "Connectivity shouldn't be dirty if realtime connectivity is on!" ); - } return m_lastResolvedColor; } diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 1a808e6289..faac0494ee 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -54,6 +54,17 @@ public: void SwapData( SCH_ITEM* aItem ) override; + void SetLastResolvedState( const SCH_ITEM* aItem ) override + { + const SCH_JUNCTION* aJunction = dynamic_cast( aItem ); + + if( aJunction ) + { + m_lastResolvedDiameter = aJunction->m_lastResolvedDiameter; + m_lastResolvedColor = aJunction->m_lastResolvedColor; + } + } + void ViewGetLayers( int aLayers[], int& aCount ) const override; const EDA_RECT GetBoundingBox() const override; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 4ad564744b..02a438ecaf 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -245,13 +245,6 @@ COLOR4D SCH_LINE::GetLineColor() const if( netclass ) m_lastResolvedColor = netclass->GetSchematicColor(); } - else - { - wxASSERT_MSG( !IsConnectable() - || !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity - || !Schematic() || !Schematic()->ConnectionGraph()->m_allowRealTime, - "Connectivity shouldn't be dirty if realtime connectivity is on!" ); - } return m_lastResolvedColor; } @@ -303,13 +296,6 @@ PLOT_DASH_TYPE SCH_LINE::GetEffectiveLineStyle() const if( netclass ) m_lastResolvedLineStyle = static_cast( netclass->GetLineStyle() ); } - else - { - wxASSERT_MSG( !IsConnectable() - || !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity - || !Schematic() || !Schematic()->ConnectionGraph()->m_allowRealTime, - "Connectivity shouldn't be dirty if realtime connectivity is on!" ); - } return m_lastResolvedLineStyle; } diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 12821de003..c3a90e0172 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -93,6 +93,18 @@ public: wxPoint GetEndPoint() const { return m_end; } void SetEndPoint( const wxPoint& aPosition ) { m_end = aPosition; } + void SetLastResolvedState( const SCH_ITEM* aItem ) override + { + const SCH_LINE* aLine = dynamic_cast( aItem ); + + if( aLine ) + { + m_lastResolvedLineStyle = aLine->m_lastResolvedLineStyle; + m_lastResolvedWidth = aLine->m_lastResolvedWidth; + m_lastResolvedColor = aLine->m_lastResolvedColor; + } + } + PLOT_DASH_TYPE GetDefaultStyle() const; void SetLineStyle( const PLOT_DASH_TYPE aStyle ); diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 2164945f1f..5f621843b5 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -1683,11 +1683,14 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) } // Build symbol list for reannotation of duplicates - SCH_SHEET_LIST sheets = m_frame->Schematic().GetSheets(); SCH_REFERENCE_LIST existingRefs; - sheets.GetSymbols( existingRefs ); + hierarchy.GetSymbols( existingRefs ); existingRefs.SortByReferenceOnly(); + // Build UUID map for fetching last-resolved-properties + std::map itemMap; + hierarchy.FillItemMap( itemMap ); + // Keep track of pasted sheets and symbols for the different // paths to the hierarchy std::map pastedSymbols; @@ -1864,8 +1867,17 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) } else { + SCH_ITEM* srcItem = dynamic_cast( itemMap[ item->m_Uuid ] ); + SCH_ITEM* destItem = dynamic_cast( item ); + // Everything gets a new KIID const_cast( item->m_Uuid ) = KIID(); + + if( srcItem && destItem ) + { + destItem->SetConnectivityDirty( true ); + destItem->SetLastResolvedState( srcItem ); + } } item->SetFlags( IS_NEW | IS_PASTED | IS_MOVING );