diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index a398f68c2a..1c99f9210f 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -471,6 +471,18 @@ public: */ bool OnHotkeyRotateItem( int aIdCommand ); + /** + * Function OnHotkeyBeginRoute + * If the current active layer is a copper layer, + * and if no item currently edited, start a new track segmenton + * the current copper layer. + * If a new track is in progress, terminate the current segment and + * start a new one. + * @param aDC = current device context + * @return a reference to the track if a track is created, or NULL + */ + TRACK * OnHotkeyBeginRoute( wxDC* aDC ); + void OnCloseWindow( wxCloseEvent& Event ); void Process_Special_Functions( wxCommandEvent& event ); void Tracks_and_Vias_Size_Event( wxCommandEvent& event ); diff --git a/pcbnew/edit.cpp b/pcbnew/edit.cpp index b948611e9a..e9299160d1 100644 --- a/pcbnew/edit.cpp +++ b/pcbnew/edit.cpp @@ -56,9 +56,6 @@ #include -// Uncomment following line to enable wxBell() command (which beeps speaker) -// #include - /* Handles the selection of command events. */ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) { @@ -94,6 +91,7 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) case ID_POPUP_PCB_EDIT_MODULE: case ID_POPUP_PCB_EDIT_TEXTMODULE: case ID_POPUP_PCB_STOP_CURRENT_DRAWING: + case ID_POPUP_PCB_BEGIN_TRACK: case ID_POPUP_PCB_END_TRACK: case ID_POPUP_PCB_PLACE_VIA: case ID_POPUP_PCB_SWITCH_TRACK_POSTURE: @@ -342,6 +340,11 @@ void PCB_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event ) m_canvas->MoveCursorToCrossHair(); break; + case ID_POPUP_PCB_BEGIN_TRACK: + m_canvas->MoveCursorToCrossHair(); + OnHotkeyBeginRoute( &dc ); + break; + case ID_POPUP_PCB_END_TRACK: m_canvas->MoveCursorToCrossHair(); End_Route( (TRACK*) GetCurItem(), &dc ); @@ -1225,14 +1228,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, int layer ) if( GetBoard()->GetCopperLayerCount() < 2 ) { if( layer != LAYER_N_BACK ) - { - // Uncomment following command (and line 17) to beep - // the speaker. (Doing that would provide feedback to - // the user that the (layer-switching) command has been - // "acknowledged", but is unable to be acted upon.) -// wxBell(); return; - } } // If more than one copper layer is enabled, the "Copper" // and "Component" layers can be selected, but the total @@ -1242,14 +1238,7 @@ void PCB_EDIT_FRAME::SwitchLayer( wxDC* DC, int layer ) { if( ( layer != LAYER_N_BACK ) && ( layer != LAYER_N_FRONT ) && ( layer >= GetBoard()->GetCopperLayerCount() - 1 ) ) - { - // Uncomment following command (and line 17) to beep - // the speaker. (Doing that would provide feedback to - // the user that the (layer-switching) command has been - // "acknowledged", but is unable to be acted upon.) -// wxBell(); return; - } } EDA_ITEM* current = GetScreen()->GetCurItem(); diff --git a/pcbnew/event_handlers_tracks_vias_sizes.cpp b/pcbnew/event_handlers_tracks_vias_sizes.cpp index 3d4b797084..fd1966840d 100644 --- a/pcbnew/event_handlers_tracks_vias_sizes.cpp +++ b/pcbnew/event_handlers_tracks_vias_sizes.cpp @@ -58,6 +58,14 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) case ID_POPUP_PCB_SELECT_WIDTH6: case ID_POPUP_PCB_SELECT_WIDTH7: case ID_POPUP_PCB_SELECT_WIDTH8: + case ID_POPUP_PCB_SELECT_WIDTH9: + case ID_POPUP_PCB_SELECT_WIDTH10: + case ID_POPUP_PCB_SELECT_WIDTH11: + case ID_POPUP_PCB_SELECT_WIDTH12: + case ID_POPUP_PCB_SELECT_WIDTH13: + case ID_POPUP_PCB_SELECT_WIDTH14: + case ID_POPUP_PCB_SELECT_WIDTH15: + case ID_POPUP_PCB_SELECT_WIDTH16: m_canvas->MoveCursorToCrossHair(); GetDesignSettings().m_UseConnectedTrackWidth = false; ii = id - ID_POPUP_PCB_SELECT_WIDTH1; @@ -71,7 +79,16 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) case ID_POPUP_PCB_SELECT_VIASIZE5: case ID_POPUP_PCB_SELECT_VIASIZE6: case ID_POPUP_PCB_SELECT_VIASIZE7: - case ID_POPUP_PCB_SELECT_VIASIZE8: // select the new current value for via size (via diameter) + case ID_POPUP_PCB_SELECT_VIASIZE8: + case ID_POPUP_PCB_SELECT_VIASIZE9: + case ID_POPUP_PCB_SELECT_VIASIZE10: + case ID_POPUP_PCB_SELECT_VIASIZE11: + case ID_POPUP_PCB_SELECT_VIASIZE12: + case ID_POPUP_PCB_SELECT_VIASIZE13: + case ID_POPUP_PCB_SELECT_VIASIZE14: + case ID_POPUP_PCB_SELECT_VIASIZE15: + case ID_POPUP_PCB_SELECT_VIASIZE16: + // select the new current value for via size (via diameter) m_canvas->MoveCursorToCrossHair(); ii = id - ID_POPUP_PCB_SELECT_VIASIZE1; GetBoard()->m_ViaSizeSelector = ii; @@ -91,4 +108,12 @@ void PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event( wxCommandEvent& event ) wxMessageBox( wxT( "PCB_EDIT_FRAME::Tracks_and_Vias_Size_Event() error") ); break; } + + // Refresh track in progress, if any, by forcing a mouse event, + // to call the current function attached to the mouse + if( m_canvas->IsMouseCaptured() ) + { + wxMouseEvent event(wxEVT_MOTION); + wxPostEvent( m_canvas, event ); + } } diff --git a/pcbnew/hotkeys.h b/pcbnew/hotkeys.h index d2aa0afbc6..98e18fb565 100644 --- a/pcbnew/hotkeys.h +++ b/pcbnew/hotkeys.h @@ -59,26 +59,28 @@ enum hotkey_id_commnand { HK_SWITCH_LAYER_TO_INNER14, HK_ADD_MODULE, HK_SLIDE_TRACK, - HK_RECORD_MACROS_0, - HK_CALL_MACROS_0, - HK_RECORD_MACROS_1, - HK_CALL_MACROS_1, + HK_MACRO_ID_BEGIN, + HK_RECORD_MACROS_0, // keep these id ordered from 0 to 9 + HK_RECORD_MACROS_1, // because this order is used in code HK_RECORD_MACROS_2, - HK_CALL_MACROS_2, HK_RECORD_MACROS_3, - HK_CALL_MACROS_3, HK_RECORD_MACROS_4, - HK_CALL_MACROS_4, HK_RECORD_MACROS_5, - HK_CALL_MACROS_5, HK_RECORD_MACROS_6, - HK_CALL_MACROS_6, HK_RECORD_MACROS_7, - HK_CALL_MACROS_7, HK_RECORD_MACROS_8, - HK_CALL_MACROS_8, HK_RECORD_MACROS_9, + HK_CALL_MACROS_0, + HK_CALL_MACROS_1, + HK_CALL_MACROS_2, + HK_CALL_MACROS_3, + HK_CALL_MACROS_4, + HK_CALL_MACROS_5, + HK_CALL_MACROS_6, + HK_CALL_MACROS_7, + HK_CALL_MACROS_8, HK_CALL_MACROS_9, + HK_MACRO_ID_END, HK_SWITCH_HIGHCONTRAST_MODE, }; diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index b428ce3986..331d336552 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -24,9 +24,8 @@ void PCB_EDIT_FRAME::RecordMacros(wxDC* aDC, int aNumber) { - assert( aNumber >= 0 ); - assert( aNumber < 10 ); - wxString msg, tmp; + wxASSERT( aNumber >= 0 && aNumber < 10 ); + wxString msg; if( m_RecordingMacros < 0 ) { @@ -34,14 +33,14 @@ void PCB_EDIT_FRAME::RecordMacros(wxDC* aDC, int aNumber) m_Macros[aNumber].m_StartPosition = GetScreen()->GetCrossHairPosition( false ); m_Macros[aNumber].m_Record.clear(); - msg.Printf( wxT( "%s %d" ), _( "Recording macros" ), aNumber ); + msg.Printf( _( "Recording macro %d" ), aNumber ); SetStatusText( msg ); } else { m_RecordingMacros = -1; - msg.Printf( wxT( "%s %d %s" ), _( "Macros" ), aNumber, _( "recorded" ) ); + msg.Printf( _( "Macro %d recorded" ), aNumber ); SetStatusText( msg ); } } @@ -54,7 +53,7 @@ void PCB_EDIT_FRAME::CallMacros( wxDC* aDC, const wxPoint& aPosition, int aNumbe wxString msg; - msg.Printf( wxT( "%s %d" ), _( "Call macros" ), aNumber ); + msg.Printf( _( "Call macro %d" ), aNumber ); SetStatusText( msg ); wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); @@ -110,27 +109,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit if( HK_Descr == NULL ) return; - if( (m_RecordingMacros != -1) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_1) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_1) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_2) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_2) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_3) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_3) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_4) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_4) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_5) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_5) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_6) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_6) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_7) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_7) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_8) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_8) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_9) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_9) - && (HK_Descr->m_Idcommand != HK_RECORD_MACROS_0) - && (HK_Descr->m_Idcommand != HK_CALL_MACROS_0) ) + int hk_id = HK_Descr->m_Idcommand; + + if( (m_RecordingMacros != -1) && + !( hk_id > HK_MACRO_ID_BEGIN && hk_id < HK_MACRO_ID_END) ) { MACROS_RECORD macros_record; macros_record.m_HotkeyCode = aHotkeyCode; @@ -138,6 +120,9 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit macros_record.m_Position = screen->GetNearestGridPosition( aPosition ) - m_Macros[m_RecordingMacros].m_StartPosition; m_Macros[m_RecordingMacros].m_Record.push_back( macros_record ); + wxString msg; + msg.Printf( _( "Add key [%c] in macro %d" ), aHotkeyCode, m_RecordingMacros ); + SetStatusText( msg ); } // Create a wxCommandEvent that will be posted in some hot keys functions @@ -147,7 +132,7 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit int ll; unsigned int cnt; - switch( HK_Descr->m_Idcommand ) + switch( hk_id ) { default: case HK_NOT_FOUND: @@ -155,83 +140,30 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit break; case HK_RECORD_MACROS_0: - RecordMacros( aDC, 0 ); - break; - case HK_RECORD_MACROS_1: - RecordMacros( aDC, 1 ); - break; - case HK_RECORD_MACROS_2: - RecordMacros( aDC, 2 ); - break; - case HK_RECORD_MACROS_3: - RecordMacros( aDC, 3 ); - break; - case HK_RECORD_MACROS_4: - RecordMacros( aDC, 4 ); - break; - case HK_RECORD_MACROS_5: - RecordMacros( aDC, 5 ); - break; - case HK_RECORD_MACROS_6: - RecordMacros( aDC, 6 ); - break; - case HK_RECORD_MACROS_7: - RecordMacros( aDC, 7 ); - break; - case HK_RECORD_MACROS_8: - RecordMacros( aDC, 8 ); - break; - case HK_RECORD_MACROS_9: - RecordMacros( aDC, 9 ); + RecordMacros( aDC, hk_id - HK_RECORD_MACROS_0 ); break; case HK_CALL_MACROS_0: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 0 ); - break; - case HK_CALL_MACROS_1: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 1 ); - break; - case HK_CALL_MACROS_2: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 2 ); - break; - case HK_CALL_MACROS_3: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 3 ); - break; - case HK_CALL_MACROS_4: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 4 ); - break; - case HK_CALL_MACROS_5: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 5 ); - break; - case HK_CALL_MACROS_6: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 6 ); - break; - case HK_CALL_MACROS_7: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 7 ); - break; - case HK_CALL_MACROS_8: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 8 ); - break; - case HK_CALL_MACROS_9: - CallMacros( aDC, screen->GetCrossHairPosition( false ), 9 ); + CallMacros( aDC, screen->GetCrossHairPosition( false ), + hk_id - HK_CALL_MACROS_0 ); break; case HK_SWITCH_TRACK_WIDTH_TO_NEXT: @@ -551,39 +483,8 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit OnHotkeyPlaceItem( aDC ); break; - case HK_ADD_NEW_TRACK: // Start new track - if( getActiveLayer() > LAYER_N_FRONT ) - break; - - if( GetToolId() != ID_TRACK_BUTT && !itemCurrentlyEdited ) - { - cmd.SetId( ID_TRACK_BUTT ); - GetEventHandler()->ProcessEvent( cmd ); - } - - if( GetToolId() != ID_TRACK_BUTT ) - break; - - if( !itemCurrentlyEdited ) // no track in progress: - { - TRACK* track = Begin_Route( NULL, aDC ); - SetCurItem( track ); - - if( track ) - m_canvas->SetAutoPanRequest( true ); - } - else if( GetCurItem()->IsNew() ) - { - TRACK* track = Begin_Route( (TRACK*) GetCurItem(), aDC ); - - // SetCurItem() must not write to the msg panel - // because a track info is displayed while moving the mouse cursor - if( track ) // A new segment was created - SetCurItem( track, false ); - - m_canvas->SetAutoPanRequest( true ); - } - + case HK_ADD_NEW_TRACK: // Start new track, if possible + OnHotkeyBeginRoute( aDC ); break; case HK_EDIT_ITEM: // Edit board item @@ -1017,6 +918,58 @@ bool PCB_EDIT_FRAME::OnHotkeyPlaceItem( wxDC* aDC ) return false; } +/* + * Function OnHotkeyBeginRoute + * If the current active layer is a copper layer, + * and if no item currently edited, starta new track on + * the current copper layer + * If a new track is in progress, terminate the current segment and + * start a new one. + * Returns a reference to the track if a track is created, or NULL + */ +TRACK * PCB_EDIT_FRAME::OnHotkeyBeginRoute( wxDC* aDC ) +{ + if( getActiveLayer() > LAYER_N_FRONT ) + return NULL; + + bool itemCurrentlyEdited = (GetCurItem() && GetCurItem()->GetFlags()); + + // Ensure the track tool is active + if( GetToolId() != ID_TRACK_BUTT && !itemCurrentlyEdited ) + { + wxCommandEvent cmd( wxEVT_COMMAND_MENU_SELECTED ); + cmd.SetEventObject( this ); + cmd.SetId( ID_TRACK_BUTT ); + GetEventHandler()->ProcessEvent( cmd ); + } + + if( GetToolId() != ID_TRACK_BUTT ) + return NULL; + + TRACK* track = NULL; + + if( !itemCurrentlyEdited ) // no track in progress: + { + track = Begin_Route( NULL, aDC ); + SetCurItem( track ); + + if( track ) + m_canvas->SetAutoPanRequest( true ); + } + else if( GetCurItem()->IsNew() ) + { + track = Begin_Route( (TRACK*) GetCurItem(), aDC ); + + // SetCurItem() must not write to the msg panel + // because a track info is displayed while moving the mouse cursor + if( track ) // A new segment was created + SetCurItem( track, false ); + + m_canvas->SetAutoPanRequest( true ); + } + + return track; +} bool PCB_EDIT_FRAME::OnHotkeyRotateItem( int aIdCommand ) { diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 9d2111589a..5b6eeccf98 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -336,11 +336,19 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) break; case ID_TRACK_BUTT: + aPopMenu->AppendSeparator(); + if ( ! locate_track ) // This menu is already added when a track is located + { + msg = AddHotkeyName( _( "Begin Track" ), + g_Board_Editor_Hokeys_Descr, HK_ADD_NEW_TRACK ); + AddMenuItem( aPopMenu, ID_POPUP_PCB_BEGIN_TRACK, + msg, KiBitmap( add_tracks_xpm ) ); + AddMenuItem( aPopMenu, Append_Track_Width_List( GetBoard() ), ID_POPUP_PCB_SELECT_WIDTH, _( "Select Track Width" ), KiBitmap( width_track_xpm ) ); - + } AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_CU_LAYER, _( "Select Working Layer" ), KiBitmap( select_w_layer_xpm ) ); AddMenuItem( aPopMenu, ID_POPUP_PCB_SELECT_LAYER_PAIR, @@ -401,6 +409,11 @@ bool PCB_EDIT_FRAME::OnRightClick( const wxPoint& aMousePos, wxMenu* aPopMenu ) aPopMenu->AppendSeparator(); } + msg = AddHotkeyName( _( "Begin Track" ), + g_Board_Editor_Hokeys_Descr, HK_ADD_NEW_TRACK ); + AddMenuItem( aPopMenu, ID_POPUP_PCB_BEGIN_TRACK, + msg, KiBitmap( add_tracks_xpm ) ); + if( locate_track ) AddMenuItem( aPopMenu, Append_Track_Width_List( GetBoard() ), ID_POPUP_PCB_SELECT_WIDTH, _( "Select Track Width" ), @@ -487,6 +500,11 @@ void PCB_EDIT_FRAME::createPopupMenuForTracks( TRACK* Track, wxMenu* PopMenu ) { if( flags & IS_NEW ) { + msg = AddHotkeyName( _( "Begin Track" ), + g_Board_Editor_Hokeys_Descr, HK_ADD_NEW_TRACK ); + AddMenuItem( PopMenu, ID_POPUP_PCB_BEGIN_TRACK, + msg, KiBitmap( add_tracks_xpm ) ); + msg = AddHotkeyName( _( "End Track" ), g_Board_Editor_Hokeys_Descr, HK_END_TRACK ); AddMenuItem( PopMenu, ID_POPUP_PCB_END_TRACK, msg, KiBitmap( apply_xpm ) ); } diff --git a/pcbnew/pcbnew_id.h b/pcbnew/pcbnew_id.h index bed0fb40f2..685e872f57 100644 --- a/pcbnew/pcbnew_id.h +++ b/pcbnew/pcbnew_id.h @@ -78,6 +78,7 @@ enum pcbnew_ids ID_POPUP_PCB_DELETE_DRAWING_LAYER, ID_POPUP_PCB_END_LINE, + ID_POPUP_PCB_BEGIN_TRACK, ID_POPUP_PCB_EDIT_TRACK, ID_POPUP_PCB_DELETE_TRACK, ID_POPUP_PCB_DELETE_TRACKNET, @@ -175,6 +176,14 @@ enum pcbnew_ids ID_POPUP_PCB_SELECT_WIDTH6, ID_POPUP_PCB_SELECT_WIDTH7, ID_POPUP_PCB_SELECT_WIDTH8, + ID_POPUP_PCB_SELECT_WIDTH9, + ID_POPUP_PCB_SELECT_WIDTH10, + ID_POPUP_PCB_SELECT_WIDTH11, + ID_POPUP_PCB_SELECT_WIDTH12, + ID_POPUP_PCB_SELECT_WIDTH13, + ID_POPUP_PCB_SELECT_WIDTH14, + ID_POPUP_PCB_SELECT_WIDTH15, + ID_POPUP_PCB_SELECT_WIDTH16, ID_POPUP_PCB_SELECT_VIASIZE, ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE2, @@ -184,6 +193,14 @@ enum pcbnew_ids ID_POPUP_PCB_SELECT_VIASIZE6, ID_POPUP_PCB_SELECT_VIASIZE7, ID_POPUP_PCB_SELECT_VIASIZE8, + ID_POPUP_PCB_SELECT_VIASIZE9, + ID_POPUP_PCB_SELECT_VIASIZE10, + ID_POPUP_PCB_SELECT_VIASIZE11, + ID_POPUP_PCB_SELECT_VIASIZE12, + ID_POPUP_PCB_SELECT_VIASIZE13, + ID_POPUP_PCB_SELECT_VIASIZE14, + ID_POPUP_PCB_SELECT_VIASIZE15, + ID_POPUP_PCB_SELECT_VIASIZE16, ID_POPUP_PCB_SELECT_WIDTH_END_RANGE, // reserve a block of MAX_ITEMS_IN_PICKER ids for the item selection popup