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

References m_Status, and UR_UNSPECIFIED.

PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST ( )

Definition at line 48 of file class_undoredo_container.cpp.

49 {
50 }

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 103 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(), SCH_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().

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

References m_ItemsList.

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

References m_ItemsList.

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

286 {
287  m_ItemsList = aSource.m_ItemsList; // Vector's copy
288 }
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 85 of file class_undoredo_container.cpp.

References m_ItemsList.

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

References m_ItemsList.

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

169 {
170  ITEM_PICKER picker;
171 
172  if( aIdx < m_ItemsList.size() )
173  picker = m_ItemsList[aIdx];
174 
175  return picker;
176 }
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 188 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().

189 {
190  if( aIdx < m_ItemsList.size() )
191  return m_ItemsList[aIdx].GetLink();
192  else
193  return NULL;
194 }
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 197 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().

198 {
199  if( aIdx < m_ItemsList.size() )
200  return m_ItemsList[aIdx].GetStatus();
201  else
202  return UR_UNSPECIFIED;
203 }
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 206 of file class_undoredo_container.cpp.

References m_ItemsList.

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

207 {
208  if( aIdx < m_ItemsList.size() )
209  return m_ItemsList[aIdx].GetFlags();
210  else
211  return 0;
212 }
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 59 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().

60 {
61  ITEM_PICKER item;
62 
63  if( m_ItemsList.size() != 0 )
64  {
65  item = m_ItemsList.back();
66  m_ItemsList.pop_back();
67  }
68 
69  return item;
70 }
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 53 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(), DeleteItemsInList(), 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(), SCH_EDIT_FRAME::Process_Special_Functions(), 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(), PCB_EDIT_FRAME::SetTrackSegmentWidth(), PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope(), PCB_EDIT_FRAME::StartMoveModule(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), and UpdateCopyOfZonesList().

54 {
55  m_ItemsList.push_back( aItem );
56 }
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 276 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().

277 {
278  if( aIdx >= m_ItemsList.size() )
279  return false;
280  m_ItemsList.erase( m_ItemsList.begin() + aIdx );
281  return true;
282 }
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 291 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().

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

References m_ItemsList.

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

216 {
217  if( aIdx < m_ItemsList.size() )
218  {
219  m_ItemsList[aIdx].SetItem( aItem );
220  return true;
221  }
222  else
223  return false;
224 }
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 239 of file class_undoredo_container.cpp.

References m_ItemsList.

240 {
241  if( aIdx < m_ItemsList.size() )
242  {
243  m_ItemsList[aIdx].SetItem( aItem );
244  m_ItemsList[aIdx].SetStatus( aStatus );
245  return true;
246  }
247  else
248  return false;
249 }
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 227 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().

228 {
229  if( aIdx < m_ItemsList.size() )
230  {
231  m_ItemsList[aIdx].SetLink( aLink );
232  return true;
233  }
234  else
235  return false;
236 }
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 252 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().

253 {
254  if( aIdx < m_ItemsList.size() )
255  {
256  m_ItemsList[aIdx].SetStatus( aStatus );
257  return true;
258  }
259  else
260  return false;
261 }
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 264 of file class_undoredo_container.cpp.

References m_ItemsList.

Referenced by SCH_SCREEN::SelectBlockItems().

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

Member Data Documentation


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