From d88126e519c198c79926d6e381fe357e39ace5c0 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 19 Apr 2019 01:00:54 +0100 Subject: [PATCH] Tidy up and fix end sheet command. --- eeschema/sch_edit_frame.cpp | 6 ++-- eeschema/schedit.cpp | 53 ++--------------------------- eeschema/tools/sch_drawing_tool.cpp | 11 ++++++ 3 files changed, 16 insertions(+), 54 deletions(-) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index fbfaaf5eca..83b09ad41b 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -287,10 +287,8 @@ BEGIN_EVENT_TABLE( SCH_EDIT_FRAME, EDA_DRAW_FRAME ) // Tools and buttons for vertical toolbar. EVT_TOOL( ID_NO_TOOL_SELECTED, SCH_EDIT_FRAME::OnSelectTool ) - EVT_TOOL_RANGE( ID_SCHEMATIC_VERTICAL_TOOLBAR_START, ID_SCHEMATIC_VERTICAL_TOOLBAR_END, - SCH_EDIT_FRAME::OnSelectTool ) - EVT_TOOL_RANGE( ID_SCHEMATIC_PLACE_MENU_START, ID_SCHEMATIC_PLACE_MENU_END, - SCH_EDIT_FRAME::OnSelectTool ) + EVT_TOOL( ID_SCHEMATIC_DELETE_ITEM_BUTT, SCH_EDIT_FRAME::OnSelectTool ) + EVT_TOOL( ID_MENU_DELETE_ITEM_BUTT, SCH_EDIT_FRAME::OnSelectTool ) #ifdef KICAD_SPICE EVT_TOOL( ID_SIM_SHOW, SCH_EDIT_FRAME::OnSimulate ) diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index b42dffc361..fbd66f9a11 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -161,6 +161,7 @@ break; case ID_POPUP_END_LINE: + case ID_POPUP_SCH_END_SHEET: m_toolManager->RunAction( SCH_ACTIONS::finishDrawing, true ); break; @@ -200,11 +201,6 @@ OnModify(); break; - case ID_POPUP_SCH_END_SHEET: - m_canvas->MoveCursorToCrossHair(); - AddItemToScreen( item ); - break; - case ID_POPUP_SCH_CLEANUP_SHEET: if( item != NULL && item->Type() == SCH_SHEET_T ) { @@ -466,51 +462,8 @@ void SCH_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent ) // Stop the current command and deselect the current tool. m_canvas->EndMouseCapture( ID_NO_TOOL_SELECTED, GetGalCanvas()->GetDefaultCursor() ); - switch( id ) - { - case ID_HIGHLIGHT_BUTT: - case ID_MENU_NOCONN_BUTT: - case ID_NOCONN_BUTT: - case ID_MENU_JUNCTION_BUTT: - case ID_JUNCTION_BUTT: - case ID_MENU_LABEL_BUTT: - case ID_LABEL_BUTT: - case ID_MENU_GLABEL_BUTT: - case ID_GLOBALLABEL_BUTT: - case ID_MENU_HIERLABEL_BUTT: - case ID_HIERLABEL_BUTT: - case ID_MENU_TEXT_COMMENT_BUTT: - case ID_TEXT_COMMENT_BUTT: - case ID_MENU_ADD_IMAGE_BUTT: - case ID_ADD_IMAGE_BUTT: - case ID_MENU_WIRETOBUS_ENTRY_BUTT: - case ID_WIRETOBUS_ENTRY_BUTT: - case ID_MENU_BUSTOBUS_ENTRY_BUTT: - case ID_BUSTOBUS_ENTRY_BUTT: - case ID_MENU_PLACE_COMPONENT: - case ID_SCH_PLACE_COMPONENT: - case ID_MENU_PLACE_POWER_BUTT: - case ID_PLACE_POWER_BUTT: - case ID_MENU_WIRE_BUTT: - case ID_WIRE_BUTT: - case ID_MENU_BUS_BUTT: - case ID_BUS_BUTT: - case ID_MENU_LINE_COMMENT_BUTT: - case ID_LINE_COMMENT_BUTT: - case ID_ZOOM_SELECTION: - case ID_MENU_SHEET_SYMBOL_BUTT: - case ID_SHEET_SYMBOL_BUTT: - case ID_MENU_SHEET_PIN_BUTT: - case ID_SHEET_PIN_BUTT: - case ID_MENU_IMPORT_HLABEL_BUTT: - case ID_IMPORT_HLABEL_BUTT: - // moved to modern toolset - return; - default: - // since legacy tools don't activate themsleves, we have to deactivate any modern - // tools that might be running until all the legacy tools are moved over.... - m_toolManager->DeactivateTool(); - } + // Same for modern toolset. + m_toolManager->DeactivateTool(); switch( id ) { diff --git a/eeschema/tools/sch_drawing_tool.cpp b/eeschema/tools/sch_drawing_tool.cpp index fcaf6e79c2..2fb6e9b0e8 100644 --- a/eeschema/tools/sch_drawing_tool.cpp +++ b/eeschema/tools/sch_drawing_tool.cpp @@ -1275,6 +1275,17 @@ int SCH_DRAWING_TOOL::doDrawSheet( SCH_SHEET *aSheet ) m_frame->GetScreen()->SetCurItem( nullptr ); } } + else if( evt->IsAction( &SCH_ACTIONS::finishDrawing ) ) + { + if( aSheet ) + { + m_frame->AddItemToScreen( aSheet ); + aSheet = nullptr; + + m_view->ClearPreview(); + m_frame->GetScreen()->SetCurItem( nullptr ); + } + } else if( evt->IsMotion() ) { m_view->ClearPreview();