From 08ef741770ddf5a4fa378f1dbc8dcc51ef8631a3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 5 Feb 2012 14:02:46 +0100 Subject: [PATCH] Undo redo change and code cleanup. --- common/class_undoredo_container.cpp | 43 +++++++++++------------ eeschema/edit_label.cpp | 4 +-- eeschema/libedit_undo_redo.cpp | 4 +-- eeschema/sch_screen.cpp | 4 +-- eeschema/schematic_undo_redo.cpp | 14 +++----- include/class_undoredo_container.h | 38 +++++++++++--------- pcbnew/automove.cpp | 5 ++- pcbnew/autoplac.cpp | 12 +++---- pcbnew/block.cpp | 15 +++----- pcbnew/board_undo_redo.cpp | 16 ++++----- pcbnew/deltrack.cpp | 6 ++-- pcbnew/dialogs/dialog_global_deletion.cpp | 8 ++--- pcbnew/edit_track_width.cpp | 2 +- pcbnew/editedge.cpp | 2 +- pcbnew/edtxtmod.cpp | 7 ++-- pcbnew/globaleditpad.cpp | 1 - pcbnew/modedit_undo_redo.cpp | 4 +-- pcbnew/modules.cpp | 8 ++--- pcbnew/move-drag_pads.cpp | 4 +-- pcbnew/move_or_drag_track.cpp | 14 ++++---- pcbnew/pcbplot.cpp | 9 ++--- pcbnew/zones_functions_for_undo_redo.cpp | 5 ++- pcbnew/zones_test_and_combine_areas.cpp | 2 -- 23 files changed, 102 insertions(+), 125 deletions(-) diff --git a/common/class_undoredo_container.cpp b/common/class_undoredo_container.cpp index 56454ec193..51fa8d54ad 100644 --- a/common/class_undoredo_container.cpp +++ b/common/class_undoredo_container.cpp @@ -33,11 +33,10 @@ ITEM_PICKER::ITEM_PICKER( EDA_ITEM* aItem, UNDO_REDO_T aUndoRedoStatus ) { - m_UndoRedoStatus = aUndoRedoStatus; - m_PickedItem = aItem; - m_PickedItemType = TYPE_NOT_INIT; - m_PickerFlags = 0; - m_Link = NULL; + m_undoRedoStatus = aUndoRedoStatus; + SetItem( aItem ); + m_pickerFlags = 0; + m_link = NULL; } @@ -75,7 +74,7 @@ bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const { for( size_t i = 0; i < m_ItemsList.size(); i++ ) { - if( m_ItemsList[ i ].m_PickedItem == aItem ) + if( m_ItemsList[ i ].GetItem() == aItem ) return true; } @@ -97,9 +96,9 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() while( GetCount() > 0 ) { ITEM_PICKER wrapper = PopItem(); - if( wrapper.m_PickedItem == NULL ) // No more item in list. + if( wrapper.GetItem() == NULL ) // No more item in list. break; - switch( wrapper.m_UndoRedoStatus ) + switch( wrapper.GetStatus() ) { case UR_UNSPECIFIED: if( show_error_message ) @@ -112,7 +111,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() { // Specific to eeschema: a linked list of wires is stored. The wrapper picks only // the first item (head of list), and is owner of all picked items. - EDA_ITEM* item = wrapper.m_PickedItem; + EDA_ITEM* item = wrapper.GetItem(); while( item ) { @@ -135,7 +134,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() case UR_CHANGED: case UR_EXCHANGE_T: - delete wrapper.m_Link; // the picker is owner of this item + delete wrapper.GetLink(); // the picker is owner of this item break; case UR_DELETED: // the picker is owner of this item @@ -146,12 +145,12 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() * copy of the current module when changed), * and the picker is owner of this item */ - delete wrapper.m_PickedItem; + delete wrapper.GetItem(); break; default: wxFAIL_MSG( wxString::Format( wxT( "Cannot clear unknown undo/redo command %d" ), - wrapper.m_UndoRedoStatus ) ); + wrapper.GetStatus() ) ); break; } } @@ -172,7 +171,7 @@ ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx ) EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) { if( aIdx < m_ItemsList.size() ) - return m_ItemsList[aIdx].m_PickedItem; + return m_ItemsList[aIdx].GetItem(); else return NULL; } @@ -181,7 +180,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) { if( aIdx < m_ItemsList.size() ) - return m_ItemsList[aIdx].m_Link; + return m_ItemsList[aIdx].GetLink(); else return NULL; } @@ -190,7 +189,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) { if( aIdx < m_ItemsList.size() ) - return m_ItemsList[aIdx].m_UndoRedoStatus; + return m_ItemsList[aIdx].GetStatus(); else return UR_UNSPECIFIED; } @@ -199,7 +198,7 @@ UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) int PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) { if( aIdx < m_ItemsList.size() ) - return m_ItemsList[aIdx].m_PickerFlags; + return m_ItemsList[aIdx].GetFlags(); else return 0; } @@ -209,7 +208,7 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, unsigned aIdx ) { if( aIdx < m_ItemsList.size() ) { - m_ItemsList[aIdx].m_PickedItem = aItem; + m_ItemsList[aIdx].SetItem( aItem ); return true; } else @@ -221,7 +220,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx ) { if( aIdx < m_ItemsList.size() ) { - m_ItemsList[aIdx].m_Link = aLink; + m_ItemsList[aIdx].SetLink( aLink ); return true; } else @@ -233,8 +232,8 @@ bool PICKED_ITEMS_LIST::SetPickedItem( EDA_ITEM* aItem, UNDO_REDO_T aStatus, uns { if( aIdx < m_ItemsList.size() ) { - m_ItemsList[aIdx].m_PickedItem = aItem; - m_ItemsList[aIdx].m_UndoRedoStatus = aStatus; + m_ItemsList[aIdx].SetItem( aItem ); + m_ItemsList[aIdx].SetStatus( aStatus ); return true; } else @@ -246,7 +245,7 @@ bool PICKED_ITEMS_LIST::SetPickedItemStatus( UNDO_REDO_T aStatus, unsigned aIdx { if( aIdx < m_ItemsList.size() ) { - m_ItemsList[aIdx].m_UndoRedoStatus = aStatus; + m_ItemsList[aIdx].SetStatus( aStatus ); return true; } else @@ -258,7 +257,7 @@ bool PICKED_ITEMS_LIST::SetPickerFlags( int aFlags, unsigned aIdx ) { if( aIdx < m_ItemsList.size() ) { - m_ItemsList[aIdx].m_PickerFlags = aFlags; + m_ItemsList[aIdx].SetFlags( aFlags ); return true; } else diff --git a/eeschema/edit_label.cpp b/eeschema/edit_label.cpp index 32d428c987..04b64de408 100644 --- a/eeschema/edit_label.cpp +++ b/eeschema/edit_label.cpp @@ -263,12 +263,12 @@ void SCH_EDIT_FRAME::OnConvertTextType( wxCommandEvent& aEvent ) } // Prepare undo command for delete old text - picker.m_UndoRedoStatus = UR_DELETED; + picker.SetStatus( UR_DELETED ); picker.SetLink( NULL ); pickList.PushItem( picker ); // Prepare undo command for new text - picker.m_UndoRedoStatus = UR_NEW; + picker.SetStatus( UR_NEW ); picker.SetItem(newtext); pickList.PushItem( picker ); diff --git a/eeschema/libedit_undo_redo.cpp b/eeschema/libedit_undo_redo.cpp index c11ba52e37..bce47576d4 100644 --- a/eeschema/libedit_undo_redo.cpp +++ b/eeschema/libedit_undo_redo.cpp @@ -48,7 +48,7 @@ void LIB_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event ) lastcmd = GetScreen()->PopCommandFromRedoList(); wrapper = lastcmd->PopItem(); - m_component = (LIB_COMPONENT*) wrapper.m_PickedItem; + m_component = (LIB_COMPONENT*) wrapper.GetItem(); if( m_component == NULL ) return; @@ -84,7 +84,7 @@ void LIB_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event ) lastcmd = GetScreen()->PopCommandFromUndoList(); wrapper = lastcmd->PopItem(); - m_component = (LIB_COMPONENT*) wrapper.m_PickedItem; + m_component = (LIB_COMPONENT*) wrapper.GetItem(); if( m_component == NULL ) return; diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index acb23c344d..bd49d17a3e 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -872,7 +872,6 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position ) for( item = GetDrawItems(); item != NULL; item = item->Next() ) { picker.SetItem( item ); - picker.SetItemType( item->Type() ); if( !item->IsConnectable() || !item->IsConnected( position ) || (item->GetFlags() & SKIP_STRUCT) ) @@ -901,7 +900,7 @@ void SCH_SCREEN::addConnectedItemsToBlock( const wxPoint& position ) if( addinlist ) { - picker.m_PickerFlags = item->GetFlags(); + picker.SetFlags( item->GetFlags() ); m_BlockLocate.m_ItemsSelection.PushItem( picker ); } } @@ -922,7 +921,6 @@ int SCH_SCREEN::UpdatePickList() if( item->HitTest( area ) ) { picker.SetItem( item ); - picker.SetItemType( item->Type() ); m_BlockLocate.PushItem( picker ); } } diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 82327663cb..18351647c3 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -121,25 +121,19 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem, if( aItem == NULL && ( aCommandType != UR_WIRE_IMAGE ) ) return; - SCH_ITEM* CopyOfItem; PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST(); commandToUndo->m_TransformPoint = aTransformPoint; - ITEM_PICKER itemWrapper( aItem, aCommandType ); + ITEM_PICKER itemWrapper( aItem, aCommandType ); if( aItem ) - { - itemWrapper.m_PickedItemType = aItem->Type(); - itemWrapper.m_PickerFlags = aItem->GetFlags(); - } + itemWrapper.SetFlags( aItem->GetFlags() ); switch( aCommandType ) { case UR_CHANGED: /* Create a copy of item */ - CopyOfItem = DuplicateStruct( aItem, true ); - itemWrapper.m_Link = CopyOfItem; - if( CopyOfItem ) - commandToUndo->PushItem( itemWrapper ); + itemWrapper.SetLink( DuplicateStruct( aItem, true ) ); + commandToUndo->PushItem( itemWrapper ); break; case UR_NEW: diff --git a/include/class_undoredo_container.h b/include/class_undoredo_container.h index 0efe9c00dd..93a699166e 100644 --- a/include/class_undoredo_container.h +++ b/include/class_undoredo_container.h @@ -80,18 +80,16 @@ enum UNDO_REDO_T { class ITEM_PICKER { - friend class PICKED_ITEMS_LIST; - -public: - UNDO_REDO_T m_UndoRedoStatus; /* type of operation to undo/redo for this item */ - EDA_ITEM* m_PickedItem; /* Pointer on the schematic or board item that is concerned +private: + int m_pickerFlags; /* a copy of m_Flags member. useful in mode/drag + * undo/redo commands */ + UNDO_REDO_T m_undoRedoStatus; /* type of operation to undo/redo for this item */ + EDA_ITEM* m_pickedItem; /* Pointer on the schematic or board item that is concerned * (picked), or in undo redo commands, the copy of an * edited item. */ - KICAD_T m_PickedItemType; /* type of schematic or board item that is concerned */ + KICAD_T m_pickedItemType; /* type of schematic or board item that is concerned */ - int m_PickerFlags; /* a copy of m_Flags member. useful in mode/drag - * undo/redo commands */ - EDA_ITEM* m_Link; /* Pointer on an other item. Used in undo redo command + EDA_ITEM* m_link; /* Pointer on an other item. Used in undo redo command * used when a duplicate exists i.e. when an item is * modified, and the copy of initial item exists (the * duplicate) m_Item points the duplicate (i.e the old @@ -101,19 +99,27 @@ public: public: ITEM_PICKER( EDA_ITEM* aItem = NULL, UNDO_REDO_T aUndoRedoStatus = UR_UNSPECIFIED ); - EDA_ITEM* GetItem() const { return m_PickedItem; } + EDA_ITEM* GetItem() const { return m_pickedItem; } - void SetItem( EDA_ITEM* aItem ) { m_PickedItem = aItem; } + void SetItem( EDA_ITEM* aItem ) + { + m_pickedItem = aItem; + m_pickedItemType = aItem ? aItem->Type() : TYPE_NOT_INIT; + } - KICAD_T GetItemType() const { return m_PickedItemType; } + KICAD_T GetItemType() const { return m_pickedItemType; } - void SetStatus( UNDO_REDO_T aStatus ) { m_UndoRedoStatus = aStatus; } + void SetStatus( UNDO_REDO_T aStatus ) { m_undoRedoStatus = aStatus; } - void SetItemType( KICAD_T aType ) { m_PickedItemType = aType; } + UNDO_REDO_T GetStatus() { return m_undoRedoStatus; } - void SetLink( EDA_ITEM* aItem ) { m_Link = aItem; } + void SetFlags( int aFlags ) { m_pickerFlags = aFlags; } - EDA_ITEM* GetLink() const { return m_Link; } + int GetFlags() { return m_pickerFlags; } + + void SetLink( EDA_ITEM* aItem ) { m_link = aItem; } + + EDA_ITEM* GetLink() const { return m_link; } }; diff --git a/pcbnew/automove.cpp b/pcbnew/automove.cpp index b8e7a838eb..0b211e9d95 100644 --- a/pcbnew/automove.cpp +++ b/pcbnew/automove.cpp @@ -264,8 +264,8 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) } // Undo: add copy of old Module to undo - picker.m_Link = Module->Clone(); - picker.m_PickedItemType = Module->Type(); + picker.SetItem( Module ); + picker.SetLink( Module->Clone() ); if( current.x > (Xsize_allowed + start.x) ) { @@ -282,7 +282,6 @@ void PCB_EDIT_FRAME::AutoMoveModulesOnPcb( bool PlaceModulesHorsPcb ) PlaceModule( Module, NULL, true ); // Undo: add new Module to undo - picker.m_PickedItem = Module; newList.PushItem( picker ); current.x += Module->m_BoundaryBox.GetWidth() + pas_grille; diff --git a/pcbnew/autoplac.cpp b/pcbnew/autoplac.cpp index d1732c6160..ae63de328c 100644 --- a/pcbnew/autoplac.cpp +++ b/pcbnew/autoplac.cpp @@ -181,8 +181,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) if( ThisModule == Module ) { // Module will be placed, add to undo. - picker.m_PickedItem = ThisModule; - picker.m_PickedItemType = ThisModule->Type(); + picker.SetItem( ThisModule ); newList.PushItem( picker ); Module->m_ModuleStatus |= MODULE_to_PLACE; @@ -199,8 +198,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) if( !bbbox.Contains( Module->m_Pos ) ) { // Module will be placed, add to undo. - picker.m_PickedItem = Module; - picker.m_PickedItemType = Module->Type(); + picker.SetItem( Module ); newList.PushItem( picker ); Module->m_ModuleStatus |= MODULE_to_PLACE; @@ -215,8 +213,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) break; // Module will be placed, add to undo. - picker.m_PickedItem = Module; - picker.m_PickedItemType = Module->Type(); + picker.SetItem( Module ); newList.PushItem( picker ); Module->m_ModuleStatus |= MODULE_to_PLACE; @@ -232,8 +229,7 @@ void PCB_EDIT_FRAME::AutoPlaceModule( MODULE* Module, int place_mode, wxDC* DC ) if( !(Module->m_ModuleStatus & MODULE_is_PLACED) ) { // Module will be placed, add to undo. - picker.m_PickedItem = Module; - picker.m_PickedItemType = Module->Type(); + picker.SetItem( Module ); newList.PushItem( picker ); Module->m_ModuleStatus |= MODULE_to_PLACE; diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index f7a8470f9f..ed59944793 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -398,8 +398,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() { if( blockIncludeItemsOnInvisibleLayers || m_Pcb->IsModuleLayerVisible( layer ) ) { - picker.m_PickedItem = module; - picker.m_PickedItemType = module->Type(); + picker.SetItem ( module ); itemsList->PushItem( picker ); } } @@ -416,8 +415,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() if( blockIncludeItemsOnInvisibleLayers || m_Pcb->IsLayerVisible( pt_segm->GetLayer() ) ) { - picker.m_PickedItem = pt_segm; - picker.m_PickedItemType = pt_segm->Type(); + picker.SetItem ( pt_segm ); itemsList->PushItem( picker ); } } @@ -486,8 +484,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() if( select_me ) { - picker.m_PickedItem = PtStruct; - picker.m_PickedItemType = PtStruct->Type(); + picker.SetItem ( PtStruct ); itemsList->PushItem( picker ); } } @@ -505,8 +502,7 @@ void PCB_EDIT_FRAME::Block_SelectItems() || m_Pcb->IsLayerVisible( area->GetLayer() ) ) { BOARD_ITEM* zone_c = (BOARD_ITEM*) area; - picker.m_PickedItem = zone_c; - picker.m_PickedItemType = zone_c->Type(); + picker.SetItem ( zone_c ); itemsList->PushItem( picker ); } } @@ -854,8 +850,7 @@ void PCB_EDIT_FRAME::Block_Duplicate() if( newitem ) { newitem->Move( MoveVector ); - picker.m_PickedItem = newitem; - picker.m_PickedItemType = newitem->Type(); + picker.SetItem ( newitem ); newList.PushItem( picker ); } } diff --git a/pcbnew/board_undo_redo.cpp b/pcbnew/board_undo_redo.cpp index 8a12dc109a..f037117693 100644 --- a/pcbnew/board_undo_redo.cpp +++ b/pcbnew/board_undo_redo.cpp @@ -312,17 +312,13 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem, commandToUndo->m_TransformPoint = aTransformPoint; ITEM_PICKER itemWrapper( aItem, aCommandType ); - itemWrapper.m_PickedItemType = aItem->Type(); switch( aCommandType ) { - case UR_CHANGED: /* Create a copy of schematic */ - if( itemWrapper.m_Link == NULL ) // When not null, the copy is already done - itemWrapper.m_Link = aItem->Clone();; - - if( itemWrapper.m_Link ) - commandToUndo->PushItem( itemWrapper ); - + case UR_CHANGED: // Create a copy of item + if( itemWrapper.GetLink() == NULL ) // When not null, the copy is already done + itemWrapper.SetLink( aItem->Clone() ); + commandToUndo->PushItem( itemWrapper ); break; case UR_NEW: @@ -466,10 +462,10 @@ void PCB_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed * - if a call to SaveCopyInUndoList was forgotten in Pcbnew * - in zones outlines, when a change in one zone merges this zone with an other * This test avoids a Pcbnew crash - * the test is made only to avoid crashes, so it is not needed for deleted or new items + * Obviouly, this test is not made for deleted items */ UNDO_REDO_T status = aList->GetPickedItemStatus( ii ); - if( status != UR_DELETED && status != UR_NEW ) + if( status != UR_DELETED ) { if( build_item_list ) // Build list of existing items, for integrity test diff --git a/pcbnew/deltrack.cpp b/pcbnew/deltrack.cpp index c97627cbca..da680175e1 100644 --- a/pcbnew/deltrack.cpp +++ b/pcbnew/deltrack.cpp @@ -177,8 +177,7 @@ void PCB_EDIT_FRAME::Delete_net( wxDC* DC, TRACK* aTrack ) // redraw the area where the track was m_canvas->RefreshDrawingRect( segm->GetBoundingBox() ); - picker.m_PickedItem = segm; - picker.m_PickedItemType = segm->Type(); + picker.SetItem( segm ); itemsList.PushItem( picker ); } @@ -223,8 +222,7 @@ void PCB_EDIT_FRAME::Remove_One_Track( wxDC* DC, TRACK* pt_segm ) // redraw the area where the track was m_canvas->RefreshDrawingRect( tracksegment->GetBoundingBox() ); - picker.m_PickedItem = tracksegment; - picker.m_PickedItemType = tracksegment->Type(); + picker.SetItem( tracksegment ); itemsList.PushItem( picker ); } diff --git a/pcbnew/dialogs/dialog_global_deletion.cpp b/pcbnew/dialogs/dialog_global_deletion.cpp index ba36a85047..47d0a20831 100644 --- a/pcbnew/dialogs/dialog_global_deletion.cpp +++ b/pcbnew/dialogs/dialog_global_deletion.cpp @@ -88,7 +88,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) while( pcb->GetAreaCount() ) { item = pcb->GetArea( 0 ); - itemPicker.m_PickedItem = item; + itemPicker.SetItem( item ); pickersList.PushItem( itemPicker ); pcb->Remove( item ); } @@ -118,7 +118,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) if( removeme ) { - itemPicker.m_PickedItem = item; + itemPicker.SetItem( item ); pickersList.PushItem( itemPicker ); item->UnLink(); } @@ -131,7 +131,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) for( item = pcb->m_Modules; item; item = nextitem ) { nextitem = item->Next(); - itemPicker.m_PickedItem = item; + itemPicker.SetItem( item ); pickersList.PushItem( itemPicker ); item->UnLink(); } @@ -165,7 +165,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete( ) if( (track->ReturnMaskLayer() & layers_filter) == 0 ) continue; - itemPicker.m_PickedItem = track; + itemPicker.SetItem( track ); pickersList.PushItem( itemPicker ); track->UnLink(); gen_rastnest = true; diff --git a/pcbnew/edit_track_width.cpp b/pcbnew/edit_track_width.cpp index f4229626fb..e8dff5c73a 100644 --- a/pcbnew/edit_track_width.cpp +++ b/pcbnew/edit_track_width.cpp @@ -100,7 +100,7 @@ bool PCB_EDIT_FRAME::SetTrackSegmentWidth( TRACK* aTrackItem, { aTrackItem->m_Width = initial_width; ITEM_PICKER picker( aTrackItem, UR_CHANGED ); - picker.m_Link = aTrackItem->Clone(); + picker.SetLink( aTrackItem->Clone() ); aItemsListPicker->PushItem( picker ); aTrackItem->m_Width = new_width; diff --git a/pcbnew/editedge.cpp b/pcbnew/editedge.cpp index c0d10fd2c8..b834b4e659 100644 --- a/pcbnew/editedge.cpp +++ b/pcbnew/editedge.cpp @@ -173,7 +173,7 @@ void PCB_EDIT_FRAME::Delete_Drawings_All_Layer( int aLayer ) if( item->GetLayer() == aLayer ) { item->UnLink(); - picker.m_PickedItem = item; + picker.SetItem( item ); pickList.PushItem( picker ); } diff --git a/pcbnew/edtxtmod.cpp b/pcbnew/edtxtmod.cpp index aa75fa534c..5ffea421b9 100644 --- a/pcbnew/edtxtmod.cpp +++ b/pcbnew/edtxtmod.cpp @@ -366,14 +366,12 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) PICKED_ITEMS_LIST undoItemList; unsigned int ii; - itemWrapper.m_PickedItemType = PCB_MODULE_T; - module = GetBoard()->m_Modules; // Prepare undo list while( module ) { - itemWrapper.m_PickedItem = module; + itemWrapper.SetItem( module ); switch( aType ) { @@ -388,7 +386,8 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( int aType, wxDC* aDC ) case TEXT_is_VALUE: item = module->m_Value; - if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || item->GetThickness() != GetDesignSettings().m_ModuleTextWidth ) + if( item->GetSize() != GetDesignSettings().m_ModuleTextSize || + item->GetThickness() != GetDesignSettings().m_ModuleTextWidth ) undoItemList.PushItem( itemWrapper ); break; diff --git a/pcbnew/globaleditpad.cpp b/pcbnew/globaleditpad.cpp index 693297db9b..5ddd1e4a34 100644 --- a/pcbnew/globaleditpad.cpp +++ b/pcbnew/globaleditpad.cpp @@ -265,7 +265,6 @@ void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad, if( saveMe ) { ITEM_PICKER itemWrapper( Module, UR_CHANGED ); - itemWrapper.m_PickedItemType = Module->Type(); itemsList.PushItem( itemWrapper ); } } diff --git a/pcbnew/modedit_undo_redo.cpp b/pcbnew/modedit_undo_redo.cpp index da6fec21a9..e9c018f349 100644 --- a/pcbnew/modedit_undo_redo.cpp +++ b/pcbnew/modedit_undo_redo.cpp @@ -63,7 +63,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromRedoList( wxCommandEvent& event ) // Retrieve last module state from undo list lastcmd = GetScreen()->PopCommandFromRedoList(); wrapper = lastcmd->PopItem(); - module = (MODULE *)wrapper.m_PickedItem; + module = (MODULE *)wrapper.GetItem(); delete lastcmd; if( module ) @@ -91,7 +91,7 @@ void FOOTPRINT_EDIT_FRAME::GetComponentFromUndoList( wxCommandEvent& event ) // Retrieve last module state from undo list lastcmd = GetScreen()->PopCommandFromUndoList(); wrapper = lastcmd->PopItem(); - module = (MODULE *)wrapper.m_PickedItem; + module = (MODULE *)wrapper.GetItem(); delete lastcmd; if( module ) diff --git a/pcbnew/modules.cpp b/pcbnew/modules.cpp index b427027ecb..b36315324a 100644 --- a/pcbnew/modules.cpp +++ b/pcbnew/modules.cpp @@ -121,9 +121,9 @@ void PCB_EDIT_FRAME::StartMove_Module( MODULE* module, wxDC* DC ) for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { TRACK* segm = g_DragSegmentList[ii].m_Segm; - itemWrapper.m_PickedItem = segm; - itemWrapper.m_Link = segm->Clone(); - itemWrapper.m_Link->SetState( IN_EDIT, OFF ); + itemWrapper.SetItem( segm ); + itemWrapper.SetLink( segm->Clone() ); + itemWrapper.GetLink()->SetState( IN_EDIT, OFF ); s_PickedList.PushItem( itemWrapper ); } } @@ -376,7 +376,7 @@ void PCB_BASE_FRAME::PlaceModule( MODULE* aModule, wxDC* aDC, bool aDoNotRecreat else if( aModule->IsMoving() ) { ITEM_PICKER picker( aModule, UR_CHANGED ); - picker.m_Link = s_ModuleInitialCopy; + picker.SetLink( s_ModuleInitialCopy ); s_PickedList.PushItem( picker ); s_ModuleInitialCopy = NULL; // the picker is now owner of s_ModuleInitialCopy. } diff --git a/pcbnew/move-drag_pads.cpp b/pcbnew/move-drag_pads.cpp index 2dc534e4a0..51d9236e00 100644 --- a/pcbnew/move-drag_pads.cpp +++ b/pcbnew/move-drag_pads.cpp @@ -320,7 +320,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) if( g_DragSegmentList[ii].m_Pad_End ) Track->m_End = Pad_OldPos; - picker.m_PickedItem = Track; + picker.SetItem( Track ); pickList.PushItem( picker ); } @@ -333,7 +333,7 @@ void PCB_BASE_FRAME::PlacePad( D_PAD* Pad, wxDC* DC ) SaveCopyInUndoList( Module, UR_CHANGED ); else { - picker.m_PickedItem = Module; + picker.SetItem( Module ); pickList.PushItem( picker ); SaveCopyInUndoList( pickList, UR_CHANGED ); } diff --git a/pcbnew/move_or_drag_track.cpp b/pcbnew/move_or_drag_track.cpp index 69f0b57cb0..0cdbf1f5ed 100644 --- a/pcbnew/move_or_drag_track.cpp +++ b/pcbnew/move_or_drag_track.cpp @@ -758,16 +758,16 @@ void PCB_EDIT_FRAME::StartMoveOneNodeOrSegment( TRACK* aTrack, wxDC* aDC, int aC // Prepare the Undo command ITEM_PICKER picker( aTrack, UR_CHANGED ); - picker.m_Link = aTrack->Clone(); + picker.SetLink( aTrack->Clone() ); s_ItemsListPicker.PushItem( picker ); for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm; - picker.m_PickedItem = draggedtrack; - picker.m_Link = draggedtrack->Clone(); + picker.SetItem( draggedtrack ); + picker.SetLink( draggedtrack->Clone() ); s_ItemsListPicker.PushItem( picker ); - draggedtrack = (TRACK*) picker.m_Link; + draggedtrack = (TRACK*) picker.GetLink(); draggedtrack->SetStatus( 0 ); draggedtrack->ClearFlags(); } @@ -979,10 +979,10 @@ void PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope( TRACK* track, wxDC* DC for( unsigned ii = 0; ii < g_DragSegmentList.size(); ii++ ) { TRACK* draggedtrack = g_DragSegmentList[ii].m_Segm; - picker.m_PickedItem = draggedtrack; - picker.m_Link = draggedtrack->Clone(); + picker.SetItem( draggedtrack); + picker.SetLink ( draggedtrack->Clone() ); s_ItemsListPicker.PushItem( picker ); - draggedtrack = (TRACK*) picker.m_Link; + draggedtrack = (TRACK*) picker.GetLink(); draggedtrack->SetStatus( 0 ); draggedtrack->ClearFlags(); } diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index b748aabfbe..8f7d00c605 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -549,11 +549,12 @@ void DIALOG_PLOT::applyPlotSettings() { msg = ReturnStringFromValue( g_UserUnit, m_PSWidthAdjust, PCB_INTERNAL_UNIT ); m_PSFineAdjustWidthOpt->SetValue( msg ); - msg.Printf( _( "Width correction constrained!\nThe reasonable width correction value must be in a range of [%+f; %+f]" ), + msg.Printf( _( "Width correction constrained!\n" +"The reasonable width correction value must be in a range of\n" +" [%+f; %+f] (%s) for current design rules!\n" ), To_User_Unit( g_UserUnit, m_WidthAdjustMinValue, PCB_INTERNAL_UNIT ), - To_User_Unit( g_UserUnit, m_WidthAdjustMaxValue, PCB_INTERNAL_UNIT ) ); - msg += ( g_UserUnit == INCHES )? _(" (\")") : _(" (mm)"); - msg += _( " for current design rules!\n" ); + To_User_Unit( g_UserUnit, m_WidthAdjustMaxValue, PCB_INTERNAL_UNIT ), + ( g_UserUnit == INCHES )? wxT("\"") : wxT("mm") ); m_messagesBox->AppendText( msg ); } diff --git a/pcbnew/zones_functions_for_undo_redo.cpp b/pcbnew/zones_functions_for_undo_redo.cpp index a774aaea2d..98d82acddb 100644 --- a/pcbnew/zones_functions_for_undo_redo.cpp +++ b/pcbnew/zones_functions_for_undo_redo.cpp @@ -137,9 +137,8 @@ int SaveCopyOfZones( PICKED_ITEMS_LIST& aPickList, BOARD* aPcb, int aNetCode, in ZONE_CONTAINER* zoneDup = new ZONE_CONTAINER( *zone ); zoneDup->SetParent( aPcb ); - ITEM_PICKER picker( zone, UR_CHANGED ); - picker.m_Link = zoneDup; - picker.m_PickedItemType = zone->Type(); + ITEM_PICKER picker( zone, UR_CHANGED ); + picker.SetLink( zoneDup ); aPickList.PushItem( picker ); copyCount++; } diff --git a/pcbnew/zones_test_and_combine_areas.cpp b/pcbnew/zones_test_and_combine_areas.cpp index 1b2e35d9b0..670ac19817 100644 --- a/pcbnew/zones_test_and_combine_areas.cpp +++ b/pcbnew/zones_test_and_combine_areas.cpp @@ -44,7 +44,6 @@ ZONE_CONTAINER* BOARD::AddArea( PICKED_ITEMS_LIST* aNewZonesList, int aNetcode, if( aNewZonesList ) { ITEM_PICKER picker( new_area, UR_NEW ); - picker.m_PickedItemType = new_area->Type(); aNewZonesList->PushItem( picker ); } return new_area; @@ -66,7 +65,6 @@ void BOARD::RemoveArea( PICKED_ITEMS_LIST* aDeletedList, ZONE_CONTAINER* area_to if( aDeletedList ) { ITEM_PICKER picker( area_to_remove, UR_DELETED ); - picker.m_PickedItemType = area_to_remove->Type(); aDeletedList->PushItem( picker ); Remove( area_to_remove ); // remove from zone list, but does not delete it }