KiCad PCB EDA Suite
PICKED_ITEMS_LIST Class Reference

PICKED_ITEMS_LIST is a holder to handle information on schematic or board items. More...

#include <undo_redo_container.h>

Public Member Functions

 PICKED_ITEMS_LIST ()
 
 ~PICKED_ITEMS_LIST ()
 
void PushItem (const ITEM_PICKER &aItem)
 Function PushItem pushes aItem to the top of the list. More...
 
ITEM_PICKER PopItem ()
 Function PopItem. More...
 
bool ContainsItem (const EDA_ITEM *aItem) const
 Function IsItemInList. More...
 
int FindItem (const EDA_ITEM *aItem) const
 Function FindItem. More...
 
void ClearItemsList ()
 Function ClearItemsList deletes only the list of pickers, NOT the picked data itself. More...
 
void ClearListAndDeleteItems ()
 Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or m_PickedItemLink, according to the type of undo/redo command recorded. More...
 
unsigned GetCount () const
 Function GetCount. More...
 
void ReversePickersListOrder ()
 Function ReversePickersListOrder reverses the order of pickers stored in this list. More...
 
ITEM_PICKER GetItemWrapper (unsigned int aIdx) const
 Function GetItemWrapper. More...
 
EDA_ITEMGetPickedItem (unsigned int aIdx) const
 Function GetPickedItem. More...
 
BASE_SCREENGetScreenForItem (unsigned int aIdx) const
 Function GetScreenForItem. More...
 
EDA_ITEMGetPickedItemLink (unsigned int aIdx) const
 Function GetPickedItemLink. More...
 
UNDO_REDO GetPickedItemStatus (unsigned int aIdx) const
 Function GetPickedItemStatus. More...
 
STATUS_FLAGS GetPickerFlags (unsigned aIdx) const
 Function GetPickerFlags returns the value of the picker flag. More...
 
bool SetPickedItem (EDA_ITEM *aItem, unsigned aIdx)
 Function SetPickedItem. More...
 
bool SetPickedItem (EDA_ITEM *aItem, UNDO_REDO aStatus, unsigned aIdx)
 Function SetPickedItem. More...
 
bool SetPickedItemLink (EDA_ITEM *aLink, unsigned aIdx)
 Function SetPickedItemLink set the link associated to a given picked item. More...
 
bool SetPickedItemStatus (UNDO_REDO aStatus, unsigned aIdx)
 Function SetPickedItemStatus sets the type of undo/redo operation for a given picked item. More...
 
bool SetPickerFlags (STATUS_FLAGS aFlags, unsigned aIdx)
 Function SetPickerFlags set the flags of the picker (usually to the picked item m_Flags value) More...
 
bool RemovePicker (unsigned aIdx)
 Function RemovePicker removes one entry (one picker) from the list of picked items. More...
 
void CopyList (const PICKED_ITEMS_LIST &aSource)
 Function CopyList copies all data from aSource to the list. More...
 

Public Attributes

UNDO_REDO m_Status
 
wxPoint m_TransformPoint
 

Private Attributes

std::vector< ITEM_PICKERm_ItemsList
 

Detailed Description

PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.

The information held is a pointer on each item, and the command made.

Definition at line 133 of file undo_redo_container.h.

Constructor & Destructor Documentation

◆ PICKED_ITEMS_LIST()

PICKED_ITEMS_LIST::PICKED_ITEMS_LIST ( )

Definition at line 62 of file undo_redo_container.cpp.

References m_Status, and UNSPECIFIED.

◆ ~PICKED_ITEMS_LIST()

PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST ( )

Definition at line 67 of file undo_redo_container.cpp.

68 {
69 }

Member Function Documentation

◆ ClearItemsList()

void PICKED_ITEMS_LIST::ClearItemsList ( )

Function ClearItemsList deletes only the list of pickers, NOT the picked data itself.

Definition at line 116 of file undo_redo_container.cpp.

117 {
118  m_ItemsList.clear();
119 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by PCB_EDIT_FRAME::Edit_Zone_Params(), and PCB_BASE_FRAME::PlaceModule().

◆ ClearListAndDeleteItems()

void PICKED_ITEMS_LIST::ClearListAndDeleteItems ( )

Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or m_PickedItemLink, according to the type of undo/redo command recorded.

Definition at line 122 of file undo_redo_container.cpp.

123 {
124  // Delete items is they are not flagged NEWITEM, or if this is a block operation
125  while( GetCount() > 0 )
126  {
127  ITEM_PICKER wrapper = PopItem();
128  if( wrapper.GetItem() == NULL ) // No more item in list.
129  break;
130 
131  // The Link is an undo construct; it is always owned by the undo/redo container
132  if( wrapper.GetLink() )
133  delete wrapper.GetLink();
134 
135  if( wrapper.GetFlags() & UR_TRANSIENT )
136  {
137  delete wrapper.GetItem();
138  }
139  else if( wrapper.GetStatus() == UNDO_REDO::DELETED )
140  {
141  // This should really be replaced with UR_TRANSIENT, but currently many clients
142  // (eeschema in particular) abuse this to achieve non-undo-related deletions.
143  delete wrapper.GetItem();
144  }
145  }
146 }
EDA_ITEM * GetItem() const
unsigned GetCount() const
Function GetCount.
EDA_ITEM * GetLink() const
#define NULL
STATUS_FLAGS GetFlags() const
ITEM_PICKER PopItem()
Function PopItem.
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
Definition: base_struct.h:143
UNDO_REDO GetStatus() const

References DELETED, GetCount(), ITEM_PICKER::GetFlags(), ITEM_PICKER::GetItem(), ITEM_PICKER::GetLink(), ITEM_PICKER::GetStatus(), NULL, PopItem(), and UR_TRANSIENT.

Referenced by PCB_BASE_EDIT_FRAME::ClearUndoORRedoList(), PL_EDITOR_FRAME::ClearUndoORRedoList(), LIB_EDIT_FRAME::ClearUndoORRedoList(), SCH_EDIT_FRAME::ClearUndoORRedoList(), EDIT_TOOL::doMoveSelection(), PCB_EDIT_FRAME::Edit_Zone_Params(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_BASE_EDIT_FRAME::RollbackFromUndo(), and SCH_EDIT_FRAME::RollbackSchematicFromUndo().

◆ ContainsItem()

bool PICKED_ITEMS_LIST::ContainsItem ( const EDA_ITEM aItem) const

Function IsItemInList.

Returns
True if aItem is found in the pick list.

Definition at line 92 of file undo_redo_container.cpp.

93 {
94  for( size_t i = 0; i < m_ItemsList.size(); i++ )
95  {
96  if( m_ItemsList[ i ].GetItem() == aItem )
97  return true;
98  }
99 
100  return false;
101 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

◆ CopyList()

void PICKED_ITEMS_LIST::CopyList ( const PICKED_ITEMS_LIST aSource)

Function CopyList copies all data from aSource to the list.

Items picked are not copied. just pointer in them are copied

Parameters
aSourceThe list of items to copy to the list.

Definition at line 276 of file undo_redo_container.cpp.

277 {
278  m_ItemsList = aSource.m_ItemsList; // Vector's copy
279 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by SCH_EDIT_FRAME::SaveCopyInUndoList().

◆ FindItem()

int PICKED_ITEMS_LIST::FindItem ( const EDA_ITEM aItem) const

Function FindItem.

Returns
Index of the searched item. If the item is not stored in the list, negative value is returned.

Definition at line 104 of file undo_redo_container.cpp.

105 {
106  for( size_t i = 0; i < m_ItemsList.size(); i++ )
107  {
108  if( m_ItemsList[i].GetItem() == aItem )
109  return i;
110  }
111 
112  return -1;
113 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem().

◆ GetCount()

◆ GetItemWrapper()

ITEM_PICKER PICKED_ITEMS_LIST::GetItemWrapper ( unsigned int  aIdx) const

Function GetItemWrapper.

Returns
The picker of a picked item.
Parameters
aIdxIndex of the picker in the picked list if this picker does not exist, a picker is returned, with its members set to 0 or NULL

Definition at line 149 of file undo_redo_container.cpp.

150 {
151  ITEM_PICKER picker;
152 
153  if( aIdx < m_ItemsList.size() )
154  picker = m_ItemsList[aIdx];
155 
156  return picker;
157 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SaveCopyInUndoList(), and UpdateCopyOfZonesList().

◆ GetPickedItem()

EDA_ITEM * PICKED_ITEMS_LIST::GetPickedItem ( unsigned int  aIdx) const

Function GetPickedItem.

Returns
A pointer to the picked item
Parameters
aIdxIndex of the picked item in the picked list

Definition at line 160 of file undo_redo_container.cpp.

161 {
162  if( aIdx < m_ItemsList.size() )
163  return m_ItemsList[aIdx].GetItem();
164 
165  return NULL;
166 }
std::vector< ITEM_PICKER > m_ItemsList
#define NULL

References m_ItemsList, and NULL.

Referenced by PCB_EDIT_FRAME::Edit_Zone_Params(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SaveCopyInUndoList(), COMMIT::Stage(), and UpdateCopyOfZonesList().

◆ GetPickedItemLink()

EDA_ITEM * PICKED_ITEMS_LIST::GetPickedItemLink ( unsigned int  aIdx) const

Function GetPickedItemLink.

Returns
link of the picked item, or null if does not exist
Parameters
aIdxIndex of the picked item in the picked list

Definition at line 178 of file undo_redo_container.cpp.

179 {
180  if( aIdx < m_ItemsList.size() )
181  return m_ItemsList[aIdx].GetLink();
182 
183  return NULL;
184 }
std::vector< ITEM_PICKER > m_ItemsList
#define NULL

References m_ItemsList, and NULL.

Referenced by PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SaveCopyInUndoList(), COMMIT::Stage(), and UpdateCopyOfZonesList().

◆ GetPickedItemStatus()

UNDO_REDO PICKED_ITEMS_LIST::GetPickedItemStatus ( unsigned int  aIdx) const

Function GetPickedItemStatus.

Returns
The type of undo/redo operation associated to the picked item, or UNSPECIFIED if does not exist
Parameters
aIdxIndex of the picked item in the picked list

Definition at line 187 of file undo_redo_container.cpp.

188 {
189  if( aIdx < m_ItemsList.size() )
190  return m_ItemsList[aIdx].GetStatus();
191 
192  return UNDO_REDO::UNSPECIFIED;
193 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList, and UNSPECIFIED.

Referenced by PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SaveCopyInUndoList(), COMMIT::Stage(), and UpdateCopyOfZonesList().

◆ GetPickerFlags()

STATUS_FLAGS PICKED_ITEMS_LIST::GetPickerFlags ( unsigned  aIdx) const

Function GetPickerFlags returns the value of the picker flag.

Parameters
aIdxIndex of the picker in the picked list
Returns
The value stored in the picker, if the picker exists, or 0 if does not exist

Definition at line 196 of file undo_redo_container.cpp.

197 {
198  if( aIdx < m_ItemsList.size() )
199  return m_ItemsList[aIdx].GetFlags();
200 
201  return 0;
202 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

◆ GetScreenForItem()

BASE_SCREEN * PICKED_ITEMS_LIST::GetScreenForItem ( unsigned int  aIdx) const

Function GetScreenForItem.

Returns
A pointer to the picked item's sceen
Parameters
aIdxIndex of the picked item in the picked list

Definition at line 169 of file undo_redo_container.cpp.

170 {
171  if( aIdx < m_ItemsList.size() )
172  return m_ItemsList[aIdx].GetScreen();
173 
174  return NULL;
175 }
std::vector< ITEM_PICKER > m_ItemsList
#define NULL

References m_ItemsList, and NULL.

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

◆ PopItem()

ITEM_PICKER PICKED_ITEMS_LIST::PopItem ( )

Function PopItem.

Returns
The picker removed from the top of the list.

Definition at line 78 of file undo_redo_container.cpp.

79 {
80  ITEM_PICKER item;
81 
82  if( m_ItemsList.size() != 0 )
83  {
84  item = m_ItemsList.back();
85  m_ItemsList.pop_back();
86  }
87 
88  return item;
89 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by ClearListAndDeleteItems(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), PL_EDITOR_FRAME::RollbackFromUndo(), and LIB_EDIT_FRAME::RollbackPartFromUndo().

◆ PushItem()

◆ RemovePicker()

bool PICKED_ITEMS_LIST::RemovePicker ( unsigned  aIdx)

Function RemovePicker removes one entry (one picker) from the list of picked items.

Parameters
aIdxIndex of the picker in the picked list
Returns
True if ok or false if did not exist

Definition at line 266 of file undo_redo_container.cpp.

267 {
268  if( aIdx >= m_ItemsList.size() )
269  return false;
270 
271  m_ItemsList.erase( m_ItemsList.begin() + aIdx );
272  return true;
273 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), and UpdateCopyOfZonesList().

◆ ReversePickersListOrder()

void PICKED_ITEMS_LIST::ReversePickersListOrder ( )

Function ReversePickersListOrder reverses the order of pickers stored in this list.

This is useful when pop a list from Undo to Redo (and vice-versa) because sometimes undo (or redo) a command needs to keep the order of successive changes. Obviously, undo and redo are in reverse order

Definition at line 282 of file undo_redo_container.cpp.

283 {
284  std::vector <ITEM_PICKER> tmp;
285  while( !m_ItemsList.empty() )
286  {
287  tmp.push_back( m_ItemsList.back() );
288  m_ItemsList.pop_back();
289  }
290 
291  m_ItemsList.swap( tmp );
292 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by SCH_EDITOR_CONTROL::Redo(), PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList(), PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList(), and SCH_EDITOR_CONTROL::Undo().

◆ SetPickedItem() [1/2]

bool PICKED_ITEMS_LIST::SetPickedItem ( EDA_ITEM aItem,
unsigned  aIdx 
)

Function SetPickedItem.

Parameters
aItemA pointer to the item to pick
aIdxIndex of the picker in the picked list
Returns
True if the picker exists or false if does not exist

Definition at line 205 of file undo_redo_container.cpp.

206 {
207  if( aIdx < m_ItemsList.size() )
208  {
209  m_ItemsList[aIdx].SetItem( aItem );
210  return true;
211  }
212 
213  return false;
214 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

◆ SetPickedItem() [2/2]

bool PICKED_ITEMS_LIST::SetPickedItem ( EDA_ITEM aItem,
UNDO_REDO  aStatus,
unsigned  aIdx 
)

Function SetPickedItem.

Parameters
aItemA pointer to the item to pick
aStatusThe type of undo/redo operation associated to the item to pick
aIdxIndex of the picker in the picked list
Returns
True if the picker exists or false if does not exist

Definition at line 229 of file undo_redo_container.cpp.

230 {
231  if( aIdx < m_ItemsList.size() )
232  {
233  m_ItemsList[aIdx].SetItem( aItem );
234  m_ItemsList[aIdx].SetStatus( aStatus );
235  return true;
236  }
237 
238  return false;
239 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

◆ SetPickedItemLink()

bool PICKED_ITEMS_LIST::SetPickedItemLink ( EDA_ITEM aLink,
unsigned  aIdx 
)

Function SetPickedItemLink set the link associated to a given picked item.

Parameters
aLink= the link to the item associated to the picked item
aIdx= index of the picker in the picked list
Returns
true if the picker exists, or false if does not exist

Definition at line 217 of file undo_redo_container.cpp.

218 {
219  if( aIdx < m_ItemsList.size() )
220  {
221  m_ItemsList[aIdx].SetLink( aLink );
222  return true;
223  }
224 
225  return false;
226 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SaveCopyInUndoList(), and UpdateCopyOfZonesList().

◆ SetPickedItemStatus()

bool PICKED_ITEMS_LIST::SetPickedItemStatus ( UNDO_REDO  aStatus,
unsigned  aIdx 
)

Function SetPickedItemStatus sets the type of undo/redo operation for a given picked item.

Parameters
aStatusThe type of undo/redo operation associated to the picked item
aIdxIndex of the picker in the picked list
Returns
True if the picker exists or false if does not exist

Definition at line 242 of file undo_redo_container.cpp.

243 {
244  if( aIdx < m_ItemsList.size() )
245  {
246  m_ItemsList[aIdx].SetStatus( aStatus );
247  return true;
248  }
249 
250  return false;
251 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SaveCopyInUndoList(), and UpdateCopyOfZonesList().

◆ SetPickerFlags()

bool PICKED_ITEMS_LIST::SetPickerFlags ( STATUS_FLAGS  aFlags,
unsigned  aIdx 
)

Function SetPickerFlags set the flags of the picker (usually to the picked item m_Flags value)

Parameters
aFlagsThe flag value to save in picker
aIdxIndex of the picker in the picked list
Returns
True if the picker exists or false if does not exist

Definition at line 254 of file undo_redo_container.cpp.

255 {
256  if( aIdx < m_ItemsList.size() )
257  {
258  m_ItemsList[aIdx].SetFlags( aFlags );
259  return true;
260  }
261 
262  return false;
263 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Member Data Documentation

◆ m_ItemsList

◆ m_Status

UNDO_REDO PICKED_ITEMS_LIST::m_Status

◆ m_TransformPoint


The documentation for this class was generated from the following files: