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

Constructor & Destructor Documentation

PICKED_ITEMS_LIST::PICKED_ITEMS_LIST ( )

Definition at line 40 of file undo_redo_container.cpp.

References EDA_ITEM::m_Status, and UR_UNSPECIFIED.

PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST ( )

Definition at line 45 of file undo_redo_container.cpp.

46 {
47 }

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

References ITEM_PICKER::GetFlags(), ITEM_PICKER::GetItem(), ITEM_PICKER::GetLink(), ITEM_PICKER::GetStatus(), EDA_ITEM::Next(), UR_DELETED, UR_TRANSIENT, 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().

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_WIRE_IMAGE )
118  {
119  // Specific to eeschema: a linked list of wires is stored. The wrapper picks only
120  // the first item (head of list), and is owner of all picked items.
121  EDA_ITEM* item = wrapper.GetItem();
122 
123  while( item )
124  {
125  // Delete old copy of wires
126  EDA_ITEM* nextitem = item->Next();
127  delete item;
128  item = nextitem;
129  }
130  }
131  else if( wrapper.GetStatus() == UR_DELETED )
132  {
133  // This should really be replaced with UR_TRANSIENT, but currently many clients
134  // (eeschema in particular) abuse this to achieve non-undo-related deletions.
135  delete wrapper.GetItem();
136  }
137  }
138 }
STATUS_FLAGS GetFlags() const
EDA_ITEM * Next() const
Definition: base_struct.h:217
UNDO_REDO_T GetStatus() const
EDA_ITEM * GetItem() const
unsigned GetCount() const
Function GetCount.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:162
ITEM_PICKER PopItem()
Function PopItem.
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
Definition: base_struct.h:137
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 70 of file undo_redo_container.cpp.

References ITEM_PICKER::GetItem(), and i.

Referenced by PYTHON_ACTION_PLUGINS::deregister_action().

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

References m_ItemsList.

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

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

References ITEM_PICKER::GetItem(), and i.

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

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

142 {
143  ITEM_PICKER picker;
144 
145  if( aIdx < m_ItemsList.size() )
146  picker = m_ItemsList[aIdx];
147 
148  return picker;
149 }
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 161 of file undo_redo_container.cpp.

References ITEM_PICKER::GetLink().

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

162 {
163  if( aIdx < m_ItemsList.size() )
164  return m_ItemsList[aIdx].GetLink();
165 
166  return NULL;
167 }
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 170 of file undo_redo_container.cpp.

References ITEM_PICKER::GetStatus(), 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().

171 {
172  if( aIdx < m_ItemsList.size() )
173  return m_ItemsList[aIdx].GetStatus();
174 
175  return UR_UNSPECIFIED;
176 }
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 179 of file undo_redo_container.cpp.

References ITEM_PICKER::GetFlags().

Referenced by SCH_EDIT_FRAME::PutDataInPreviousState().

180 {
181  if( aIdx < m_ItemsList.size() )
182  return m_ItemsList[aIdx].GetFlags();
183 
184  return 0;
185 }
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 56 of file undo_redo_container.cpp.

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

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

Referenced by BOARD::AddArea(), SCH_SCREEN::addConnectedItemsToBlock(), AddNewTrace(), PCB_EDIT_FRAME::AppendBoardFile(), 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::DeleteJunction(), PYTHON_ACTION_PLUGINS::deregister_action(), 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().

51 {
52  m_ItemsList.push_back( aItem );
53 }
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 249 of file undo_redo_container.cpp.

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

250 {
251  if( aIdx >= m_ItemsList.size() )
252  return false;
253 
254  m_ItemsList.erase( m_ItemsList.begin() + aIdx );
255  return true;
256 }
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 265 of file undo_redo_container.cpp.

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

266 {
267  std::vector <ITEM_PICKER> tmp;
268  while( !m_ItemsList.empty() )
269  {
270  tmp.push_back( m_ItemsList.back() );
271  m_ItemsList.pop_back();
272  }
273 
274  m_ItemsList.swap( tmp );
275 }
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 188 of file undo_redo_container.cpp.

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

189 {
190  if( aIdx < m_ItemsList.size() )
191  {
192  m_ItemsList[aIdx].SetItem( aItem );
193  return true;
194  }
195 
196  return false;
197 }
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 212 of file undo_redo_container.cpp.

213 {
214  if( aIdx < m_ItemsList.size() )
215  {
216  m_ItemsList[aIdx].SetItem( aItem );
217  m_ItemsList[aIdx].SetStatus( aStatus );
218  return true;
219  }
220 
221  return false;
222 }
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 200 of file undo_redo_container.cpp.

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

201 {
202  if( aIdx < m_ItemsList.size() )
203  {
204  m_ItemsList[aIdx].SetLink( aLink );
205  return true;
206  }
207 
208  return false;
209 }
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 225 of file undo_redo_container.cpp.

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

226 {
227  if( aIdx < m_ItemsList.size() )
228  {
229  m_ItemsList[aIdx].SetStatus( aStatus );
230  return true;
231  }
232 
233  return false;
234 }
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 237 of file undo_redo_container.cpp.

Referenced by SCH_SCREEN::SelectBlockItems().

238 {
239  if( aIdx < m_ItemsList.size() )
240  {
241  m_ItemsList[aIdx].SetFlags( aFlags );
242  return true;
243  }
244 
245  return false;
246 }
std::vector< ITEM_PICKER > m_ItemsList

Member Data Documentation

std::vector<ITEM_PICKER> PICKED_ITEMS_LIST::m_ItemsList
private

Definition at line 141 of file undo_redo_container.h.

Referenced by CopyList().


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