KiCad PCB EDA Suite
block_commande.h File Reference

This file is part of the common library. More...

#include <base_struct.h>
#include <undo_redo_container.h>
#include <gr_basic.h>
#include <eda_rect.h>

Go to the source code of this file.

Classes

class  BLOCK_SELECTOR
 

Enumerations

enum  BLOCK_STATE_T {
  STATE_NO_BLOCK, STATE_BLOCK_INIT, STATE_BLOCK_END, STATE_BLOCK_MOVE,
  STATE_BLOCK_STOP
}
 
enum  BLOCK_COMMAND_T {
  BLOCK_IDLE, BLOCK_MOVE, BLOCK_DUPLICATE, BLOCK_DUPLICATE_AND_INCREMENT,
  BLOCK_COPY, BLOCK_DELETE, BLOCK_PASTE, BLOCK_CUT,
  BLOCK_DRAG, BLOCK_DRAG_ITEM, BLOCK_ROTATE, BLOCK_FLIP,
  BLOCK_ZOOM, BLOCK_ABORT, BLOCK_PRESELECT_MOVE, BLOCK_MOVE_EXACT,
  BLOCK_SELECT_ITEMS_ONLY, BLOCK_MIRROR_X, BLOCK_MIRROR_Y
}
 

Functions

void AbortBlockCurrentCommand (EDA_DRAW_PANEL *aPanel, wxDC *aDC)
 Function AbortBlockCurrentCommand cancels the current block operation. More...
 
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...
 

Detailed Description

This file is part of the common library.

See also
common.h

Definition in file block_commande.h.

Enumeration Type Documentation

◆ BLOCK_COMMAND_T

Enumerator
BLOCK_IDLE 
BLOCK_MOVE 
BLOCK_DUPLICATE 
BLOCK_DUPLICATE_AND_INCREMENT 
BLOCK_COPY 
BLOCK_DELETE 
BLOCK_PASTE 
BLOCK_CUT 
BLOCK_DRAG 
BLOCK_DRAG_ITEM 
BLOCK_ROTATE 
BLOCK_FLIP 
BLOCK_ZOOM 
BLOCK_ABORT 
BLOCK_PRESELECT_MOVE 
BLOCK_MOVE_EXACT 
BLOCK_SELECT_ITEMS_ONLY 
BLOCK_MIRROR_X 
BLOCK_MIRROR_Y 

Definition at line 51 of file block_commande.h.

◆ BLOCK_STATE_T

Enumerator
STATE_NO_BLOCK 
STATE_BLOCK_INIT 
STATE_BLOCK_END 
STATE_BLOCK_MOVE 
STATE_BLOCK_STOP 

Definition at line 41 of file block_commande.h.

Function Documentation

◆ AbortBlockCurrentCommand()

void AbortBlockCurrentCommand ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC 
)

Function AbortBlockCurrentCommand cancels the current block operation.

Definition at line 179 of file common/legacy_gal/block.cpp.

180 {
181  BASE_SCREEN* screen = aPanel->GetScreen();
182 
183  if( aPanel->IsMouseCaptured() )
184  {
185  aPanel->SetMouseCapture( NULL, NULL );
186  screen->SetCurItem( NULL );
187  }
188 
190  aPanel->GetParent()->HandleBlockEnd( aDC );
191 
192  aPanel->GetParent()->DisplayToolMsg( wxEmptyString );
193 
194  // ugly, but temporary
195  auto gal_panel = dynamic_cast<EDA_DRAW_PANEL_GAL*>( aPanel );
196 
197  if( gal_panel )
198  gal_panel->SetDefaultCursor();
199 }
virtual BASE_SCREEN * GetScreen()=0
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
Definition: base_screen.h:231
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
virtual EDA_DRAW_FRAME * GetParent() const =0
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
virtual void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
virtual bool HandleBlockEnd(wxDC *DC)
Handle the "end" of a block command, i.e.
void DisplayToolMsg(const wxString &msg)
void SetCommand(BLOCK_COMMAND_T aCommand)

References BLOCK_ABORT, BLOCK_IDLE, EDA_DRAW_PANEL::CallMouseCapture(), BLOCK_SELECTOR::ClearItemsList(), EDA_DRAW_FRAME::DisplayToolMsg(), EDA_DRAW_PANEL::GetCurrentCursor(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), EDA_DRAW_FRAME::HandleBlockEnd(), EDA_DRAW_PANEL::IsMouseCaptured(), BASE_SCREEN::m_BlockLocate, BLOCK_SELECTOR::SetCommand(), BASE_SCREEN::SetCurItem(), EDA_DRAW_PANEL::SetMouseCapture(), BLOCK_SELECTOR::SetState(), and STATE_NO_BLOCK.

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

◆ 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.

References FRAME_SCH_LIB_EDITOR, g_XorMode, EDA_DRAW_FRAME::GetCrossHairPosition(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), BASE_SCREEN::m_BlockLocate, STATE_BLOCK_END, and STATE_BLOCK_INIT.

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