Commit efb96bcc authored by Wayne Stambaugh's avatar Wayne Stambaugh

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.
parent bec78be1
This diff is collapsed.
......@@ -183,9 +183,9 @@ static EDA_HOTKEY HkCopyComponentOrText( wxT( "Copy Component or Label" ),
ID_POPUP_SCH_COPY_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" ),
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 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_CENTER:
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 );
GetEventHandler()->ProcessEvent( cmd );
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:
if( notBusy )
DeleteItemAtCrossHair( aDC );
......
......@@ -127,7 +127,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
if( screen->m_BlockLocate.GetCommand() != BLOCK_MOVE )
break;
HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
screen->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
SetRepeatItem( NULL );
SetSheetNumberAndCount();
break;
......@@ -314,7 +316,9 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
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;
case ID_POPUP_PLACE_BLOCK:
......@@ -324,23 +328,31 @@ void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_ZOOM_BLOCK:
HandleBlockEndByPopUp( BLOCK_ZOOM, &dc );
screen->m_BlockLocate.SetCommand( BLOCK_ZOOM );
screen->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
break;
case ID_POPUP_DELETE_BLOCK:
m_canvas->MoveCursorToCrossHair();
HandleBlockEndByPopUp( BLOCK_DELETE, &dc );
screen->m_BlockLocate.SetCommand( BLOCK_DELETE );
screen->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
SetSheetNumberAndCount();
break;
case ID_POPUP_COPY_BLOCK:
m_canvas->MoveCursorToCrossHair();
HandleBlockEndByPopUp( BLOCK_COPY, &dc );
screen->m_BlockLocate.SetCommand( BLOCK_COPY );
screen->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
break;
case ID_POPUP_DRAG_BLOCK:
m_canvas->MoveCursorToCrossHair();
HandleBlockEndByPopUp( BLOCK_DRAG, &dc );
screen->m_BlockLocate.SetCommand( BLOCK_DRAG );
screen->m_BlockLocate.SetMessageBlock( this );
HandleBlockEnd( &dc );
break;
case ID_POPUP_SCH_ADD_JUNCTION:
......@@ -736,7 +748,8 @@ void SCH_EDIT_FRAME::OnRotate( wxCommandEvent& aEvent )
// Allows block rotate operation on hot key.
if( screen->m_BlockLocate.GetState() != STATE_NO_BLOCK )
{
HandleBlockEndByPopUp( BLOCK_ROTATE, &dc );
screen->m_BlockLocate.SetCommand( BLOCK_ROTATE );
HandleBlockEnd( &dc );
return;
}
......@@ -818,6 +831,7 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
// Set the locat filter, according to the edit command
const KICAD_T* filterList = SCH_COLLECTOR::EditableItems;
const KICAD_T* filterListAux = NULL;
switch( aEvent.GetId() )
{
case ID_SCH_EDIT_COMPONENT_REFERENCE:
......@@ -838,13 +852,12 @@ void SCH_EDIT_FRAME::OnEditItem( wxCommandEvent& aEvent )
default:
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( !item && filterListAux )
item = LocateAndShowItem( data->GetPosition(), filterListAux,
aEvent.GetInt() );
item = LocateAndShowItem( data->GetPosition(), filterListAux, aEvent.GetInt() );
// Exit if no item found at the current location or the item is already being edited.
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( 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 )
HandleBlockEndByPopUp( BLOCK_MIRROR_Y, &dc );
{
m_canvas->MoveCursorToCrossHair();
screen->m_BlockLocate.SetMessageBlock( this );
screen->m_BlockLocate.SetCommand( BLOCK_MIRROR_Y );
HandleBlockEnd( &dc );
}
else
{
wxFAIL_MSG( wxT( "Unknown block oriention command ID." ) );
}
return;
}
......
......@@ -1135,17 +1135,6 @@ public:
*/
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
* 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
* or parameters are initialized to prepare a call to HandleBlockPlace
* in GetScreen()->m_BlockLocate
*
* @param aDC is a device context to draw on.
* @return false if no item selected, or command finished,
* true if some items found and HandleBlockPlace must be called later
*/
virtual bool HandleBlockEnd( wxDC* DC );
virtual bool HandleBlockEnd( wxDC* aDC );
/**
* Function RepeatDrawItem
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment