KiCad PCB EDA Suite
common/legacy_wx/block.cpp File Reference
#include <fctsys.h>
#include <gr_basic.h>
#include <draw_frame.h>
#include <common.h>
#include <macros.h>
#include <base_struct.h>
#include <base_screen.h>
#include <class_drawpanel.h>
#include <confirm.h>
#include <block_commande.h>

Go to the source code of this file.

Functions

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

Function Documentation

void AbortBlockCurrentCommand ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC 
)

Function AbortBlockCurrentCommand cancels the current block operation.

Definition at line 200 of file common/legacy_wx/block.cpp.

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_GAL::SetDefaultCursor(), EDA_DRAW_PANEL::SetMouseCapture(), BLOCK_SELECTOR::SetState(), and STATE_NO_BLOCK.

Referenced by BLOCK_SELECTOR::IsIdle().

201 {
202  BASE_SCREEN* screen = aPanel->GetScreen();
203 
204  if( aPanel->IsMouseCaptured() ) // Erase current drawing on screen
205  {
206  // Clear block outline.
207  aPanel->CallMouseCapture( aDC, wxDefaultPosition, false );
208  aPanel->SetMouseCapture( NULL, NULL );
209  screen->SetCurItem( NULL );
210 
211  // Delete the picked wrapper if this is a picked list.
212  screen->m_BlockLocate.ClearItemsList();
213  }
214 
217  aPanel->GetParent()->HandleBlockEnd( aDC );
218 
220  aPanel->GetParent()->DisplayToolMsg( wxEmptyString );
221  aPanel->SetCursor( (wxStockCursor) aPanel->GetCurrentCursor() );
222 }
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
int GetCurrentCursor() const
Function GetCurrentCursor.
void ClearItemsList()
Function ClearItemsList clear only the list of EDA_ITEM pointers, it does NOT delete the EDA_ITEM obj...
virtual EDA_DRAW_FRAME * GetParent() const =0
void SetState(BLOCK_STATE_T aState)
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 void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
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)
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 175 of file common/legacy_wx/block.cpp.

References BLOCK_SELECTOR::Draw(), FRAME_SCH_LIB_EDITOR, g_XorMode, BLOCK_SELECTOR::GetColor(), EDA_DRAW_FRAME::GetCrossHairPosition(), EDA_RECT::GetEnd(), EDA_RECT::GetHeight(), EDA_RECT::GetOrigin(), EDA_DRAW_PANEL::GetParent(), EDA_DRAW_PANEL::GetScreen(), KIGFX::SCH_VIEW::GetSelectionArea(), BLOCK_SELECTOR::GetState(), SCH_DRAW_PANEL::GetView(), 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 BLOCK_SELECTOR::IsIdle().

177 {
179 
180  block->SetMoveVector( wxPoint( 0, 0 ) );
181 
182  if( aErase && aDC ) // Erase current outline
183  block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() );
184 
186  block->SetEnd( aPanel->GetParent()->GetCrossHairPosition() );
187 
188  if( aDC ) // Draw new outline
189  block->Draw( aPanel, aDC, wxPoint( 0, 0 ), g_XorMode, block->GetColor() );
190 
191  if( block->GetState() == STATE_BLOCK_INIT )
192  {
193  if( block->GetWidth() || block->GetHeight() )
194  // 2nd point exists: the rectangle is not surface anywhere
195  block->SetState( STATE_BLOCK_END );
196  }
197 }
virtual BASE_SCREEN * GetScreen()=0
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:74
BLOCK_SELECTOR m_BlockLocate
Block description for block commands.
Definition: base_screen.h:214
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor)
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)
COLOR4D GetColor() const
void SetEnd(int x, int y)
Definition: eda_rect.h:134
Definition: solve.cpp:178
BLOCK_STATE_T GetState() const
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.