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 503 of file eeschema/block.cpp.

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

505 {
506  auto panel =static_cast<SCH_DRAW_PANEL*>(aPanel);
507  auto area = panel->GetView()->GetSelectionArea();
508  auto frame = static_cast<EDA_BASE_FRAME*>(aPanel->GetParent());
509 
511  bool isLibEdit = frame->IsType( FRAME_SCH_LIB_EDITOR );
512 
513  block = &aPanel->GetScreen()->m_BlockLocate;
514  block->SetMoveVector( wxPoint( 0, 0 ) );
515  block->SetLastCursorPosition( aPanel->GetParent()->GetCrossHairPosition( isLibEdit ) );
516  block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
517 
518  panel->GetView()->ClearPreview();
519  panel->GetView()->ClearHiddenFlags();
520 
521  area->SetOrigin( block->GetOrigin() );;
522  area->SetEnd( block->GetEnd() );
523 
524  panel->GetView()->SetVisible( area );
525  panel->GetView()->Hide( area, false );
526  panel->GetView()->Update( area );
527 
528  if( block->GetState() == STATE_BLOCK_INIT )
529  {
530  if( block->GetWidth() || block->GetHeight() )
531  // 2nd point exists: the rectangle is not surface anywhere
532  block->SetState( STATE_BLOCK_END );
533  }
534 }
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:53
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
Function GetCrossHairPosition 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 336 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().

338 {
339  SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel );
340  KIGFX::SCH_VIEW* view = panel->GetView();
341  KIGFX::VIEW_GROUP* preview = view->GetPreview();
342 
343  BASE_SCREEN* screen = aPanel->GetScreen();
344  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
345  SCH_ITEM* schitem;
346 
347  block->SetMoveVector( panel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
348 
349  preview->Clear();
350  view->SetVisible( preview, true );
351 
352  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
353  {
354  schitem = (SCH_ITEM*) block->GetItem( ii );
355  SCH_ITEM* copy = static_cast<SCH_ITEM*>( schitem->Clone() );
356 
357  copy->Move( block->GetMoveVector() );
358  copy->SetFlags( IS_MOVED );
359  preview->Add( copy );
360 
361  view->Hide( schitem );
362  }
363 
364  view->Update( preview );
365 }
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:1505
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:55
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
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:1538
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:1484
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition 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:110
virtual void Move(const wxPoint &aMoveVector)=0
Function Move moves the item by aMoveVector to a new position.