Commit 48129681 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: Fix a minor issue in block command

Very minor code cleaning
parents 5cda6bc1 30c7e318
......@@ -139,7 +139,7 @@ EDA_DRAW_FRAME::EDA_DRAW_FRAME( wxWindow* father, int idtype, const wxString& ti
GetTextSize( wxT( "dx 0234.567890 dx 0234.567890 d 0234.567890" ), stsbar ).x + 10,
// units display, Inches is bigger than mm
GetTextSize( wxT( "Inches" ), stsbar ).x + 10,
GetTextSize( _( "Inches" ), stsbar ).x + 10,
FUNCTION_DISPLAY_SIZE,
};
......@@ -428,11 +428,11 @@ void EDA_DRAW_FRAME::DisplayUnitsMsg()
break;
case MILLIMETRES:
msg += _( "mm" );
msg = _( "mm" );
break;
default:
msg += _( "Units" );
msg = _( "Units" );
break;
}
......
......@@ -66,7 +66,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
int SCH_EDIT_FRAME::ReturnBlockCommand( int key )
{
int cmd;
int cmd = BLOCK_IDLE;
switch( key )
{
......@@ -78,11 +78,14 @@ int SCH_EDIT_FRAME::ReturnBlockCommand( int key )
cmd = BLOCK_MOVE;
break;
case GR_KB_ALT:
case GR_KB_SHIFT:
cmd = BLOCK_COPY;
break;
case GR_KB_ALT:
cmd = BLOCK_ROTATE;
break;
case GR_KB_CTRL:
cmd = BLOCK_DRAG;
break;
......@@ -130,12 +133,6 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
switch( block->GetCommand() )
{
case BLOCK_IDLE:
break;
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_DRAG: /* Drag */
case BLOCK_MOVE: /* Move */
if( m_canvas->IsMouseCaptured() )
......@@ -167,12 +164,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
block->ClearItemsList();
break;
case BLOCK_ZOOM: // Handled by HandleBlockEnd()
case BLOCK_DELETE:
case BLOCK_SAVE:
case BLOCK_FLIP:
case BLOCK_ABORT:
case BLOCK_SELECT_ITEMS_ONLY:
default: // others are handled by HandleBlockEnd()
break;
}
......@@ -225,15 +217,31 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
DisplayError( this, wxT( "Error in HandleBlockPLace()" ) );
break;
case BLOCK_ROTATE:
GetScreen()->UpdatePickList();
DrawAndSizingBlockOutlines( m_canvas, DC, wxDefaultPosition, false );
if( block->GetCount() )
{
// Compute the rotation center and put it on grid:
wxPoint rotationPoint = block->Centre();
rotationPoint = GetScreen()->GetNearestGridPosition( rotationPoint );
GetScreen()->SetCrossHairPosition( rotationPoint );
SaveCopyInUndoList( block->GetItems(), UR_ROTATED, rotationPoint );
RotateListOfItems( block->GetItems(), rotationPoint );
OnModify();
}
block->ClearItemsList();
GetScreen()->TestDanglingEnds( m_canvas, DC );
m_canvas->Refresh();
break;
case BLOCK_DRAG: /* Drag */
GetScreen()->BreakSegmentsOnJunctions();
// fall through
case BLOCK_ROTATE:
case BLOCK_MIRROR_X:
case BLOCK_MIRROR_Y:
case BLOCK_MOVE: /* Move */
case BLOCK_COPY: /* Copy */
case BLOCK_MOVE:
case BLOCK_COPY:
GetScreen()->UpdatePickList();
// fall through
......@@ -263,7 +271,6 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
DeleteItemsInList( m_canvas, block->GetItems() );
OnModify();
}
block->ClearItemsList();
GetScreen()->TestDanglingEnds( m_canvas, DC );
m_canvas->Refresh();
......@@ -291,9 +298,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
zoom_command = true;
break;
case BLOCK_FLIP: /* Pcbnew only! */
case BLOCK_SELECT_ITEMS_ONLY: /* Not used */
case BLOCK_ABORT: /* not executed here */
default:
break;
}
}
......
......@@ -44,7 +44,7 @@ static void DrawMovingBlockOutlines( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wx
int LIB_EDIT_FRAME::ReturnBlockCommand( int key )
{
int cmd;
int cmd = BLOCK_IDLE;
switch( key )
{
......@@ -60,11 +60,14 @@ int LIB_EDIT_FRAME::ReturnBlockCommand( int key )
cmd = BLOCK_MOVE;
break;
case GR_KB_ALT:
case GR_KB_SHIFT:
cmd = BLOCK_COPY;
break;
case GR_KB_ALT:
cmd = BLOCK_ROTATE;
break;
case GR_KB_SHIFTCTRL:
cmd = BLOCK_DELETE;
break;
......@@ -168,7 +171,8 @@ bool LIB_EDIT_FRAME::HandleBlockEnd( wxDC* DC )
SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.Centre();
pt.y *= -1;
pt = GetScreen()->GetNearestGridPosition( pt );
NEGATE( pt.y );
if ( m_component )
{
......@@ -253,7 +257,7 @@ void LIB_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
SaveCopyInUndoList( m_component );
pt = GetScreen()->m_BlockLocate.GetMoveVector();
pt.y *= -1;
NEGATE( pt.y );
if ( m_component )
m_component->CopySelectedItems( pt );
......
......@@ -104,7 +104,7 @@ void GERBVIEW_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aH
if( aHotKey )
{
OnHotKey( aDC, aHotKey, NULL );
OnHotKey( aDC, aHotKey, aPosition );
}
UpdateStatusBar();
......
......@@ -476,10 +476,15 @@ public:
void OnQuit( wxCommandEvent& event );
/**
* Function OnHotKey
* called when on hotkey trigger
* Function OnHotKey.
* ** Commands are case insensitive **
* Some commands are relatives to the item under the mouse cursor
* @param aDC = current device context
* @param aHotkeyCode = hotkey code (ascii or wxWidget code for special keys)
* @param aPosition The cursor position in logical (drawing) units.
* @param aItem = NULL or pointer on a EDA_ITEM under the mouse cursor
*/
void OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct );
void OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem = NULL );
GERBER_DRAW_ITEM* GerberGeneralLocateAndDisplay();
GERBER_DRAW_ITEM* Locate( const wxPoint& aPosition, int typeloc );
......@@ -548,17 +553,6 @@ public:
*/
void ToPrinter( wxCommandEvent& event );
/* void Genere_HPGL( const wxString& FullFileName, int Layers );
* void Genere_GERBER( const wxString& FullFileName, int Layers );
* void Genere_PS( const wxString& FullFileName, int Layers );
* void Plot_Layer_HPGL( FILE* File, int masque_layer, int garde, bool trace_via,
* EDA_DRAW_MODE_T trace_mode );
* void Plot_Layer_GERBER( FILE* File, int masque_layer, int garde, bool trace_via,
* EDA_DRAW_MODE_T trace_mode );
* int Gen_D_CODE_File( const wxString& Name_File );
* void Plot_Layer_PS( FILE* File, int masque_layer, int garde, bool trace_via,
* EDA_DRAW_MODE_T trace_mode );
*/
void Files_io( wxCommandEvent& event );
/**
......
......@@ -71,23 +71,26 @@ struct EDA_HOTKEY_CONFIG s_Gerbview_Hokeys_Descr[] =
};
/* Hot keys. Some commands are relatives to the item under the mouse cursor
* Commands are case insensitive
* @param DC = current device context
* @param hotkey = hotkey code (ascii or wxWidget code for special keys)
* @param DrawStruct = NULL or pointer on a EDA_ITEM under the mouse cursor
/*
* Function OnHotKey.
* ** Commands are case insensitive **
* Some commands are relatives to the item under the mouse cursor
* aDC = current device context
* aHotkeyCode = hotkey code (ascii or wxWidget code for special keys)
* aPosition The cursor position in logical (drawing) units.
* aItem = NULL or pointer on a EDA_ITEM under the mouse cursor
*/
void GERBVIEW_FRAME::OnHotKey( wxDC* DC, int hotkey, EDA_ITEM* DrawStruct )
void GERBVIEW_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosition, EDA_ITEM* aItem )
{
wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED );
cmd.SetEventObject( this );
/* Convert lower to upper case (the usual toupper function has problem with non ascii
* codes like function keys */
if( (hotkey >= 'a') && (hotkey <= 'z') )
hotkey += 'A' - 'a';
if( (aHotkeyCode >= 'a') && (aHotkeyCode <= 'z') )
aHotkeyCode += 'A' - 'a';
EDA_HOTKEY * HK_Descr = GetDescriptorFromHotkey( hotkey, s_Gerbview_Hotkey_List );
EDA_HOTKEY * HK_Descr = GetDescriptorFromHotkey( aHotkeyCode, s_Gerbview_Hotkey_List );
if( HK_Descr == NULL )
return;
......
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