Move some more immediate actions to modern toolset.
This commit is contained in:
parent
d0bc84bcbf
commit
f274e0f68b
|
@ -164,16 +164,6 @@
|
||||||
m_toolManager->RunAction( SCH_ACTIONS::finishDrawing, true );
|
m_toolManager->RunAction( SCH_ACTIONS::finishDrawing, true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_SCH_BEGIN_WIRE:
|
|
||||||
m_canvas->MoveCursorToCrossHair();
|
|
||||||
OnLeftClick( nullptr, GetCrossHairPosition() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_POPUP_SCH_BEGIN_BUS:
|
|
||||||
m_canvas->MoveCursorToCrossHair();
|
|
||||||
OnLeftClick( nullptr, GetCrossHairPosition() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_POPUP_SCH_DELETE_NODE:
|
case ID_POPUP_SCH_DELETE_NODE:
|
||||||
case ID_POPUP_SCH_DELETE_CONNECTION:
|
case ID_POPUP_SCH_DELETE_CONNECTION:
|
||||||
m_canvas->MoveCursorToCrossHair();
|
m_canvas->MoveCursorToCrossHair();
|
||||||
|
@ -311,26 +301,6 @@
|
||||||
HandleBlockEnd( nullptr );
|
HandleBlockEnd( nullptr );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_SCH_ADD_JUNCTION:
|
|
||||||
m_canvas->MoveCursorToCrossHair();
|
|
||||||
screen->SetCurItem( AddJunction( GetCrossHairPosition() ) );
|
|
||||||
|
|
||||||
TestDanglingEnds();
|
|
||||||
m_canvas->Refresh();
|
|
||||||
|
|
||||||
screen->SetCurItem( NULL );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_POPUP_SCH_ADD_LABEL:
|
|
||||||
case ID_POPUP_SCH_ADD_GLABEL:
|
|
||||||
item = CreateNewText( id == ID_POPUP_SCH_ADD_LABEL ? LAYER_LOCLABEL : LAYER_GLOBLABEL );
|
|
||||||
screen->SetCurItem( item );
|
|
||||||
|
|
||||||
if( item )
|
|
||||||
AddItemToScreen( item );
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ID_POPUP_SCH_GETINFO_MARKER:
|
case ID_POPUP_SCH_GETINFO_MARKER:
|
||||||
if( item && item->Type() == SCH_MARKER_T )
|
if( item && item->Type() == SCH_MARKER_T )
|
||||||
( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
|
( (SCH_MARKER*) item )->DisplayMarkerInfo( this );
|
||||||
|
|
|
@ -89,10 +89,16 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||||
case ID_PLACE_POWER_BUTT:
|
case ID_PLACE_POWER_BUTT:
|
||||||
return SCH_ACTIONS::placePower.MakeEvent();
|
return SCH_ACTIONS::placePower.MakeEvent();
|
||||||
|
|
||||||
|
case ID_POPUP_SCH_BEGIN_WIRE:
|
||||||
|
return SCH_ACTIONS::startWire.MakeEvent();
|
||||||
|
|
||||||
case ID_MENU_WIRE_BUTT:
|
case ID_MENU_WIRE_BUTT:
|
||||||
case ID_WIRE_BUTT:
|
case ID_WIRE_BUTT:
|
||||||
return SCH_ACTIONS::drawWire.MakeEvent();
|
return SCH_ACTIONS::drawWire.MakeEvent();
|
||||||
|
|
||||||
|
case ID_POPUP_SCH_BEGIN_BUS:
|
||||||
|
return SCH_ACTIONS::startBus.MakeEvent();
|
||||||
|
|
||||||
case ID_MENU_BUS_BUTT:
|
case ID_MENU_BUS_BUTT:
|
||||||
case ID_BUS_BUTT:
|
case ID_BUS_BUTT:
|
||||||
return SCH_ACTIONS::drawBus.MakeEvent();
|
return SCH_ACTIONS::drawBus.MakeEvent();
|
||||||
|
@ -101,6 +107,9 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||||
case ID_NOCONN_BUTT:
|
case ID_NOCONN_BUTT:
|
||||||
return SCH_ACTIONS::placeNoConnect.MakeEvent();
|
return SCH_ACTIONS::placeNoConnect.MakeEvent();
|
||||||
|
|
||||||
|
case ID_POPUP_SCH_ADD_JUNCTION:
|
||||||
|
return SCH_ACTIONS::addJunction.MakeEvent();
|
||||||
|
|
||||||
case ID_MENU_JUNCTION_BUTT:
|
case ID_MENU_JUNCTION_BUTT:
|
||||||
case ID_JUNCTION_BUTT:
|
case ID_JUNCTION_BUTT:
|
||||||
return SCH_ACTIONS::placeJunction.MakeEvent();
|
return SCH_ACTIONS::placeJunction.MakeEvent();
|
||||||
|
@ -113,13 +122,19 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
||||||
case ID_BUSTOBUS_ENTRY_BUTT:
|
case ID_BUSTOBUS_ENTRY_BUTT:
|
||||||
return SCH_ACTIONS::placeBusBusEntry.MakeEvent();
|
return SCH_ACTIONS::placeBusBusEntry.MakeEvent();
|
||||||
|
|
||||||
|
case ID_POPUP_SCH_ADD_LABEL:
|
||||||
|
return SCH_ACTIONS::addLabel.MakeEvent();
|
||||||
|
|
||||||
case ID_MENU_LABEL_BUTT:
|
case ID_MENU_LABEL_BUTT:
|
||||||
case ID_LABEL_BUTT:
|
case ID_LABEL_BUTT:
|
||||||
return SCH_ACTIONS::placeLabel.MakeEvent();
|
return SCH_ACTIONS::placeLabel.MakeEvent();
|
||||||
|
|
||||||
|
case ID_POPUP_SCH_ADD_GLABEL:
|
||||||
|
return SCH_ACTIONS::addGlobalLabel.MakeEvent();
|
||||||
|
|
||||||
case ID_MENU_GLABEL_BUTT:
|
case ID_MENU_GLABEL_BUTT:
|
||||||
case ID_GLOBALLABEL_BUTT:
|
case ID_GLOBALLABEL_BUTT:
|
||||||
return SCH_ACTIONS::placeLabel.MakeEvent();
|
return SCH_ACTIONS::placeGlobalLabel.MakeEvent();
|
||||||
|
|
||||||
case ID_MENU_HIERLABEL_BUTT:
|
case ID_MENU_HIERLABEL_BUTT:
|
||||||
case ID_HIERLABEL_BUTT:
|
case ID_HIERLABEL_BUTT:
|
||||||
|
|
|
@ -90,7 +90,9 @@ public:
|
||||||
static TOOL_ACTION pickerTool;
|
static TOOL_ACTION pickerTool;
|
||||||
static TOOL_ACTION placeSymbol;
|
static TOOL_ACTION placeSymbol;
|
||||||
static TOOL_ACTION placePower;
|
static TOOL_ACTION placePower;
|
||||||
|
static TOOL_ACTION startWire;
|
||||||
static TOOL_ACTION drawWire;
|
static TOOL_ACTION drawWire;
|
||||||
|
static TOOL_ACTION startBus;
|
||||||
static TOOL_ACTION drawBus;
|
static TOOL_ACTION drawBus;
|
||||||
static TOOL_ACTION unfoldBus;
|
static TOOL_ACTION unfoldBus;
|
||||||
static TOOL_ACTION placeNoConnect;
|
static TOOL_ACTION placeNoConnect;
|
||||||
|
@ -111,6 +113,9 @@ public:
|
||||||
|
|
||||||
// Editing
|
// Editing
|
||||||
static TOOL_ACTION properties;
|
static TOOL_ACTION properties;
|
||||||
|
static TOOL_ACTION addJunction;
|
||||||
|
static TOOL_ACTION addLabel;
|
||||||
|
static TOOL_ACTION addGlobalLabel;
|
||||||
|
|
||||||
/// Clipboard
|
/// Clipboard
|
||||||
static TOOL_ACTION copyToClipboard;
|
static TOOL_ACTION copyToClipboard;
|
||||||
|
|
|
@ -56,10 +56,18 @@ TOOL_ACTION SCH_ACTIONS::placePower( "eeschema.InteractiveDrawing.placePowerPort
|
||||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_POWER ),
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_POWER ),
|
||||||
_( "Add Power" ), _( "Add a power port" ), NULL, AF_ACTIVATE );
|
_( "Add Power" ), _( "Add a power port" ), NULL, AF_ACTIVATE );
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::startWire( "eeschema.InteractiveDrawing.startWire",
|
||||||
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_WIRE ),
|
||||||
|
_( "Add Wire" ), _( "Start drawing a wire" ), NULL, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION SCH_ACTIONS::drawWire( "eeschema.InteractiveDrawing.drawWire",
|
TOOL_ACTION SCH_ACTIONS::drawWire( "eeschema.InteractiveDrawing.drawWire",
|
||||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_WIRE ),
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_WIRE ),
|
||||||
_( "Add Wire" ), _( "Add a wire" ), NULL, AF_ACTIVATE );
|
_( "Add Wire" ), _( "Add a wire" ), NULL, AF_ACTIVATE );
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::startBus( "eeschema.InteractiveDrawing.startBus",
|
||||||
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_WIRE ),
|
||||||
|
_( "Add Bus" ), _( "Start drawing a bus" ), NULL, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION SCH_ACTIONS::drawBus( "eeschema.InteractiveDrawing.drawBus",
|
TOOL_ACTION SCH_ACTIONS::drawBus( "eeschema.InteractiveDrawing.drawBus",
|
||||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_BUS ),
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BEGIN_BUS ),
|
||||||
_( "Add Bus" ), _( "Add a bus" ), NULL, AF_ACTIVATE );
|
_( "Add Bus" ), _( "Add a bus" ), NULL, AF_ACTIVATE );
|
||||||
|
@ -83,7 +91,7 @@ TOOL_ACTION SCH_ACTIONS::placeBusBusEntry( "eeschema.InteractiveDrawing.placeBus
|
||||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_BUS_ENTRY ),
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_BUS_ENTRY ),
|
||||||
_( "Add Bus to Bus Entry" ), _( "Add a bus entry to a bus" ), NULL, AF_ACTIVATE );
|
_( "Add Bus to Bus Entry" ), _( "Add a bus entry to a bus" ), NULL, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION SCH_ACTIONS::placeLabel( "eeschema.InteractiveDrawing.placePLabel",
|
TOOL_ACTION SCH_ACTIONS::placeLabel( "eeschema.InteractiveDrawing.placeLabel",
|
||||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_LABEL ),
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_LABEL ),
|
||||||
_( "Add Label" ), _( "Add a net label" ), NULL, AF_ACTIVATE );
|
_( "Add Label" ), _( "Add a net label" ), NULL, AF_ACTIVATE );
|
||||||
|
|
||||||
|
@ -127,6 +135,16 @@ TOOL_ACTION SCH_ACTIONS::finishDrawing( "eeschema.InteractiveDrawing.finishDrawi
|
||||||
AS_GLOBAL, 0, "", "", NULL, AF_NONE );
|
AS_GLOBAL, 0, "", "", NULL, AF_NONE );
|
||||||
|
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::addJunction( "eeschema.InteractiveEditing.addJunction",
|
||||||
|
AS_GLOBAL, 0, "", "", NULL, AF_NONE );
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::addLabel( "eeschema.InteractiveEditing.addLabel",
|
||||||
|
AS_GLOBAL, 0, "", "", NULL, AF_NONE );
|
||||||
|
|
||||||
|
TOOL_ACTION SCH_ACTIONS::addGlobalLabel( "eeschema.InteractiveEditing.addGlobalLabel",
|
||||||
|
AS_GLOBAL, 0, "", "", NULL, AF_NONE );
|
||||||
|
|
||||||
|
|
||||||
SCH_DRAWING_TOOL::SCH_DRAWING_TOOL() :
|
SCH_DRAWING_TOOL::SCH_DRAWING_TOOL() :
|
||||||
TOOL_INTERACTIVE( "eeschema.InteractiveDrawing" ),
|
TOOL_INTERACTIVE( "eeschema.InteractiveDrawing" ),
|
||||||
m_view( nullptr ),
|
m_view( nullptr ),
|
||||||
|
@ -168,6 +186,49 @@ void SCH_DRAWING_TOOL::Reset( RESET_REASON aReason )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_DRAWING_TOOL::AddJunction( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
|
m_frame->GetCanvas()->MoveCursorToCrossHair();
|
||||||
|
m_frame->AddJunction( m_frame->GetCrossHairPosition() );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_DRAWING_TOOL::AddLabel( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
return doAddItem( SCH_LABEL_T );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_DRAWING_TOOL::AddGlobalLabel( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
return doAddItem( SCH_GLOBAL_LABEL_T );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_DRAWING_TOOL::doAddItem( KICAD_T aType )
|
||||||
|
{
|
||||||
|
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||||
|
|
||||||
|
SCH_ITEM* item = nullptr;
|
||||||
|
|
||||||
|
switch( aType )
|
||||||
|
{
|
||||||
|
case SCH_LABEL_T: item = m_frame->CreateNewText( LAYER_LOCLABEL ); break;
|
||||||
|
case SCH_GLOBAL_LABEL_T: item = m_frame->CreateNewText( LAYER_GLOBLABEL ); break;
|
||||||
|
default: wxFAIL_MSG( "doAddItem(): unknown type" );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_frame->AddItemToScreen( item );
|
||||||
|
m_frame->SetNoToolSelected();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// History lists for PlaceSymbol()
|
// History lists for PlaceSymbol()
|
||||||
static SCH_BASE_FRAME::HISTORY_LIST s_SymbolHistoryList;
|
static SCH_BASE_FRAME::HISTORY_LIST s_SymbolHistoryList;
|
||||||
static SCH_BASE_FRAME::HISTORY_LIST s_PowerHistoryList;
|
static SCH_BASE_FRAME::HISTORY_LIST s_PowerHistoryList;
|
||||||
|
@ -569,17 +630,37 @@ int SCH_DRAWING_TOOL::doTwoClickPlace( KICAD_T aType )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_DRAWING_TOOL::StartWire( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
m_frame->SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
|
||||||
|
|
||||||
|
m_frame->GetCanvas()->MoveCursorToCrossHair();
|
||||||
|
SCH_LINE* segment = startSegments( LAYER_WIRE, m_frame->GetCrossHairPosition() );
|
||||||
|
return doDrawSegments( LAYER_WIRE, segment );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_DRAWING_TOOL::DrawWire( const TOOL_EVENT& aEvent )
|
int SCH_DRAWING_TOOL::DrawWire( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
|
m_frame->SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
|
||||||
return doDrawSegments( LAYER_WIRE );
|
return doDrawSegments( LAYER_WIRE, nullptr );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int SCH_DRAWING_TOOL::StartBus( const TOOL_EVENT& aEvent )
|
||||||
|
{
|
||||||
|
m_frame->SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add bus" ) );
|
||||||
|
|
||||||
|
m_frame->GetCanvas()->MoveCursorToCrossHair();
|
||||||
|
SCH_LINE* segment = startSegments( LAYER_BUS, m_frame->GetCrossHairPosition() );
|
||||||
|
return doDrawSegments( LAYER_BUS, segment );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_DRAWING_TOOL::DrawBus( const TOOL_EVENT& aEvent )
|
int SCH_DRAWING_TOOL::DrawBus( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
m_frame->SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add bus" ) );
|
m_frame->SetToolID( ID_BUS_BUTT, wxCURSOR_PENCIL, _( "Add bus" ) );
|
||||||
return doDrawSegments( LAYER_BUS );
|
return doDrawSegments( LAYER_BUS, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -618,14 +699,14 @@ int SCH_DRAWING_TOOL::UnfoldBus( const TOOL_EVENT& aEvent )
|
||||||
m_frame->SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
|
m_frame->SetToolID( ID_WIRE_BUTT, wxCURSOR_PENCIL, _( "Add wire" ) );
|
||||||
|
|
||||||
m_frame->SetCrossHairPosition( m_busUnfold.entry->m_End() );
|
m_frame->SetCrossHairPosition( m_busUnfold.entry->m_End() );
|
||||||
return doDrawSegments( LAYER_WIRE );
|
return doDrawSegments( LAYER_WIRE, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_DRAWING_TOOL::DrawLines( const TOOL_EVENT& aEvent)
|
int SCH_DRAWING_TOOL::DrawLines( const TOOL_EVENT& aEvent)
|
||||||
{
|
{
|
||||||
m_frame->SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add lines" ) );
|
m_frame->SetToolID( ID_LINE_COMMENT_BUTT, wxCURSOR_PENCIL, _( "Add lines" ) );
|
||||||
return doDrawSegments( LAYER_NOTES );
|
return doDrawSegments( LAYER_NOTES, nullptr );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -784,10 +865,9 @@ static void computeBreakPoint( SCH_SCREEN* aScreen, SCH_LINE* aSegment, wxPoint&
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SCH_DRAWING_TOOL::doDrawSegments( int aType )
|
int SCH_DRAWING_TOOL::doDrawSegments( int aType, SCH_LINE* aSegment )
|
||||||
{
|
{
|
||||||
SCH_LINE* segment = nullptr;
|
bool forceHV = m_frame->GetForceHVLines();
|
||||||
bool forceHV = m_frame->GetForceHVLines();
|
|
||||||
|
|
||||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( SCH_ACTIONS::selectionClear, true );
|
||||||
m_controls->ShowCursor( true );
|
m_controls->ShowCursor( true );
|
||||||
|
@ -802,9 +882,9 @@ int SCH_DRAWING_TOOL::doDrawSegments( int aType )
|
||||||
|
|
||||||
if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsActivate() || evt->IsCancel() )
|
if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsActivate() || evt->IsCancel() )
|
||||||
{
|
{
|
||||||
if( segment || m_busUnfold.in_progress )
|
if( aSegment || m_busUnfold.in_progress )
|
||||||
{
|
{
|
||||||
segment = nullptr;
|
aSegment = nullptr;
|
||||||
s_wires.DeleteAll();
|
s_wires.DeleteAll();
|
||||||
|
|
||||||
if( m_busUnfold.entry )
|
if( m_busUnfold.entry )
|
||||||
|
@ -833,7 +913,7 @@ int SCH_DRAWING_TOOL::doDrawSegments( int aType )
|
||||||
}
|
}
|
||||||
else if( evt->IsAction( &SCH_ACTIONS::finishDrawing ) )
|
else if( evt->IsAction( &SCH_ACTIONS::finishDrawing ) )
|
||||||
{
|
{
|
||||||
if( segment || m_busUnfold.in_progress )
|
if( aSegment || m_busUnfold.in_progress )
|
||||||
{
|
{
|
||||||
finishSegments();
|
finishSegments();
|
||||||
break;
|
break;
|
||||||
|
@ -844,7 +924,7 @@ int SCH_DRAWING_TOOL::doDrawSegments( int aType )
|
||||||
// JEY TODO
|
// JEY TODO
|
||||||
// m_menu.ShowContextMenu();
|
// m_menu.ShowContextMenu();
|
||||||
}
|
}
|
||||||
else if( evt->IsClick( BUT_LEFT ) || ( segment && evt->IsDblClick( BUT_LEFT ) ) )
|
else if( evt->IsClick( BUT_LEFT ) || ( aSegment && evt->IsDblClick( BUT_LEFT ) ) )
|
||||||
{
|
{
|
||||||
// First click when unfolding places the label and wire-to-bus entry
|
// First click when unfolding places the label and wire-to-bus entry
|
||||||
if( m_busUnfold.in_progress && !m_busUnfold.label_placed )
|
if( m_busUnfold.in_progress && !m_busUnfold.label_placed )
|
||||||
|
@ -854,60 +934,41 @@ int SCH_DRAWING_TOOL::doDrawSegments( int aType )
|
||||||
m_frame->AddToScreen( m_busUnfold.label );
|
m_frame->AddToScreen( m_busUnfold.label );
|
||||||
m_busUnfold.label_placed = true;
|
m_busUnfold.label_placed = true;
|
||||||
|
|
||||||
segment->ClearFlags( IS_NEW );
|
aSegment->ClearFlags( IS_NEW );
|
||||||
segment->SetFlags( SELECTED );
|
aSegment->SetFlags( SELECTED );
|
||||||
|
|
||||||
segment = new SCH_LINE( *segment );
|
aSegment = new SCH_LINE( *aSegment );
|
||||||
segment->SetFlags( IS_NEW );
|
aSegment->SetFlags( IS_NEW );
|
||||||
segment->SetStartPoint( cursorPos );
|
aSegment->SetStartPoint( cursorPos );
|
||||||
s_wires.PushBack( segment );
|
s_wires.PushBack( aSegment );
|
||||||
m_frame->GetScreen()->SetCurItem( segment );
|
m_frame->GetScreen()->SetCurItem( aSegment );
|
||||||
}
|
}
|
||||||
else if( !segment )
|
else if( !aSegment )
|
||||||
{
|
{
|
||||||
switch( aType )
|
aSegment = startSegments( aType, cursorPos );
|
||||||
{
|
|
||||||
default: segment = new SCH_LINE( cursorPos, LAYER_NOTES ); break;
|
|
||||||
case LAYER_WIRE: segment = new SCH_LINE( cursorPos, LAYER_WIRE ); break;
|
|
||||||
case LAYER_BUS: segment = new SCH_LINE( cursorPos, LAYER_BUS ); break;
|
|
||||||
}
|
|
||||||
|
|
||||||
segment->SetFlags( IS_NEW );
|
|
||||||
s_wires.PushBack( segment );
|
|
||||||
m_frame->GetScreen()->SetCurItem( segment );
|
|
||||||
|
|
||||||
// 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( forceHV )
|
|
||||||
{
|
|
||||||
segment = new SCH_LINE( *segment );
|
|
||||||
segment->SetFlags( IS_NEW );
|
|
||||||
s_wires.PushBack( segment );
|
|
||||||
m_frame->GetScreen()->SetCurItem( segment );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Create a new segment if we're out of previously-created ones
|
// Create a new segment if we're out of previously-created ones
|
||||||
else if( !segment->IsNull() || ( forceHV && !segment->Back()->IsNull() ) )
|
else if( !aSegment->IsNull() || ( forceHV && !aSegment->Back()->IsNull() ) )
|
||||||
{
|
{
|
||||||
// Terminate the command if the end point is on a pin, junction, or another
|
// Terminate the command if the end point is on a pin, junction, or another
|
||||||
// wire or bus.
|
// wire or bus.
|
||||||
if( !m_busUnfold.in_progress &&
|
if( !m_busUnfold.in_progress &&
|
||||||
m_frame->GetScreen()->IsTerminalPoint( cursorPos, segment->GetLayer() ) )
|
m_frame->GetScreen()->IsTerminalPoint( cursorPos, aSegment->GetLayer() ) )
|
||||||
{
|
{
|
||||||
finishSegments();
|
finishSegments();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
segment->SetEndPoint( cursorPos );
|
aSegment->SetEndPoint( cursorPos );
|
||||||
segment->ClearFlags( IS_NEW );
|
aSegment->ClearFlags( IS_NEW );
|
||||||
segment->SetFlags( SELECTED );
|
aSegment->SetFlags( SELECTED );
|
||||||
|
|
||||||
// Create a new segment, and chain it after the current new segment.
|
// Create a new segment, and chain it after the current new segment.
|
||||||
segment = new SCH_LINE( *segment );
|
aSegment = new SCH_LINE( *aSegment );
|
||||||
segment->SetFlags( IS_NEW );
|
aSegment->SetFlags( IS_NEW );
|
||||||
segment->SetStartPoint( cursorPos );
|
aSegment->SetStartPoint( cursorPos );
|
||||||
s_wires.PushBack( segment );
|
s_wires.PushBack( aSegment );
|
||||||
m_frame->GetScreen()->SetCurItem( segment );
|
m_frame->GetScreen()->SetCurItem( aSegment );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( evt->IsDblClick( BUT_LEFT ) )
|
if( evt->IsDblClick( BUT_LEFT ) )
|
||||||
|
@ -953,13 +1014,13 @@ int SCH_DRAWING_TOOL::doDrawSegments( int aType )
|
||||||
m_view->AddToPreview( m_busUnfold.label->Clone() );
|
m_view->AddToPreview( m_busUnfold.label->Clone() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( segment )
|
if( aSegment )
|
||||||
{
|
{
|
||||||
// Coerce the line to vertical or horizontal if necessary
|
// Coerce the line to vertical or horizontal if necessary
|
||||||
if( forceHV )
|
if( forceHV )
|
||||||
computeBreakPoint( m_frame->GetScreen(), segment->Back(), cursorPos );
|
computeBreakPoint( m_frame->GetScreen(), aSegment->Back(), cursorPos );
|
||||||
else
|
else
|
||||||
segment->SetEndPoint( cursorPos );
|
aSegment->SetEndPoint( cursorPos );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( auto seg = s_wires.begin(); seg; seg = seg->Next() )
|
for( auto seg = s_wires.begin(); seg; seg = seg->Next() )
|
||||||
|
@ -970,8 +1031,8 @@ int SCH_DRAWING_TOOL::doDrawSegments( int aType )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable autopanning and cursor capture only when there is a segment to be placed
|
// Enable autopanning and cursor capture only when there is a segment to be placed
|
||||||
m_controls->SetAutoPan( !!segment );
|
m_controls->SetAutoPan( !!aSegment );
|
||||||
m_controls->CaptureCursor( !!segment );
|
m_controls->CaptureCursor( !!aSegment );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_frame->SetNoToolSelected();
|
m_frame->SetNoToolSelected();
|
||||||
|
@ -980,6 +1041,36 @@ int SCH_DRAWING_TOOL::doDrawSegments( int aType )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SCH_LINE* SCH_DRAWING_TOOL::startSegments( int aType, const wxPoint& aPos )
|
||||||
|
{
|
||||||
|
SCH_LINE* segment = nullptr;
|
||||||
|
bool forceHV = m_frame->GetForceHVLines();
|
||||||
|
|
||||||
|
switch( aType )
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
segment->SetFlags( IS_NEW );
|
||||||
|
s_wires.PushBack( segment );
|
||||||
|
m_frame->GetScreen()->SetCurItem( segment );
|
||||||
|
|
||||||
|
// 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( forceHV )
|
||||||
|
{
|
||||||
|
segment = new SCH_LINE( *segment );
|
||||||
|
segment->SetFlags( IS_NEW );
|
||||||
|
s_wires.PushBack( segment );
|
||||||
|
m_frame->GetScreen()->SetCurItem( segment );
|
||||||
|
}
|
||||||
|
|
||||||
|
return segment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_DRAWING_TOOL::finishSegments()
|
void SCH_DRAWING_TOOL::finishSegments()
|
||||||
{
|
{
|
||||||
PICKED_ITEMS_LIST itemList;
|
PICKED_ITEMS_LIST itemList;
|
||||||
|
@ -1251,4 +1342,10 @@ void SCH_DRAWING_TOOL::setTransitions()
|
||||||
Go( &SCH_DRAWING_TOOL::PlaceSchematicText, SCH_ACTIONS::placeSchematicText.MakeEvent() );
|
Go( &SCH_DRAWING_TOOL::PlaceSchematicText, SCH_ACTIONS::placeSchematicText.MakeEvent() );
|
||||||
Go( &SCH_DRAWING_TOOL::DrawLines, SCH_ACTIONS::drawLines.MakeEvent() );
|
Go( &SCH_DRAWING_TOOL::DrawLines, SCH_ACTIONS::drawLines.MakeEvent() );
|
||||||
Go( &SCH_DRAWING_TOOL::PlaceImage, SCH_ACTIONS::placeImage.MakeEvent() );
|
Go( &SCH_DRAWING_TOOL::PlaceImage, SCH_ACTIONS::placeImage.MakeEvent() );
|
||||||
|
|
||||||
|
Go( &SCH_DRAWING_TOOL::StartWire, SCH_ACTIONS::startWire.MakeEvent() );
|
||||||
|
Go( &SCH_DRAWING_TOOL::StartBus, SCH_ACTIONS::startBus.MakeEvent() );
|
||||||
|
Go( &SCH_DRAWING_TOOL::AddJunction, SCH_ACTIONS::addJunction.MakeEvent() );
|
||||||
|
Go( &SCH_DRAWING_TOOL::AddLabel, SCH_ACTIONS::addLabel.MakeEvent() );
|
||||||
|
Go( &SCH_DRAWING_TOOL::AddGlobalLabel, SCH_ACTIONS::addGlobalLabel.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,12 @@ public:
|
||||||
return m_menu;
|
return m_menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int StartWire( const TOOL_EVENT& aEvent );
|
||||||
|
int StartBus( const TOOL_EVENT& aEvent );
|
||||||
|
int AddJunction( const TOOL_EVENT& aEvent );
|
||||||
|
int AddLabel( const TOOL_EVENT& aEvent );
|
||||||
|
int AddGlobalLabel( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
int PlaceSymbol( const TOOL_EVENT& aEvent );
|
int PlaceSymbol( const TOOL_EVENT& aEvent );
|
||||||
int PlacePower( const TOOL_EVENT& aEvent );
|
int PlacePower( const TOOL_EVENT& aEvent );
|
||||||
int DrawWire( const TOOL_EVENT& aEvent );
|
int DrawWire( const TOOL_EVENT& aEvent );
|
||||||
|
@ -98,6 +104,8 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
int doAddItem( KICAD_T aType );
|
||||||
|
|
||||||
int doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter,
|
int doPlaceComponent( SCH_COMPONENT* aComponent, SCHLIB_FILTER* aFilter,
|
||||||
SCH_BASE_FRAME::HISTORY_LIST aHistoryList );
|
SCH_BASE_FRAME::HISTORY_LIST aHistoryList );
|
||||||
|
|
||||||
|
@ -105,7 +113,8 @@ private:
|
||||||
|
|
||||||
int doTwoClickPlace( KICAD_T aType );
|
int doTwoClickPlace( KICAD_T aType );
|
||||||
|
|
||||||
int doDrawSegments( int aType );
|
int doDrawSegments( int aType, SCH_LINE* aSegment );
|
||||||
|
SCH_LINE* startSegments( int aType, const wxPoint& aPos );
|
||||||
void finishSegments();
|
void finishSegments();
|
||||||
|
|
||||||
int doDrawSheet( SCH_SHEET* aSheet );
|
int doDrawSheet( SCH_SHEET* aSheet );
|
||||||
|
|
Loading…
Reference in New Issue