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
This commit is contained in:
Mike Williams 2022-12-15 10:26:48 -05:00
parent 8db015bc0f
commit 389f0655cd
13 changed files with 275 additions and 22 deletions

View File

@ -482,6 +482,7 @@ void BuildBitmapInfo( std::unordered_map<BITMAPS, std::vector<BITMAP_INFO>>& 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<BITMAPS, std::vector<BITMAP_INFO>>& 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" ) );

View File

@ -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
//

View File

@ -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;

View File

@ -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 );

View File

@ -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<SCH_LINE*> 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() );

View File

@ -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 );

View File

@ -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<bool>();
}
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 );

View File

@ -525,6 +525,7 @@ enum class BITMAPS : unsigned int
sim_stop,
sim_tune,
simulator,
slice_line,
small_down,
small_edit,
small_folder,

View File

@ -459,6 +459,7 @@ set( BMAPS_MID
sim_tune
sim_probe
sim_add_signal
slice_line
search_tree
set_origin
show_dcodenumber

Binary file not shown.

After

Width:  |  Height:  |  Size: 356 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 B

View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
id="Слой_1"
data-name="Слой 1"
viewBox="0 0 24 24"
version="1.1"
sodipodi:docname="slice_line.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1049"
id="namedview30"
showgrid="true"
inkscape:zoom="11.053739"
inkscape:cx="12.077361"
inkscape:cy="3.6639185"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:document-rotation="0"
inkscape:current-layer="Слой_1"
inkscape:pagecheckerboard="0">
<inkscape:grid
type="xygrid"
id="grid_kicad"
spacingx="0.5"
spacingy="0.5"
color="#9999ff"
opacity="0.13"
empspacing="2" />
</sodipodi:namedview>
<metadata
id="metadata43">
<rdf:RDF>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>break_line</dc:title>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<defs
id="defs116256">
<style
id="style116254">.cls-1,.cls-2,.cls-3,.cls-4{fill:none;stroke-linecap:round;stroke-linejoin:round;}.cls-1,.cls-2{stroke:#8f8f8f;stroke-width:0.5px;}.cls-2{stroke-dasharray:1.662 1.662;}.cls-3{stroke:#DED3DD;}.cls-4{stroke:#42B8EB;}.cls-5{fill:#DED3DD;}</style>
</defs>
<title
id="title116258">break_line</title>
<line
class="cls-3"
x1="2"
y1="12.010201"
x2="10"
y2="12.007999"
id="line116272"
style="opacity:1;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none" />
<path
id="line116274"
style="fill:none;stroke:#42B8EB;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none"
d="m 14,12 8,0.008"
sodipodi:nodetypes="cc" />
<path
id="line11"
style="fill:none;stroke:#42b8eb;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 16.5,16.5 -9,-9"
sodipodi:nodetypes="cc" />
<path
id="line9"
style="fill:none;stroke:#42b8eb;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 16.5,7.5 -9,9"
sodipodi:nodetypes="cc" />
<path
class="cls-5"
d="m 14,11.5 v 10.763724 l 2.388017,-2.246815 c 0.313049,0.729733 0.771993,1.807325 1.173453,2.748038 0.26289,0.615616 0.975695,0.90077 1.590646,0.636332 v 0 c 0.613964,-0.262516 0.899148,-0.972818 0.637179,-1.587016 -0.401388,-0.940895 -0.860899,-2.020203 -1.174642,-2.752127 l 3.274221,-0.180982 z"
id="path116278"
sodipodi:nodetypes="ccccsscccc"
style="stroke-width:1" />
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
id="Слой_1"
data-name="Слой 1"
viewBox="0 0 24 24"
version="1.1"
sodipodi:docname="slice_line.svg"
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1049"
id="namedview30"
showgrid="true"
inkscape:zoom="31.264696"
inkscape:cx="7.9802471"
inkscape:cy="14.089374"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:document-rotation="0"
inkscape:current-layer="Слой_1"
inkscape:pagecheckerboard="0">
<inkscape:grid
type="xygrid"
id="grid_kicad"
spacingx="0.5"
spacingy="0.5"
color="#9999ff"
opacity="0.13"
empspacing="2" />
</sodipodi:namedview>
<metadata
id="metadata43">
<rdf:RDF>
<cc:Work
rdf:about="">
<cc:license
rdf:resource="http://creativecommons.org/licenses/by-sa/4.0/" />
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>break_line</dc:title>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/4.0/">
<cc:permits
rdf:resource="http://creativecommons.org/ns#Reproduction" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#Distribution" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Notice" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#Attribution" />
<cc:permits
rdf:resource="http://creativecommons.org/ns#DerivativeWorks" />
<cc:requires
rdf:resource="http://creativecommons.org/ns#ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<defs
id="defs116256">
<style
id="style116254">.cls-1,.cls-2,.cls-3,.cls-4{fill:none;stroke-linecap:round;stroke-linejoin:round;}.cls-1,.cls-2{stroke:#b9b9b9;stroke-width:0.5px;}.cls-2{stroke-dasharray:1.662 1.662;}.cls-3{stroke:#545454;}.cls-4{stroke:#1a81c4;}.cls-5{fill:#545454;}</style>
</defs>
<title
id="title116258">break_line</title>
<line
class="cls-3"
x1="2"
y1="12.010201"
x2="10"
y2="12.007999"
id="line116272"
style="opacity:1;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none" />
<path
id="line116274"
style="fill:none;stroke:#1a81c4;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none"
d="m 14,12 8,0.008"
sodipodi:nodetypes="cc" />
<path
id="line11"
style="fill:none;stroke:#1a81c4;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 16.5,16.5 -9,-9"
sodipodi:nodetypes="cc" />
<path
class="cls-5"
d="m 14,11.5 v 10.763724 l 2.388017,-2.246815 c 0.313049,0.729733 0.771993,1.807325 1.173453,2.748038 0.26289,0.615616 0.975695,0.90077 1.590646,0.636332 v 0 c 0.613964,-0.262516 0.899148,-0.972818 0.637179,-1.587016 -0.401388,-0.940895 -0.860899,-2.020203 -1.174642,-2.752127 l 3.274221,-0.180982 z"
id="path116278"
sodipodi:nodetypes="ccccsscccc"
style="stroke-width:1" />
<path
id="line9"
style="fill:none;stroke:#1a81c4;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 16.5,7.5 -9,9"
sodipodi:nodetypes="cc" />
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB