diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index 4988728b14..60bc6c55bf 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -717,14 +717,14 @@ TOOL_ACTION EE_ACTIONS::addNeededJunctions( "eeschema.InteractiveDrawingLineWire BITMAPS::INVALID_BITMAP, AF_ACTIVATE ); -const DRAW_SEGMENT_EVENT_PARAMS drawWireActionParam = { LAYER_WIRE, false }; +const DRAW_SEGMENT_EVENT_PARAMS drawWireActionParam = { LAYER_WIRE, false, nullptr }; TOOL_ACTION EE_ACTIONS::drawWire( "eeschema.InteractiveDrawingLineWireBus.drawWires", AS_GLOBAL, 'W', LEGACY_HK_NAME( "Begin Wire" ), _( "Add Wire" ), _( "Add a wire" ), BITMAPS::add_line, AF_ACTIVATE, (void*) &drawWireActionParam ); -const DRAW_SEGMENT_EVENT_PARAMS drawBusActionParam = { LAYER_BUS, false }; +const DRAW_SEGMENT_EVENT_PARAMS drawBusActionParam = { LAYER_BUS, false, nullptr }; TOOL_ACTION EE_ACTIONS::drawBus( "eeschema.InteractiveDrawingLineWireBus.drawBuses", AS_GLOBAL, 'B', LEGACY_HK_NAME( "Begin Bus" ), @@ -737,7 +737,7 @@ TOOL_ACTION EE_ACTIONS::unfoldBus( "eeschema.InteractiveDrawingLineWireBus.unfol _( "Unfold from Bus" ), _( "Break a wire out of a bus" ), BITMAPS::INVALID_BITMAP, AF_ACTIVATE ); -const DRAW_SEGMENT_EVENT_PARAMS drawLinesActionParam = { LAYER_NOTES, false }; +const DRAW_SEGMENT_EVENT_PARAMS drawLinesActionParam = { LAYER_NOTES, false, nullptr }; TOOL_ACTION EE_ACTIONS::drawLines( "eeschema.InteractiveDrawingLineWireBus.drawLines", AS_GLOBAL, 'I', LEGACY_HK_NAME( "Add Graphic PolyLine" ), diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 7577fb0d5e..f61d8adeb4 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -420,6 +420,10 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) newParams->quitOnDraw = true; newEvt->SetParameter( newParams ); + // Make it so we can copy the parameters of the line we are extending + if( collector[0]->Type() == SCH_LINE_T ) + newParams->sourceSegment = static_cast( collector[0] ); + getViewControls()->ForceCursorPosition( true, snappedCursorPos ); newEvt->SetMousePosition( snappedCursorPos ); newEvt->SetHasPosition( true ); diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index a4b108c375..3df90ce821 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -292,7 +292,7 @@ int SCH_LINE_WIRE_BUS_TOOL::DrawSegments( const TOOL_EVENT& aEvent ) grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !aEvent.DisableGridSnapping() ); VECTOR2D cursorPos = grid.BestSnapAnchor( aEvent.Position(), LAYER_CONNECTABLE, nullptr ); - startSegments( params->layer, cursorPos ); + startSegments( params->layer, cursorPos, params->sourceSegment ); } return doDrawSegments( tool, params->layer, params->quitOnDraw ); @@ -792,36 +792,46 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType, } -SCH_LINE* SCH_LINE_WIRE_BUS_TOOL::startSegments( int aType, const VECTOR2D& aPos ) +SCH_LINE* SCH_LINE_WIRE_BUS_TOOL::startSegments( int aType, const VECTOR2D& aPos, + SCH_LINE* aSegment ) { - SCH_LINE* segment = nullptr; - - switch ( aType ) + // If a segment isn't provided to copy properties from, we need to create one + if( aSegment == nullptr ) { - default: segment = new SCH_LINE( aPos, LAYER_NOTES ); break; - case LAYER_WIRE: segment = new SCH_LINE( aPos, LAYER_WIRE ); break; - case LAYER_BUS: segment = new SCH_LINE( aPos, LAYER_BUS ); break; + switch( aType ) + { + default: aSegment = new SCH_LINE( aPos, LAYER_NOTES ); break; + case LAYER_WIRE: aSegment = new SCH_LINE( aPos, LAYER_WIRE ); break; + case LAYER_BUS: aSegment = new SCH_LINE( aPos, LAYER_BUS ); break; + } + + // Give segments a parent so they find the default line/wire/bus widths + aSegment->SetParent( &m_frame->Schematic() ); + } + else + { + aSegment = static_cast( aSegment->Duplicate() ); + aSegment->SetStartPoint( (wxPoint) aPos ); } - // Give segments a parent so they find the default line/wire/bus widths - segment->SetParent( &m_frame->Schematic() ); - segment->SetFlags( IS_NEW | IS_MOVING ); - m_wires.push_back( segment ); - m_selectionTool->AddItemToSel( segment, true /*quiet mode*/ ); + aSegment->SetFlags( IS_NEW | IS_MOVING ); + m_wires.push_back( aSegment ); + + m_selectionTool->AddItemToSel( aSegment, true /*quiet mode*/ ); // We need 2 segments to go from a given start pin to an end point when the // horizontal and vertical lines only switch is on. if( m_frame->eeconfig()->m_Drawing.hv_lines_only ) { - segment = static_cast( segment->Duplicate() ); - segment->SetFlags( IS_NEW | IS_MOVING ); - m_wires.push_back( segment ); + aSegment = static_cast( aSegment->Duplicate() ); + aSegment->SetFlags( IS_NEW | IS_MOVING ); + m_wires.push_back( aSegment ); - m_selectionTool->AddItemToSel( segment, true /*quiet mode*/ ); + m_selectionTool->AddItemToSel( aSegment, true /*quiet mode*/ ); } - return segment; + return aSegment; } diff --git a/eeschema/tools/sch_line_wire_bus_tool.h b/eeschema/tools/sch_line_wire_bus_tool.h index d242b3c19d..89c031e950 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.h +++ b/eeschema/tools/sch_line_wire_bus_tool.h @@ -64,6 +64,7 @@ struct DRAW_SEGMENT_EVENT_PARAMS { SCH_LAYER_ID layer; bool quitOnDraw; + SCH_LINE* sourceSegment; }; /** @@ -95,7 +96,7 @@ public: private: int doDrawSegments( const std::string& aTool, int aType, bool aQuitOnDraw ); - SCH_LINE* startSegments( int aType, const VECTOR2D& aPos ); + SCH_LINE* startSegments( int aType, const VECTOR2D& aPos, SCH_LINE* aSegment = nullptr ); SCH_LINE* doUnfoldBus( const wxString& aNet, const VECTOR2I& aPos = VECTOR2I( 0, 0 ) ); void finishSegments();