diff --git a/common/class_undoredo_container.cpp b/common/class_undoredo_container.cpp index e56d765139..2dd862ef01 100644 --- a/common/class_undoredo_container.cpp +++ b/common/class_undoredo_container.cpp @@ -50,7 +50,7 @@ PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST() } -void PICKED_ITEMS_LIST::PushItem( ITEM_PICKER& aItem ) +void PICKED_ITEMS_LIST::PushItem( const ITEM_PICKER& aItem ) { m_ItemsList.push_back( aItem ); } @@ -70,7 +70,7 @@ ITEM_PICKER PICKED_ITEMS_LIST::PopItem() } -bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const +bool PICKED_ITEMS_LIST::ContainsItem( const EDA_ITEM* aItem ) const { for( size_t i = 0; i < m_ItemsList.size(); i++ ) { @@ -82,6 +82,18 @@ bool PICKED_ITEMS_LIST::ContainsItem( EDA_ITEM* aItem ) const } +int PICKED_ITEMS_LIST::FindItem( const EDA_ITEM* aItem ) const +{ + for( size_t i = 0; i < m_ItemsList.size(); i++ ) + { + if( m_ItemsList[i].GetItem() == aItem ) + return i; + } + + return -1; +} + + void PICKED_ITEMS_LIST::ClearItemsList() { m_ItemsList.clear(); @@ -157,7 +169,7 @@ void PICKED_ITEMS_LIST::ClearListAndDeleteItems() } -ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx ) +ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx ) const { ITEM_PICKER picker; @@ -168,7 +180,7 @@ ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper( unsigned int aIdx ) } -EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) +EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) const { if( aIdx < m_ItemsList.size() ) return m_ItemsList[aIdx].GetItem(); @@ -177,7 +189,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItem( unsigned int aIdx ) } -EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) +EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) const { if( aIdx < m_ItemsList.size() ) return m_ItemsList[aIdx].GetLink(); @@ -186,7 +198,7 @@ EDA_ITEM* PICKED_ITEMS_LIST::GetPickedItemLink( unsigned int aIdx ) } -UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) +UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) const { if( aIdx < m_ItemsList.size() ) return m_ItemsList[aIdx].GetStatus(); @@ -195,7 +207,7 @@ UNDO_REDO_T PICKED_ITEMS_LIST::GetPickedItemStatus( unsigned int aIdx ) } -STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) +STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags( unsigned aIdx ) const { if( aIdx < m_ItemsList.size() ) return m_ItemsList[aIdx].GetFlags(); diff --git a/cvpcb/class_DisplayFootprintsFrame.h b/cvpcb/class_DisplayFootprintsFrame.h index 52b1366813..3244d62325 100644 --- a/cvpcb/class_DisplayFootprintsFrame.h +++ b/cvpcb/class_DisplayFootprintsFrame.h @@ -124,7 +124,7 @@ public: * @param aTransformPoint = the reference point of the transformation, * for commands like move */ - virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, + virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) { diff --git a/eeschema/schematic_undo_redo.cpp b/eeschema/schematic_undo_redo.cpp index 4481e8cce0..1ab8948d78 100644 --- a/eeschema/schematic_undo_redo.cpp +++ b/eeschema/schematic_undo_redo.cpp @@ -160,7 +160,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem, } -void SCH_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, +void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint ) { diff --git a/gerbview/gerbview_frame.h b/gerbview/gerbview_frame.h index 6a69191706..9cabd38b16 100644 --- a/gerbview/gerbview_frame.h +++ b/gerbview/gerbview_frame.h @@ -676,7 +676,7 @@ public: * @param aTransformPoint = the reference point of the transformation, * for commands like move */ - void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, + void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) { diff --git a/include/class_undoredo_container.h b/include/class_undoredo_container.h index 6c95bae24d..13c9e85b23 100644 --- a/include/class_undoredo_container.h +++ b/include/class_undoredo_container.h @@ -111,7 +111,7 @@ public: void SetStatus( UNDO_REDO_T aStatus ) { m_undoRedoStatus = aStatus; } - UNDO_REDO_T GetStatus() { return m_undoRedoStatus; } + UNDO_REDO_T GetStatus() const { return m_undoRedoStatus; } void SetFlags( STATUS_FLAGS aFlags ) { m_pickerFlags = aFlags; } @@ -148,7 +148,7 @@ public: * pushes \a aItem to the top of the list * @param aItem Picker to push on to the list. */ - void PushItem( ITEM_PICKER& aItem ); + void PushItem( const ITEM_PICKER& aItem ); /** * Function PopItem @@ -160,7 +160,14 @@ public: * Function IsItemInList * @return True if \a aItem is found in the pick list. */ - bool ContainsItem( EDA_ITEM* aItem ) const; + bool ContainsItem( const EDA_ITEM* aItem ) const; + + /** + * Function FindItem + * @return Index of the searched item. If the item is not stored in the list, negative value + * is returned. + */ + int FindItem( const EDA_ITEM* aItem ) const; /** * Function ClearItemsList @@ -201,21 +208,21 @@ public: * if this picker does not exist, a picker is returned, * with its members set to 0 or NULL */ - ITEM_PICKER GetItemWrapper( unsigned int aIdx ); + ITEM_PICKER GetItemWrapper( unsigned int aIdx ) const; /** * Function GetPickedItem * @return A pointer to the picked item * @param aIdx Index of the picked item in the picked list */ - EDA_ITEM* GetPickedItem( unsigned int aIdx ); + EDA_ITEM* GetPickedItem( unsigned int aIdx ) const; /** * Function GetPickedItemLink * @return link of the picked item, or null if does not exist * @param aIdx Index of the picked item in the picked list */ - EDA_ITEM* GetPickedItemLink( unsigned int aIdx ); + EDA_ITEM* GetPickedItemLink( unsigned int aIdx ) const; /** * Function GetPickedItemStatus @@ -223,7 +230,7 @@ public: * or UR_UNSPECIFIED if does not exist * @param aIdx Index of the picked item in the picked list */ - UNDO_REDO_T GetPickedItemStatus( unsigned int aIdx ); + UNDO_REDO_T GetPickedItemStatus( unsigned int aIdx ) const; /** * Function GetPickerFlags @@ -231,7 +238,7 @@ public: * @param aIdx Index of the picker in the picked list * @return The value stored in the picker, if the picker exists, or 0 if does not exist */ - STATUS_FLAGS GetPickerFlags( unsigned aIdx ); + STATUS_FLAGS GetPickerFlags( unsigned aIdx ) const; /** * Function SetPickedItem diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index ff0db2f2c2..cbc96f31df 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -669,7 +669,7 @@ public: * @param aTransformPoint = the reference point of the transformation, * for commands like move */ - virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, + virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0; diff --git a/include/wxEeschemaStruct.h b/include/wxEeschemaStruct.h index b3f60bac0f..30a5b3827a 100644 --- a/include/wxEeschemaStruct.h +++ b/include/wxEeschemaStruct.h @@ -1080,7 +1080,7 @@ public: * @param aTransformPoint = the reference point of the transformation, * for commands like move */ - void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, + void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ); diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index fc7d379a07..33ab87d567 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -659,7 +659,7 @@ public: * @param aTransformPoint = the reference point of the transformation, for * commands like move */ - virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, + virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ); diff --git a/pcbnew/board_undo_redo.cpp b/pcbnew/board_undo_redo.cpp index e58e734320..36a073d065 100644 --- a/pcbnew/board_undo_redo.cpp +++ b/pcbnew/board_undo_redo.cpp @@ -346,7 +346,7 @@ void PCB_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem, } -void PCB_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, +void PCB_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint ) { diff --git a/pcbnew/footprint_wizard_frame.h b/pcbnew/footprint_wizard_frame.h index f65ee1d62d..9027e29e73 100644 --- a/pcbnew/footprint_wizard_frame.h +++ b/pcbnew/footprint_wizard_frame.h @@ -198,7 +198,7 @@ private: */ void OnLeftDClick( wxDC*, const wxPoint& ) {} void SaveCopyInUndoList( BOARD_ITEM*, UNDO_REDO_T, const wxPoint& ) {} - void SaveCopyInUndoList( PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint& ) {} + void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint& ) {} DECLARE_EVENT_TABLE() diff --git a/pcbnew/modedit_undo_redo.cpp b/pcbnew/modedit_undo_redo.cpp index 4f273eb3c7..613f4d8d2b 100644 --- a/pcbnew/modedit_undo_redo.cpp +++ b/pcbnew/modedit_undo_redo.cpp @@ -46,7 +46,7 @@ void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( BOARD_ITEM* aItem, } -void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, +void FOOTPRINT_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint ) { diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index 01e9a304ca..49682348e5 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -245,7 +245,7 @@ public: * @param aTransformPoint = the reference point of the transformation, for * commands like move */ - virtual void SaveCopyInUndoList( PICKED_ITEMS_LIST& aItemsList, + virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO_T aTypeCommand, const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ); diff --git a/pcbnew/modview_frame.h b/pcbnew/modview_frame.h index c833e5c10c..0e099e4fea 100644 --- a/pcbnew/modview_frame.h +++ b/pcbnew/modview_frame.h @@ -202,7 +202,7 @@ private: */ void OnLeftDClick( wxDC*, const wxPoint& ) {} void SaveCopyInUndoList( BOARD_ITEM*, UNDO_REDO_T, const wxPoint& ) {} - void SaveCopyInUndoList( PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint &) {} + void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO_T, const wxPoint &) {} DECLARE_EVENT_TABLE()