KiCad PCB EDA Suite
eeschema/block.cpp File Reference
#include <fctsys.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <schframe.h>
#include <general.h>
#include <class_library.h>
#include <lib_pin.h>
#include <protos.h>
#include <sch_bus_entry.h>
#include <sch_marker.h>
#include <sch_junction.h>
#include <sch_line.h>
#include <sch_no_connect.h>
#include <sch_text.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_sheet_path.h>

Go to the source code of this file.

Functions

void SetSchItemParent (SCH_ITEM *Struct, SCH_SCREEN *Screen)
 
void MoveItemsInList (PICKED_ITEMS_LIST &aItemsList, const wxPoint aMoveVector)
 Function MoveItemsInList Move a list of items to a given move vector. More...
 
void RotateListOfItems (PICKED_ITEMS_LIST &aItemsList, wxPoint &Center)
 
void MirrorX (PICKED_ITEMS_LIST &aItemsList, wxPoint &aMirrorPoint)
 
void MirrorY (PICKED_ITEMS_LIST &aItemsList, wxPoint &Center)
 
void DuplicateItemsInList (SCH_SCREEN *screen, PICKED_ITEMS_LIST &aItemsList, const wxPoint aMoveVector)
 
static void DrawMovingBlockOutlines (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 

Function Documentation

static void DrawMovingBlockOutlines ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aPosition,
bool  aErase 
)
static

Definition at line 383 of file eeschema/block.cpp.

References BLOCK_SELECTOR::Draw(), SCH_ITEM::Draw(), g_GhostColor, g_XorMode, BLOCK_SELECTOR::GetColor(), BLOCK_SELECTOR::GetCount(), EDA_DRAW_FRAME::GetCrossHairPosition(), BLOCK_SELECTOR::GetItem(), BLOCK_SELECTOR::GetLastCursorPosition(), BLOCK_SELECTOR::GetMoveVector(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), BASE_SCREEN::m_BlockLocate, SCH_COMPONENT_T, BLOCK_SELECTOR::SetMoveVector(), and EDA_ITEM::Type().

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

385 {
386  BASE_SCREEN* screen = aPanel->GetScreen();
387  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
388  SCH_ITEM* schitem;
389 
390  /* Erase old block contents. */
391  if( aErase )
392  {
393  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
394 
395  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
396  {
397  schitem = (SCH_ITEM*) block->GetItem( ii );
398 
399  if( schitem->Type() == SCH_COMPONENT_T )
400  ((SCH_COMPONENT*)schitem)->Draw( aPanel, aDC, block->GetMoveVector(),
401  g_XorMode, g_GhostColor, false );
402  else
403  schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
404  }
405  }
406 
407  /* Repaint new view. */
408  block->SetMoveVector( aPanel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
409  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
410 
411  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
412  {
413  schitem = (SCH_ITEM*) block->GetItem( ii );
414 
415  if( schitem->Type() == SCH_COMPONENT_T )
416  ((SCH_COMPONENT*)schitem)->Draw( aPanel, aDC, block->GetMoveVector(),
417  g_XorMode, g_GhostColor, false );
418  else
419  schitem->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, g_GhostColor );
420  }
421 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor)
void SetMoveVector(const wxPoint &aMoveVector)
EDA_ITEM * GetItem(unsigned aIndex)
COLOR4D GetColor() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
Definition: solve.cpp:178
wxPoint GetLastCursorPosition() const
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:68
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
unsigned GetCount() const
virtual void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED)=0
Function Draw Draw a schematic item.
COLOR4D g_GhostColor
Draw color for moving objects.
Definition: common.cpp:58
wxPoint GetMoveVector() const
void DuplicateItemsInList ( SCH_SCREEN screen,
PICKED_ITEMS_LIST aItemsList,
const wxPoint  aMoveVector 
)

Definition at line 189 of file operations_on_items_lists.cpp.

References SCH_SCREEN::Append(), DuplicateStruct(), PICKED_ITEMS_LIST::GetCount(), GetNewTimeStamp(), PICKED_ITEMS_LIST::GetPickedItem(), MoveItemsInList(), 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, PICKED_ITEMS_LIST::SetPickedItem(), PICKED_ITEMS_LIST::SetPickedItemStatus(), SetSchItemParent(), EDA_ITEM::SetTimeStamp(), EDA_ITEM::Type(), and UR_NEW.

Referenced by SCH_EDIT_FRAME::HandleBlockPlace().

191 {
192  SCH_ITEM* newitem;
193 
194  if( aItemsList.GetCount() == 0 )
195  return;
196 
197  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
198  {
199  newitem = DuplicateStruct( (SCH_ITEM*) aItemsList.GetPickedItem( ii ) );
200  aItemsList.SetPickedItem( newitem, ii );
201  aItemsList.SetPickedItemStatus( UR_NEW, ii );
202  {
203  switch( newitem->Type() )
204  {
205  case SCH_JUNCTION_T:
206  case SCH_LINE_T:
207  case SCH_BUS_BUS_ENTRY_T:
209  case SCH_TEXT_T:
210  case SCH_LABEL_T:
211  case SCH_GLOBAL_LABEL_T:
213  case SCH_SHEET_PIN_T:
214  case SCH_MARKER_T:
215  case SCH_NO_CONNECT_T:
216  default:
217  break;
218 
219  case SCH_SHEET_T:
220  {
221  SCH_SHEET* sheet = (SCH_SHEET*) newitem;
222  sheet->SetTimeStamp( GetNewTimeStamp() );
223  break;
224  }
225 
226  case SCH_COMPONENT_T:
227  ( (SCH_COMPONENT*) newitem )->SetTimeStamp( GetNewTimeStamp() );
228  ( (SCH_COMPONENT*) newitem )->ClearAnnotation( NULL );
229  break;
230  }
231 
232  SetSchItemParent( newitem, screen );
233  screen->Append( newitem );
234  }
235  }
236 
237  MoveItemsInList( aItemsList, aMoveVector );
238 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
time_t GetNewTimeStamp()
Definition: common.cpp:266
void MoveItemsInList(PICKED_ITEMS_LIST &aItemsList, const wxPoint aMoveVector)
Function MoveItemsInList Move a list of items to a given move vector.
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
void SetSchItemParent(SCH_ITEM *Struct, SCH_SCREEN *Screen)
bool SetPickedItem(EDA_ITEM *aItem, unsigned aIdx)
Function SetPickedItem.
Class SCH_SHEET is the sheet symbol placed in a schematic, and is the entry point for a sub schematic...
Definition: sch_sheet.h:216
unsigned GetCount() const
Function GetCount.
bool SetPickedItemStatus(UNDO_REDO_T aStatus, unsigned aIdx)
Function SetPickedItemStatus sets the type of undo/redo operation for a given picked item...
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
void Append(SCH_ITEM *aItem)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:68
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
SCH_ITEM * DuplicateStruct(SCH_ITEM *aDrawStruct, bool aClone)
Function DuplicateStruct Routine to create a new copy of given struct.
void MirrorX ( PICKED_ITEMS_LIST aItemsList,
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_EDIT_FRAME::HandleBlockEnd().

98 {
99  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
100  {
101  SCH_ITEM* item = (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:254
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,
wxPoint Center 
)

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_EDIT_FRAME::HandleBlockEnd().

87 {
88  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
89  {
90  SCH_ITEM* item = (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:254
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
void MoveItemsInList ( PICKED_ITEMS_LIST aItemsList,
const wxPoint  aMoveVector 
)

Function MoveItemsInList Move a list of items to a given move vector.

Parameters
aItemsList= list of picked items
aMoveVector= the move vector value

Definition at line 114 of file operations_on_items_lists.cpp.

References PICKED_ITEMS_LIST::GetCount(), PICKED_ITEMS_LIST::GetPickedItem(), and SCH_ITEM::Move().

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

115 {
116  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
117  {
118  SCH_ITEM* item = (SCH_ITEM*) aItemsList.GetPickedItem( ii );
119  item->Move( aMoveVector );
120  }
121 }
unsigned GetCount() const
Function GetCount.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
Function GetPickedItem.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
virtual void Move(const wxPoint &aMoveVector)=0
Function Move moves the item by aMoveVector to a new position.
void RotateListOfItems ( PICKED_ITEMS_LIST aItemsList,
wxPoint Center 
)

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

76 {
77  for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
78  {
79  SCH_ITEM* item = (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:254
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 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:198
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:213