Improve selection behavior of DRC markers in DRC dialog list

Fixes: lp:1813373
* https://bugs.launchpad.net/kicad/+bug/1813373
This commit is contained in:
Jon Evans 2019-03-25 22:38:18 -04:00
parent c1ee395303
commit 3d9b5daf9c
6 changed files with 218 additions and 822 deletions

View File

@ -320,22 +320,8 @@ void DIALOG_DRC_CONTROL::OnLeftDClickClearance( wxMouseEvent& event )
if( selection != wxNOT_FOUND )
{
// Find the selected MARKER in the PCB, position cursor there.
// Then close the dialog.
const DRC_ITEM* item = m_ClearanceListBox->GetItem( selection );
if( item )
if( focusOnItem( m_ClearanceListBox->GetItem( selection ) ) )
{
auto pos = item->GetPointA();
if( auto marker = item->GetParent() )
pos = marker->GetPos();
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( pos, true, center );
if( !IsModal() )
{
// turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window,
@ -354,19 +340,62 @@ void DIALOG_DRC_CONTROL::OnLeftDClickClearance( wxMouseEvent& event )
void DIALOG_DRC_CONTROL::OnRightUpFootprints( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
// Check if user right-clicked on a different item
int selection = m_FootprintsListBox->HitTest( event.GetPosition() );
int selection = m_FootprintsListBox->GetSelection();
if( selection == wxNOT_FOUND )
selection = m_FootprintsListBox->GetSelection();
else
m_FootprintsListBox->SetSelection( selection );
if( selection != wxNOT_FOUND )
doSelectionMenu( m_FootprintsListBox->GetItem( selection ) );
}
void DIALOG_DRC_CONTROL::OnLeftUpClearance( wxMouseEvent& event )
{
int selection = m_ClearanceListBox->GetSelection();
if( selection != wxNOT_FOUND )
focusOnItem( m_ClearanceListBox->GetItem( selection ) );
}
bool DIALOG_DRC_CONTROL::focusOnItem( const DRC_ITEM* aItem )
{
if( !aItem )
return false;
auto toolmgr = m_brdEditor->GetToolManager();
auto pos = aItem->GetPointA();
auto marker = static_cast<MARKER_PCB*>( aItem->GetParent() );
if( marker )
{
pos = marker->GetPos();
toolmgr->RunAction( PCB_ACTIONS::selectionClear, true );
toolmgr->RunAction( PCB_ACTIONS::selectItem, true, marker );
}
toolmgr->GetView()->SetCenter( pos );
m_brdEditor->GetCanvas()->Refresh();
return true;
}
void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
// Check if user right-clicked on a different item
int selection = m_UnconnectedListBox->HitTest( event.GetPosition() );
int selection = m_UnconnectedListBox->GetSelection();
if( selection == wxNOT_FOUND )
selection = m_UnconnectedListBox->GetSelection();
else
m_UnconnectedListBox->SetSelection( selection );
if( selection != wxNOT_FOUND )
doSelectionMenu( m_UnconnectedListBox->GetItem( selection ) );
@ -376,8 +405,13 @@ void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event )
void DIALOG_DRC_CONTROL::OnRightUpClearance( wxMouseEvent& event )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
// Check if user right-clicked on a different item
int selection = m_ClearanceListBox->HitTest( event.GetPosition() );
int selection = m_ClearanceListBox->GetSelection();
if( selection == wxNOT_FOUND )
selection = m_ClearanceListBox->GetSelection();
else
m_ClearanceListBox->SetSelection( selection );
if( selection != wxNOT_FOUND )
doSelectionMenu( m_ClearanceListBox->GetItem( selection ) );
@ -387,15 +421,29 @@ void DIALOG_DRC_CONTROL::OnRightUpClearance( wxMouseEvent& event )
void DIALOG_DRC_CONTROL::doSelectionMenu( const DRC_ITEM* aItem )
{
// popup menu to go to either of the items listed in the DRC_ITEM.
BOARD_ITEM* first = aItem->GetMainItem( m_brdEditor->GetBoard() );
BOARD_ITEM* second = nullptr;
GENERAL_COLLECTOR items;
items.Append( aItem->GetMainItem( m_brdEditor->GetBoard() ) );
items.Append( first );
if( aItem->HasSecondItem() )
items.Append( aItem->GetAuxiliaryItem( m_brdEditor->GetBoard() ) );
{
second = aItem->GetAuxiliaryItem( m_brdEditor->GetBoard() );
items.Append( second );
}
WINDOW_THAWER thawer( m_brdEditor );
m_brdEditor->GetToolManager()->RunAction( PCB_ACTIONS::selectionMenu, true, &items );
// If we got an item, focus on it
BOARD_ITEM* selection = m_brdEditor->GetCurItem();
if( selection && ( selection == first || selection == second ) )
m_brdEditor->GetToolManager()->GetView()->SetCenter( selection->GetPosition() );
m_brdEditor->GetCanvas()->Refresh();
}
@ -410,14 +458,8 @@ void DIALOG_DRC_CONTROL::OnLeftDClickFootprints( wxMouseEvent& event )
{
// Find the selected DRC_ITEM in the listbox, position cursor there.
// Then hide the dialog.
const DRC_ITEM* item = m_FootprintsListBox->GetItem( selection );
if( item )
if( focusOnItem( m_FootprintsListBox->GetItem( selection ) ) )
{
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), true, center );
if( !IsModal() )
{
Show( false );
@ -439,18 +481,12 @@ void DIALOG_DRC_CONTROL::OnLeftDClickUnconnected( wxMouseEvent& event )
if( selection != wxNOT_FOUND )
{
// Find the selected DRC_ITEM in the listbox, position cursor there.
// Then hide the dialog.
const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection );
if( item )
if( focusOnItem( m_UnconnectedListBox->GetItem( selection ) ) )
{
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), true, center );
if( !IsModal() )
{
// turn control over to m_brdEditor, hide this DIALOG_DRC_CONTROL window,
// no destruction so we can preserve listbox cursor
Show( false );
// We do not want the clarify selection popup when releasing the
@ -462,6 +498,15 @@ void DIALOG_DRC_CONTROL::OnLeftDClickUnconnected( wxMouseEvent& event )
}
void DIALOG_DRC_CONTROL::OnLeftUpUnconnected( wxMouseEvent& event )
{
int selection = m_UnconnectedListBox->GetSelection();
if( selection != wxNOT_FOUND )
focusOnItem( m_UnconnectedListBox->GetItem( selection ) );
}
/* called when switching from Error list to Unconnected list
* To avoid mistakes, the current marker is selection is cleared
*/
@ -487,20 +532,7 @@ void DIALOG_DRC_CONTROL::OnMarkerSelectionEvent( wxCommandEvent& event )
m_DeleteCurrentMarkerButton->Enable( true );
// Find the selected DRC_ITEM in the listbox, position cursor there.
const DRC_ITEM* item = m_ClearanceListBox->GetItem( selection );
if( item )
{
auto pos = item->GetPointA();
if( auto marker = item->GetParent() )
pos = marker->GetPos();
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( pos, false, center );
RedrawDrawPanel();
}
focusOnItem( m_ClearanceListBox->GetItem( selection ) );
}
event.Skip();
@ -517,16 +549,7 @@ void DIALOG_DRC_CONTROL::OnUnconnectedSelectionEvent( wxCommandEvent& event )
m_DeleteCurrentMarkerButton->Enable( true );
// Find the selected DRC_ITEM in the listbox, position cursor there.
const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection );
if( item )
{
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), false, center );
RedrawDrawPanel();
}
focusOnItem( m_UnconnectedListBox->GetItem( selection ) );
}
event.Skip();
@ -543,16 +566,7 @@ void DIALOG_DRC_CONTROL::OnFootprintsSelectionEvent( wxCommandEvent& event )
m_DeleteCurrentMarkerButton->Enable( true );
// Find the selected DRC_ITEM in the listbox, position cursor there.
const DRC_ITEM* item = m_FootprintsListBox->GetItem( selection );
if( item )
{
// When selecting a item, center it on GAL and just move the graphic
// cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), false, center );
RedrawDrawPanel();
}
focusOnItem( m_FootprintsListBox->GetItem( selection ) );
}
event.Skip();

View File

@ -115,12 +115,18 @@ private:
/// wxEVT_LEFT_DCLICK event handler for ID_CLEARANCE_LIST
void OnLeftDClickClearance( wxMouseEvent& event ) override;
/// wxEVT_LEFT_UP event handler for ID_CLEARANCE_LIST
void OnLeftUpClearance( wxMouseEvent& event ) override;
/// wxEVT_RIGHT_UP event handler for ID_CLEARANCE_LIST
void OnRightUpClearance( wxMouseEvent& event ) override;
/// wxEVT_LEFT_DCLICK event handler for ID_UNCONNECTED_LIST
void OnLeftDClickUnconnected( wxMouseEvent& event ) override;
/// wxEVT_LEFT_UP event handler for ID_UNCONNECTED_LIST
void OnLeftUpUnconnected( wxMouseEvent& event ) override;
/// wxEVT_RIGHT_UP event handler for ID_UNCONNECTED_LIST
void OnRightUpUnconnected( wxMouseEvent& event ) override;
@ -149,6 +155,8 @@ private:
/// in the DRC_ITEM.
void doSelectionMenu( const DRC_ITEM* aItem );
bool focusOnItem( const DRC_ITEM* aItem );
BOARD* m_currentBoard; // the board currently on test
DRC* m_tester;
PCB_EDIT_FRAME* m_brdEditor;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -127,7 +127,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
fgSizerRpt->Add( m_RptFilenameCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxTOP|wxBOTTOM, 3 );
m_BrowseButton = new wxBitmapButton( this, ID_BUTTON_BROWSE_RPT_FILE, wxNullBitmap, wxDefaultPosition, wxDefaultSize, 0 );
m_BrowseButton = new wxBitmapButton( this, ID_BUTTON_BROWSE_RPT_FILE, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
m_BrowseButton->SetMinSize( wxSize( 30,28 ) );
fgSizerRpt->Add( m_BrowseButton, 0, wxALIGN_CENTER_VERTICAL, 2 );
@ -220,9 +220,11 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
m_BrowseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this );
m_Notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingMarkerList ), NULL, this );
m_ClearanceListBox->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickClearance ), NULL, this );
m_ClearanceListBox->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftUpClearance ), NULL, this );
m_ClearanceListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnMarkerSelectionEvent ), NULL, this );
m_ClearanceListBox->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpClearance ), NULL, this );
m_UnconnectedListBox->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickUnconnected ), NULL, this );
m_UnconnectedListBox->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftUpUnconnected ), NULL, this );
m_UnconnectedListBox->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnUnconnectedSelectionEvent ), NULL, this );
m_UnconnectedListBox->Connect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpUnconnected ), NULL, this );
m_FootprintsListBox->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickFootprints ), NULL, this );
@ -243,9 +245,11 @@ DIALOG_DRC_CONTROL_BASE::~DIALOG_DRC_CONTROL_BASE()
m_BrowseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnButtonBrowseRptFileClick ), NULL, this );
m_Notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_CONTROL_BASE::OnChangingMarkerList ), NULL, this );
m_ClearanceListBox->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickClearance ), NULL, this );
m_ClearanceListBox->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftUpClearance ), NULL, this );
m_ClearanceListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnMarkerSelectionEvent ), NULL, this );
m_ClearanceListBox->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpClearance ), NULL, this );
m_UnconnectedListBox->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickUnconnected ), NULL, this );
m_UnconnectedListBox->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftUpUnconnected ), NULL, this );
m_UnconnectedListBox->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_DRC_CONTROL_BASE::OnUnconnectedSelectionEvent ), NULL, this );
m_UnconnectedListBox->Disconnect( wxEVT_RIGHT_UP, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnRightUpUnconnected ), NULL, this );
m_FootprintsListBox->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_DRC_CONTROL_BASE::OnLeftDClickFootprints ), NULL, this );

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,11 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Dec 30 2017)
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_DRC_BASE_H__
#define __DIALOG_DRC_BASE_H__
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
@ -23,10 +22,10 @@ class DRCLISTBOX;
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/bmpbuttn.h>
#include <wx/button.h>
#include <wx/gbsizer.h>
#include <wx/listbox.h>
@ -83,9 +82,11 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM
virtual void OnButtonBrowseRptFileClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnChangingMarkerList( wxNotebookEvent& event ) { event.Skip(); }
virtual void OnLeftDClickClearance( wxMouseEvent& event ) { event.Skip(); }
virtual void OnLeftUpClearance( wxMouseEvent& event ) { event.Skip(); }
virtual void OnMarkerSelectionEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRightUpClearance( wxMouseEvent& event ) { event.Skip(); }
virtual void OnLeftDClickUnconnected( wxMouseEvent& event ) { event.Skip(); }
virtual void OnLeftUpUnconnected( wxMouseEvent& event ) { event.Skip(); }
virtual void OnUnconnectedSelectionEvent( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRightUpUnconnected( wxMouseEvent& event ) { event.Skip(); }
virtual void OnLeftDClickFootprints( wxMouseEvent& event ) { event.Skip(); }
@ -110,4 +111,3 @@ class DIALOG_DRC_CONTROL_BASE : public DIALOG_SHIM
};
#endif //__DIALOG_DRC_BASE_H__

View File

@ -579,7 +579,6 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag,
if( item )
{
toggleSelection( item );
return true;
}
else
@ -1518,6 +1517,9 @@ BOARD_ITEM* SELECTION_TOOL::doSelectionMenu( GENERAL_COLLECTOR* aCollector,
}
getView()->Remove( &highlightGroup );
if( current )
toggleSelection( current );
return current;
}