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 <class_undoredo_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 129 of file class_undoredo_container.h.

Constructor & Destructor Documentation

PICKED_ITEMS_LIST::PICKED_ITEMS_LIST ( )

Definition at line 41 of file class_undoredo_container.cpp.

References m_Status, and UR_UNSPECIFIED.

PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST ( )

Definition at line 46 of file class_undoredo_container.cpp.

47 {
48 }

Member Function Documentation

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 101 of file class_undoredo_container.cpp.

References Format(), GetCount(), ITEM_PICKER::GetItem(), ITEM_PICKER::GetLink(), ITEM_PICKER::GetStatus(), EDA_ITEM::Next(), PopItem(), UR_CHANGED, UR_DELETED, UR_EXCHANGE_T, UR_FLIPPED, UR_LIBEDIT, UR_MIRRORED_X, UR_MIRRORED_Y, UR_MOVED, UR_NEW, UR_ROTATED, UR_ROTATED_CLOCKWISE, UR_UNSPECIFIED, and UR_WIRE_IMAGE.

Referenced by Abort_Create_Track(), Abort_MoveOrCopyModule(), Abort_MoveTrack(), Abort_Zone_Move_Corner_Or_Outlines(), PCB_EDIT_FRAME::Begin_Route(), BLOCK_SELECTOR::ClearListAndDeleteItems(), 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(), PCB_EDIT_FRAME::Solve(), PCB_EDIT_FRAME::Start_Move_Zone_Corner(), PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge(), and PCB_EDIT_FRAME::Start_Move_Zone_Outlines().

102 {
103  bool show_error_message = true;
104 
105  // Delete items is they are not flagged UR_NEW, or if this is a block operation
106  while( GetCount() > 0 )
107  {
108  ITEM_PICKER wrapper = PopItem();
109  if( wrapper.GetItem() == NULL ) // No more item in list.
110  break;
111  switch( wrapper.GetStatus() )
112  {
113  case UR_UNSPECIFIED:
114  if( show_error_message )
115  wxMessageBox( wxT( "ClearListAndDeleteItems() error: UR_UNSPECIFIED command type" ) );
116 
117  show_error_message = false;
118  break;
119 
120  case UR_WIRE_IMAGE:
121  {
122  // Specific to eeschema: a linked list of wires is stored. The wrapper picks only
123  // the first item (head of list), and is owner of all picked items.
124  EDA_ITEM* item = wrapper.GetItem();
125 
126  while( item )
127  {
128  // Delete old copy of wires
129  EDA_ITEM* nextitem = item->Next();
130  delete item;
131  item = nextitem;
132  }
133  }
134  break;
135 
136  case UR_MOVED:
137  case UR_FLIPPED:
138  case UR_MIRRORED_X:
139  case UR_MIRRORED_Y:
140  case UR_ROTATED:
142  case UR_NEW: // Do nothing, items are in use, the picker is not owner of items
143  break;
144 
145  case UR_CHANGED:
146  case UR_EXCHANGE_T:
147  delete wrapper.GetLink(); // the picker is owner of this item
148  break;
149 
150  case UR_DELETED: // the picker is owner of this item
151  case UR_LIBEDIT: /* Libedit save always a copy of the current item
152  * So, the picker is always owner of the picked item
153  */
154  delete wrapper.GetItem();
155  break;
156 
157  default:
158  wxFAIL_MSG( wxString::Format( wxT( "Cannot clear unknown undo/redo command %d" ),
159  wrapper.GetStatus() ) );
160  break;
161  }
162  }
163 }
Use for changing the schematic text type where swapping data structure is insufficient to restor the ...
EDA_ITEM * Next() const
Definition: base_struct.h:233
UNDO_REDO_T GetStatus() const
EDA_ITEM * GetItem() const
unsigned GetCount() const
Function GetCount.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:178
ITEM_PICKER PopItem()
Function PopItem.
EDA_ITEM * GetLink() const
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 71 of file class_undoredo_container.cpp.

References m_ItemsList.

72 {
73  for( size_t i = 0; i < m_ItemsList.size(); i++ )
74  {
75  if( m_ItemsList[ i ].GetItem() == aItem )
76  return true;
77  }
78 
79  return false;
80 }
std::vector< ITEM_PICKER > m_ItemsList
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 284 of file class_undoredo_container.cpp.

References m_ItemsList.

Referenced by LIB_EDIT_FRAME::InitBlockPasteInfos(), SCH_EDIT_FRAME::InitBlockPasteInfos(), and SCH_EDIT_FRAME::SaveCopyInUndoList().

285 {
286  m_ItemsList = aSource.m_ItemsList; // Vector's copy
287 }
std::vector< ITEM_PICKER > m_ItemsList
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 83 of file class_undoredo_container.cpp.

References m_ItemsList.

84 {
85  for( size_t i = 0; i < m_ItemsList.size(); i++ )
86  {
87  if( m_ItemsList[i].GetItem() == aItem )
88  return i;
89  }
90 
91  return -1;
92 }
std::vector< ITEM_PICKER > m_ItemsList
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 166 of file class_undoredo_container.cpp.

References m_ItemsList.

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

167 {
168  ITEM_PICKER picker;
169 
170  if( aIdx < m_ItemsList.size() )
171  picker = m_ItemsList[aIdx];
172 
173  return picker;
174 }
std::vector< ITEM_PICKER > m_ItemsList
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 186 of file class_undoredo_container.cpp.

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().

187 {
188  if( aIdx < m_ItemsList.size() )
189  return m_ItemsList[aIdx].GetLink();
190 
191  return NULL;
192 }
std::vector< ITEM_PICKER > m_ItemsList
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 195 of file class_undoredo_container.cpp.

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().

196 {
197  if( aIdx < m_ItemsList.size() )
198  return m_ItemsList[aIdx].GetStatus();
199 
200  return UR_UNSPECIFIED;
201 }
std::vector< ITEM_PICKER > m_ItemsList
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 204 of file class_undoredo_container.cpp.

References m_ItemsList.

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

205 {
206  if( aIdx < m_ItemsList.size() )
207  return m_ItemsList[aIdx].GetFlags();
208 
209  return 0;
210 }
std::vector< ITEM_PICKER > m_ItemsList
ITEM_PICKER PICKED_ITEMS_LIST::PopItem ( )

Function PopItem.

Returns
The picker removed from the top of the list.

Definition at line 57 of file class_undoredo_container.cpp.

References m_ItemsList.

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

58 {
59  ITEM_PICKER item;
60 
61  if( m_ItemsList.size() != 0 )
62  {
63  item = m_ItemsList.back();
64  m_ItemsList.pop_back();
65  }
66 
67  return item;
68 }
std::vector< ITEM_PICKER > m_ItemsList
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 51 of file class_undoredo_container.cpp.

References m_ItemsList.

Referenced by BOARD::AddArea(), SCH_SCREEN::addConnectedItemsToBlock(), AddNewTrace(), PCB_EDIT_FRAME::AppendBoardFile(), DIALOG_BOM_EDITOR::ApplyAllChanges(), PCB_EDIT_FRAME::AutoPlaceModule(), 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::DeleteItem(), PCB_BASE_EDIT_FRAME::duplicateItem(), PCB_EDIT_FRAME::duplicateZone(), PCB_EDIT_FRAME::End_Route(), PCB_EDIT_FRAME::End_Zone(), SCH_EDIT_FRAME::EndSegment(), PCB_EDIT_FRAME::EraseRedundantTrack(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), SCH_SCREEN::GetConnection(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), PCB_BASE_FRAME::GlobalChange_PadSettings(), InvokeDXFDialogBoardImport(), SCH_EDIT_FRAME::OnConvertTextType(), SCH_EDIT_FRAME::PasteListOfItems(), PCB_BASE_FRAME::PlaceModule(), PCB_BASE_FRAME::PlacePad(), BOARD_COMMIT::Push(), BLOCK_SELECTOR::PushItem(), SCH_EDIT_FRAME::PutDataInPreviousState(), 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::SaveWireImage(), 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().

52 {
53  m_ItemsList.push_back( aItem );
54 }
std::vector< ITEM_PICKER > m_ItemsList
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 274 of file class_undoredo_container.cpp.

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(), and UpdateCopyOfZonesList().

275 {
276  if( aIdx >= m_ItemsList.size() )
277  return false;
278 
279  m_ItemsList.erase( m_ItemsList.begin() + aIdx );
280  return true;
281 }
std::vector< ITEM_PICKER > m_ItemsList
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 290 of file class_undoredo_container.cpp.

References m_ItemsList.

Referenced by SCH_EDIT_FRAME::GetSchematicFromRedoList(), SCH_EDIT_FRAME::GetSchematicFromUndoList(), PCB_BASE_EDIT_FRAME::RestoreCopyFromRedoList(), and PCB_BASE_EDIT_FRAME::RestoreCopyFromUndoList().

291 {
292  std::vector <ITEM_PICKER> tmp;
293  while( !m_ItemsList.empty() )
294  {
295  tmp.push_back( m_ItemsList.back() );
296  m_ItemsList.pop_back();
297  }
298 
299  m_ItemsList.swap( tmp );
300 }
std::vector< ITEM_PICKER > m_ItemsList
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 213 of file class_undoredo_container.cpp.

References m_ItemsList.

Referenced by DuplicateItemsInList(), and SCH_EDIT_FRAME::PutDataInPreviousState().

214 {
215  if( aIdx < m_ItemsList.size() )
216  {
217  m_ItemsList[aIdx].SetItem( aItem );
218  return true;
219  }
220 
221  return false;
222 }
std::vector< ITEM_PICKER > m_ItemsList
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 237 of file class_undoredo_container.cpp.

References m_ItemsList.

238 {
239  if( aIdx < m_ItemsList.size() )
240  {
241  m_ItemsList[aIdx].SetItem( aItem );
242  m_ItemsList[aIdx].SetStatus( aStatus );
243  return true;
244  }
245 
246  return false;
247 }
std::vector< ITEM_PICKER > m_ItemsList
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 225 of file class_undoredo_container.cpp.

References m_ItemsList.

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

226 {
227  if( aIdx < m_ItemsList.size() )
228  {
229  m_ItemsList[aIdx].SetLink( aLink );
230  return true;
231  }
232 
233  return false;
234 }
std::vector< ITEM_PICKER > m_ItemsList
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 250 of file class_undoredo_container.cpp.

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(), DuplicateItemsInList(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SaveCopyInUndoList(), and UpdateCopyOfZonesList().

251 {
252  if( aIdx < m_ItemsList.size() )
253  {
254  m_ItemsList[aIdx].SetStatus( aStatus );
255  return true;
256  }
257 
258  return false;
259 }
std::vector< ITEM_PICKER > m_ItemsList
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 262 of file class_undoredo_container.cpp.

References m_ItemsList.

Referenced by SCH_SCREEN::SelectBlockItems().

263 {
264  if( aIdx < m_ItemsList.size() )
265  {
266  m_ItemsList[aIdx].SetFlags( aFlags );
267  return true;
268  }
269 
270  return false;
271 }
std::vector< ITEM_PICKER > m_ItemsList

Member Data Documentation


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