From 57e043e0e6cc5cc07fdb1f83ada023128a8bf9f1 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 19 Feb 2021 14:51:18 +0000 Subject: [PATCH] Don't allow moving markers. Do allow excluding them. --- eeschema/tools/ee_actions.cpp | 2 +- eeschema/tools/ee_inspection_tool.cpp | 22 +++++++++++++++++++++- eeschema/tools/ee_selection_tool.cpp | 9 +++++---- eeschema/tools/sch_edit_tool.cpp | 3 ++- eeschema/tools/sch_move_tool.cpp | 2 +- include/tool/selection_conditions.h | 1 - 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/eeschema/tools/ee_actions.cpp b/eeschema/tools/ee_actions.cpp index d131817eec..691e0a1656 100644 --- a/eeschema/tools/ee_actions.cpp +++ b/eeschema/tools/ee_actions.cpp @@ -577,7 +577,7 @@ TOOL_ACTION EE_ACTIONS::schematicSetup( "eeschema.EditorControl.schematicSetup", TOOL_ACTION EE_ACTIONS::editPageNumber( "eeschema.EditorControl.editPageNumber", AS_GLOBAL, 0, "", - _( "Edit Page Number..." ), + _( "Edit Sheet Page Number..." ), _( "Edit the page number of the current or selected sheet" ), nullptr ); diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 54918135ca..d5f9c8bc09 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -62,6 +62,8 @@ bool EE_INSPECTION_TOOL::Init() // CONDITIONAL_MENU& selToolMenu = m_selectionTool->GetToolMenu().GetMenu(); + selToolMenu.AddItem( EE_ACTIONS::excludeMarker, singleMarkerCondition, 100 ); + selToolMenu.AddItem( EE_ACTIONS::showDatasheet, EE_CONDITIONS::SingleSymbol && EE_CONDITIONS::Idle, 220 ); return true; @@ -154,7 +156,25 @@ int EE_INSPECTION_TOOL::NextMarker( const TOOL_EVENT& aEvent ) int EE_INSPECTION_TOOL::ExcludeMarker( const TOOL_EVENT& aEvent ) { if( m_ercDialog ) + { + // Let the ERC dialog handle it since it has more update hassles to worry about m_ercDialog->ExcludeMarker(); + } + else + { + EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool(); + EE_SELECTION& selection = selTool->GetSelection(); + + if( selection.GetSize() == 1 && selection.Front()->Type() == SCH_MARKER_T ) + { + SCH_MARKER* marker = static_cast( selection.Front() ); + + marker->SetExcluded( true ); + m_frame->GetCanvas()->GetView()->Update( marker ); + m_frame->GetCanvas()->Refresh(); + m_frame->OnModify(); + } + } return 0; } diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 06bcf819fe..31f96ec856 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -168,11 +168,12 @@ bool EE_SELECTION_TOOL::Init() auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T ); auto schEditSheetPageNumberCondition = - [this] ( const SELECTION& aSel ) + [&] ( const SELECTION& aSel ) { - return !m_isSymbolEditor - && !m_isSymbolViewer - && ( E_C::Empty || ( E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T ) ) ); + if( m_isSymbolEditor || m_isSymbolViewer ) + return false; + + return ( E_C::Empty( aSel ) || sheetSelection( aSel ) ); }; auto schEditCondition = diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index dd19234479..80dd6e5cd3 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -261,6 +261,7 @@ bool SCH_EDIT_TOOL::Init() auto singleSymbolCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_COMPONENT_T ); auto singleSheetCondition = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T ); + // // Add edit actions to the move tool menu // @@ -1798,7 +1799,7 @@ int SCH_EDIT_TOOL::EditPageNumber( const TOOL_EVENT& aEvent ) msg.Printf( _( "Enter page number for sheet path%s" ), ( sheetPath.Length() > 20 ) ? "\n" + sheetPath : " " + sheetPath ); - wxTextEntryDialog dlg( m_frame, msg, _( "Edit Page Number" ), pageNumber ); + wxTextEntryDialog dlg( m_frame, msg, _( "Edit Sheet Page Number" ), pageNumber ); dlg.SetTextValidator( wxFILTER_ALPHANUMERIC ); // No white space. diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 20bfab2401..67f99ba8e8 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -60,7 +60,7 @@ bool SCH_MOVE_TOOL::Init() auto moveCondition = []( const SELECTION& aSel ) { - if( aSel.Empty() ) + if( aSel.Empty() || SELECTION_CONDITIONS::OnlyType( SCH_MARKER_T )( aSel ) ) return false; if( SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus( aSel ) ) diff --git a/include/tool/selection_conditions.h b/include/tool/selection_conditions.h index d4d482764f..e804f8498f 100644 --- a/include/tool/selection_conditions.h +++ b/include/tool/selection_conditions.h @@ -41,7 +41,6 @@ SELECTION_CONDITION operator||( const SELECTION_CONDITION& aConditionA, SELECTION_CONDITION operator&&( const SELECTION_CONDITION& aConditionA, const SELECTION_CONDITION& aConditionB ); -SELECTION_CONDITION operator!( const SELECTION_CONDITION& aCondition ); /// Signature for a reference to a function that takes a SELECTION and returns