Converted global deletion, global text size setting & module exchange to BOARD_COMMIT.
This commit is contained in:
parent
91ea4242ca
commit
6701b80f77
|
@ -39,6 +39,7 @@
|
|||
/* Forward declarations of classes. */
|
||||
class PCB_SCREEN;
|
||||
class BOARD;
|
||||
class BOARD_COMMIT;
|
||||
class BOARD_ITEM_CONTAINER;
|
||||
class TEXTE_PCB;
|
||||
class MODULE;
|
||||
|
@ -1088,11 +1089,9 @@ public:
|
|||
* OldModule is deleted or put in undo list.
|
||||
* @param aOldModule = footprint to replace
|
||||
* @param aNewModule = footprint to put
|
||||
* @param aUndoPickList = the undo list used to save OldModule. If null,
|
||||
* OldModule is deleted
|
||||
* @param aCommit = commit that should store the changes
|
||||
*/
|
||||
void Exchange_Module( MODULE* aOldModule, MODULE* aNewModule,
|
||||
PICKED_ITEMS_LIST* aUndoPickList );
|
||||
void Exchange_Module( MODULE* aOldModule, MODULE* aNewModule, BOARD_COMMIT& aCommit );
|
||||
|
||||
// loading modules: see PCB_BASE_FRAME
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ using namespace std::placeholders;
|
|||
#include <pcbnew.h>
|
||||
#include <wxPcbStruct.h>
|
||||
#include <ratsnest_data.h>
|
||||
#include <board_commit.h>
|
||||
|
||||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
|
@ -108,11 +109,9 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
|
|||
return;
|
||||
|
||||
BOARD* pcb = m_Parent->GetBoard();
|
||||
PICKED_ITEMS_LIST pickersList;
|
||||
ITEM_PICKER itemPicker( NULL, UR_DELETED );
|
||||
BOARD_COMMIT commit( m_Parent );
|
||||
BOARD_ITEM* item;
|
||||
BOARD_ITEM* nextitem;
|
||||
RN_DATA* ratsnest = pcb->GetRatsnest();
|
||||
|
||||
LSET layers_filter = LSET().set();
|
||||
|
||||
|
@ -128,11 +127,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
|
|||
{
|
||||
if( delAll || layers_filter[item->GetLayer()] )
|
||||
{
|
||||
itemPicker.SetItem( item );
|
||||
pickersList.PushItem( itemPicker );
|
||||
pcb->Remove( item );
|
||||
item->ViewRelease();
|
||||
ratsnest->Remove( item );
|
||||
commit.Remove( item );
|
||||
gen_rastnest = true;
|
||||
}
|
||||
else
|
||||
|
@ -160,13 +155,9 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
|
|||
{
|
||||
nextitem = item->Next();
|
||||
|
||||
if( delAll ||
|
||||
( item->Type() == PCB_LINE_T && masque_layer[item->GetLayer()] ) )
|
||||
if( delAll || ( item->Type() == PCB_LINE_T && masque_layer[item->GetLayer()] ) )
|
||||
{
|
||||
itemPicker.SetItem( item );
|
||||
pickersList.PushItem( itemPicker );
|
||||
item->ViewRelease();
|
||||
item->UnLink();
|
||||
commit.Remove( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,13 +170,9 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
|
|||
{
|
||||
nextitem = item->Next();
|
||||
|
||||
if( delAll ||
|
||||
( item->Type() == PCB_TEXT_T && del_text_layers[item->GetLayer()] ) )
|
||||
if( delAll || ( item->Type() == PCB_TEXT_T && del_text_layers[item->GetLayer()] ) )
|
||||
{
|
||||
itemPicker.SetItem( item );
|
||||
pickersList.PushItem( itemPicker );
|
||||
item->ViewRelease();
|
||||
item->UnLink();
|
||||
commit.Remove( item );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -205,13 +192,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
|
|||
|
||||
if( del_fp )
|
||||
{
|
||||
itemPicker.SetItem( item );
|
||||
pickersList.PushItem( itemPicker );
|
||||
static_cast<MODULE*>( item )->RunOnChildren(
|
||||
std::bind( &KIGFX::VIEW_ITEM::ViewRelease, _1 ) );
|
||||
ratsnest->Remove( item );
|
||||
item->ViewRelease();
|
||||
item->UnLink();
|
||||
commit.Remove( item );
|
||||
gen_rastnest = true;
|
||||
}
|
||||
}
|
||||
|
@ -249,17 +230,12 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
|
|||
continue;
|
||||
}
|
||||
|
||||
itemPicker.SetItem( track );
|
||||
pickersList.PushItem( itemPicker );
|
||||
track->ViewRelease();
|
||||
ratsnest->Remove( track );
|
||||
track->UnLink();
|
||||
commit.Remove( track );
|
||||
gen_rastnest = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( pickersList.GetCount() )
|
||||
m_Parent->SaveCopyInUndoList( pickersList, UR_DELETED );
|
||||
commit.Push( wxT( "Global delete" ) );
|
||||
|
||||
if( m_DelMarkers->GetValue() )
|
||||
pcb->DeleteMARKERs();
|
||||
|
@ -268,9 +244,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
|
|||
m_Parent->Compile_Ratsnest( NULL, true );
|
||||
|
||||
// There is a chance that some of tracks have changed their nets, so rebuild ratsnest from scratch
|
||||
if( m_Parent->IsGalCanvasActive() )
|
||||
pcb->GetRatsnest()->ProcessBoard();
|
||||
|
||||
m_Parent->GetCanvas()->Refresh();
|
||||
m_Parent->OnModify();
|
||||
// TODO necessary? if not, remove rn_data.h header as well
|
||||
//if( m_Parent->IsGalCanvasActive() )
|
||||
//pcb->GetRatsnest()->ProcessBoard();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <base_units.h>
|
||||
#include <kicad_string.h>
|
||||
#include <macros.h>
|
||||
#include <board_commit.h>
|
||||
|
||||
#include <pcbnew.h>
|
||||
#include <wxPcbStruct.h>
|
||||
|
@ -134,35 +135,21 @@ void DIALOG_GLOBAL_MODULES_FIELDS_EDITION::OnOKClick( wxCommandEvent& event )
|
|||
|
||||
void PCB_EDIT_FRAME::OnResetModuleTextSizes( wxCommandEvent& event )
|
||||
{
|
||||
DIALOG_GLOBAL_MODULES_FIELDS_EDITION dlg(this);
|
||||
DIALOG_GLOBAL_MODULES_FIELDS_EDITION dlg( this );
|
||||
dlg.ShowModal();
|
||||
|
||||
if( IsGalCanvasActive() )
|
||||
{
|
||||
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
|
||||
{
|
||||
module->Value().ViewUpdate();
|
||||
module->Reference().ViewUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
|
||||
bool aValue, bool aOthers )
|
||||
{
|
||||
MODULE* module;
|
||||
BOARD_ITEM* boardItem;
|
||||
ITEM_PICKER itemWrapper( NULL, UR_CHANGED );
|
||||
PICKED_ITEMS_LIST undoItemList;
|
||||
unsigned int ii;
|
||||
BOARD_COMMIT commit( this );
|
||||
|
||||
int modTextWidth = GetDesignSettings().m_ModuleTextWidth;
|
||||
const wxSize& modTextSize = GetDesignSettings().m_ModuleTextSize;
|
||||
|
||||
// Prepare undo list
|
||||
for( module = GetBoard()->m_Modules; module; module = module->Next() )
|
||||
for( MODULE* module = GetBoard()->m_Modules; module; module = module->Next() )
|
||||
{
|
||||
itemWrapper.SetItem( module );
|
||||
|
||||
if( ! aFilter.IsEmpty() )
|
||||
{
|
||||
if( ! WildCompareString( aFilter, FROM_UTF8( module->GetFPID().Format().c_str() ),
|
||||
|
@ -173,81 +160,50 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
|
|||
|
||||
if( aRef )
|
||||
{
|
||||
TEXTE_MODULE *item = &module->Reference();
|
||||
TEXTE_MODULE* item = &module->Reference();
|
||||
|
||||
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize ||
|
||||
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
|
||||
{
|
||||
undoItemList.PushItem( itemWrapper );
|
||||
commit.Modify( item );
|
||||
item->SetThickness( modTextWidth );
|
||||
item->SetSize( modTextSize );
|
||||
}
|
||||
}
|
||||
|
||||
if( aValue )
|
||||
{
|
||||
TEXTE_MODULE *item = &module->Value();
|
||||
TEXTE_MODULE* item = &module->Value();
|
||||
|
||||
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize ||
|
||||
item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
|
||||
{
|
||||
undoItemList.PushItem( itemWrapper );
|
||||
commit.Modify( item );
|
||||
item->SetThickness( modTextWidth );
|
||||
item->SetSize( modTextSize );
|
||||
}
|
||||
}
|
||||
|
||||
if( aOthers )
|
||||
{
|
||||
// Go through all other module text fields
|
||||
for( boardItem = module->GraphicalItems(); boardItem; boardItem = boardItem->Next() )
|
||||
for( BOARD_ITEM* boardItem = module->GraphicalItems(); boardItem; boardItem = boardItem->Next() )
|
||||
{
|
||||
if( boardItem->Type() == PCB_MODULE_TEXT_T )
|
||||
{
|
||||
TEXTE_MODULE *item = static_cast<TEXTE_MODULE*>( boardItem );
|
||||
TEXTE_MODULE* item = static_cast<TEXTE_MODULE*>( boardItem );
|
||||
|
||||
if( item->GetSize() != GetDesignSettings().m_ModuleTextSize
|
||||
|| item->GetThickness() != GetDesignSettings().m_ModuleTextWidth )
|
||||
{
|
||||
undoItemList.PushItem( itemWrapper );
|
||||
commit.Modify( item );
|
||||
item->SetThickness( modTextWidth );
|
||||
item->SetSize( modTextSize );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exit if there's nothing to do
|
||||
if( !undoItemList.GetCount() )
|
||||
return;
|
||||
|
||||
SaveCopyInUndoList( undoItemList, UR_CHANGED );
|
||||
|
||||
// Apply changes to modules in the undo list
|
||||
for( ii = 0; ii < undoItemList.GetCount(); ii++ )
|
||||
{
|
||||
module = (MODULE*) undoItemList.GetPickedItem( ii );
|
||||
|
||||
if( aRef )
|
||||
{
|
||||
module->Reference().SetThickness( GetDesignSettings().m_ModuleTextWidth );
|
||||
module->Reference().SetSize( GetDesignSettings().m_ModuleTextSize );
|
||||
}
|
||||
|
||||
if( aValue )
|
||||
{
|
||||
module->Value().SetThickness( GetDesignSettings().m_ModuleTextWidth );
|
||||
module->Value().SetSize( GetDesignSettings().m_ModuleTextSize );
|
||||
}
|
||||
|
||||
if( aOthers )
|
||||
{
|
||||
for( boardItem = module->GraphicalItems(); boardItem; boardItem = boardItem->Next() )
|
||||
{
|
||||
if( boardItem->Type() == PCB_MODULE_TEXT_T )
|
||||
{
|
||||
TEXTE_MODULE *item = static_cast<TEXTE_MODULE*>( boardItem );
|
||||
item->SetThickness( GetDesignSettings().m_ModuleTextWidth );
|
||||
item->SetSize( GetDesignSettings().m_ModuleTextSize );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OnModify();
|
||||
commit.Push( wxT( "Reset module text size" ) );
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <macros.h>
|
||||
#include <invoke_pcb_dialog.h>
|
||||
#include <class_pcb_layer_widget.h>
|
||||
#include <board_commit.h>
|
||||
|
||||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
|
@ -451,7 +452,7 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
// the new module replace the old module (pos, orient, ref, value
|
||||
// and connexions are kept)
|
||||
// and the source_module (old module) is deleted
|
||||
PICKED_ITEMS_LIST pickList;
|
||||
BOARD_COMMIT commit( pcbframe );
|
||||
|
||||
if( pcbframe->IsGalCanvasActive() )
|
||||
{
|
||||
|
@ -461,11 +462,10 @@ void FOOTPRINT_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
|||
view->Remove( source_module );
|
||||
}
|
||||
|
||||
pcbframe->Exchange_Module( source_module, newmodule, &pickList );
|
||||
pcbframe->Exchange_Module( source_module, newmodule, commit );
|
||||
newmodule->SetTimeStamp( module_in_edit->GetLink() );
|
||||
|
||||
if( pickList.GetCount() )
|
||||
pcbframe->SaveCopyInUndoList( pickList, UR_UNSPECIFIED );
|
||||
commit.Push( wxT( "" ) );
|
||||
}
|
||||
else // This is an insert command
|
||||
{
|
||||
|
|
|
@ -375,7 +375,7 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
|
|||
STATUS_FLAGS flags = item->GetFlags();
|
||||
item->ClearFlags();
|
||||
|
||||
// Do not handle undo buffer, it is done by the properties dialogs
|
||||
// Do not handle undo buffer, it is done by the properties dialogs @todo LEGACY
|
||||
// Display properties dialog provided by the legacy canvas frame
|
||||
editFrame->OnEditItemRequest( NULL, item );
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <kicad_string.h>
|
||||
#include <wxPcbStruct.h>
|
||||
#include <macros.h>
|
||||
#include <board_commit.h>
|
||||
|
||||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
|
@ -76,7 +77,7 @@ private:
|
|||
const FPID& aNewFootprintFPID,
|
||||
bool eShowError );
|
||||
|
||||
PICKED_ITEMS_LIST m_undoPickList;
|
||||
BOARD_COMMIT m_commit;
|
||||
};
|
||||
|
||||
|
||||
|
@ -84,7 +85,7 @@ int DIALOG_EXCHANGE_MODULE::m_selectionMode = 0;
|
|||
|
||||
|
||||
DIALOG_EXCHANGE_MODULE::DIALOG_EXCHANGE_MODULE( PCB_EDIT_FRAME* parent, MODULE* Module ) :
|
||||
DIALOG_EXCHANGE_MODULE_BASE( parent )
|
||||
DIALOG_EXCHANGE_MODULE_BASE( parent ), m_commit( parent )
|
||||
{
|
||||
m_parent = parent;
|
||||
m_currentModule = Module;
|
||||
|
@ -141,7 +142,6 @@ void DIALOG_EXCHANGE_MODULE::init()
|
|||
|
||||
void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event )
|
||||
{
|
||||
m_undoPickList.ClearItemsList();
|
||||
m_selectionMode = m_Selection->GetSelection();
|
||||
bool result = false;
|
||||
|
||||
|
@ -172,8 +172,7 @@ void DIALOG_EXCHANGE_MODULE::OnOkClick( wxCommandEvent& event )
|
|||
m_parent->GetCanvas()->Refresh();
|
||||
}
|
||||
|
||||
if( m_undoPickList.GetCount() )
|
||||
m_parent->SaveCopyInUndoList( m_undoPickList, UR_UNSPECIFIED );
|
||||
m_commit.Push( wxT( "Changed footprint" ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -367,8 +366,7 @@ bool DIALOG_EXCHANGE_MODULE::change_1_Module( MODULE* aModule,
|
|||
return false;
|
||||
}
|
||||
|
||||
m_parent->Exchange_Module( aModule, newModule, &m_undoPickList );
|
||||
m_parent->GetBoard()->Add( newModule, ADD_APPEND );
|
||||
m_parent->Exchange_Module( aModule, newModule, m_commit );
|
||||
|
||||
if( aModule == m_currentModule )
|
||||
m_currentModule = newModule;
|
||||
|
@ -381,13 +379,12 @@ bool DIALOG_EXCHANGE_MODULE::change_1_Module( MODULE* aModule,
|
|||
|
||||
void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
|
||||
MODULE* aNewModule,
|
||||
PICKED_ITEMS_LIST* aUndoPickList )
|
||||
BOARD_COMMIT& aCommit )
|
||||
{
|
||||
aNewModule->SetParent( GetBoard() );
|
||||
|
||||
/* place module without ratsnest refresh: this will be made later
|
||||
* when all modules are on board
|
||||
*/
|
||||
* when all modules are on board */
|
||||
PlaceModule( aNewModule, NULL, true );
|
||||
|
||||
// Copy full placement and pad net names (when possible)
|
||||
|
@ -402,23 +399,12 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aOldModule,
|
|||
aNewModule->SetTimeStamp( aOldModule->GetTimeStamp() );
|
||||
aNewModule->SetPath( aOldModule->GetPath() );
|
||||
|
||||
if( aUndoPickList )
|
||||
{
|
||||
GetBoard()->Remove( aOldModule );
|
||||
ITEM_PICKER picker_old( aOldModule, UR_DELETED );
|
||||
ITEM_PICKER picker_new( aNewModule, UR_NEW );
|
||||
aUndoPickList->PushItem( picker_old );
|
||||
aUndoPickList->PushItem( picker_new );
|
||||
}
|
||||
else
|
||||
{
|
||||
GetGalCanvas()->GetView()->Remove( aOldModule );
|
||||
aOldModule->DeleteStructure();
|
||||
}
|
||||
aCommit.Remove( aOldModule );
|
||||
aCommit.Add( aNewModule );
|
||||
|
||||
// @todo LEGACY should be unnecessary
|
||||
GetBoard()->m_Status_Pcb = 0;
|
||||
aNewModule->ClearFlags();
|
||||
OnModify();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue