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
This commit is contained in:
Seth Hillbrand 2024-03-11 17:48:58 -07:00
parent 347c50b26d
commit 0f57d76ecd
4 changed files with 44 additions and 23 deletions

View File

@ -164,6 +164,25 @@ 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 && dlg->IsShownOnScreen() )
dlg->SelectMarker( static_cast<SCH_MARKER*>( selection.Front() ) );
}
// Show the item info on a left click on this item
UpdateMessagePanel( aEvent );
return 0;
}
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() )
@ -172,14 +191,8 @@ int EE_INSPECTION_TOOL::CrossProbe( const TOOL_EVENT& aEvent )
dlg->Raise();
}
dlg->SelectMarker( static_cast<SCH_MARKER*>( selection.Front() ) );
dlg->SelectMarker( aMarker );
}
}
// Show the item info on a left click on this item
UpdateMessagePanel( aEvent );
return 0;
}

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 );
wxString InspectERCErrorMenuText( const std::shared_ptr<RC_ITEM>& aERCItem );
void InspectERCError( const std::shared_ptr<RC_ITEM>& aERCItem );

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,14 +49,8 @@
#include <sch_textbox.h>
#include <sch_table.h>
#include <sch_tablecell.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>
@ -1750,7 +1752,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() )
@ -2041,7 +2043,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,19 +250,14 @@ 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;
}