From c9096c7168268a728dd05a3be1c49a0a6bf8ace7 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 5 Oct 2020 11:54:37 +0100 Subject: [PATCH] Re-enable selection of intersheet references. Un-modified roll-overs and clicks still produce hypertext action, but modified clicks and drag-selects will select. --- eeschema/sch_iref.cpp | 4 +-- eeschema/sch_iref.h | 2 +- eeschema/tools/ee_selection_tool.cpp | 33 ++++++++++++--------- eeschema/tools/ee_selection_tool.h | 43 ++++++++++++++++------------ 4 files changed, 45 insertions(+), 37 deletions(-) diff --git a/eeschema/sch_iref.cpp b/eeschema/sch_iref.cpp index a63388ea36..22d961e97b 100644 --- a/eeschema/sch_iref.cpp +++ b/eeschema/sch_iref.cpp @@ -24,14 +24,12 @@ #include #include -#include #include #include #include #include -SCH_IREF::SCH_IREF( const wxPoint& pos, const wxString& text, SCH_GLOBALLABEL* aParent, - KICAD_T aType ) : +SCH_IREF::SCH_IREF( const wxPoint& pos, const wxString& text, SCH_GLOBALLABEL* aParent ) : SCH_TEXT( pos, text, SCH_IREF_T ) { m_Layer = LAYER_GLOBLABEL; diff --git a/eeschema/sch_iref.h b/eeschema/sch_iref.h index 8d302a122d..e1e0dec6a2 100644 --- a/eeschema/sch_iref.h +++ b/eeschema/sch_iref.h @@ -39,7 +39,7 @@ class SCH_IREF : public SCH_TEXT { public: SCH_IREF( const wxPoint& pos = wxPoint( 0, 0 ), const wxString& text = wxEmptyString, - SCH_GLOBALLABEL* aParent = nullptr, KICAD_T aType = SCH_IREF_T ); + SCH_GLOBALLABEL* aParent = nullptr ); ~SCH_IREF() { } diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 0b8bccdf7f..9aa0d15de5 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -355,7 +355,8 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) m_toolMgr->ProcessEvent( *newEvt ); continueSelect = false; } - else if( collector[0]->Type() == SCH_IREF_T ) + else if( collector[0]->Type() == SCH_IREF_T + && !m_additive && !m_subtractive && !m_exclusive_or ) { wxMenu menu; @@ -363,6 +364,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) intptr_t sel = m_frame->GetPopupMenuSelectionFromUser( menu ); m_toolMgr->RunAction( EE_ACTIONS::hypertextCommand, true, (void*) sel ); + continueSelect = false; } } } @@ -371,7 +373,7 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { // If we didn't click on an anchor, we perform a normal select, pass in the // items we previously collected - SelectPoint( collector, nullptr, nullptr, m_additive, m_subtractive, + selectPoint( collector, nullptr, nullptr, m_additive, m_subtractive, m_exclusive_or ); } } @@ -513,7 +515,8 @@ int EE_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { displayPencil = true; } - else if( collector[0]->Type() == SCH_IREF_T ) + else if( collector[0]->Type() == SCH_IREF_T + && !m_additive && !m_subtractive && !m_exclusive_or ) { rolloverItem = collector[0]->m_Uuid; } @@ -631,18 +634,20 @@ void EE_SELECTION_TOOL::narrowSelection( EE_COLLECTOR& collector, const VECTOR2I } -bool EE_SELECTION_TOOL::SelectPoint( EE_COLLECTOR& aCollector, EDA_ITEM** aItem, +bool EE_SELECTION_TOOL::selectPoint( EE_COLLECTOR& aCollector, EDA_ITEM** aItem, bool* aSelectionCancelledFlag, bool aAdd, bool aSubtract, bool aExclusiveOr ) { m_selection.ClearReferencePoint(); - // We have to allow SCH_IREFs in Selectable() for hypertext rollovers and linking to work, - // but at the end of the day we don't actually want them to be selectable. - for( int i = aCollector.GetCount() - 1; i >= 0; --i ) + // Unmodified clicking of SCH_IREFs results in hypertext links rather than selection. + if( !aAdd && !aSubtract && !aExclusiveOr ) { - if( aCollector[i]->Type() == SCH_IREF_T ) - aCollector.Remove( i ); + for( int i = aCollector.GetCount() - 1; i >= 0; --i ) + { + if( aCollector[i]->Type() == SCH_IREF_T ) + aCollector.Remove( i ); + } } // If still more than one item we're going to have to ask the user. @@ -704,8 +709,9 @@ bool EE_SELECTION_TOOL::SelectPoint( EE_COLLECTOR& aCollector, EDA_ITEM** aItem, bool EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T* aFilterList, - EDA_ITEM** aItem, bool* aSelectionCancelledFlag, bool aCheckLocked, bool aAdd, - bool aSubtract, bool aExclusiveOr ) + EDA_ITEM** aItem, bool* aSelectionCancelledFlag, + bool aCheckLocked, bool aAdd, bool aSubtract, + bool aExclusiveOr ) { EE_COLLECTOR collector; @@ -714,7 +720,7 @@ bool EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T* aFil narrowSelection( collector, aWhere, aCheckLocked ); - return SelectPoint( collector, aItem, aSelectionCancelledFlag, aAdd, aSubtract, aExclusiveOr ); + return selectPoint( collector, aItem, aSelectionCancelledFlag, aAdd, aSubtract, aExclusiveOr ); } @@ -1032,8 +1038,7 @@ bool EE_SELECTION_TOOL::selectMultiple() { EDA_ITEM* item = dynamic_cast( pair.first ); - if( item && Selectable( item ) && item->Type() != SCH_IREF_T - && item->HitTest( selectionRect, windowSelection ) ) + if( item && Selectable( item ) && item->HitTest( selectionRect, windowSelection ) ) { if( m_subtractive || ( m_exclusive_or && item->IsSelected() ) ) { diff --git a/eeschema/tools/ee_selection_tool.h b/eeschema/tools/ee_selection_tool.h index 4be93789d4..ed4d627462 100644 --- a/eeschema/tools/ee_selection_tool.h +++ b/eeschema/tools/ee_selection_tool.h @@ -92,9 +92,11 @@ public: * before calling the primary SelectPoint method. * * @param aWhere is the location where the item(s) should be collected - * @param aItem is set to the newly selected item if only one was selected, otherwise is unchanged. + * @param aItem is set to the newly selected item if only one was selected, otherwise is + * unchanged. * @param aSelectionCancelledFlag allows the function to inform its caller that a selection - * was cancelled (for instance, by clicking outside of the disambiguation menu). + * was cancelled (for instance, by clicking outside of the + * disambiguation menu). * @param aCheckLocked indicates if locked items should be excluded. * @param aAdd indicates if found item(s) should be added to the selection * @param aSubtract indicates if found item(s) should be subtracted from the selection @@ -105,23 +107,6 @@ public: bool aCheckLocked = false, bool aAdd = false, bool aSubtract = false, bool aExclusiveOr = false ); - /** - * Function SelectPoint() - * This is the primary SelectPoint method that will prompt the user with a menu to disambiguate multiple selections - * and then finish by adding, subtracting or toggling the item(s) to the actual selection group. - * - * @param aCollector is an EE_COLLECTOR that already has collected items - * @param aItem is set to the newly selected item if only one was selected, otherwise is unchanged. - * @param aSelectionCancelledFlag allows the function to inform its caller that a selection - * was cancelled (for instance, by clicking outside of the disambiguation menu). - * @param aAdd indicates if found item(s) should be added to the selection - * @param aSubtract indicates if found item(s) should be subtracted from the selection - * @param aExclusiveOr indicates if found item(s) should be toggle in the selection - */ - bool SelectPoint( EE_COLLECTOR& aCollector, EDA_ITEM** aItem = nullptr, - bool* aSelectionCancelledFlag = nullptr, bool aAdd = false, - bool aSubtract = false, bool aExclusiveOr = false ); - int AddItemToSel( const TOOL_EVENT& aEvent ); void AddItemToSel( EDA_ITEM* aItem, bool aQuietMode = false ); int AddItemsToSel( const TOOL_EVENT& aEvent ); @@ -206,6 +191,26 @@ private: */ void narrowSelection( EE_COLLECTOR& collector, const VECTOR2I& aWhere, bool aCheckLocked ); + /** + * Function SelectPoint() + * This is the primary SelectPoint method that will prompt the user with a menu to disambiguate + * multiple selections and then finish by adding, subtracting or toggling the item(s) to the + * actual selection group. + * + * @param aCollector is an EE_COLLECTOR that already has collected items + * @param aItem is set to the newly selected item if only one was selected, otherwise is + * unchanged. + * @param aSelectionCancelledFlag allows the function to inform its caller that a selection + * was cancelled (for instance, by clicking outside of the + * disambiguation menu). + * @param aAdd indicates if found item(s) should be added to the selection + * @param aSubtract indicates if found item(s) should be subtracted from the selection + * @param aExclusiveOr indicates if found item(s) should be toggle in the selection + */ + bool selectPoint( EE_COLLECTOR& aCollector, EDA_ITEM** aItem = nullptr, + bool* aSelectionCancelledFlag = nullptr, bool aAdd = false, + bool aSubtract = false, bool aExclusiveOr = false ); + /** * Function selectMultiple() * Handles drawing a selection box that allows one to select many items at