KiCad PCB EDA Suite
PICKED_ITEMS_LIST Class Reference

Class 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...
 
EDA_ITEMGetPickedItemLink (unsigned int aIdx) const
 Function GetPickedItemLink. More...
 
UNDO_REDO_T 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_T 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_T 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_T m_Status
 
wxPoint m_TransformPoint
 

Private Attributes

std::vector< ITEM_PICKERm_ItemsList
 

Detailed Description

Class 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 131 of file undo_redo_container.h.

Constructor & Destructor Documentation

◆ PICKED_ITEMS_LIST()

PICKED_ITEMS_LIST::PICKED_ITEMS_LIST ( )

Definition at line 40 of file undo_redo_container.cpp.

References m_Status, and UR_UNSPECIFIED.

◆ ~PICKED_ITEMS_LIST()

PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST ( )

Definition at line 45 of file undo_redo_container.cpp.

46 {
47 }

Member Function Documentation

◆ ClearItemsList()

void PICKED_ITEMS_LIST::ClearItemsList ( )

◆ 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 100 of file undo_redo_container.cpp.

101 {
102  // Delete items is they are not flagged UR_NEW, or if this is a block operation
103  while( GetCount() > 0 )
104  {
105  ITEM_PICKER wrapper = PopItem();
106  if( wrapper.GetItem() == NULL ) // No more item in list.
107  break;
108 
109  // The Link is an undo construct; it is always owned by the undo/redo container
110  if( wrapper.GetLink() )
111  delete wrapper.GetLink();
112 
113  if( wrapper.GetFlags() & UR_TRANSIENT )
114  {
115  delete wrapper.GetItem();
116  }
117  else if( wrapper.GetStatus() == UR_DELETED )
118  {
119  // This should really be replaced with UR_TRANSIENT, but currently many clients
120  // (eeschema in particular) abuse this to achieve non-undo-related deletions.
121  delete wrapper.GetItem();
122  }
123  }
124 }
UNDO_REDO_T GetStatus() const
EDA_ITEM * GetItem() const
unsigned GetCount() const
Function GetCount.
EDA_ITEM * GetLink() const
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:141

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

Referenced by Abort_Create_Track(), Abort_MoveOrCopyModule(), Abort_MoveTrack(), Abort_Zone_Move_Corner_Or_Outlines(), PCB_EDIT_FRAME::Begin_Route(), PL_EDITOR_SCREEN::ClearUndoORRedoList(), PCB_SCREEN::ClearUndoORRedoList(), PCB_EDIT_FRAME::duplicateZone(), PCB_EDIT_FRAME::Edit_Zone_Params(), PCB_EDIT_FRAME::End_Zone(), PCB_EDIT_FRAME::Remove_Zone_Corner(), SCH_EDIT_FRAME::RollbackSchematicFromUndo(), PCB_EDIT_FRAME::Start_Move_Zone_Corner(), PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge(), and PCB_EDIT_FRAME::Start_Move_Zone_Outlines().

◆ 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 70 of file undo_redo_container.cpp.

71 {
72  for( size_t i = 0; i < m_ItemsList.size(); i++ )
73  {
74  if( m_ItemsList[ i ].GetItem() == aItem )
75  return true;
76  }
77 
78  return false;
79 }
std::vector< ITEM_PICKER > m_ItemsList
size_t i
Definition: json11.cpp:597

References i, and 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 245 of file undo_redo_container.cpp.

246 {
247  m_ItemsList = aSource.m_ItemsList; // Vector's copy
248 }
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 82 of file undo_redo_container.cpp.

83 {
84  for( size_t i = 0; i < m_ItemsList.size(); i++ )
85  {
86  if( m_ItemsList[i].GetItem() == aItem )
87  return i;
88  }
89 
90  return -1;
91 }
std::vector< ITEM_PICKER > m_ItemsList
size_t i
Definition: json11.cpp:597

References i, and 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 127 of file undo_redo_container.cpp.

128 {
129  ITEM_PICKER picker;
130 
131  if( aIdx < m_ItemsList.size() )
132  picker = m_ItemsList[aIdx];
133 
134  return picker;
135 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

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

◆ GetPickedItem()

◆ 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 147 of file undo_redo_container.cpp.

148 {
149  if( aIdx < m_ItemsList.size() )
150  return m_ItemsList[aIdx].GetLink();
151 
152  return NULL;
153 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by PCB_EDIT_FRAME::Edit_Track_Width(), PCB_EDIT_FRAME::Edit_TrackSegm_Width(), 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_T PICKED_ITEMS_LIST::GetPickedItemStatus ( unsigned int  aIdx) const

Function GetPickedItemStatus.

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

Definition at line 156 of file undo_redo_container.cpp.

157 {
158  if( aIdx < m_ItemsList.size() )
159  return m_ItemsList[aIdx].GetStatus();
160 
161  return UR_UNSPECIFIED;
162 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList, and UR_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 165 of file undo_redo_container.cpp.

166 {
167  if( aIdx < m_ItemsList.size() )
168  return m_ItemsList[aIdx].GetFlags();
169 
170  return 0;
171 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

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 56 of file undo_redo_container.cpp.

57 {
58  ITEM_PICKER item;
59 
60  if( m_ItemsList.size() != 0 )
61  {
62  item = m_ItemsList.back();
63  m_ItemsList.pop_back();
64  }
65 
66  return item;
67 }
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::RemoveLastCommandInUndoList(), and LIB_EDIT_FRAME::RollbackPartFromUndo().

◆ PushItem()

void PICKED_ITEMS_LIST::PushItem ( const ITEM_PICKER aItem)

Function PushItem pushes aItem to the top of the list.

Parameters
aItemPicker to push on to the list.

Definition at line 50 of file undo_redo_container.cpp.

51 {
52  m_ItemsList.push_back( aItem );
53 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by BOARD::AddArea(), AddNewTrace(), PCB_EDIT_FRAME::AppendBoardFile(), PCB_EDIT_FRAME::Block_Duplicate(), PCB_EDIT_FRAME::Block_SelectItems(), BOARD::CreateLockPoint(), PCB_EDIT_FRAME::Delete_Drawings_All_Layer(), PCB_EDIT_FRAME::Delete_net(), SCH_EDIT_FRAME::DeleteJunction(), PCB_BASE_FRAME::DoPushPadProperties(), PCB_BASE_EDIT_FRAME::duplicateItem(), PCB_EDIT_FRAME::duplicateZone(), PCB_EDIT_FRAME::End_Route(), PCB_EDIT_FRAME::End_Zone(), PCB_EDIT_FRAME::EraseRedundantTrack(), SCH_WIRE_BUS_TOOL::finishSegments(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), InvokeDialogImportGfxBoard(), InvokeDialogImportGfxModule(), PCB_BASE_FRAME::PlaceModule(), PCB_BASE_FRAME::PlacePad(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), BOARD_COMMIT::Push(), PCB_EDIT_FRAME::Remove_One_Track(), BOARD::RemoveArea(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), PL_EDITOR_FRAME::SaveCopyInUndoList(), LIB_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SaveCopyOfZones(), SCH_EDIT_FRAME::SchematicCleanUp(), PCB_EDIT_FRAME::SetTrackSegmentWidth(), PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope(), PCB_EDIT_FRAME::StartMoveModule(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), DIALOG_UPDATE_FIELDS::TransferDataFromWindow(), and UpdateCopyOfZonesList().

◆ 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 235 of file undo_redo_container.cpp.

236 {
237  if( aIdx >= m_ItemsList.size() )
238  return false;
239 
240  m_ItemsList.erase( m_ItemsList.begin() + aIdx );
241  return true;
242 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by PCB_EDIT_FRAME::Block_Delete(), 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 251 of file undo_redo_container.cpp.

252 {
253  std::vector <ITEM_PICKER> tmp;
254  while( !m_ItemsList.empty() )
255  {
256  tmp.push_back( m_ItemsList.back() );
257  m_ItemsList.pop_back();
258  }
259 
260  m_ItemsList.swap( tmp );
261 }
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 174 of file undo_redo_container.cpp.

175 {
176  if( aIdx < m_ItemsList.size() )
177  {
178  m_ItemsList[aIdx].SetItem( aItem );
179  return true;
180  }
181 
182  return false;
183 }
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_T  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 198 of file undo_redo_container.cpp.

199 {
200  if( aIdx < m_ItemsList.size() )
201  {
202  m_ItemsList[aIdx].SetItem( aItem );
203  m_ItemsList[aIdx].SetStatus( aStatus );
204  return true;
205  }
206 
207  return false;
208 }
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 186 of file undo_redo_container.cpp.

187 {
188  if( aIdx < m_ItemsList.size() )
189  {
190  m_ItemsList[aIdx].SetLink( aLink );
191  return true;
192  }
193 
194  return false;
195 }
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_T  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 211 of file undo_redo_container.cpp.

212 {
213  if( aIdx < m_ItemsList.size() )
214  {
215  m_ItemsList[aIdx].SetStatus( aStatus );
216  return true;
217  }
218 
219  return false;
220 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Referenced by PCB_EDIT_FRAME::Block_Delete(), PCB_EDIT_FRAME::Block_Flip(), PCB_EDIT_FRAME::Block_Move(), PCB_EDIT_FRAME::Block_Rotate(), 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 223 of file undo_redo_container.cpp.

224 {
225  if( aIdx < m_ItemsList.size() )
226  {
227  m_ItemsList[aIdx].SetFlags( aFlags );
228  return true;
229  }
230 
231  return false;
232 }
std::vector< ITEM_PICKER > m_ItemsList

References m_ItemsList.

Member Data Documentation

◆ m_ItemsList

◆ m_Status

◆ m_TransformPoint


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