Re-enable selection of intersheet references.

Un-modified roll-overs and clicks still produce hypertext action, but
modified clicks and drag-selects will select.
This commit is contained in:
Jeff Young 2020-10-05 11:54:37 +01:00
parent 37906511f5
commit c9096c7168
4 changed files with 45 additions and 37 deletions

View File

@ -24,14 +24,12 @@
#include <sch_text.h>
#include <sch_iref.h>
#include <sch_sheet.h>
#include <schematic.h>
#include <tool/tool_manager.h>
#include <tools/sch_editor_control.h>
#include <tools/sch_navigate_tool.h>
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;

View File

@ -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() { }

View File

@ -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,19 +634,21 @@ 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.
// Unmodified clicking of SCH_IREFs results in hypertext links rather than selection.
if( !aAdd && !aSubtract && !aExclusiveOr )
{
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.
if( aCollector.GetCount() > 1 )
@ -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<EDA_ITEM*>( 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() ) )
{

View File

@ -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