From 389f0655cde98b89054b00ff60fbc5a47d170085 Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Thu, 15 Dec 2022 10:26:48 -0500 Subject: [PATCH] Schematic: re-enable old break wire functionality, add slice Also fix break/slice wires for multiple wires. The shortcut and code always allowed it, the context menu just didn't appear. Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13163 --- common/bitmap_info.cpp | 2 + eeschema/tools/ee_actions.cpp | 9 +- eeschema/tools/ee_actions.h | 2 +- eeschema/tools/ee_selection_tool.cpp | 8 +- eeschema/tools/sch_edit_tool.cpp | 34 ++++-- eeschema/tools/sch_line_wire_bus_tool.cpp | 4 +- eeschema/tools/sch_move_tool.cpp | 12 +- include/bitmaps/bitmaps_list.h | 1 + resources/bitmaps_png/CMakeLists.txt | 1 + resources/bitmaps_png/png/slice_line_24.png | Bin 0 -> 356 bytes .../bitmaps_png/png/slice_line_dark_24.png | Bin 0 -> 375 bytes .../bitmaps_png/sources/dark/slice_line.svg | 112 ++++++++++++++++++ .../bitmaps_png/sources/light/slice_line.svg | 112 ++++++++++++++++++ 13 files changed, 275 insertions(+), 22 deletions(-) create mode 100644 resources/bitmaps_png/png/slice_line_24.png create mode 100644 resources/bitmaps_png/png/slice_line_dark_24.png create mode 100644 resources/bitmaps_png/sources/dark/slice_line.svg create mode 100644 resources/bitmaps_png/sources/light/slice_line.svg diff --git a/common/bitmap_info.cpp b/common/bitmap_info.cpp index bc98636835..afcb2b2a83 100644 --- a/common/bitmap_info.cpp +++ b/common/bitmap_info.cpp @@ -482,6 +482,7 @@ void BuildBitmapInfo( std::unordered_map>& aBi aBitmapInfoCache[BITMAPS::sim_tune].emplace_back( BITMAPS::sim_tune, wxT( "sim_tune_24.png" ), 24, wxT( "light" ) ); aBitmapInfoCache[BITMAPS::sim_probe].emplace_back( BITMAPS::sim_probe, wxT( "sim_probe_24.png" ), 24, wxT( "light" ) ); aBitmapInfoCache[BITMAPS::sim_add_signal].emplace_back( BITMAPS::sim_add_signal, wxT( "sim_add_signal_24.png" ), 24, wxT( "light" ) ); + aBitmapInfoCache[BITMAPS::slice_line].emplace_back( BITMAPS::slice_line, wxT( "slice_line_24.png" ), 24, wxT( "light" ) ); aBitmapInfoCache[BITMAPS::search_tree].emplace_back( BITMAPS::search_tree, wxT( "search_tree_24.png" ), 24, wxT( "light" ) ); aBitmapInfoCache[BITMAPS::set_origin].emplace_back( BITMAPS::set_origin, wxT( "set_origin_24.png" ), 24, wxT( "light" ) ); aBitmapInfoCache[BITMAPS::show_dcodenumber].emplace_back( BITMAPS::show_dcodenumber, wxT( "show_dcodenumber_24.png" ), 24, wxT( "light" ) ); @@ -864,6 +865,7 @@ void BuildBitmapInfo( std::unordered_map>& aBi aBitmapInfoCache[BITMAPS::sim_tune].emplace_back( BITMAPS::sim_tune, wxT( "sim_tune_dark_24.png" ), 24, wxT( "dark" ) ); aBitmapInfoCache[BITMAPS::sim_probe].emplace_back( BITMAPS::sim_probe, wxT( "sim_probe_dark_24.png" ), 24, wxT( "dark" ) ); aBitmapInfoCache[BITMAPS::sim_add_signal].emplace_back( BITMAPS::sim_add_signal, wxT( "sim_add_signal_dark_24.png" ), 24, wxT( "dark" ) ); + aBitmapInfoCache[BITMAPS::slice_line].emplace_back( BITMAPS::slice_line, wxT( "slice_line_dark_24.png" ), 24, wxT( "dark" ) ); aBitmapInfoCache[BITMAPS::search_tree].emplace_back( BITMAPS::search_tree, wxT( "search_tree_dark_24.png" ), 24, wxT( "dark" ) ); aBitmapInfoCache[BITMAPS::set_origin].emplace_back( BITMAPS::set_origin, wxT( "set_origin_dark_24.png" ), 24, wxT( "dark" ) ); aBitmapInfoCache[BITMAPS::show_dcodenumber].emplace_back( BITMAPS::show_dcodenumber, wxT( "show_dcodenumber_dark_24.png" ), 24, wxT( "dark" ) ); diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 5f2ef86eb2..1a284c944a 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -555,14 +555,13 @@ TOOL_ACTION EE_ACTIONS::pinTable( "eeschema.InteractiveEdit.pinTable", TOOL_ACTION EE_ACTIONS::breakWire( "eeschema.InteractiveEdit.breakWire", AS_GLOBAL, 0, "", - _( "Break Wire" ), _( "Divide a wire into segments which can be dragged independently" ), + _( "Break" ), _( "Divide into connected segments" ), BITMAPS::break_line ); -TOOL_ACTION EE_ACTIONS::breakBus( "eeschema.InteractiveEdit.breakBus", +TOOL_ACTION EE_ACTIONS::slice( "eeschema.InteractiveEdit.slice", AS_GLOBAL, 0, "", - _( "Break Bus" ), _( "Divide a bus into segments which can be dragged independently" ), - BITMAPS::break_line ); - + _( "Slice" ), _( "Divide into unconnected segments" ), + BITMAPS::slice_line ); // SCH_EDITOR_CONTROL // diff --git a/eeschema/tools/ee_actions.h b/eeschema/tools/ee_actions.h index 9cc5da381e..ecfbf40e33 100644 --- a/eeschema/tools/ee_actions.h +++ b/eeschema/tools/ee_actions.h @@ -144,7 +144,7 @@ public: static TOOL_ACTION toText; static TOOL_ACTION toTextBox; static TOOL_ACTION breakWire; - static TOOL_ACTION breakBus; + static TOOL_ACTION slice; static TOOL_ACTION pointEditorAddCorner; static TOOL_ACTION pointEditorRemoveCorner; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 2a97a12c4e..aadec9ce55 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -179,8 +179,8 @@ bool EE_SELECTION_TOOL::Init() m_isSymbolViewer = symbolViewerFrame != nullptr; } - auto wireSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_WIRE_T } ); - auto busSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_BUS_T }); + auto linesSelection = E_C::MoreThan( 0 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T, + SCH_ITEM_LOCATE_GRAPHIC_LINE_T } ); auto wireOrBusSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } ); auto connectedSelection = E_C::Count( 1 ) && E_C::OnlyTypes( connectedTypes ); auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } ); @@ -266,8 +266,8 @@ bool EE_SELECTION_TOOL::Init() menu.AddItem( EE_ACTIONS::placeClassLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 ); - menu.AddItem( EE_ACTIONS::breakWire, wireSelection && EE_CONDITIONS::Idle, 250 ); - menu.AddItem( EE_ACTIONS::breakBus, busSelection && EE_CONDITIONS::Idle, 250 ); + menu.AddItem( EE_ACTIONS::breakWire, linesSelection && EE_CONDITIONS::Idle, 250 ); + menu.AddItem( EE_ACTIONS::slice, linesSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::importSingleSheetPin, sheetSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::assignNetclass, connectedSelection && EE_CONDITIONS::Idle, 250 ); menu.AddItem( EE_ACTIONS::editPageNumber, schEditSheetPageNumberCondition, 250 ); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 3ef1d489b3..0cdc33948d 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -2195,7 +2195,8 @@ int SCH_EDIT_TOOL::ChangeTextType( const TOOL_EVENT& aEvent ) int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent ) { - VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() ); + bool isSlice = aEvent.Matches( EE_ACTIONS::slice.MakeEvent() ); + VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !aEvent.DisableGridSnapping() ); EE_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_LINE_T } ); std::vector lines; @@ -2214,11 +2215,30 @@ int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent ) for( SCH_LINE* line : lines ) { - m_frame->BreakSegment( line, cursorPos ); + SCH_LINE* newLine; - VECTOR2I v = line->GetEndPoint() - line->GetStartPoint(); - v = v.Resize( v.EuclideanNorm() - 10 ); - line->SetEndPoint( line->GetStartPoint() + v ); + // We let the user select the break point if they're on a single line + if( lines.size() == 1 && line->HitTest( cursorPos ) ) + m_frame->BreakSegment( line, cursorPos, &newLine ); + else + m_frame->BreakSegment( line, line->GetMidPoint(), &newLine ); + + // Make sure both endpoints are deselected + newLine->ClearFlags(); + + m_selectionTool->AddItemToSel( line ); + line->SetFlags( ENDPOINT ); + + // If we're a break, we want to drag both wires. + // Side note: the drag/move tool only checks whether the first item is + // new to determine if it should append undo or not, someday this should + // be cleaned up and explictly controlled but for now the newLine + // selection addition must be after the existing line. + if( !isSlice ) + { + m_selectionTool->AddItemToSel( newLine ); + newLine->SetFlags( STARTPOINT ); + } } if( !lines.empty() ) @@ -2228,7 +2248,7 @@ int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent ) m_frame->OnModify(); m_frame->GetCanvas()->Refresh(); - m_toolMgr->RunAction( EE_ACTIONS::drag ); + m_toolMgr->RunAction( EE_ACTIONS::drag, false, true ); } return 0; @@ -2367,7 +2387,7 @@ void SCH_EDIT_TOOL::setTransitions() Go( &SCH_EDIT_TOOL::ChangeTextType, EE_ACTIONS::toTextBox.MakeEvent() ); Go( &SCH_EDIT_TOOL::BreakWire, EE_ACTIONS::breakWire.MakeEvent() ); - Go( &SCH_EDIT_TOOL::BreakWire, EE_ACTIONS::breakBus.MakeEvent() ); + Go( &SCH_EDIT_TOOL::BreakWire, EE_ACTIONS::slice.MakeEvent() ); Go( &SCH_EDIT_TOOL::CleanupSheetPins, EE_ACTIONS::cleanupSheetPins.MakeEvent() ); Go( &SCH_EDIT_TOOL::GlobalEdit, EE_ACTIONS::editTextAndGraphics.MakeEvent() ); diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 44c0a2b96c..4b9d508bd0 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -247,8 +247,8 @@ bool SCH_LINE_WIRE_BUS_TOOL::Init() ctxMenu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); ctxMenu.AddItem( EE_ACTIONS::breakWire, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); - ctxMenu.AddItem( EE_ACTIONS::breakBus, wireOrBusTool && EE_CONDITIONS::Idle, 100 ); - + ctxMenu.AddItem( EE_ACTIONS::slice, ( wireOrBusTool || lineTool ) + && EE_CONDITIONS::Idle, 100 ); ctxMenu.AddSeparator( 200 ); ctxMenu.AddItem( EE_ACTIONS::selectNode, wireOrBusTool && EE_CONDITIONS::Idle, 200 ); ctxMenu.AddItem( EE_ACTIONS::selectConnection, wireOrBusTool && EE_CONDITIONS::Idle, 200 ); diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index f7e836b7be..b865e52a89 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -359,13 +359,17 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) KIGFX::VIEW_CONTROLS* controls = getViewControls(); EE_GRID_HELPER grid( m_toolMgr ); bool wasDragging = m_moveInProgress && m_isDrag; + bool isSlice = false; m_anchorPos.reset(); if( aEvent.IsAction( &EE_ACTIONS::move ) ) m_isDrag = false; else if( aEvent.IsAction( &EE_ACTIONS::drag ) ) + { m_isDrag = true; + isSlice = aEvent.Parameter(); + } else if( aEvent.IsAction( &EE_ACTIONS::moveActivate ) ) m_isDrag = !cfg->m_Input.drag_is_move; else @@ -455,7 +459,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) if( !m_moveInProgress ) // Prepare to start moving/dragging { SCH_ITEM* sch_item = (SCH_ITEM*) selection.Front(); - bool appendUndo = sch_item && sch_item->IsNew(); + bool appendUndo = ( sch_item && sch_item->IsNew() ) || isSlice; bool placingNewItems = sch_item && sch_item->IsNew(); //------------------------------------------------------------------------ @@ -475,7 +479,9 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) it->ClearFlags( STARTPOINT | ENDPOINT ); } - if( m_isDrag ) + // Drag of split items start over top of their other segment so + // we want to skip grabbing the segments we split from + if( m_isDrag && !isSlice ) { EDA_ITEMS connectedDragItems; @@ -895,7 +901,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) // This needs to run prior to `RecalculateConnections` because we need to identify // the lines that are newly dangling - if( m_isDrag ) + if( m_isDrag && !isSlice ) trimDanglingLines(); m_frame->RecalculateConnections( LOCAL_CLEANUP ); diff --git a/include/bitmaps/bitmaps_list.h b/include/bitmaps/bitmaps_list.h index 0264472dc8..0f00d9c7a1 100644 --- a/include/bitmaps/bitmaps_list.h +++ b/include/bitmaps/bitmaps_list.h @@ -525,6 +525,7 @@ enum class BITMAPS : unsigned int sim_stop, sim_tune, simulator, + slice_line, small_down, small_edit, small_folder, diff --git a/resources/bitmaps_png/CMakeLists.txt b/resources/bitmaps_png/CMakeLists.txt index bee4ec7693..38622b02ec 100644 --- a/resources/bitmaps_png/CMakeLists.txt +++ b/resources/bitmaps_png/CMakeLists.txt @@ -459,6 +459,7 @@ set( BMAPS_MID sim_tune sim_probe sim_add_signal + slice_line search_tree set_origin show_dcodenumber diff --git a/resources/bitmaps_png/png/slice_line_24.png b/resources/bitmaps_png/png/slice_line_24.png new file mode 100644 index 0000000000000000000000000000000000000000..3a520f74bb4688a783f6591531ffb263cdfc6629 GIT binary patch literal 356 zcmV-q0h|7bP)*VAJ7SQjLeNk!*NqXz0O^kdXhluzy7C ze}(F;U!evA@!{`^)!Y6f_*n5FxCKB%juEmzv3kolWDEQv;{K~tZop%~;iF^((a~Fy z&>#X?92^qz0qA>6>V!Wu%wb|M-vKT83be$P>d6!>7=HqB5LGi8mbm%@#EDcZDsUu- ze?VM7m9h#?s{0Zg9GpsZ3xE-QxuKzfiE5=S)ZjBfT!Unh71b;N<^JgCXujCkSZ<)f z@1YhfqnZW2zP?;YzUhWqaE>OG6Vw;Ez{u4`mjeKDwn;sUg?NGh0000ecg7)Ye{r5hpn$9D2fX-18)J@*GM+}-sQUof%rczeDUJF|Dn5I zeT5nf3YPETyI=lC@Uh}UNEX~XM#zG&Jukn(HE)0Q{rrV{|Ks-Jv*gWDl7q+@DTqK8 z-??=6!-Gq=EvXg$;4p`Y!F+f3^4+h%5OAe>GDQx;yO-|%1X>hC)r^KEuKoZmN~Bs* zfg?fuyMN_w0aeN>JgM%>y({-pX<@N7d@nA(;0ChagDt#tcNx_zcy{I)7s9eT-C$o_x_6Eyl@r7lcXDrEy{(Nd2LQL- V^A%bT&{zNf002ovPDHLkV1nrZt}Orn literal 0 HcmV?d00001 diff --git a/resources/bitmaps_png/sources/dark/slice_line.svg b/resources/bitmaps_png/sources/dark/slice_line.svg new file mode 100644 index 0000000000..00f369d68d --- /dev/null +++ b/resources/bitmaps_png/sources/dark/slice_line.svg @@ -0,0 +1,112 @@ + + + + + + + + + + image/svg+xml + + break_line + + + + + + + + + + + + + + + break_line + + + + + + diff --git a/resources/bitmaps_png/sources/light/slice_line.svg b/resources/bitmaps_png/sources/light/slice_line.svg new file mode 100644 index 0000000000..427dd30a03 --- /dev/null +++ b/resources/bitmaps_png/sources/light/slice_line.svg @@ -0,0 +1,112 @@ + + + + + + + + + + image/svg+xml + + break_line + + + + + + + + + + + + + + + break_line + + + + + +