KiCad PCB EDA Suite
eeschema/block.cpp File Reference
#include <fctsys.h>
#include <pgm_base.h>
#include <gr_basic.h>
#include <sch_draw_panel.h>
#include <confirm.h>
#include <sch_edit_frame.h>
#include <general.h>
#include <class_library.h>
#include <lib_pin.h>
#include <list_operations.h>
#include <sch_bus_entry.h>
#include <sch_marker.h>
#include <sch_junction.h>
#include <sch_line.h>
#include <sch_no_connect.h>
#include <sch_text.h>
#include <sch_component.h>
#include <sch_sheet.h>
#include <sch_sheet_path.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)
 
void DrawAndSizingBlockOutlines (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
 Function DrawAndSizingBlockOutlines redraws the outlines of the block which shows the search area for block commands. More...
 

Function Documentation

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

Function DrawAndSizingBlockOutlines redraws the outlines of the block which shows the search area for block commands.

The first point of the rectangle showing the area is initialized by InitBlockLocateDatas(). The other point of the rectangle is the mouse cursor position.

Definition at line 544 of file eeschema/block.cpp.

Referenced by LIB_EDIT_FRAME::HandleBlockEnd(), PCB_EDIT_FRAME::HandleBlockEnd(), SCH_EDIT_FRAME::HandleBlockEnd(), and BLOCK_SELECTOR::InitData().

546 {
547  auto panel =static_cast<SCH_DRAW_PANEL*>(aPanel);
548  auto area = panel->GetView()->GetSelectionArea();
549  auto frame = static_cast<EDA_BASE_FRAME*>(aPanel->GetParent());
550 
552  bool isLibEdit = frame->IsType( FRAME_SCH_LIB_EDITOR );
553 
554  block = &aPanel->GetScreen()->m_BlockLocate;
555  block->SetMoveVector( wxPoint( 0, 0 ) );
556  block->SetLastCursorPosition( aPanel->GetParent()->GetCrossHairPosition( isLibEdit ) );
557  block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
558 
559  panel->GetView()->ClearPreview();
560  panel->GetView()->ClearHiddenFlags();
561 
562  area->SetOrigin( block->GetOrigin() );;
563  area->SetEnd( block->GetEnd() );
564 
565  panel->GetView()->SetVisible( area );
566  panel->GetView()->Hide( area, false );
567  panel->GetView()->Update( area );
568 
569  if( block->GetState() == STATE_BLOCK_INIT )
570  {
571  if( block->GetWidth() || block->GetHeight() )
572  // 2nd point exists: the rectangle is not surface anywhere
573  block->SetState( STATE_BLOCK_END );
574  }
575 }
virtual BASE_SCREEN * GetScreen()=0
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
KIGFX::PREVIEW::SELECTION_AREA * GetSelectionArea() const
Definition: sch_view.h:84
void SetMoveVector(const wxPoint &aMoveVector)
int GetHeight() const
Definition: eda_rect.h:118
virtual EDA_DRAW_FRAME * GetParent() const =0
void SetState(BLOCK_STATE_T aState)
void SetEnd(int x, int y)
Definition: eda_rect.h:134
KIGFX::SCH_VIEW * GetView() const
Definition: solve.cpp:178
const wxPoint GetEnd() const
Definition: eda_rect.h:114
BLOCK_STATE_T GetState() const
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
int GetWidth() const
Definition: eda_rect.h:117
void SetLastCursorPosition(const wxPoint &aPosition)
Function SetLastCursorPosition sets the last cursor position to aPosition.
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
static void DrawMovingBlockOutlines ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint &  aPosition,
bool  aErase 
)
static

Definition at line 365 of file eeschema/block.cpp.

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

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

367 {
368  SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel );
369  KIGFX::SCH_VIEW* view = panel->GetView();
370  KIGFX::VIEW_GROUP* preview = view->GetPreview();
371 
372  BASE_SCREEN* screen = aPanel->GetScreen();
373  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
374  SCH_ITEM* schitem;
375 
376  block->SetMoveVector( panel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
377 
378  preview->Clear();
379  view->SetVisible( preview, true );
380 
381  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
382  {
383  schitem = (SCH_ITEM*) block->GetItem( ii );
384  SCH_ITEM* copy = static_cast<SCH_ITEM*>( schitem->Clone() );
385 
386  copy->Move( block->GetMoveVector() );
387  copy->SetFlags( IS_MOVED );
388  preview->Add( copy );
389 
390  view->Hide( schitem );
391  }
392 
393  view->Update( preview );
394 }
virtual BASE_SCREEN * GetScreen()=0
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1497
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
virtual EDA_DRAW_FRAME * GetParent() const override
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
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)
KIGFX::VIEW_GROUP * GetPreview() const
Definition: sch_view.h:86
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
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:1530
KIGFX::SCH_VIEW * GetView() const
Definition: solve.cpp:178
wxPoint GetLastCursorPosition() const
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1476
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
unsigned GetCount() const
wxPoint GetMoveVector() const
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113
virtual void Move(const wxPoint &aMoveVector)=0
Function Move moves the item by aMoveVector to a new position.