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