KiCad PCB EDA Suite
block_libedit.cpp File Reference
#include <fctsys.h>
#include <gr_basic.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <general.h>
#include <class_library.h>
#include <lib_edit_frame.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 430 of file block_libedit.cpp.

References PART_DRAW_OPTIONS::Default(), BLOCK_SELECTOR::Draw(), LIB_ITEM::Draw(), LIB_PART::Draw(), g_GhostColor, g_XorMode, BLOCK_SELECTOR::GetColor(), LIB_EDIT_FRAME::GetConvert(), BLOCK_SELECTOR::GetCount(), EDA_DRAW_FRAME::GetCrossHairPosition(), LIB_EDIT_FRAME::GetCurPart(), BLOCK_SELECTOR::GetItem(), BLOCK_SELECTOR::GetLastCursorPosition(), BLOCK_SELECTOR::GetMoveVector(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), LIB_EDIT_FRAME::GetUnit(), GRSetDrawMode(), BASE_SCREEN::m_BlockLocate, and BLOCK_SELECTOR::SetMoveVector().

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

432 {
433  BASE_SCREEN* screen = aPanel->GetScreen();
434  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
435 
436  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
437  wxASSERT( parent != NULL );
438 
439  LIB_PART* component = parent->GetCurPart();
440 
441  if( component == NULL )
442  return;
443 
444  int unit = parent->GetUnit();
445  int convert = parent->GetConvert();
446 
447  auto opts = PART_DRAW_OPTIONS::Default();
448  opts.draw_mode = g_XorMode;
449  opts.only_selected = true;
450 
451  if( aErase )
452  {
453  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
454  component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert, opts );
455 
456  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
457  {
458  LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
459  libItem->Draw( aPanel, aDC, block->GetMoveVector(), g_GhostColor, g_XorMode, nullptr, opts.transform );
460  }
461  }
462 
463  // Repaint new view
464  block->SetMoveVector( parent->GetCrossHairPosition() - block->GetLastCursorPosition() );
465 
466  GRSetDrawMode( aDC, g_XorMode );
467  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
468 
469  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
470  {
471  LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
472  libItem->Draw( aPanel, aDC, block->GetMoveVector(), g_GhostColor, g_XorMode, nullptr, opts.transform );
473  }
474 
475  component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert, opts );
476 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDc, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Draw part.
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:318
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)
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:66
LIB_PART * GetCurPart() const
Return the current part being edited or NULL if none selected.
COLOR4D GetColor() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
Define a library symbol object.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:180
static PART_DRAW_OPTIONS Default()
Definition: solve.cpp:178
wxPoint GetLastCursorPosition() const
The symbol library editor main window.
virtual void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform)
Draw an item.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:193
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
unsigned GetCount() const
COLOR4D g_GhostColor
Draw color for moving objects.
Definition: common.cpp:58
wxPoint GetMoveVector() const