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 <libeditframe.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 432 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().

434 {
435  BASE_SCREEN* screen = aPanel->GetScreen();
436  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
437 
438  LIB_EDIT_FRAME* parent = (LIB_EDIT_FRAME*) aPanel->GetParent();
439  wxASSERT( parent != NULL );
440 
441  LIB_PART* component = parent->GetCurPart();
442 
443  if( component == NULL )
444  return;
445 
446  int unit = parent->GetUnit();
447  int convert = parent->GetConvert();
448 
449  auto opts = PART_DRAW_OPTIONS::Default();
450  opts.draw_mode = g_XorMode;
451  opts.only_selected = true;
452 
453  if( aErase )
454  {
455  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
456  component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert, opts );
457 
458  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
459  {
460  LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
461  libItem->Draw( aPanel, aDC, block->GetMoveVector(), g_GhostColor, g_XorMode, nullptr, opts.transform );
462  }
463  }
464 
465  // Repaint new view
466  block->SetMoveVector( parent->GetCrossHairPosition() - block->GetLastCursorPosition() );
467 
468  GRSetDrawMode( aDC, g_XorMode );
469  block->Draw( aPanel, aDC, block->GetMoveVector(), g_XorMode, block->GetColor() );
470 
471  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
472  {
473  LIB_ITEM* libItem = (LIB_ITEM*) block->GetItem( ii );
474  libItem->Draw( aPanel, aDC, block->GetMoveVector(), g_GhostColor, g_XorMode, nullptr, opts.transform );
475  }
476 
477  component->Draw( aPanel, aDC, block->GetMoveVector(), unit, convert, opts );
478 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
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.
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:296
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.
Definition: libeditframe.h:158
COLOR4D GetColor() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Define a library symbol object.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
static PART_DRAW_OPTIONS Default()
Definition: solve.cpp:178
wxPoint GetLastCursorPosition() const
The symbol library editor main window.
Definition: libeditframe.h:58
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:187
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:57
wxPoint GetMoveVector() const