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

◆ DrawMovingBlockOutlines()

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

Definition at line 555 of file block_libedit.cpp.

557 {
558  SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel );
559  LIB_EDIT_FRAME* frame = (LIB_EDIT_FRAME*) aPanel->GetParent();
560  KIGFX::SCH_VIEW* view = panel->GetView();
561  KIGFX::VIEW_GROUP* preview = view->GetPreview();
562 
563  BASE_SCREEN* screen = aPanel->GetScreen();
564  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
565  LIB_PART* component = frame->GetCurPart();
566 
567  if( component == NULL )
568  return;
569 
570  block->SetMoveVector( frame->GetCrossHairPosition( true ) - block->GetLastCursorPosition() );
571 
572  preview->Clear();
573  view->SetVisible( preview, true );
574 
575  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
576  {
577  LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
578  LIB_ITEM* copy = static_cast<LIB_ITEM*>( libItem->Clone() );
579 
580  copy->Move( copy->GetPosition() + block->GetMoveVector() );
581  copy->SetFlags( IS_MOVED );
582  preview->Add( copy );
583 
584  view->Hide( libItem );
585  }
586 
587  view->Update( preview );
588 }
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:1506
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
KIGFX::VIEW_GROUP * GetPreview() const
Definition: sch_view.h:88
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
virtual void Move(const wxPoint &aPosition)=0
Move a draw object to aPosition.
virtual void Clear()
Function Clear() Removes all the stored items from the group.
Definition: view_group.cpp:74
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
virtual EDA_DRAW_FRAME * GetParent() const =0
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:1539
Definition: solve.cpp:178
KIGFX::SCH_VIEW * GetView() const
The symbol library editor main window.
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1485
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113

References KIGFX::VIEW_GROUP::Add(), KIGFX::VIEW_GROUP::Clear(), EDA_ITEM::Clone(), EDA_DRAW_FRAME::GetCrossHairPosition(), LIB_EDIT_FRAME::GetCurPart(), 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(), KIGFX::VIEW::SetVisible(), and KIGFX::VIEW::Update().

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