Implement immediate bus unfold and add bus unfold to selection context menu.

This commit is contained in:
Jeff Young 2019-05-05 15:16:29 +01:00
parent fd546da640
commit a42a4b0b52
11 changed files with 166 additions and 68 deletions

View File

@ -637,6 +637,8 @@ bool TOOL_MANAGER::dispatchActivation( const TOOL_EVENT& aEvent )
{
if( aEvent.IsActivate() )
{
wxString cmdStr( *aEvent.GetCommandStr() );
std::map<std::string, TOOL_STATE*>::iterator tool = m_toolNameIndex.find( *aEvent.GetCommandStr() );
if( tool != m_toolNameIndex.end() )

View File

@ -240,7 +240,7 @@ set( EESCHEMA_SRCS
tools/sch_edit_tool.cpp
tools/sch_editor_control.cpp
tools/sch_inspection_tool.cpp
tools/sch_line_drawing_tool.cpp
tools/sch_wire_bus_tool.cpp
tools/sch_move_tool.cpp
tools/sch_picker_tool.cpp
tools/sch_selection_tool.cpp

View File

@ -63,6 +63,7 @@ enum hotkey_id_command {
HK_ADD_NEW_POWER,
HK_BEGIN_WIRE,
HK_BEGIN_BUS,
HK_UNFOLD_BUS,
HK_END_CURR_LINEWIREBUS,
HK_ADD_WIRE_ENTRY,
HK_ADD_BUS_ENTRY,
@ -81,7 +82,6 @@ enum hotkey_id_command {
HK_AUTOPLACE_FIELDS,
HK_UPDATE_PCB_FROM_SCH,
HK_SELECT_ITEMS_ON_PCB,
HK_UNFOLD_BUS,
HK_CANVAS_OPENGL,
HK_CANVAS_CAIRO,
};

View File

@ -62,7 +62,7 @@
#include <tools/sch_selection_tool.h>
#include <tools/sch_picker_tool.h>
#include <tools/sch_drawing_tool.h>
#include <tools/sch_line_drawing_tool.h>
#include <tools/sch_wire_bus_tool.h>
#include <tools/sch_move_tool.h>
#include <tools/sch_edit_tool.h>
#include <tools/sch_inspection_tool.h>
@ -430,7 +430,7 @@ void SCH_EDIT_FRAME::setupTools()
m_toolManager->RegisterTool( new SCH_SELECTION_TOOL );
m_toolManager->RegisterTool( new SCH_PICKER_TOOL );
m_toolManager->RegisterTool( new SCH_DRAWING_TOOL );
m_toolManager->RegisterTool( new SCH_LINE_DRAWING_TOOL );
m_toolManager->RegisterTool( new SCH_WIRE_BUS_TOOL );
m_toolManager->RegisterTool( new SCH_MOVE_TOOL );
m_toolManager->RegisterTool( new SCH_EDIT_TOOL );
m_toolManager->RegisterTool( new SCH_INSPECTION_TOOL );

View File

@ -201,6 +201,9 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
case ID_HOTKEY_SELECT_CONNECTION:
return SCH_ACTIONS::selectConnection.MakeEvent();
case ID_SCH_UNFOLD_BUS:
return SCH_ACTIONS::unfoldBus.MakeEvent();
}
return OPT<TOOL_EVENT>();

View File

@ -24,7 +24,7 @@
#include <tool/tool_manager.h>
#include <tools/sch_edit_tool.h>
#include <tools/sch_selection_tool.h>
#include <tools/sch_line_drawing_tool.h>
#include <tools/sch_wire_bus_tool.h>
#include <tools/sch_picker_tool.h>
#include <tools/sch_move_tool.h>
#include <sch_actions.h>
@ -260,7 +260,7 @@ bool SCH_EDIT_TOOL::Init()
};
auto duplicateCondition = [] ( const SELECTION& aSel ) {
if( SCH_LINE_DRAWING_TOOL::IsDrawingLineWireOrBus( aSel ) )
if( SCH_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
return false;
return true;
@ -270,7 +270,7 @@ bool SCH_EDIT_TOOL::Init()
if( aSel.Empty() )
return false;
if( SCH_LINE_DRAWING_TOOL::IsDrawingLineWireOrBus( aSel ) )
if( SCH_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
return false;
SCH_ITEM* item = (SCH_ITEM*) aSel.Front();

View File

@ -48,7 +48,7 @@
#include <class_library.h>
#include <confirm.h>
#include <lib_edit_frame.h>
#include "sch_line_drawing_tool.h"
#include "sch_wire_bus_tool.h"
TOOL_ACTION SCH_ACTIONS::refreshPreview( "eeschema.EditorControl.refreshPreview",
AS_GLOBAL, 0, "", "" );

View File

@ -25,7 +25,7 @@
#include <tools/sch_edit_tool.h>
#include <tools/sch_selection_tool.h>
#include <tools/sch_drawing_tool.h>
#include <tools/sch_line_drawing_tool.h>
#include <tools/sch_wire_bus_tool.h>
#include <tools/sch_picker_tool.h>
#include <sch_actions.h>
#include <hotkeys.h>
@ -86,7 +86,7 @@ bool SCH_MOVE_TOOL::Init()
if( aSel.Empty() )
return false;
if( SCH_LINE_DRAWING_TOOL::IsDrawingLineWireOrBus( aSel ) )
if( SCH_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) )
return false;
return true;

View File

@ -37,7 +37,7 @@
#include <preview_items/selection_area.h>
#include <tool/tool_event.h>
#include <tool/tool_manager.h>
#include <tools/sch_line_drawing_tool.h>
#include <tools/sch_wire_bus_tool.h>
#include <sch_actions.h>
#include <sch_collectors.h>
#include <painter.h>
@ -187,8 +187,6 @@ bool SCH_SELECTION_TOOL::Init()
auto& menu = m_menu.GetMenu();
// TODO(JE): add menu access to unfold bus on busSelectionCondition...
menu.AddItem( SCH_ACTIONS::enterSheet, sheetSelection && SCH_CONDITIONS::Idle, 1 );
menu.AddItem( SCH_ACTIONS::explicitCrossProbe, sheetSelection && SCH_CONDITIONS::Idle, 1 );
menu.AddItem( SCH_ACTIONS::resizeSheet, sheetSelection && SCH_CONDITIONS::Idle, 1 );
@ -198,11 +196,11 @@ bool SCH_SELECTION_TOOL::Init()
menu.AddItem( SCH_ACTIONS::startWire, SCH_CONDITIONS::Empty, 100 );
menu.AddItem( SCH_ACTIONS::startBus, SCH_CONDITIONS::Empty, 100 );
menu.AddSeparator( SCH_LINE_DRAWING_TOOL::IsDrawingWire, 100 );
menu.AddItem( SCH_ACTIONS::finishWire, SCH_LINE_DRAWING_TOOL::IsDrawingWire, 100 );
menu.AddSeparator( SCH_WIRE_BUS_TOOL::IsDrawingWire, 100 );
menu.AddItem( SCH_ACTIONS::finishWire, SCH_WIRE_BUS_TOOL::IsDrawingWire, 100 );
menu.AddSeparator( SCH_LINE_DRAWING_TOOL::IsDrawingBus, 100 );
menu.AddItem( SCH_ACTIONS::finishBus, SCH_LINE_DRAWING_TOOL::IsDrawingBus, 100 );
menu.AddSeparator( SCH_WIRE_BUS_TOOL::IsDrawingBus, 100 );
menu.AddItem( SCH_ACTIONS::finishBus, SCH_WIRE_BUS_TOOL::IsDrawingBus, 100 );
menu.AddSeparator( SCH_CONDITIONS::NotEmpty, 200 );
menu.AddItem( SCH_ACTIONS::selectConnection, wireOrBusSelection && SCH_CONDITIONS::Idle, 200 );
@ -333,7 +331,7 @@ int SCH_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
}
}
// symbol unit selection menu? Adjust the unit if a symbol is selected
// context sub-menu selection? Handle unit selection or bus unfolding
else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CONTEXT_MENU_CHOICE )
{
if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
@ -345,6 +343,13 @@ int SCH_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
if( component )
static_cast<SCH_EDIT_FRAME*>( m_frame )->SelectUnit( component, unit );
}
else if( evt->GetCommandId().get() >= ID_POPUP_SCH_UNFOLD_BUS
&& evt->GetCommandId().get() <= ID_POPUP_SCH_UNFOLD_BUS_END )
{
wxString* net = new wxString( *evt->Parameter<wxString*>() );
m_toolMgr->RunAction( SCH_ACTIONS::unfoldBus, true, net );
}
}
else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )

View File

@ -22,7 +22,7 @@
*/
#include <connection_graph.h>
#include <sch_line_drawing_tool.h>
#include <sch_wire_bus_tool.h>
#include <sch_selection_tool.h>
#include <sch_actions.h>
#include <sch_edit_frame.h>
@ -43,52 +43,54 @@
#include <sch_sheet.h>
#include <advanced_config.h>
TOOL_ACTION SCH_ACTIONS::startWire( "eeschema.InteractiveLineDrawing.startWire",
TOOL_ACTION SCH_ACTIONS::startWire( "eeschema.WireBusDrawing.startWire",
AS_GLOBAL, 0,
_( "Start Wire" ), _( "Start drawing a wire" ),
add_line_xpm, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::drawWire( "eeschema.InteractiveLineDrawing.drawWire",
TOOL_ACTION SCH_ACTIONS::drawWire( "eeschema.WireBusDrawing.drawWire",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_WIRE ),
_( "Add Wire" ), _( "Add a wire" ),
add_line_xpm, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::startBus( "eeschema.InteractiveLineDrawing.startBus",
TOOL_ACTION SCH_ACTIONS::startBus( "eeschema.WireBusDrawing.startBus",
AS_GLOBAL, 0,
_( "Start Bus" ), _( "Start drawing a bus" ),
add_bus_xpm, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::drawBus( "eeschema.InteractiveLineDrawing.drawBus",
TOOL_ACTION SCH_ACTIONS::drawBus( "eeschema.WireBusDrawing.drawBus",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_BUS ),
_( "Add Bus" ), _( "Add a bus" ),
add_bus_xpm, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::unfoldBus( "eeschema.InteractiveLineDrawing.unfoldBus",
AS_GLOBAL, 0, "", "", nullptr, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::unfoldBus( "eeschema.WireBusDrawing.unfoldBus",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_UNFOLD_BUS ),
_( "Unfold Bus" ), _( "Break a wire out of a bus" ),
nullptr, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::startLines( "eeschema.InteractiveLineDrawing.startLines",
TOOL_ACTION SCH_ACTIONS::startLines( "eeschema.WireBusDrawing.startLines",
AS_GLOBAL, 0, _( "Begin Lines" ), _( "Start drawing connected graphic lines" ),
add_line_xpm, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::drawLines( "eeschema.InteractiveLineDrawing.drawLines",
TOOL_ACTION SCH_ACTIONS::drawLines( "eeschema.WireBusDrawing.drawLines",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_GRAPHIC_POLYLINE ),
_( "Add Lines" ), _( "Add connected graphic lines" ),
add_graphical_segments_xpm, AF_ACTIVATE );
TOOL_ACTION SCH_ACTIONS::finishLineWireOrBus( "eeschema.InteractiveLineDrawing.finishLineWireOrBus",
TOOL_ACTION SCH_ACTIONS::finishLineWireOrBus( "eeschema.WireBusDrawing.finishLineWireOrBus",
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_END_CURR_LINEWIREBUS ),
_( "Finish Wire or Bus" ), _( "Complete drawing at current segment" ),
checked_ok_xpm, AF_NONE );
TOOL_ACTION SCH_ACTIONS::finishWire( "eeschema.InteractiveLineDrawing.finishWire",
TOOL_ACTION SCH_ACTIONS::finishWire( "eeschema.WireBusDrawing.finishWire",
AS_GLOBAL, 0, _( "Finish Wire" ), _( "Complete wire with current segment" ),
checked_ok_xpm, AF_NONE );
TOOL_ACTION SCH_ACTIONS::finishBus( "eeschema.InteractiveLineDrawing.finishBus",
TOOL_ACTION SCH_ACTIONS::finishBus( "eeschema.WireBusDrawing.finishBus",
AS_GLOBAL, 0, _( "Finish Bus" ), _( "Complete bus with current segment" ),
checked_ok_xpm, AF_NONE );
TOOL_ACTION SCH_ACTIONS::finishLine( "eeschema.InteractiveLineDrawing.finishLine",
TOOL_ACTION SCH_ACTIONS::finishLine( "eeschema.WireBusDrawing.finishLine",
AS_GLOBAL, 0, _( "Finish Lines" ), _( "Complete connected lines with current segment" ),
checked_ok_xpm, AF_NONE );
@ -96,12 +98,18 @@ TOOL_ACTION SCH_ACTIONS::finishLine( "eeschema.InteractiveLineDrawing.finishLine
class BUS_UNFOLD_MENU : public CONTEXT_MENU
{
public:
BUS_UNFOLD_MENU()
BUS_UNFOLD_MENU() :
m_showTitle( false )
{
SetIcon( add_line2bus_xpm );
SetTitle( _( "Unfold Bus" ) );
}
void SetShowTitle()
{
m_showTitle = true;
}
protected:
CONTEXT_MENU* create() const override
@ -145,6 +153,12 @@ private:
int idx = 0;
if( m_showTitle )
{
Append( ID_POPUP_SCH_UNFOLD_BUS, _( "Unfold from Bus" ), wxEmptyString );
Enable( ID_POPUP_SCH_UNFOLD_BUS, false );
}
for( const auto& member : connection->Members() )
{
int id = ID_POPUP_SCH_UNFOLD_BUS + ( idx++ );
@ -167,12 +181,13 @@ private:
}
}
}
bool m_showTitle;
};
SCH_LINE_DRAWING_TOOL::SCH_LINE_DRAWING_TOOL() :
TOOL_INTERACTIVE( "eeschema.InteractiveLineDrawing" ),
SCH_WIRE_BUS_TOOL::SCH_WIRE_BUS_TOOL() :
TOOL_INTERACTIVE( "eeschema.WireBusDrawing" ),
m_selectionTool( nullptr ),
m_view( nullptr ),
m_controls( nullptr ),
@ -180,15 +195,15 @@ SCH_LINE_DRAWING_TOOL::SCH_LINE_DRAWING_TOOL() :
m_menu( *this )
{
m_busUnfold = {};
};
}
SCH_LINE_DRAWING_TOOL::~SCH_LINE_DRAWING_TOOL()
SCH_WIRE_BUS_TOOL::~SCH_WIRE_BUS_TOOL()
{
}
bool SCH_LINE_DRAWING_TOOL::Init()
bool SCH_WIRE_BUS_TOOL::Init()
{
m_frame = getEditFrame<SCH_EDIT_FRAME>();
m_selectionTool = m_toolMgr->GetTool<SCH_SELECTION_TOOL>();
@ -209,6 +224,9 @@ bool SCH_LINE_DRAWING_TOOL::Init()
return g_CurrentSheet->Last() != g_RootSheet;
};
auto busSelection = SCH_CONDITIONS::MoreThan( 0 )
&& SCH_CONDITIONS::OnlyType( SCH_LINE_LOCATE_BUS_T );
auto& ctxMenu = m_menu.GetMenu();
//
@ -245,11 +263,21 @@ bool SCH_LINE_DRAWING_TOOL::Init()
ctxMenu.AddSeparator( activeTool, 1000 );
m_menu.AddStandardSubMenus( m_frame );
//
// Add bus unfolding to the selection tool
//
CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu();
std::shared_ptr<BUS_UNFOLD_MENU> selBusUnfoldMenu = std::make_shared<BUS_UNFOLD_MENU>();
selBusUnfoldMenu->SetTool( m_selectionTool );
m_selectionTool->GetToolMenu().AddSubMenu( selBusUnfoldMenu );
selToolMenu.AddMenu( selBusUnfoldMenu.get(), false, busSelection && SCH_CONDITIONS::Idle, 100 );
return true;
}
void SCH_LINE_DRAWING_TOOL::Reset( RESET_REASON aReason )
void SCH_WIRE_BUS_TOOL::Reset( RESET_REASON aReason )
{
// Init variables used by every drawing tool
m_view = static_cast<KIGFX::SCH_VIEW*>( getView() );
@ -264,28 +292,28 @@ static bool isNewSegment( SCH_ITEM* aItem )
}
bool SCH_LINE_DRAWING_TOOL::IsDrawingLine( const SELECTION& aSelection )
bool SCH_WIRE_BUS_TOOL::IsDrawingLine( const SELECTION& aSelection )
{
static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
return IsDrawingLineWireOrBus( aSelection ) && !aSelection.Front()->IsType( wireOrBusTypes );
}
bool SCH_LINE_DRAWING_TOOL::IsDrawingWire( const SELECTION& aSelection )
bool SCH_WIRE_BUS_TOOL::IsDrawingWire( const SELECTION& aSelection )
{
static KICAD_T wireType[] = { SCH_LINE_LOCATE_WIRE_T, EOT };
return IsDrawingLineWireOrBus( aSelection ) && aSelection.Front()->IsType( wireType );
}
bool SCH_LINE_DRAWING_TOOL::IsDrawingBus( const SELECTION& aSelection )
bool SCH_WIRE_BUS_TOOL::IsDrawingBus( const SELECTION& aSelection )
{
static KICAD_T busType[] = { SCH_LINE_LOCATE_BUS_T, EOT };
return IsDrawingLineWireOrBus( aSelection ) && aSelection.Front()->IsType( busType );
}
bool SCH_LINE_DRAWING_TOOL::IsDrawingLineWireOrBus( const SELECTION& aSelection )
bool SCH_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( const SELECTION& aSelection )
{
// NOTE: for immediate hotkeys, it is NOT required that the line, wire or bus tool
// be selected
@ -294,17 +322,19 @@ bool SCH_LINE_DRAWING_TOOL::IsDrawingLineWireOrBus( const SELECTION& aSelection
}
int SCH_LINE_DRAWING_TOOL::StartWire( const TOOL_EVENT& aEvent )
int SCH_WIRE_BUS_TOOL::StartWire( const TOOL_EVENT& aEvent )
{
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
Activate();
m_frame->GetCanvas()->MoveCursorToCrossHair();
SCH_LINE* segment = startSegments( LAYER_WIRE, m_frame->GetCrossHairPosition() );
return doDrawSegments( LAYER_WIRE, segment );
}
int SCH_LINE_DRAWING_TOOL::DrawWire( const TOOL_EVENT& aEvent )
int SCH_WIRE_BUS_TOOL::DrawWire( const TOOL_EVENT& aEvent )
{
if( m_frame->GetToolId() == ID_WIRE_BUTT )
return StartWire( aEvent );
@ -318,17 +348,19 @@ int SCH_LINE_DRAWING_TOOL::DrawWire( const TOOL_EVENT& aEvent )
}
int SCH_LINE_DRAWING_TOOL::StartBus( const TOOL_EVENT& aEvent )
int SCH_WIRE_BUS_TOOL::StartBus( const TOOL_EVENT& aEvent )
{
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
Activate();
m_frame->GetCanvas()->MoveCursorToCrossHair();
SCH_LINE* segment = startSegments( LAYER_BUS, m_frame->GetCrossHairPosition() );
return doDrawSegments( LAYER_BUS, segment );
}
int SCH_LINE_DRAWING_TOOL::DrawBus( const TOOL_EVENT& aEvent )
int SCH_WIRE_BUS_TOOL::DrawBus( const TOOL_EVENT& aEvent )
{
if( m_frame->GetToolId() == ID_BUS_BUTT )
return StartBus( aEvent );
@ -342,7 +374,60 @@ int SCH_LINE_DRAWING_TOOL::DrawBus( const TOOL_EVENT& aEvent )
}
SCH_LINE* SCH_LINE_DRAWING_TOOL::unfoldBus( const wxString& aNet )
int SCH_WIRE_BUS_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
{
wxString* netPtr = aEvent.Parameter<wxString*>();
wxString net;
SCH_LINE* segment = nullptr;
Activate();
if( netPtr )
{
net = *netPtr;
delete netPtr;
}
else
{
BUS_UNFOLD_MENU unfoldMenu;
unfoldMenu.SetTool( this );
unfoldMenu.SetShowTitle();
unfoldMenu.UpdateAll();
SetContextMenu( &unfoldMenu, CMENU_NOW );
while( OPT_TOOL_EVENT evt = Wait() )
{
if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
{
OPT<int> id = evt->GetCommandId();
if( id && ( *id > 0 ) )
{
net = *evt->Parameter<wxString*>();
break;
}
}
}
}
if( !net.IsEmpty() )
{
// Break a wire for the given net out of the bus
segment = doUnfoldBus( net );
}
if( segment )
{
// Continue drawing with the unfolded wire
doDrawSegments( LAYER_WIRE, segment );
}
return 0;
}
SCH_LINE* SCH_WIRE_BUS_TOOL::doUnfoldBus( const wxString& aNet )
{
wxPoint pos = m_frame->GetCrossHairPosition();
@ -367,7 +452,7 @@ SCH_LINE* SCH_LINE_DRAWING_TOOL::unfoldBus( const wxString& aNet )
}
int SCH_LINE_DRAWING_TOOL::StartLines( const TOOL_EVENT& aEvent)
int SCH_WIRE_BUS_TOOL::StartLines( const TOOL_EVENT& aEvent)
{
m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true );
@ -377,7 +462,7 @@ int SCH_LINE_DRAWING_TOOL::StartLines( const TOOL_EVENT& aEvent)
}
int SCH_LINE_DRAWING_TOOL::DrawLines( const TOOL_EVENT& aEvent)
int SCH_WIRE_BUS_TOOL::DrawLines( const TOOL_EVENT& aEvent)
{
if( m_frame->GetToolId() == ID_LINE_COMMENT_BUTT )
return StartLines( aEvent );
@ -483,13 +568,14 @@ static void computeBreakPoint( SCH_SCREEN* aScreen, SCH_LINE* aSegment, wxPoint&
}
int SCH_LINE_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
int SCH_WIRE_BUS_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
{
bool forceHV = m_frame->GetForceHVLines();
SCH_SCREEN* screen = m_frame->GetScreen();
m_controls->ShowCursor( true );
if( aSegment == nullptr )
Activate();
// Main loop: keep receiving events
@ -681,7 +767,7 @@ int SCH_LINE_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
wxASSERT_MSG( !aSegment, "Bus unfold event recieved when already drawing!" );
wxString net = *evt->Parameter<wxString*>();
aSegment = unfoldBus( net );
aSegment = doUnfoldBus( net );
}
}
@ -694,7 +780,7 @@ int SCH_LINE_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
}
SCH_LINE* SCH_LINE_DRAWING_TOOL::startSegments( int aType, const wxPoint& aPos )
SCH_LINE* SCH_WIRE_BUS_TOOL::startSegments( int aType, const wxPoint& aPos )
{
SCH_LINE* segment = nullptr;
bool forceHV = m_frame->GetForceHVLines();
@ -789,7 +875,7 @@ static void removeBacktracks( DLIST<SCH_LINE>& aWires )
}
void SCH_LINE_DRAWING_TOOL::finishSegments()
void SCH_WIRE_BUS_TOOL::finishSegments()
{
// Clear selection when done so that a new wire can be started.
// NOTE: this must be done before RemoveBacktracks is called or we might end up with
@ -884,13 +970,15 @@ void SCH_LINE_DRAWING_TOOL::finishSegments()
}
void SCH_LINE_DRAWING_TOOL::setTransitions()
void SCH_WIRE_BUS_TOOL::setTransitions()
{
Go( &SCH_LINE_DRAWING_TOOL::DrawWire, SCH_ACTIONS::drawWire.MakeEvent() );
Go( &SCH_LINE_DRAWING_TOOL::DrawBus, SCH_ACTIONS::drawBus.MakeEvent() );
Go( &SCH_LINE_DRAWING_TOOL::DrawLines, SCH_ACTIONS::drawLines.MakeEvent() );
Go( &SCH_WIRE_BUS_TOOL::DrawWire, SCH_ACTIONS::drawWire.MakeEvent() );
Go( &SCH_WIRE_BUS_TOOL::DrawBus, SCH_ACTIONS::drawBus.MakeEvent() );
Go( &SCH_WIRE_BUS_TOOL::DrawLines, SCH_ACTIONS::drawLines.MakeEvent() );
Go( &SCH_LINE_DRAWING_TOOL::StartWire, SCH_ACTIONS::startWire.MakeEvent() );
Go( &SCH_LINE_DRAWING_TOOL::StartBus, SCH_ACTIONS::startBus.MakeEvent() );
Go( &SCH_LINE_DRAWING_TOOL::StartLines, SCH_ACTIONS::startLines.MakeEvent() );
Go( &SCH_WIRE_BUS_TOOL::StartWire, SCH_ACTIONS::startWire.MakeEvent() );
Go( &SCH_WIRE_BUS_TOOL::StartBus, SCH_ACTIONS::startBus.MakeEvent() );
Go( &SCH_WIRE_BUS_TOOL::StartLines, SCH_ACTIONS::startLines.MakeEvent() );
Go( &SCH_WIRE_BUS_TOOL::UnfoldBus, SCH_ACTIONS::unfoldBus.MakeEvent() );
}

View File

@ -30,10 +30,8 @@
#include <sch_base_frame.h>
class SCH_COMPONENT;
class SCH_BUS_WIRE_ENTRY;
class SCH_LABEL;
class SCHLIB_FILTER;
class SCH_EDIT_FRAME;
class SCH_SELECTION_TOOL;
@ -59,11 +57,11 @@ struct BUS_UNFOLDING_T
* Tool responsible for drawing/placing items (symbols, wires, busses, labels, etc.)
*/
class SCH_LINE_DRAWING_TOOL : public TOOL_INTERACTIVE
class SCH_WIRE_BUS_TOOL : public TOOL_INTERACTIVE
{
public:
SCH_LINE_DRAWING_TOOL();
~SCH_LINE_DRAWING_TOOL();
SCH_WIRE_BUS_TOOL();
~SCH_WIRE_BUS_TOOL();
/// @copydoc TOOL_INTERACTIVE::Init()
bool Init() override;
@ -82,6 +80,8 @@ public:
int DrawBus( const TOOL_EVENT& aEvent );
int DrawLines( const TOOL_EVENT& aEvent );
int UnfoldBus( const TOOL_EVENT& aEvent );
// SELECTION_CONDITIONs:
static bool IsDrawingLine( const SELECTION& aSelection );
static bool IsDrawingWire( const SELECTION& aSelection );
@ -92,7 +92,7 @@ private:
int doDrawSegments( int aType, SCH_LINE* aSegment );
SCH_LINE* startSegments( int aType, const wxPoint& aPos );
SCH_LINE* unfoldBus( const wxString& aNet );
SCH_LINE* doUnfoldBus( const wxString& aNet );
void finishSegments();
///> Sets up handlers for various events.