Eeschema block end handler code improvements.
* Merge HandleBlockEnd() and HandleBlockEndByPopUp() into as single block end function HandleBlockEnd(). * Replace all instances of HandleBlockEndByPopUp() with HandleBlockEnd(). * Change block hot keys to send command events instead of directly calling end block handler.
This commit is contained in:
parent
19ff8e95e5
commit
76c9029ec3
|
@ -186,31 +186,22 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* HandleBlockEnd is called when:
|
bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
* a block is defined
|
|
||||||
* or a schematic iten should be dragged
|
|
||||||
* When the block is defined, all items inside the block should be collected
|
|
||||||
* When a schematic iten should be dragged, only this item should be collected
|
|
||||||
*
|
|
||||||
* In all cases, connected items are collected when a drag command is activated
|
|
||||||
*/
|
|
||||||
bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
|
||||||
{
|
{
|
||||||
bool nextcmd = false;
|
bool nextcmd = false;
|
||||||
bool zoom_command = false;
|
bool zoom_command = false;
|
||||||
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
||||||
bool currItemOnly = false;
|
|
||||||
|
|
||||||
if ( block->GetCommand() == BLOCK_DRAG && GetScreen()->GetCurItem() != NULL )
|
wxLogDebug( wxT( "Block end command %d, state %d, count %d" ),
|
||||||
currItemOnly = true;
|
block->GetCommand(), block->GetState(), block->GetCount() );
|
||||||
|
|
||||||
if( block->GetCount() )
|
if( block->GetCount() )
|
||||||
{
|
{
|
||||||
BLOCK_STATE_T state = block->GetState();
|
BLOCK_STATE_T state = block->GetState();
|
||||||
BLOCK_COMMAND_T command = block->GetCommand();
|
BLOCK_COMMAND_T command = block->GetCommand();
|
||||||
|
|
||||||
m_canvas->CallEndMouseCapture( DC );
|
m_canvas->CallEndMouseCapture( aDC );
|
||||||
|
|
||||||
block->SetState( state );
|
block->SetState( state );
|
||||||
block->SetCommand( command );
|
block->SetCommand( command );
|
||||||
|
@ -231,7 +222,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
||||||
|
|
||||||
case BLOCK_ROTATE:
|
case BLOCK_ROTATE:
|
||||||
GetScreen()->UpdatePickList();
|
GetScreen()->UpdatePickList();
|
||||||
DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
|
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
|
||||||
|
|
||||||
if( block->GetCount() )
|
if( block->GetCount() )
|
||||||
{
|
{
|
||||||
|
@ -243,25 +234,28 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
||||||
RotateListOfItems( block->GetItems(), rotationPoint );
|
RotateListOfItems( block->GetItems(), rotationPoint );
|
||||||
OnModify();
|
OnModify();
|
||||||
}
|
}
|
||||||
|
|
||||||
block->ClearItemsList();
|
block->ClearItemsList();
|
||||||
GetScreen()->TestDanglingEnds( m_canvas, DC );
|
GetScreen()->TestDanglingEnds( m_canvas, aDC );
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_DRAG: /* Drag */
|
case BLOCK_DRAG:
|
||||||
GetScreen()->BreakSegmentsOnJunctions();
|
GetScreen()->BreakSegmentsOnJunctions();
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
case BLOCK_MOVE:
|
case BLOCK_MOVE:
|
||||||
case BLOCK_COPY:
|
case BLOCK_COPY:
|
||||||
if( currItemOnly )
|
if( GetScreen()->GetCurItem() != NULL )
|
||||||
{
|
{
|
||||||
ITEM_PICKER picker;
|
ITEM_PICKER picker;
|
||||||
picker.SetItem( GetScreen()->GetCurItem() );
|
picker.SetItem( GetScreen()->GetCurItem() );
|
||||||
block->PushItem( picker );
|
block->PushItem( picker );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
GetScreen()->UpdatePickList();
|
GetScreen()->UpdatePickList();
|
||||||
|
}
|
||||||
// fall through
|
// fall through
|
||||||
|
|
||||||
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
case BLOCK_PRESELECT_MOVE: /* Move with preselection list*/
|
||||||
|
@ -269,21 +263,21 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
||||||
{
|
{
|
||||||
nextcmd = true;
|
nextcmd = true;
|
||||||
GetScreen()->SelectBlockItems();
|
GetScreen()->SelectBlockItems();
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
|
||||||
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
|
m_canvas->SetMouseCaptureCallback( DrawMovingBlockOutlines );
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
|
||||||
block->SetState( STATE_BLOCK_MOVE );
|
block->SetState( STATE_BLOCK_MOVE );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
|
||||||
m_canvas->SetMouseCapture( NULL, NULL );
|
m_canvas->SetMouseCapture( NULL, NULL );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_DELETE: /* Delete */
|
case BLOCK_DELETE:
|
||||||
GetScreen()->UpdatePickList();
|
GetScreen()->UpdatePickList();
|
||||||
DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
|
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
|
||||||
|
|
||||||
if( block->GetCount() )
|
if( block->GetCount() )
|
||||||
{
|
{
|
||||||
|
@ -291,13 +285,13 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
||||||
OnModify();
|
OnModify();
|
||||||
}
|
}
|
||||||
block->ClearItemsList();
|
block->ClearItemsList();
|
||||||
GetScreen()->TestDanglingEnds( m_canvas, DC );
|
GetScreen()->TestDanglingEnds( m_canvas, aDC );
|
||||||
m_canvas->Refresh();
|
m_canvas->Refresh();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_SAVE: /* Save */
|
case BLOCK_SAVE:
|
||||||
GetScreen()->UpdatePickList();
|
GetScreen()->UpdatePickList();
|
||||||
DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
|
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
|
||||||
|
|
||||||
if( block->GetCount() )
|
if( block->GetCount() )
|
||||||
{
|
{
|
||||||
|
@ -313,10 +307,48 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
||||||
block->SetState( STATE_BLOCK_MOVE );
|
block->SetState( STATE_BLOCK_MOVE );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLOCK_ZOOM: /* Window Zoom */
|
case BLOCK_ZOOM:
|
||||||
zoom_command = true;
|
zoom_command = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BLOCK_MIRROR_X:
|
||||||
|
GetScreen()->UpdatePickList();
|
||||||
|
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
|
||||||
|
|
||||||
|
if( block->GetCount() )
|
||||||
|
{
|
||||||
|
// Compute the mirror center and put it on grid.
|
||||||
|
wxPoint mirrorPoint = block->Centre();
|
||||||
|
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
||||||
|
SetCrossHairPosition( mirrorPoint );
|
||||||
|
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_X, mirrorPoint );
|
||||||
|
MirrorX( block->GetItems(), mirrorPoint );
|
||||||
|
OnModify();
|
||||||
|
}
|
||||||
|
|
||||||
|
GetScreen()->TestDanglingEnds( m_canvas, aDC );
|
||||||
|
m_canvas->Refresh();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BLOCK_MIRROR_Y:
|
||||||
|
GetScreen()->UpdatePickList();
|
||||||
|
DrawAndSizingBlockOutlines( m_canvas, aDC, wxDefaultPosition, false );
|
||||||
|
|
||||||
|
if( block->GetCount() )
|
||||||
|
{
|
||||||
|
// Compute the mirror center and put it on grid.
|
||||||
|
wxPoint mirrorPoint = block->Centre();
|
||||||
|
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
||||||
|
SetCrossHairPosition( mirrorPoint );
|
||||||
|
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_Y, mirrorPoint );
|
||||||
|
MirrorY( block->GetItems(), mirrorPoint );
|
||||||
|
OnModify();
|
||||||
|
}
|
||||||
|
|
||||||
|
GetScreen()->TestDanglingEnds( m_canvas, aDC );
|
||||||
|
m_canvas->Refresh();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -344,158 +376,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::HandleBlockEndByPopUp( int Command, wxDC* DC )
|
|
||||||
{
|
|
||||||
bool blockCmdFinished = true; /* set to false for block command which
|
|
||||||
* have a next step
|
|
||||||
* and true if the block command is finished here
|
|
||||||
*/
|
|
||||||
BLOCK_SELECTOR* block = &GetScreen()->m_BlockLocate;
|
|
||||||
|
|
||||||
// can convert only a block move command to an other command
|
|
||||||
if( block->GetCommand() != BLOCK_MOVE )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Useless if the new command is block move because we are already in block move.
|
|
||||||
if( Command == BLOCK_MOVE )
|
|
||||||
return;
|
|
||||||
|
|
||||||
block->SetCommand( (BLOCK_COMMAND_T) Command );
|
|
||||||
block->SetMessageBlock( this );
|
|
||||||
|
|
||||||
switch( block->GetCommand() )
|
|
||||||
{
|
|
||||||
case BLOCK_COPY: /* move to copy */
|
|
||||||
block->SetState( STATE_BLOCK_MOVE );
|
|
||||||
blockCmdFinished = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLOCK_DRAG: /* move to Drag */
|
|
||||||
if( m_canvas->IsMouseCaptured() )
|
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
|
||||||
|
|
||||||
// Clear list of items to move, and rebuild it with items to drag:
|
|
||||||
block->ClearItemsList();
|
|
||||||
|
|
||||||
GetScreen()->BreakSegmentsOnJunctions();
|
|
||||||
GetScreen()->UpdatePickList();
|
|
||||||
|
|
||||||
if( block->GetCount() )
|
|
||||||
{
|
|
||||||
blockCmdFinished = false;
|
|
||||||
GetScreen()->SelectBlockItems();
|
|
||||||
|
|
||||||
if( m_canvas->IsMouseCaptured() )
|
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
|
||||||
|
|
||||||
block->SetState( STATE_BLOCK_MOVE );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLOCK_DELETE: /* move to Delete */
|
|
||||||
if( m_canvas->IsMouseCaptured() )
|
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
|
||||||
|
|
||||||
if( block->GetCount() )
|
|
||||||
{
|
|
||||||
DeleteItemsInList( m_canvas, block->GetItems() );
|
|
||||||
OnModify();
|
|
||||||
}
|
|
||||||
|
|
||||||
GetScreen()->TestDanglingEnds( m_canvas, DC );
|
|
||||||
m_canvas->Refresh();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLOCK_SAVE: /* Save list in paste buffer*/
|
|
||||||
if( m_canvas->IsMouseCaptured() )
|
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
|
||||||
|
|
||||||
if( block->GetCount() )
|
|
||||||
{
|
|
||||||
wxPoint move_vector = -GetScreen()->m_BlockLocate.GetLastCursorPosition();
|
|
||||||
copyBlockItems( block->GetItems() );
|
|
||||||
MoveItemsInList( m_blockItems.GetItems(), move_vector );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLOCK_ZOOM: /* Window Zoom */
|
|
||||||
m_canvas->CallEndMouseCapture( DC );
|
|
||||||
m_canvas->SetCursor( (wxStockCursor) m_canvas->GetDefaultCursor() );
|
|
||||||
Window_Zoom( GetScreen()->m_BlockLocate );
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case BLOCK_ROTATE:
|
|
||||||
if( m_canvas->IsMouseCaptured() )
|
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
|
||||||
|
|
||||||
if( block->GetCount() )
|
|
||||||
{
|
|
||||||
/* Compute the rotation center and put it on grid */
|
|
||||||
wxPoint rotationPoint = block->Centre();
|
|
||||||
rotationPoint = GetNearestGridPosition( rotationPoint );
|
|
||||||
SetCrossHairPosition( rotationPoint );
|
|
||||||
SaveCopyInUndoList( block->GetItems(), UR_ROTATED, rotationPoint );
|
|
||||||
RotateListOfItems( block->GetItems(), rotationPoint );
|
|
||||||
OnModify();
|
|
||||||
}
|
|
||||||
|
|
||||||
GetScreen()->TestDanglingEnds( m_canvas, DC );
|
|
||||||
m_canvas->Refresh();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLOCK_MIRROR_X:
|
|
||||||
if( m_canvas->IsMouseCaptured() )
|
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
|
||||||
|
|
||||||
if( block->GetCount() )
|
|
||||||
{
|
|
||||||
/* Compute the mirror center and put it on grid */
|
|
||||||
wxPoint mirrorPoint = block->Centre();
|
|
||||||
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
|
||||||
SetCrossHairPosition( mirrorPoint );
|
|
||||||
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_X, mirrorPoint );
|
|
||||||
MirrorX( block->GetItems(), mirrorPoint );
|
|
||||||
OnModify();
|
|
||||||
}
|
|
||||||
|
|
||||||
GetScreen()->TestDanglingEnds( m_canvas, DC );
|
|
||||||
m_canvas->Refresh();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BLOCK_MIRROR_Y:
|
|
||||||
if( m_canvas->IsMouseCaptured() )
|
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
|
||||||
|
|
||||||
if( block->GetCount() )
|
|
||||||
{
|
|
||||||
/* Compute the mirror center and put it on grid */
|
|
||||||
wxPoint mirrorPoint = block->Centre();
|
|
||||||
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
|
||||||
SetCrossHairPosition( mirrorPoint );
|
|
||||||
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_Y, mirrorPoint );
|
|
||||||
MirrorY( block->GetItems(), mirrorPoint );
|
|
||||||
OnModify();
|
|
||||||
}
|
|
||||||
|
|
||||||
GetScreen()->TestDanglingEnds( m_canvas, DC );
|
|
||||||
m_canvas->Refresh();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( blockCmdFinished )
|
|
||||||
{
|
|
||||||
block->Clear();
|
|
||||||
GetScreen()->SetCurItem( NULL );
|
|
||||||
m_canvas->EndMouseCapture( GetToolId(), m_canvas->GetCurrentCursor(), wxEmptyString,
|
|
||||||
false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Traces the outline of the search block structures
|
/* Traces the outline of the search block structures
|
||||||
* The entire block follows the cursor
|
* The entire block follows the cursor
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -183,9 +183,9 @@ static EDA_HOTKEY HkCopyComponentOrText( wxT( "Copy Component or Label" ),
|
||||||
ID_POPUP_SCH_COPY_ITEM );
|
ID_POPUP_SCH_COPY_ITEM );
|
||||||
|
|
||||||
static EDA_HOTKEY HkDrag( wxT( "Drag Item" ), HK_DRAG, 'G', ID_SCH_DRAG_ITEM );
|
static EDA_HOTKEY HkDrag( wxT( "Drag Item" ), HK_DRAG, 'G', ID_SCH_DRAG_ITEM );
|
||||||
static EDA_HOTKEY HkSaveBlock( wxT( "Save Block" ), HK_SAVE_BLOCK, 'C' + GR_KB_CTRL );
|
static EDA_HOTKEY HkSaveBlock( wxT( "Save Block" ), HK_SAVE_BLOCK, 'C' + GR_KB_CTRL, wxID_COPY );
|
||||||
static EDA_HOTKEY HkMove2Drag( wxT( "Move Block -> Drag Block" ),
|
static EDA_HOTKEY HkMove2Drag( wxT( "Move Block -> Drag Block" ),
|
||||||
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t' );
|
HK_MOVEBLOCK_TO_DRAGBLOCK, '\t', ID_POPUP_DRAG_BLOCK );
|
||||||
static EDA_HOTKEY HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
|
static EDA_HOTKEY HkInsert( wxT( "Repeat Last Item" ), HK_REPEAT_LAST, WXK_INSERT );
|
||||||
static EDA_HOTKEY HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE );
|
static EDA_HOTKEY HkDelete( wxT( "Delete Item" ), HK_DELETE, WXK_DELETE );
|
||||||
|
|
||||||
|
@ -367,18 +367,12 @@ void SCH_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotKey, const wxPoint& aPosition,
|
||||||
case HK_ZOOM_REDRAW:
|
case HK_ZOOM_REDRAW:
|
||||||
case HK_ZOOM_CENTER:
|
case HK_ZOOM_CENTER:
|
||||||
case HK_ZOOM_AUTO:
|
case HK_ZOOM_AUTO:
|
||||||
|
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
|
||||||
|
case HK_SAVE_BLOCK: // Copy block to clip board.
|
||||||
cmd.SetId( hotKey->m_IdMenuEvent );
|
cmd.SetId( hotKey->m_IdMenuEvent );
|
||||||
GetEventHandler()->ProcessEvent( cmd );
|
GetEventHandler()->ProcessEvent( cmd );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HK_MOVEBLOCK_TO_DRAGBLOCK: // Switch to drag mode, when block moving
|
|
||||||
HandleBlockEndByPopUp( BLOCK_DRAG, aDC );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HK_SAVE_BLOCK:
|
|
||||||
HandleBlockEndByPopUp( BLOCK_SAVE, aDC );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HK_DELETE:
|
case HK_DELETE:
|
||||||
if( notBusy )
|
if( notBusy )
|
||||||
DeleteItemAtCrossHair( aDC );
|
DeleteItemAtCrossHair( aDC );
|
||||||
|
|
|
@ -127,7 +127,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
|
screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
|
||||||
|
screen->m_BlockLocate.SetMessageBlock( this );
|
||||||
|
HandleBlockEnd( &dc );
|
||||||
SetRepeatItem( NULL );
|
SetRepeatItem( NULL );
|
||||||
SetSheetNumberAndCount();
|
SetSheetNumberAndCount();
|
||||||
break;
|
break;
|
||||||
|
@ -314,7 +316,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxID_COPY: // really this is a Save block for paste
|
case wxID_COPY: // really this is a Save block for paste
|
||||||
HandleBlockEndByPopUp( BLOCK_SAVE, &dc );
|
screen->m_BlockLocate.SetCommand( BLOCK_SAVE );
|
||||||
|
screen->m_BlockLocate.SetMessageBlock( this );
|
||||||
|
HandleBlockEnd( &dc );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_PLACE_BLOCK:
|
case ID_POPUP_PLACE_BLOCK:
|
||||||
|
@ -324,23 +328,31 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_ZOOM_BLOCK:
|
case ID_POPUP_ZOOM_BLOCK:
|
||||||
HandleBlockEndByPopUp( BLOCK_ZOOM, &dc );
|
screen->m_BlockLocate.SetCommand( BLOCK_ZOOM );
|
||||||
|
screen->m_BlockLocate.SetMessageBlock( this );
|
||||||
|
HandleBlockEnd( &dc );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_DELETE_BLOCK:
|
case ID_POPUP_DELETE_BLOCK:
|
||||||
m_canvas->MoveCursorToCrossHair();
|
m_canvas->MoveCursorToCrossHair();
|
||||||
HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
|
screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
|
||||||
|
screen->m_BlockLocate.SetMessageBlock( this );
|
||||||
|
HandleBlockEnd( &dc );
|
||||||
SetSheetNumberAndCount();
|
SetSheetNumberAndCount();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_COPY_BLOCK:
|
case ID_POPUP_COPY_BLOCK:
|
||||||
m_canvas->MoveCursorToCrossHair();
|
m_canvas->MoveCursorToCrossHair();
|
||||||
HandleBlockEndByPopUp( BLOCK_COPY, &dc );
|
screen->m_BlockLocate.SetCommand( BLOCK_COPY );
|
||||||
|
screen->m_BlockLocate.SetMessageBlock( this );
|
||||||
|
HandleBlockEnd( &dc );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_DRAG_BLOCK:
|
case ID_POPUP_DRAG_BLOCK:
|
||||||
m_canvas->MoveCursorToCrossHair();
|
m_canvas->MoveCursorToCrossHair();
|
||||||
HandleBlockEndByPopUp( BLOCK_DRAG, &dc );
|
screen->m_BlockLocate.SetCommand( BLOCK_DRAG );
|
||||||
|
screen->m_BlockLocate.SetMessageBlock( this );
|
||||||
|
HandleBlockEnd( &dc );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_SCH_ADD_JUNCTION:
|
case ID_POPUP_SCH_ADD_JUNCTION:
|
||||||
|
@ -736,7 +748,8 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
||||||
// Allows block rotate operation on hot key.
|
// Allows block rotate operation on hot key.
|
||||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||||
{
|
{
|
||||||
HandleBlockEndByPopUp( BLOCK_ROTATE, &dc );
|
screen->m_BlockLocate.SetCommand( BLOCK_ROTATE );
|
||||||
|
HandleBlockEnd( &dc );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,7 +775,7 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
case SCH_COMPONENT_T:
|
case SCH_COMPONENT_T:
|
||||||
if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
|
if( aEvent.GetId() == ID_SCH_ROTATE_CLOCKWISE )
|
||||||
OrientComponent( CMP_ROTATE_CLOCKWISE );
|
OrientComponent( CMP_ROTATE_CLOCKWISE );
|
||||||
else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
|
else if( aEvent.GetId() == ID_SCH_ROTATE_COUNTERCLOCKWISE )
|
||||||
OrientComponent( CMP_ROTATE_COUNTERCLOCKWISE );
|
OrientComponent( CMP_ROTATE_COUNTERCLOCKWISE );
|
||||||
else
|
else
|
||||||
|
@ -818,6 +831,7 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
||||||
// Set the locat filter, according to the edit command
|
// Set the locat filter, according to the edit command
|
||||||
const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
|
const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
|
||||||
const KICAD_T* filterListAux = NULL;
|
const KICAD_T* filterListAux = NULL;
|
||||||
|
|
||||||
switch( aEvent.GetId() )
|
switch( aEvent.GetId() )
|
||||||
{
|
{
|
||||||
case ID_SCH_EDIT_COMPONENT_REFERENCE:
|
case ID_SCH_EDIT_COMPONENT_REFERENCE:
|
||||||
|
@ -838,13 +852,12 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
item = LocateAndShowItem( data->GetPosition(), filterList,
|
|
||||||
aEvent.GetInt() );
|
item = LocateAndShowItem( data->GetPosition(), filterList, aEvent.GetInt() );
|
||||||
|
|
||||||
// If no item found, and if an auxiliary filter exists, try to use it
|
// If no item found, and if an auxiliary filter exists, try to use it
|
||||||
if( !item && filterListAux )
|
if( !item && filterListAux )
|
||||||
item = LocateAndShowItem( data->GetPosition(), filterListAux,
|
item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
|
||||||
aEvent.GetInt() );
|
|
||||||
|
|
||||||
// Exit if no item found at the current location or the item is already being edited.
|
// Exit if no item found at the current location or the item is already being edited.
|
||||||
if( (item == NULL) || (item->GetFlags() != 0) )
|
if( (item == NULL) || (item->GetFlags() != 0) )
|
||||||
|
@ -988,11 +1001,23 @@ void SCH_EDIT_FRAME::OnOrient( wxCommandEvent& aEvent )
|
||||||
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
|
||||||
{
|
{
|
||||||
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
if( aEvent.GetId() == ID_SCH_MIRROR_X )
|
||||||
HandleBlockEndByPopUp( BLOCK_MIRROR_X, &dc );
|
{
|
||||||
|
m_canvas->MoveCursorToCrossHair();
|
||||||
|
screen->m_BlockLocate.SetMessageBlock( this );
|
||||||
|
screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_X );
|
||||||
|
HandleBlockEnd( &dc );
|
||||||
|
}
|
||||||
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
else if( aEvent.GetId() == ID_SCH_MIRROR_Y )
|
||||||
HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc );
|
{
|
||||||
|
m_canvas->MoveCursorToCrossHair();
|
||||||
|
screen->m_BlockLocate.SetMessageBlock( this );
|
||||||
|
screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_Y );
|
||||||
|
HandleBlockEnd( &dc );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
|
wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1135,17 +1135,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void InitBlockPasteInfos();
|
void InitBlockPasteInfos();
|
||||||
|
|
||||||
/* Function HandleBlockEndByPopUp
|
|
||||||
* performs an end block command from context menu.
|
|
||||||
*
|
|
||||||
* This can be called only after HandleBlockEnd and the current command is block
|
|
||||||
* move. Execute a command other than block move from the current block move
|
|
||||||
* selected items list. Due to (minor) problems in undo/redo or/and display block,
|
|
||||||
* a mirror/rotate command is immediately executed and multiple block commands are
|
|
||||||
* not allowed (multiple commands are tricky to undo/redo in one time)
|
|
||||||
*/
|
|
||||||
void HandleBlockEndByPopUp( int Command, wxDC* DC );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ReturnBlockCommand
|
* Function ReturnBlockCommand
|
||||||
* Returns the block command internat code (BLOCK_MOVE, BLOCK_COPY...)
|
* Returns the block command internat code (BLOCK_MOVE, BLOCK_COPY...)
|
||||||
|
@ -1172,10 +1161,12 @@ public:
|
||||||
* depending on the current block command, this command is executed
|
* depending on the current block command, this command is executed
|
||||||
* or parameters are initialized to prepare a call to HandleBlockPlace
|
* or parameters are initialized to prepare a call to HandleBlockPlace
|
||||||
* in GetScreen()->m_BlockLocate
|
* in GetScreen()->m_BlockLocate
|
||||||
|
*
|
||||||
|
* @param aDC is a device context to draw on.
|
||||||
* @return false if no item selected, or command finished,
|
* @return false if no item selected, or command finished,
|
||||||
* true if some items found and HandleBlockPlace must be called later
|
* true if some items found and HandleBlockPlace must be called later
|
||||||
*/
|
*/
|
||||||
virtual bool HandleBlockEnd( wxDC* DC );
|
virtual bool HandleBlockEnd( wxDC* aDC );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function RepeatDrawItem
|
* Function RepeatDrawItem
|
||||||
|
|
Loading…
Reference in New Issue