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.

Functions

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 
)
static

Definition at line 554 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().

556 {
557  SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel );
558  LIB_EDIT_FRAME* frame = (LIB_EDIT_FRAME*) aPanel->GetParent();
559  KIGFX::SCH_VIEW* view = panel->GetView();
560  KIGFX::VIEW_GROUP* preview = view->GetPreview();
561 
562  BASE_SCREEN* screen = aPanel->GetScreen();
563  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
564  LIB_PART* component = frame->GetCurPart();
565 
566  if( component == NULL )
567  return;
568 
569  block->SetMoveVector( frame->GetCrossHairPosition( true ) - block->GetLastCursorPosition() );
570 
571  preview->Clear();
572  view->SetVisible( preview, true );
573 
574  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
575  {
576  LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
577  LIB_ITEM* copy = static_cast<LIB_ITEM*>( libItem->Clone() );
578 
579  copy->Move( copy->GetPosition() + block->GetMoveVector() );
580  copy->SetFlags( IS_MOVED );
581  preview->Add( copy );
582 
583  view->Hide( libItem );
584  }
585 
586  view->Update( preview );
587 }
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:1488
BLOCK_SELECTOR m_BlockLocate
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:80
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:1521
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:1467
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