From 55b20ea70d8a74cab360ccba57b6623d6a422b24 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 22 May 2014 15:01:58 +0200 Subject: [PATCH] Added missing changes required for updating footprints with the module editor. --- pcbnew/tools/edit_tool.cpp | 18 ++++++++++-------- pcbnew/xchgmod.cpp | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 727f20b9b3..3badc60fb2 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -229,8 +229,6 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent ) // Check if user wants to edit pad or module properties if( item->Type() == PCB_MODULE_T ) { - item->ClearFlags(); // Necessary for having an undo entry - for( D_PAD* pad = static_cast( item )->Pads(); pad; pad = pad->Next() ) { if( pad->ViewBBox().Contains( getViewControls()->GetCursorPosition() ) ) @@ -244,6 +242,11 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent ) std::vector& undoList = editFrame->GetScreen()->m_UndoList.m_CommandsList; + // Some of properties dialogs alter pointers, so we should deselect them + m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear ); + STATUS_FLAGS flags = item->GetFlags(); + item->ClearFlags(); + // It is necessary to determine if anything has changed PICKED_ITEMS_LIST* lastChange = undoList.empty() ? NULL : undoList.back(); @@ -254,17 +257,15 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent ) if( lastChange != currentChange ) // Something has changed { - // Some of properties dialogs alter pointers, so we should deselect them - m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear ); - processChanges( currentChange ); - // Seems unnecessary, as the items are removed/added to the board - // updateRatsnest( true ); - // getModel( PCB_T )->GetRatsnest()->Recalculate(); + updateRatsnest( true ); + getModel( PCB_T )->GetRatsnest()->Recalculate(); m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate ); } + + item->SetFlags( flags ); } if( unselect ) @@ -554,6 +555,7 @@ void EDIT_TOOL::processChanges( const PICKED_ITEMS_LIST* aList ) getView(), _1 ) ); getView()->Add( updItem ); + updItem->ViewUpdate(); break; default: diff --git a/pcbnew/xchgmod.cpp b/pcbnew/xchgmod.cpp index 1343ed9fb2..9f4ba54c72 100644 --- a/pcbnew/xchgmod.cpp +++ b/pcbnew/xchgmod.cpp @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -44,6 +45,8 @@ #include #include +#include + static bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName ); class DIALOG_EXCHANGE_MODULE : public DIALOG_EXCHANGE_MODULE_BASE @@ -470,9 +473,21 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule, ITEM_PICKER picker_new( aNewModule, UR_NEW ); aUndoPickList->PushItem( picker_old ); aUndoPickList->PushItem( picker_new ); + + if( IsGalCanvasActive() ) + { + KIGFX::VIEW* view = GetGalCanvas()->GetView(); + + aOldModule->RunOnChildren( boost::bind( &KIGFX::VIEW::Remove, view, _1 ) ); + view->Remove( aOldModule ); + + aNewModule->RunOnChildren( boost::bind( &KIGFX::VIEW::Add, view, _1 ) ); + view->Add( aNewModule ); + } } else { + GetGalCanvas()->GetView()->Remove( aOldModule ); aOldModule->DeleteStructure(); }