KiCad PCB EDA Suite
block_libedit.cpp File Reference
#include <fctsys.h>
#include <gr_basic.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <general.h>
#include <class_library.h>
#include <lib_edit_frame.h>
#include <preview_items/selection_area.h>
#include <sch_view.h>
#include <view/view_group.h>

Go to the source code of this file.


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

Function Documentation

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

Definition at line 553 of file block_libedit.cpp.

References KIGFX::VIEW_GROUP::Add(), KIGFX::VIEW_GROUP::Clear(), EDA_ITEM::Clone(), BLOCK_SELECTOR::GetCount(), EDA_DRAW_FRAME::GetCrossHairPosition(), LIB_EDIT_FRAME::GetCurPart(), BLOCK_SELECTOR::GetItem(), BLOCK_SELECTOR::GetLastCursorPosition(), BLOCK_SELECTOR::GetMoveVector(), EDA_DRAW_PANEL::GetParent(), LIB_ITEM::GetPosition(), KIGFX::SCH_VIEW::GetPreview(), EDA_DRAW_PANEL::GetScreen(), SCH_DRAW_PANEL::GetView(), KIGFX::VIEW::Hide(), IS_MOVED, BASE_SCREEN::m_BlockLocate, LIB_ITEM::Move(), EDA_ITEM::SetFlags(), BLOCK_SELECTOR::SetMoveVector(), KIGFX::VIEW::SetVisible(), and KIGFX::VIEW::Update().

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

555 {
556  SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel );
557  LIB_EDIT_FRAME* frame = (LIB_EDIT_FRAME*) aPanel->GetParent();
558  KIGFX::SCH_VIEW* view = panel->GetView();
559  KIGFX::VIEW_GROUP* preview = view->GetPreview();
561  BASE_SCREEN* screen = aPanel->GetScreen();
562  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
563  LIB_PART* component = frame->GetCurPart();
565  if( component == NULL )
566  return;
568  block->SetMoveVector( frame->GetCrossHairPosition( true ) - block->GetLastCursorPosition() );
570  preview->Clear();
571  view->SetVisible( preview, true );
573  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
574  {
575  LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
576  LIB_ITEM* copy = static_cast<LIB_ITEM*>( libItem->Clone() );
578  copy->Move( copy->GetPosition() + block->GetMoveVector() );
579  copy->SetFlags( IS_MOVED );
580  preview->Add( copy );
582  view->Hide( libItem );
583  }
585  view->Update( preview );
586 }
virtual BASE_SCREEN * GetScreen()=0
virtual wxPoint GetPosition() const =0
Return the current draw object position.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1505
Block description for block commands.
Definition: base_screen.h:214
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
virtual void Move(const wxPoint &aPosition)=0
Move a draw object to aPosition.
void SetMoveVector(const wxPoint &aMoveVector)
virtual void Clear()
Function Clear() Removes all the stored items from the group.
Definition: view_group.cpp:74
EDA_ITEM * GetItem(unsigned aIndex)
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
KIGFX::VIEW_GROUP * GetPreview() const
Definition: sch_view.h:88
virtual EDA_DRAW_FRAME * GetParent() const =0
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
Define a library symbol object.
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1538
KIGFX::SCH_VIEW * GetView() const
Definition: solve.cpp:178
wxPoint GetLastCursorPosition() const
The symbol library editor main window.
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1484
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
unsigned GetCount() const
wxPoint GetMoveVector() const
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113