Implement RMB Import Sheet Pin as a single-shot.
Fixes https://gitlab.com/kicad/code/kicad/issues/7638
This commit is contained in:
parent
fbf12cb85c
commit
18d4d517b0
|
@ -304,13 +304,13 @@ TOOL_ACTION EE_ACTIONS::placeLabel( "eeschema.InteractiveDrawing.placeLabel",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
'L', LEGACY_HK_NAME( "Add Label" ),
|
'L', LEGACY_HK_NAME( "Add Label" ),
|
||||||
_( "Add Label" ), _( "Add a net label" ),
|
_( "Add Label" ), _( "Add a net label" ),
|
||||||
add_label_xpm, AF_ACTIVATE, (void*) SCH_LABEL_T );
|
add_label_xpm, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::placeHierLabel( "eeschema.InteractiveDrawing.placeHierarchicalLabel",
|
TOOL_ACTION EE_ACTIONS::placeHierLabel( "eeschema.InteractiveDrawing.placeHierarchicalLabel",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
'H', LEGACY_HK_NAME( "Add Hierarchical Label" ),
|
'H', LEGACY_HK_NAME( "Add Hierarchical Label" ),
|
||||||
_( "Add Hierarchical Label" ), _( "Add a hierarchical label" ),
|
_( "Add Hierarchical Label" ), _( "Add a hierarchical label" ),
|
||||||
add_hierarchical_label_xpm, AF_ACTIVATE, (void*) SCH_HIER_LABEL_T );
|
add_hierarchical_label_xpm, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::drawSheet( "eeschema.InteractiveDrawing.drawSheet",
|
TOOL_ACTION EE_ACTIONS::drawSheet( "eeschema.InteractiveDrawing.drawSheet",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
|
@ -318,27 +318,27 @@ TOOL_ACTION EE_ACTIONS::drawSheet( "eeschema.InteractiveDrawing.drawSheet",
|
||||||
_( "Add Sheet" ), _( "Add a hierarchical sheet" ),
|
_( "Add Sheet" ), _( "Add a hierarchical sheet" ),
|
||||||
add_hierarchical_subsheet_xpm, AF_ACTIVATE, (void*) SCH_SHEET_T );
|
add_hierarchical_subsheet_xpm, AF_ACTIVATE, (void*) SCH_SHEET_T );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::placeSheetPin( "eeschema.InteractiveDrawing.placeSheetPin",
|
TOOL_ACTION EE_ACTIONS::importSingleSheetPin( "eeschema.InteractiveDrawing.importSingleSheetPin",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
_( "Add Sheet Pin" ), _( "Add a sheet pin" ),
|
_( "Import Sheet Pin" ), _( "Import a hierarchical sheet pin" ),
|
||||||
add_hierar_pin_xpm, AF_ACTIVATE, (void*) SCH_SHEET_PIN_T );
|
add_hierar_pin_xpm, AF_ACTIVATE, (void*) SCH_SHEET_PIN_T );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::importSheetPin( "eeschema.InteractiveDrawing.importSheetPin",
|
TOOL_ACTION EE_ACTIONS::importSheetPin( "eeschema.InteractiveDrawing.importSheetPin",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
_( "Import Sheet Pin" ), _( "Import a hierarchical sheet pin" ),
|
_( "Import Sheet Pin" ), _( "Import a hierarchical sheet pin" ),
|
||||||
import_hierarchical_label_xpm, AF_ACTIVATE, (void*) SCH_SHEET_PIN_T );
|
import_hierarchical_label_xpm, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::placeGlobalLabel( "eeschema.InteractiveDrawing.placeGlobalLabel",
|
TOOL_ACTION EE_ACTIONS::placeGlobalLabel( "eeschema.InteractiveDrawing.placeGlobalLabel",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
MD_CTRL + 'H', LEGACY_HK_NAME( "Add Global Label" ),
|
MD_CTRL + 'H', LEGACY_HK_NAME( "Add Global Label" ),
|
||||||
_( "Add Global Label" ), _( "Add a global label" ),
|
_( "Add Global Label" ), _( "Add a global label" ),
|
||||||
add_glabel_xpm, AF_ACTIVATE, (void*) SCH_GLOBAL_LABEL_T );
|
add_glabel_xpm, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::placeSchematicText( "eeschema.InteractiveDrawing.placeSchematicText",
|
TOOL_ACTION EE_ACTIONS::placeSchematicText( "eeschema.InteractiveDrawing.placeSchematicText",
|
||||||
AS_GLOBAL,
|
AS_GLOBAL,
|
||||||
'T', LEGACY_HK_NAME( "Add Graphic Text" ),
|
'T', LEGACY_HK_NAME( "Add Graphic Text" ),
|
||||||
_( "Add Text" ), _( "Add text" ),
|
_( "Add Text" ), _( "Add text" ),
|
||||||
text_xpm, AF_ACTIVATE, (void*) SCH_TEXT_T );
|
text_xpm, AF_ACTIVATE );
|
||||||
|
|
||||||
TOOL_ACTION EE_ACTIONS::placeImage( "eeschema.InteractiveDrawing.placeImage",
|
TOOL_ACTION EE_ACTIONS::placeImage( "eeschema.InteractiveDrawing.placeImage",
|
||||||
AS_GLOBAL, 0, "",
|
AS_GLOBAL, 0, "",
|
||||||
|
|
|
@ -84,7 +84,6 @@ public:
|
||||||
static TOOL_ACTION placeGlobalLabel;
|
static TOOL_ACTION placeGlobalLabel;
|
||||||
static TOOL_ACTION placeHierLabel;
|
static TOOL_ACTION placeHierLabel;
|
||||||
static TOOL_ACTION drawSheet;
|
static TOOL_ACTION drawSheet;
|
||||||
static TOOL_ACTION placeSheetPin;
|
|
||||||
static TOOL_ACTION importSheetPin;
|
static TOOL_ACTION importSheetPin;
|
||||||
static TOOL_ACTION placeSchematicText;
|
static TOOL_ACTION placeSchematicText;
|
||||||
static TOOL_ACTION drawLines;
|
static TOOL_ACTION drawLines;
|
||||||
|
@ -183,6 +182,7 @@ public:
|
||||||
static TOOL_ACTION leaveSheet;
|
static TOOL_ACTION leaveSheet;
|
||||||
static TOOL_ACTION navigateHierarchy;
|
static TOOL_ACTION navigateHierarchy;
|
||||||
static TOOL_ACTION hypertextCommand;
|
static TOOL_ACTION hypertextCommand;
|
||||||
|
static TOOL_ACTION importSingleSheetPin;
|
||||||
|
|
||||||
// Global edit tools
|
// Global edit tools
|
||||||
static TOOL_ACTION cleanupSheetPins;
|
static TOOL_ACTION cleanupSheetPins;
|
||||||
|
|
|
@ -221,7 +221,7 @@ bool EE_SELECTION_TOOL::Init()
|
||||||
menu.AddItem( EE_ACTIONS::placeHierLabel, 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::breakWire, wireSelection && EE_CONDITIONS::Idle, 250 );
|
||||||
menu.AddItem( EE_ACTIONS::breakBus, busSelection && EE_CONDITIONS::Idle, 250 );
|
menu.AddItem( EE_ACTIONS::breakBus, busSelection && EE_CONDITIONS::Idle, 250 );
|
||||||
menu.AddItem( EE_ACTIONS::importSheetPin, sheetSelection && 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::assignNetclass, connectedSelection && EE_CONDITIONS::Idle, 250 );
|
||||||
menu.AddItem( EE_ACTIONS::editPageNumber, schEditSheetPageNumberCondition, 250 );
|
menu.AddItem( EE_ACTIONS::editPageNumber, schEditSheetPageNumberCondition, 250 );
|
||||||
|
|
||||||
|
|
|
@ -502,16 +502,14 @@ int SCH_DRAWING_TOOLS::PlaceImage( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxPoint cursorPos;
|
wxPoint cursorPos;
|
||||||
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
||||||
EE_GRID_HELPER grid( m_toolMgr );
|
EE_GRID_HELPER grid( m_toolMgr );
|
||||||
|
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
|
SCH_ITEM* previewItem;
|
||||||
|
|
||||||
if( m_inSingleClickPlace )
|
if( m_inSingleClickPlace )
|
||||||
return 0;
|
return 0;
|
||||||
else
|
|
||||||
m_inSingleClickPlace = true;
|
|
||||||
|
|
||||||
if( type == SCH_JUNCTION_T && aEvent.HasPosition() )
|
if( type == SCH_JUNCTION_T && aEvent.HasPosition() )
|
||||||
{
|
{
|
||||||
|
@ -527,40 +525,68 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch( type )
|
||||||
|
{
|
||||||
|
case SCH_NO_CONNECT_T:
|
||||||
|
previewItem = new SCH_NO_CONNECT( cursorPos );
|
||||||
|
previewItem->SetParent( m_frame->GetScreen() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SCH_JUNCTION_T:
|
||||||
|
previewItem = new SCH_JUNCTION( cursorPos );
|
||||||
|
previewItem->SetParent( m_frame->GetScreen() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SCH_BUS_WIRE_ENTRY_T:
|
||||||
|
previewItem = new SCH_BUS_WIRE_ENTRY( cursorPos );
|
||||||
|
previewItem->SetParent( m_frame->GetScreen() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SCH_SHEET_PIN_T:
|
||||||
|
{
|
||||||
|
EE_SELECTION& selection = m_selectionTool->GetSelection();
|
||||||
|
SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( selection.Front() );
|
||||||
|
|
||||||
|
if( !sheet )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
SCH_HIERLABEL* label = importHierLabel( sheet );
|
||||||
|
|
||||||
|
if( !label )
|
||||||
|
{
|
||||||
|
m_statusPopup.reset( new STATUS_TEXT_POPUP( m_frame ) );
|
||||||
|
m_statusPopup->SetText( _( "No new hierarchical labels found." ) );
|
||||||
|
m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, 20 ) );
|
||||||
|
m_statusPopup->PopupFor( 2000 );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
previewItem = createSheetPin( sheet, label );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxASSERT_MSG( false, "Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_inSingleClickPlace = true;
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
|
|
||||||
cursorPos = aEvent.IsPrime() ? (wxPoint) aEvent.Position()
|
cursorPos = aEvent.IsPrime() ? (wxPoint) aEvent.Position()
|
||||||
: (wxPoint) controls->GetMousePosition();
|
: (wxPoint) controls->GetMousePosition();
|
||||||
|
|
||||||
SCH_ITEM* previewItem;
|
|
||||||
switch( type )
|
|
||||||
{
|
|
||||||
case SCH_NO_CONNECT_T:
|
|
||||||
previewItem = new SCH_NO_CONNECT( cursorPos );
|
|
||||||
break;
|
|
||||||
case SCH_JUNCTION_T:
|
|
||||||
previewItem = new SCH_JUNCTION( cursorPos );
|
|
||||||
break;
|
|
||||||
case SCH_BUS_WIRE_ENTRY_T:
|
|
||||||
previewItem = new SCH_BUS_WIRE_ENTRY( cursorPos );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
wxASSERT_MSG( false, "Unknown item type in SCH_DRAWING_TOOLS::SingleClickPlace" );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
previewItem->SetParent( m_frame->GetScreen() );
|
|
||||||
|
|
||||||
m_view->ClearPreview();
|
|
||||||
m_view->AddToPreview( previewItem->Clone() );
|
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
m_frame->PushTool( tool );
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
|
m_view->ClearPreview();
|
||||||
|
m_view->AddToPreview( previewItem->Clone() );
|
||||||
|
|
||||||
// Prime the pump
|
// Prime the pump
|
||||||
if( aEvent.HasPosition() )
|
if( aEvent.HasPosition() && type != SCH_SHEET_PIN_T )
|
||||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||||
else
|
else
|
||||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||||
|
@ -614,7 +640,9 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
newItem->SetFlags( IS_NEW );
|
newItem->SetFlags( IS_NEW );
|
||||||
|
|
||||||
m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), newItem, false );
|
m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), newItem, false );
|
||||||
m_frame->SaveCopyForRepeatItem( newItem );
|
|
||||||
|
if( type != SCH_SHEET_PIN_T )
|
||||||
|
m_frame->SaveCopyForRepeatItem( newItem );
|
||||||
|
|
||||||
if( type == SCH_JUNCTION_T )
|
if( type == SCH_JUNCTION_T )
|
||||||
m_frame->TestDanglingEnds();
|
m_frame->TestDanglingEnds();
|
||||||
|
@ -624,7 +652,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( evt->IsDblClick( BUT_LEFT ) ) // Finish tool.
|
if( evt->IsDblClick( BUT_LEFT ) || type == SCH_SHEET_PIN_T ) // Finish tool.
|
||||||
{
|
{
|
||||||
m_frame->PopTool( tool );
|
m_frame->PopTool( tool );
|
||||||
break;
|
break;
|
||||||
|
@ -1255,6 +1283,7 @@ void SCH_DRAWING_TOOLS::setTransitions()
|
||||||
Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeGlobalLabel.MakeEvent() );
|
Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeGlobalLabel.MakeEvent() );
|
||||||
Go( &SCH_DRAWING_TOOLS::DrawSheet, EE_ACTIONS::drawSheet.MakeEvent() );
|
Go( &SCH_DRAWING_TOOLS::DrawSheet, EE_ACTIONS::drawSheet.MakeEvent() );
|
||||||
Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::importSheetPin.MakeEvent() );
|
Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::importSheetPin.MakeEvent() );
|
||||||
|
Go( &SCH_DRAWING_TOOLS::SingleClickPlace, EE_ACTIONS::importSingleSheetPin.MakeEvent() );
|
||||||
Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeSchematicText.MakeEvent() );
|
Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeSchematicText.MakeEvent() );
|
||||||
Go( &SCH_DRAWING_TOOLS::PlaceImage, EE_ACTIONS::placeImage.MakeEvent() );
|
Go( &SCH_DRAWING_TOOLS::PlaceImage, EE_ACTIONS::placeImage.MakeEvent() );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue