Commit 957f959e authored by Maciej Suminski's avatar Maciej Suminski

Fixed bug 1321936: changing a footprint for a set of modules relocates them in GAL canvas.

Changes introduced by the module editor are updated in GAL canvas.
parent 69816d87
...@@ -229,6 +229,8 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent ) ...@@ -229,6 +229,8 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
// Check if user wants to edit pad or module properties // Check if user wants to edit pad or module properties
if( item->Type() == PCB_MODULE_T ) if( item->Type() == PCB_MODULE_T )
{ {
item->ClearFlags(); // Necessary for having an undo entry
for( D_PAD* pad = static_cast<MODULE*>( item )->Pads(); pad; pad = pad->Next() ) for( D_PAD* pad = static_cast<MODULE*>( item )->Pads(); pad; pad = pad->Next() )
{ {
if( pad->ViewBBox().Contains( getViewControls()->GetCursorPosition() ) ) if( pad->ViewBBox().Contains( getViewControls()->GetCursorPosition() ) )
...@@ -240,20 +242,34 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent ) ...@@ -240,20 +242,34 @@ int EDIT_TOOL::Properties( TOOL_EVENT& aEvent )
} }
} }
editFrame->SaveCopyInUndoList( item, UR_CHANGED ); std::vector<PICKED_ITEMS_LIST*>& undoList = editFrame->GetScreen()->m_UndoList.m_CommandsList;
editFrame->OnModify();
// It is necessary to determine if anything has changed
PICKED_ITEMS_LIST* lastChange = undoList.empty() ? NULL : undoList.back();
// Display properties dialog
editFrame->OnEditItemRequest( NULL, item ); editFrame->OnEditItemRequest( NULL, item );
item->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY ); PICKED_ITEMS_LIST* currentChange = undoList.empty() ? NULL : undoList.back();
updateRatsnest( true ); if( lastChange != currentChange ) // Something has changed
getModel<BOARD>( PCB_T )->GetRatsnest()->Recalculate(); {
// 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<BOARD>( PCB_T )->GetRatsnest()->Recalculate();
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate );
}
}
if( unselect ) if( unselect )
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear ); m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear );
}
m_toolMgr->RunAction( COMMON_ACTIONS::pointEditorUpdate );
setTransitions(); setTransitions();
return 0; return 0;
...@@ -509,3 +525,40 @@ bool EDIT_TOOL::makeSelection( const SELECTION_TOOL::SELECTION& aSelection ) ...@@ -509,3 +525,40 @@ bool EDIT_TOOL::makeSelection( const SELECTION_TOOL::SELECTION& aSelection )
return !aSelection.Empty(); return !aSelection.Empty();
} }
void EDIT_TOOL::processChanges( const PICKED_ITEMS_LIST* aList )
{
for( unsigned int i = 0; i < aList->GetCount(); ++i )
{
UNDO_REDO_T operation = aList->GetPickedItemStatus( i );
EDA_ITEM* updItem = aList->GetPickedItem( i );
switch( operation )
{
case UR_CHANGED:
updItem->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
break;
case UR_DELETED:
if( updItem->Type() == PCB_MODULE_T )
static_cast<MODULE*>( updItem )->RunOnChildren( boost::bind( &KIGFX::VIEW::Remove,
getView(), _1 ) );
getView()->Remove( updItem );
break;
case UR_NEW:
if( updItem->Type() == PCB_MODULE_T )
static_cast<MODULE*>( updItem )->RunOnChildren( boost::bind( &KIGFX::VIEW::Add,
getView(), _1 ) );
getView()->Add( updItem );
break;
default:
assert( false ); // Not handled
break;
}
}
}
...@@ -133,6 +133,9 @@ private: ...@@ -133,6 +133,9 @@ private:
///> If there are no items currently selected, it tries to choose the item that is under ///> If there are no items currently selected, it tries to choose the item that is under
///> the cursor or displays a disambiguation menu if there are multpile items. ///> the cursor or displays a disambiguation menu if there are multpile items.
bool makeSelection( const SELECTION_TOOL::SELECTION& aSelection ); bool makeSelection( const SELECTION_TOOL::SELECTION& aSelection );
///> Updates view with the changes in the list.
void processChanges( const PICKED_ITEMS_LIST* aList );
}; };
#endif #endif
...@@ -428,10 +428,8 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule, ...@@ -428,10 +428,8 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
/* place module without ratsnest refresh: this will be made later /* place module without ratsnest refresh: this will be made later
* when all modules are on board * when all modules are on board
*/ */
wxPoint oldpos = GetCrossHairPosition();
SetCrossHairPosition( aOldModule->GetPosition(), false );
PlaceModule( aNewModule, NULL, true ); PlaceModule( aNewModule, NULL, true );
SetCrossHairPosition( oldpos, false ); aNewModule->SetPosition( aOldModule->GetPosition() );
// Flip footprint if needed // Flip footprint if needed
if( aOldModule->GetLayer() != aNewModule->GetLayer() ) if( aOldModule->GetLayer() != aNewModule->GetLayer() )
...@@ -457,9 +455,8 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule, ...@@ -457,9 +455,8 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
for( D_PAD* pad = aNewModule->Pads(); pad != NULL; pad = pad->Next() ) for( D_PAD* pad = aNewModule->Pads(); pad != NULL; pad = pad->Next() )
{ {
pad->SetNetCode( NETINFO_LIST::UNCONNECTED ); pad->SetNetCode( NETINFO_LIST::UNCONNECTED );
D_PAD* old_pad = aOldModule->Pads();
for( ; old_pad != NULL; old_pad = old_pad->Next() ) for( D_PAD* old_pad = aOldModule->Pads(); old_pad != NULL; old_pad = old_pad->Next() )
{ {
if( pad->PadNameEqual( old_pad ) ) if( pad->PadNameEqual( old_pad ) )
pad->SetNetCode( old_pad->GetNetCode() ); pad->SetNetCode( old_pad->GetNetCode() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment