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

◆ DrawAndSizingBlockOutlines()

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

562 {
563  auto panel =static_cast<SCH_DRAW_PANEL*>(aPanel);
564  auto area = panel->GetView()->GetSelectionArea();
565  auto frame = static_cast<EDA_BASE_FRAME*>(aPanel->GetParent());
566 
568  bool isLibEdit = frame->IsType( FRAME_SCH_LIB_EDITOR );
569 
570  block = &aPanel->GetScreen()->m_BlockLocate;
571  block->SetMoveVector( wxPoint( 0, 0 ) );
572  block->SetLastCursorPosition( aPanel->GetParent()->GetCrossHairPosition( isLibEdit ) );
573  block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
574 
575  panel->GetView()->ClearPreview();
576  panel->GetView()->ClearHiddenFlags();
577 
578  area->SetOrigin( block->GetOrigin() );;
579  area->SetEnd( block->GetEnd() );
580 
581  panel->GetView()->SetVisible( area );
582  panel->GetView()->Hide( area, false );
583  panel->GetView()->Update( area );
584 
585  if( block->GetState() == STATE_BLOCK_INIT )
586  {
587  if( block->GetWidth() || block->GetHeight() )
588  // 2nd point exists: the rectangle is not surface anywhere
589  block->SetState( STATE_BLOCK_END );
590  }
591 }
virtual BASE_SCREEN * GetScreen()=0
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
virtual EDA_DRAW_FRAME * GetParent() const =0
Definition: solve.cpp:178
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Return the current cross hair position in logical (drawing) coordinates.

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

◆ DrawMovingBlockOutlines()

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

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

383 {
384  SCH_DRAW_PANEL* panel =static_cast<SCH_DRAW_PANEL*>( aPanel );
385  KIGFX::SCH_VIEW* view = panel->GetView();
386  KIGFX::VIEW_GROUP* preview = view->GetPreview();
387 
388  BASE_SCREEN* screen = aPanel->GetScreen();
389  BLOCK_SELECTOR* block = &screen->m_BlockLocate;
390  SCH_ITEM* schitem;
391 
392  block->SetMoveVector( panel->GetParent()->GetCrossHairPosition() - block->GetLastCursorPosition() );
393 
394  preview->Clear();
395  view->SetVisible( preview, true );
396 
397  for( unsigned ii = 0; ii < block->GetCount(); ii++ )
398  {
399  schitem = (SCH_ITEM*) block->GetItem( ii );
400  SCH_ITEM* copy = static_cast<SCH_ITEM*>( schitem->Clone() );
401 
402  copy->Move( block->GetMoveVector() );
403  copy->SetFlags( IS_MOVED );
404  preview->Add( copy );
405 
406  view->Hide( schitem );
407  }
408 
409  view->Update( preview );
410 }
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:1506
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 EDA_DRAW_FRAME * GetParent() const override
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.
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:1539
Definition: solve.cpp:178
KIGFX::SCH_VIEW * GetView() const
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1485
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
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
virtual void Move(const wxPoint &aMoveVector)=0
Function Move moves the item by aMoveVector to a new position.

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

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