KiCad PCB EDA Suite
operations_on_items_lists.cpp File Reference

Functions used in block commands, or undo/redo, to move, mirror, delete, copy ... More...

#include <fctsys.h>
#include <pgm_base.h>
#include <sch_draw_panel.h>
#include <sch_edit_frame.h>
#include <general.h>
#include <list_operations.h>
#include <sch_bus_entry.h>
#include <sch_marker.h>
#include <sch_line.h>
#include <sch_no_connect.h>
#include <sch_sheet.h>
#include <sch_component.h>
#include <sch_junction.h>

Go to the source code of this file.

Functions

void SetSchItemParent (SCH_ITEM *Struct, SCH_SCREEN *Screen)
 
void RotateListOfItems (PICKED_ITEMS_LIST &aItemsList, const wxPoint &rotationPoint)
 
void MirrorY (PICKED_ITEMS_LIST &aItemsList, const wxPoint &aMirrorPoint)
 
void MirrorX (PICKED_ITEMS_LIST &aItemsList, const wxPoint &aMirrorPoint)
 
SCH_ITEMDuplicateStruct (SCH_ITEM *aDrawStruct, bool aClone)
 Routine to create a new copy of given struct. More...
 

Detailed Description

Functions used in block commands, or undo/redo, to move, mirror, delete, copy ...

lists of schematic items.

Definition in file operations_on_items_lists.cpp.

Function Documentation

SCH_ITEM* DuplicateStruct ( SCH_ITEM aDrawStruct,
bool  aClone = false 
)

Routine to create a new copy of given struct.

The new object is not put in draw list (not linked)

Parameters
aDrawStruct= the SCH_ITEM to duplicate
aClone(default = false) if true duplicate also some parameters that must be unique (timestamp and sheet name) aClone must be false. use true only is undo/redo duplications

Definition at line 295 of file operations_on_items_lists.cpp.

References EDA_ITEM::Clone(), EDA_ITEM::GetTimeStamp(), and EDA_ITEM::SetTimeStamp().

Referenced by SCH_EDIT_FRAME::copyBlockItems(), SCH_EDIT_FRAME::DuplicateItemsInList(), SCH_EDIT_FRAME::PasteListOfItems(), and SCH_EDIT_FRAME::SaveCopyInUndoList().

296 {
297  wxCHECK_MSG( aDrawStruct != NULL, NULL,
298  wxT( "Cannot duplicate NULL schematic item! Bad programmer." ) );
299 
300  SCH_ITEM* NewDrawStruct = (SCH_ITEM*) aDrawStruct->Clone();
301 
302  if( aClone )
303  NewDrawStruct->SetTimeStamp( aDrawStruct->GetTimeStamp() );
304 
305  return NewDrawStruct;
306 }
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
timestamp_t GetTimeStamp() const
Definition: base_struct.h:207
void SetTimeStamp(timestamp_t aNewTimeStamp)
Definition: base_struct.h:206
void MirrorX ( PICKED_ITEMS_LIST aItemsList,
const wxPoint aMirrorPoint 
)

Definition at line 97 of file operations_on_items_lists.cpp.

References EDA_ITEM::ClearFlags(), PICKED_ITEMS_LIST::GetCount(), PICKED_ITEMS_LIST::GetPickedItem(), SCH_ITEM::MirrorX(), and wxPoint::y.

Referenced by SCH_ITEM::GetPenSize(), and SCH_EDIT_FRAME::OnOrient().

98 {
99  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
100  {
101  SCH_ITEM* item = static_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
102  item->MirrorX( aMirrorPoint.y ); // Place it in its new position.
103  item->ClearFlags();
104  }
105 }
virtual void MirrorX(int aXaxis_position)=0
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
unsigned GetCount() const
Function GetCount.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void MirrorY ( PICKED_ITEMS_LIST aItemsList,
const wxPoint aMirrorPoint 
)

Definition at line 86 of file operations_on_items_lists.cpp.

References EDA_ITEM::ClearFlags(), PICKED_ITEMS_LIST::GetCount(), PICKED_ITEMS_LIST::GetPickedItem(), SCH_ITEM::MirrorY(), and wxPoint::x.

Referenced by SCH_ITEM::GetPenSize(), and SCH_EDIT_FRAME::OnOrient().

87 {
88  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
89  {
90  SCH_ITEM* item = static_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
91  item->MirrorY( aMirrorPoint.x ); // Place it in its new position.
92  item->ClearFlags();
93  }
94 }
virtual void MirrorY(int aYaxis_position)=0
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
unsigned GetCount() const
Function GetCount.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void RotateListOfItems ( PICKED_ITEMS_LIST aItemsList,
const wxPoint rotationPoint 
)

Definition at line 75 of file operations_on_items_lists.cpp.

References EDA_ITEM::ClearFlags(), PICKED_ITEMS_LIST::GetCount(), PICKED_ITEMS_LIST::GetPickedItem(), and SCH_ITEM::Rotate().

Referenced by SCH_EDIT_FRAME::OnRotate().

76 {
77  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
78  {
79  SCH_ITEM* item = static_cast<SCH_ITEM*>( aItemsList.GetPickedItem( ii ) );
80  item->Rotate( rotationPoint ); // Place it in its new position.
81  item->ClearFlags();
82  }
83 }
virtual void Rotate(wxPoint aPosition)=0
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
unsigned GetCount() const
Function GetCount.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void SetSchItemParent ( SCH_ITEM Struct,
SCH_SCREEN Screen 
)

Definition at line 47 of file operations_on_items_lists.cpp.

References SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_COMPONENT_T, SCH_GLOBAL_LABEL_T, SCH_HIERARCHICAL_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_MARKER_T, SCH_NO_CONNECT_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_TEXT_T, EDA_ITEM::SetParent(), and EDA_ITEM::Type().

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

48 {
49  switch( Struct->Type() )
50  {
51  case SCH_JUNCTION_T:
52  case SCH_TEXT_T:
53  case SCH_LABEL_T:
54  case SCH_GLOBAL_LABEL_T:
56  case SCH_COMPONENT_T:
57  case SCH_LINE_T:
60  case SCH_SHEET_T:
61  case SCH_MARKER_T:
62  case SCH_NO_CONNECT_T:
63  Struct->SetParent( Screen );
64  break;
65 
66  case SCH_SHEET_PIN_T:
67  break;
68 
69  default:
70  break;
71  }
72 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216