Clean and standardize cross-probing action

Between schematic and pcb editors, we want the following actions:

- Single click on ERC/DRC item should show the item in the ERC/DRC
  window.  But if the window is not visible, it should only update the
  status bar
- Double click on ERC/DRC item should show and raid the ERC/DRC window
  as well as select the line item

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17383

(cherry picked from commit 0f57d76ecd)
This commit is contained in:
Seth Hillbrand 2024-03-11 17:48:58 -07:00
parent 1e13a7640e
commit b1677d5f47
4 changed files with 44 additions and 22 deletions

View File

@ -164,16 +164,8 @@ int EE_INSPECTION_TOOL::CrossProbe( const TOOL_EVENT& aEvent )
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
DIALOG_ERC* dlg = frame ? frame->GetErcDialog() : nullptr;
if( dlg )
{
if( !dlg->IsShownOnScreen() )
{
dlg->Show( true );
dlg->Raise();
}
if( dlg && dlg->IsShownOnScreen() )
dlg->SelectMarker( static_cast<SCH_MARKER*>( selection.Front() ) );
}
}
// Show the item info on a left click on this item
@ -183,6 +175,27 @@ int EE_INSPECTION_TOOL::CrossProbe( const TOOL_EVENT& aEvent )
}
void EE_INSPECTION_TOOL::CrossProbe( const SCH_MARKER* aMarker )
{
SCH_EDIT_FRAME* frame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
wxCHECK( frame, /* void */ );
DIALOG_ERC* dlg = frame->GetErcDialog();
if( dlg )
{
if( !dlg->IsShownOnScreen() )
{
dlg->Show( true );
dlg->Raise();
}
dlg->SelectMarker( aMarker );
}
}
int EE_INSPECTION_TOOL::ExcludeMarker( const TOOL_EVENT& aEvent )
{
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();

View File

@ -56,6 +56,8 @@ public:
/// Called when clicking on a item:
int CrossProbe( const TOOL_EVENT& aEvent );
void CrossProbe( const SCH_MARKER* aMarker );
int ExcludeMarker( const TOOL_EVENT& aEvent );
int CheckSymbol( const TOOL_EVENT& aEvent );

View File

@ -26,13 +26,21 @@
#include <tool/picker_tool.h>
#include <tools/sch_edit_tool.h>
#include <tools/ee_selection_tool.h>
#include <tools/ee_inspection_tool.h>
#include <tools/sch_line_wire_bus_tool.h>
#include <tools/sch_move_tool.h>
#include <tools/sch_drawing_tools.h>
#include <ee_actions.h>
#include <confirm.h>
#include <string_utils.h>
#include <sch_bitmap.h>
#include <sch_bus_entry.h>
#include <sch_commit.h>
#include <sch_edit_frame.h>
#include <sch_item.h>
#include <sch_junction.h>
#include <sch_line.h>
#include <sch_marker.h>
#include <sch_symbol.h>
#include <sch_shape.h>
#include <sch_sheet.h>
@ -41,12 +49,7 @@
#include <sch_textbox.h>
#include <sch_bitmap.h>
#include <sch_view.h>
#include <sch_line.h>
#include <sch_bus_entry.h>
#include <sch_junction.h>
#include <sch_edit_frame.h>
#include <schematic.h>
#include <sch_commit.h>
#include <drawing_sheet/ds_proxy_view_item.h>
#include <eeschema_id.h>
#include <dialogs/dialog_change_symbols.h>
@ -1719,7 +1722,7 @@ int SCH_EDIT_TOOL::ChangeBodyStyle( const TOOL_EVENT& aEvent )
int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
{
EE_SELECTION& selection = m_selectionTool->RequestSelection( EE_COLLECTOR::EditableItems );
EE_SELECTION& selection = m_selectionTool->RequestSelection();
bool clearSelection = selection.IsHover();
if( selection.Empty() )
@ -2003,7 +2006,16 @@ int SCH_EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
break;
case SCH_MARKER_T: // These items have no properties to edit
case SCH_MARKER_T:
if( SELECTION_CONDITIONS::OnlyTypes( { SCH_MARKER_T } )( selection ) )
{
EE_INSPECTION_TOOL* inspectionTool = m_toolMgr->GetTool<EE_INSPECTION_TOOL>();
if( inspectionTool )
inspectionTool->CrossProbe( static_cast<SCH_MARKER*> ( selection.Front() ) );
}
break;
case SCH_NO_CONNECT_T:
break;

View File

@ -250,18 +250,13 @@ int DRC_TOOL::NextMarker( const TOOL_EVENT& aEvent )
int DRC_TOOL::CrossProbe( const TOOL_EVENT& aEvent )
{
if( m_drcDialog )
if( m_drcDialog && m_drcDialog->IsShownOnScreen() )
{
PCB_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<PCB_SELECTION_TOOL>();
PCB_SELECTION& selection = selectionTool->GetSelection();
if( selection.GetSize() == 1 && selection.Front()->Type() == PCB_MARKER_T )
{
if( !m_drcDialog->IsShownOnScreen() )
m_drcDialog->Show( true );
m_drcDialog->SelectMarker( static_cast<PCB_MARKER*>( selection.Front() ) );
}
}
return 0;