KiCad PCB EDA Suite
block_commande.h File Reference

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

#include <base_struct.h>
#include <class_undoredo_container.h>
#include <gr_basic.h>
#include <class_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_COPY, BLOCK_COPY_AND_INCREMENT,
  BLOCK_SAVE, BLOCK_DELETE, BLOCK_PASTE, 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

Enumerator
BLOCK_IDLE 
BLOCK_MOVE 
BLOCK_COPY 
BLOCK_COPY_AND_INCREMENT 
BLOCK_SAVE 
BLOCK_DELETE 
BLOCK_PASTE 
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.

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

void AbortBlockCurrentCommand ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC 
)

Function AbortBlockCurrentCommand cancels the current block operation.

Definition at line 210 of file block_commande.cpp.

References BLOCK_ABORT, BLOCK_IDLE, BLOCK_PASTE, EDA_DRAW_PANEL::CallMouseCapture(), BLOCK_SELECTOR::ClearItemsList(), EDA_DRAW_FRAME::DisplayToolMsg(), BLOCK_SELECTOR::GetCommand(), 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().

211 {
212  BASE_SCREEN* screen = aPanel->GetScreen();
213 
214  if( aPanel->IsMouseCaptured() ) // Erase current drawing on screen
215  {
216  // Clear block outline.
217  aPanel->CallMouseCapture( aDC, wxDefaultPosition, false );
218  aPanel->SetMouseCapture( NULL, NULL );
219  screen->SetCurItem( NULL );
220 
221  // Delete the picked wrapper if this is a picked list.
222  if( screen->m_BlockLocate.GetCommand() != BLOCK_PASTE )
223  screen->m_BlockLocate.ClearItemsList();
224  }
225 
228  aPanel->GetParent()->HandleBlockEnd( aDC );
229 
231  aPanel->GetParent()->DisplayToolMsg( wxEmptyString );
232  aPanel->SetCursor( (wxStockCursor) aPanel->GetCurrentCursor() );
233 }
void SetCurItem(EDA_ITEM *aItem)
Function SetCurItem sets the currently selected object, m_CurrentItem.
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
int GetCurrentCursor() const
Function GetCurrentCursor return the current cursor shape, depending on the current selected tool...
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
void SetState(BLOCK_STATE_T aState)
bool IsMouseCaptured() const
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
virtual bool HandleBlockEnd(wxDC *DC)
Function HandleBlockEnd( ) Handle the "end" of a block command, i.e.
Definition: draw_frame.cpp:644
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:497
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
BLOCK_COMMAND_T GetCommand() const
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
void SetCommand(BLOCK_COMMAND_T aCommand)
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 183 of file block_commande.cpp.

References BLOCK_SELECTOR::Draw(), g_XorMode, BLOCK_SELECTOR::GetColor(), EDA_DRAW_FRAME::GetCrossHairPosition(), EDA_RECT::GetHeight(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), BLOCK_SELECTOR::GetState(), EDA_RECT::GetWidth(), BASE_SCREEN::m_BlockLocate, EDA_RECT::SetEnd(), BLOCK_SELECTOR::SetLastCursorPosition(), BLOCK_SELECTOR::SetMoveVector(), BLOCK_SELECTOR::SetState(), 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().

185 {
187 
188  block = &aPanel->GetScreen()->m_BlockLocate;
189 
190  block->SetMoveVector( wxPoint( 0, 0 ) );
191 
192  if( aErase && aDC )
193  block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() );
194 
196  block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
197 
198  if( aDC )
199  block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() );
200 
201  if( block->GetState() == STATE_BLOCK_INIT )
202  {
203  if( block->GetWidth() || block->GetHeight() )
204  // 2nd point exists: the rectangle is not surface anywhere
205  block->SetState( STATE_BLOCK_END );
206  }
207 }
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor)
void SetMoveVector(const wxPoint &aMoveVector)
int GetHeight() const
void SetState(BLOCK_STATE_T aState)
COLOR4D GetColor() const
void SetEnd(int x, int y)
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
Definition: solve.cpp:178
BLOCK_STATE_T GetState() const
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
int GetWidth() const
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...