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,
|
||||
'L', LEGACY_HK_NAME( "Add 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",
|
||||
AS_GLOBAL,
|
||||
'H', LEGACY_HK_NAME( "Add 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",
|
||||
AS_GLOBAL,
|
||||
|
@ -318,27 +318,27 @@ TOOL_ACTION EE_ACTIONS::drawSheet( "eeschema.InteractiveDrawing.drawSheet",
|
|||
_( "Add Sheet" ), _( "Add a hierarchical sheet" ),
|
||||
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, "",
|
||||
_( "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 );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::importSheetPin( "eeschema.InteractiveDrawing.importSheetPin",
|
||||
AS_GLOBAL, 0, "",
|
||||
_( "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",
|
||||
AS_GLOBAL,
|
||||
MD_CTRL + 'H', LEGACY_HK_NAME( "Add 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",
|
||||
AS_GLOBAL,
|
||||
'T', LEGACY_HK_NAME( "Add Graphic 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",
|
||||
AS_GLOBAL, 0, "",
|
||||
|
|
|
@ -84,7 +84,6 @@ public:
|
|||
static TOOL_ACTION placeGlobalLabel;
|
||||
static TOOL_ACTION placeHierLabel;
|
||||
static TOOL_ACTION drawSheet;
|
||||
static TOOL_ACTION placeSheetPin;
|
||||
static TOOL_ACTION importSheetPin;
|
||||
static TOOL_ACTION placeSchematicText;
|
||||
static TOOL_ACTION drawLines;
|
||||
|
@ -183,6 +182,7 @@ public:
|
|||
static TOOL_ACTION leaveSheet;
|
||||
static TOOL_ACTION navigateHierarchy;
|
||||
static TOOL_ACTION hypertextCommand;
|
||||
static TOOL_ACTION importSingleSheetPin;
|
||||
|
||||
// Global edit tools
|
||||
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::breakWire, wireSelection && 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::editPageNumber, schEditSheetPageNumberCondition, 250 );
|
||||
|
||||
|
|
|
@ -505,13 +505,11 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
wxPoint cursorPos;
|
||||
KICAD_T type = aEvent.Parameter<KICAD_T>();
|
||||
EE_GRID_HELPER grid( m_toolMgr );
|
||||
|
||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||
SCH_ITEM* previewItem;
|
||||
|
||||
if( m_inSingleClickPlace )
|
||||
return 0;
|
||||
else
|
||||
m_inSingleClickPlace = true;
|
||||
|
||||
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 );
|
||||
getViewControls()->ShowCursor( true );
|
||||
|
||||
cursorPos = aEvent.IsPrime() ? (wxPoint) aEvent.Position()
|
||||
: (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();
|
||||
m_frame->PushTool( tool );
|
||||
Activate();
|
||||
|
||||
m_view->ClearPreview();
|
||||
m_view->AddToPreview( previewItem->Clone() );
|
||||
|
||||
// Prime the pump
|
||||
if( aEvent.HasPosition() )
|
||||
if( aEvent.HasPosition() && type != SCH_SHEET_PIN_T )
|
||||
m_toolMgr->RunAction( ACTIONS::cursorClick );
|
||||
else
|
||||
m_toolMgr->RunAction( ACTIONS::refreshPreview );
|
||||
|
@ -614,6 +640,8 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
newItem->SetFlags( IS_NEW );
|
||||
|
||||
m_frame->AddItemToScreenAndUndoList( m_frame->GetScreen(), newItem, false );
|
||||
|
||||
if( type != SCH_SHEET_PIN_T )
|
||||
m_frame->SaveCopyForRepeatItem( newItem );
|
||||
|
||||
if( type == SCH_JUNCTION_T )
|
||||
|
@ -624,7 +652,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
|||
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 );
|
||||
break;
|
||||
|
@ -1255,6 +1283,7 @@ void SCH_DRAWING_TOOLS::setTransitions()
|
|||
Go( &SCH_DRAWING_TOOLS::TwoClickPlace, EE_ACTIONS::placeGlobalLabel.MakeEvent() );
|
||||
Go( &SCH_DRAWING_TOOLS::DrawSheet, EE_ACTIONS::drawSheet.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::PlaceImage, EE_ACTIONS::placeImage.MakeEvent() );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue