Implement sheet cleanup in modern toolset.
This commit is contained in:
parent
1e5334f5d4
commit
90a663facd
|
@ -172,10 +172,6 @@ void AddMenusForHierchicalSheet( wxMenu* PopMenu, SCH_SHEET* Sheet )
|
|||
{
|
||||
AddMenuItem( PopMenu, ID_POPUP_IMPORT_HLABEL_TO_SHEETPIN, _( "Import Sheet Pins" ),
|
||||
KiBitmap( import_hierarchical_label_xpm ) );
|
||||
|
||||
if( Sheet->HasUndefinedPins() ) // Sheet has pin labels, and can be cleaned
|
||||
AddMenuItem( PopMenu, ID_POPUP_SCH_CLEANUP_SHEET, _( "Cleanup Sheet Pins" ),
|
||||
KiBitmap( options_pinsheet_xpm ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -27,70 +27,26 @@
|
|||
#include <kiway.h>
|
||||
#include <gr_basic.h>
|
||||
#include <sch_draw_panel.h>
|
||||
#include <confirm.h>
|
||||
#include <sch_edit_frame.h>
|
||||
#include <hotkeys_basic.h>
|
||||
#include <general.h>
|
||||
#include <eeschema_id.h>
|
||||
#include <list_operations.h>
|
||||
#include <class_library.h>
|
||||
#include <sch_bus_entry.h>
|
||||
#include <sch_marker.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_junction.h>
|
||||
#include <sch_line.h>
|
||||
#include <sch_sheet.h>
|
||||
#include <sch_sheet_path.h>
|
||||
#include <sch_view.h>
|
||||
#include <tool/tool_manager.h>
|
||||
#include <tools/sch_actions.h>
|
||||
#include <tools/sch_selection_tool.h>
|
||||
|
||||
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||
void SCH_EDIT_FRAME::Process_Special_Functions( wxCommandEvent& event )
|
||||
{
|
||||
int id = event.GetId();
|
||||
wxPoint pos;
|
||||
SCH_SCREEN* screen = GetScreen();
|
||||
SCH_ITEM* item = screen->GetCurItem();
|
||||
|
||||
pos = wxGetMousePosition();
|
||||
|
||||
pos.y += 20;
|
||||
|
||||
switch( id )
|
||||
if( event.GetId() == ID_HIERARCHY )
|
||||
{
|
||||
case ID_HIERARCHY:
|
||||
wxPoint pos = wxGetMousePosition();
|
||||
pos.y += 20;
|
||||
|
||||
SetNoToolSelected();
|
||||
InstallHierarchyFrame( pos );
|
||||
SetRepeatItem( NULL );
|
||||
break;
|
||||
|
||||
case ID_POPUP_SCH_CLEANUP_SHEET:
|
||||
if( item != NULL && item->Type() == SCH_SHEET_T )
|
||||
{
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) item;
|
||||
|
||||
if( !sheet->HasUndefinedPins() )
|
||||
{
|
||||
DisplayInfoMessage( this, _( "There are no undefined labels in this sheet to clean up." ) );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !IsOK( this, _( "Do you wish to cleanup this sheet?" ) ) )
|
||||
return;
|
||||
|
||||
/* Save sheet in undo list before cleaning up unreferenced hierarchical labels. */
|
||||
SaveCopyInUndoList( sheet, UR_CHANGED );
|
||||
sheet->CleanupSheet();
|
||||
SyncView();
|
||||
GetCanvas()->Refresh();
|
||||
OnModify();
|
||||
}
|
||||
break;
|
||||
|
||||
default: // Log error:
|
||||
wxFAIL_MSG( wxString::Format( "Cannot process command event ID %d", event.GetId() ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -269,6 +269,9 @@ OPT<TOOL_EVENT> SCH_ACTIONS::TranslateLegacyId( int aId )
|
|||
case ID_POPUP_SCH_LEAVE_SHEET:
|
||||
return SCH_ACTIONS::leaveSheet.MakeEvent();
|
||||
|
||||
case ID_POPUP_SCH_CLEANUP_SHEET:
|
||||
return SCH_ACTIONS::cleanupSheetPins.MakeEvent();
|
||||
|
||||
case ID_POPUP_SCH_SELECT_ON_PCB:
|
||||
return SCH_ACTIONS::explicitCrossProbe.MakeEvent();
|
||||
}
|
||||
|
|
|
@ -145,6 +145,7 @@ public:
|
|||
// Miscellaneous
|
||||
static TOOL_ACTION enterSheet;
|
||||
static TOOL_ACTION leaveSheet;
|
||||
static TOOL_ACTION cleanupSheetPins;
|
||||
static TOOL_ACTION switchCursor;
|
||||
static TOOL_ACTION switchUnits;
|
||||
static TOOL_ACTION updateUnits;
|
||||
|
|
|
@ -147,6 +147,11 @@ TOOL_ACTION SCH_ACTIONS::toText( "eeschema.InteractiveEdit.toText",
|
|||
_( "Change to Text" ), _( "Change existing item to a text comment" ),
|
||||
text_xpm );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::cleanupSheetPins( "eeschema.InteractiveEdit.cleanupSheetPins",
|
||||
AS_GLOBAL, 0,
|
||||
_( "Cleanup Sheet Pins" ), _( "Delete unreferenced sheet pins" ),
|
||||
nullptr );
|
||||
|
||||
TOOL_ACTION SCH_ACTIONS::doDelete( "eeschema.InteractiveEdit.doDelete",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DELETE ),
|
||||
_( "Delete" ), _( "Deletes selected item(s)" ),
|
||||
|
@ -275,6 +280,9 @@ bool SCH_EDIT_TOOL::Init()
|
|||
auto singleComponentCondition = SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyType( SCH_COMPONENT_T );
|
||||
|
||||
auto singleSheetCondition = SELECTION_CONDITIONS::Count( 1 )
|
||||
&& SELECTION_CONDITIONS::OnlyType( SCH_SHEET_T );
|
||||
|
||||
auto singleSymbolCondition = [] ( const SELECTION& aSel ) {
|
||||
if( aSel.GetSize() == 1 )
|
||||
{
|
||||
|
@ -406,6 +414,7 @@ bool SCH_EDIT_TOOL::Init()
|
|||
selToolMenu.AddItem( SCH_ACTIONS::toText, toTextlCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::breakWire, wireSelectionCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::breakBus, busSelectionCondition, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::cleanupSheetPins, singleSheetCondition, 200 );
|
||||
|
||||
selToolMenu.AddSeparator( SELECTION_CONDITIONS::NotEmpty, 200 );
|
||||
selToolMenu.AddItem( SCH_ACTIONS::cut, SELECTION_CONDITIONS::NotEmpty, 200 );
|
||||
|
@ -1609,6 +1618,34 @@ int SCH_EDIT_TOOL::BreakWire( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_EDIT_TOOL::CleanupSheetPins( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
SELECTION& selection = m_selectionTool->RequestSelection( SCH_COLLECTOR::SheetsOnly );
|
||||
SCH_SHEET* sheet = (SCH_SHEET*) selection.Front();
|
||||
|
||||
if( !sheet )
|
||||
return 0;
|
||||
|
||||
if( !sheet->HasUndefinedPins() )
|
||||
{
|
||||
DisplayInfoMessage( m_frame, _( "There are no unreferenced pins in this sheet to remove." ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !IsOK( m_frame, _( "Do you wish to delete the unreferenced pins from this sheet?" ) ) )
|
||||
return 0;
|
||||
|
||||
m_frame->SaveCopyInUndoList( sheet, UR_CHANGED );
|
||||
|
||||
sheet->CleanupSheet();
|
||||
|
||||
updateView( sheet );
|
||||
m_frame->OnModify();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_TOOL::updateView( EDA_ITEM* aItem )
|
||||
{
|
||||
KICAD_T itemType = aItem->Type();
|
||||
|
@ -1660,4 +1697,6 @@ void SCH_EDIT_TOOL::setTransitions()
|
|||
|
||||
Go( &SCH_EDIT_TOOL::BreakWire, SCH_ACTIONS::breakWire.MakeEvent() );
|
||||
Go( &SCH_EDIT_TOOL::BreakWire, SCH_ACTIONS::breakBus.MakeEvent() );
|
||||
|
||||
Go( &SCH_EDIT_TOOL::CleanupSheetPins, SCH_ACTIONS::cleanupSheetPins.MakeEvent() );
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ public:
|
|||
|
||||
int BreakWire( const TOOL_EVENT& aEvent );
|
||||
|
||||
int CleanupSheetPins( const TOOL_EVENT& aEvent );
|
||||
|
||||
/**
|
||||
* Function DoDelete()
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue