Pcbnew, DRC dialog: Fix a few issues:

Gal mode: graphic cross-air cursor moved on items when clicking on & DRC error, like in legacy mode.
Make popup menu shown when right clicking on a DRC error item working.
This commit is contained in:
jean-pierre charras 2018-01-17 15:36:04 +01:00
parent 60963fe2fc
commit 6014307d06
10 changed files with 125 additions and 56 deletions

View File

@ -449,6 +449,23 @@ void WX_VIEW_CONTROLS::SetCursorPosition( const VECTOR2D& aPosition, bool aWarpV
} }
void WX_VIEW_CONTROLS::SetCrossAirCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true )
{
m_updateCursor = false;
const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
BOX2I screen( VECTOR2I( 0, 0 ), screenSize );
VECTOR2D screenPos = m_view->ToScreen( aPosition );
if( !screen.Contains( screenPos ) )
{
m_view->SetCenter( aPosition );
}
m_cursorPos = aPosition;
}
void WX_VIEW_CONTROLS::WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates, void WX_VIEW_CONTROLS::WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates,
bool aWarpView ) const bool aWarpView ) const
{ {

View File

@ -235,6 +235,15 @@ public:
*/ */
virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true ) = 0; virtual void SetCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true ) = 0;
/**
* Moves the graphic crossair cursor to the requested position expressed in world coordinates.
* @param aPosition is the requested cursor position in the world coordinates.
* @param aWarpView enables/disables view warp if the cursor is outside the current viewport.
*/
virtual void SetCrossAirCursorPosition( const VECTOR2D& aPosition, bool aWarpView = true ) = 0;
/** /**
* Function ForcedCursorPosition() * Function ForcedCursorPosition()
* Returns true if the current cursor position is forced to a specific location, ignoring * Returns true if the current cursor position is forced to a specific location, ignoring

View File

@ -83,6 +83,9 @@ public:
void SetCursorPosition( const VECTOR2D& aPosition, bool warpView ) override; void SetCursorPosition( const VECTOR2D& aPosition, bool warpView ) override;
/// @copydoc VIEW_CONTROLS::SetCrossAirCursorPosition()
void SetCrossAirCursorPosition( const VECTOR2D& aPosition, bool aWarpView ) override;
/// @copydoc VIEW_CONTROLS::CursorWarp() /// @copydoc VIEW_CONTROLS::CursorWarp()
void WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false, void WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,
bool aWarpView = false ) const override; bool aWarpView = false ) const override;

View File

@ -1,9 +1,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -271,13 +271,15 @@ public:
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide(); GENERAL_COLLECTORS_GUIDE GetCollectorsGuide();
/** /**
* Function CursorGoto * Useful to focus on a particular location, in find functions
* positions the cursor at a given coordinate and reframes the drawing if the * Move the graphic cursor at a given coordinate and reframes the drawing if the
* requested point is out of view. * requested point is out of view or if center on location is requested.
* @param aPos is the point to go to. * @param aPos is the point to go to.
* @param aWarp is true if the pointer should be warped to the new position. * @param aWarpMouseCursor is true if the pointer should be warped to the new position.
* @param aCenterView is true if the new cursor position should be centered on canvas.
*/ */
void CursorGoto( const wxPoint& aPos, bool aWarp = true ); void FocusOnLocation( const wxPoint& aPos, bool aWarpMouseCursor = true,
bool aCenterView = false );
/** /**
* Function SelectLibrary * Function SelectLibrary

View File

@ -1,10 +1,10 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -340,17 +340,28 @@ double PCB_BASE_FRAME::BestZoom()
} }
void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos, bool aWarp ) void PCB_BASE_FRAME::FocusOnLocation( const wxPoint& aPos,
bool aWarpMouseCursor, bool aCenterView )
{ {
// factored out of pcbnew/find.cpp if( IsGalCanvasActive() )
{
if( aCenterView )
GetGalCanvas()->GetView()->SetCenter( aPos );
if( aWarpMouseCursor )
GetGalCanvas()->GetViewControls()->SetCursorPosition( aPos );
else
GetGalCanvas()->GetViewControls()->SetCrossAirCursorPosition( aPos );
}
else
{
INSTALL_UNBUFFERED_DC( dc, m_canvas ); INSTALL_UNBUFFERED_DC( dc, m_canvas );
// There may be need to reframe the drawing. // There may be need to reframe the drawing.
if( !m_canvas->IsPointOnDisplay( aPos ) ) if( aCenterView || !m_canvas->IsPointOnDisplay( aPos ) )
{ {
SetCrossHairPosition( aPos ); SetCrossHairPosition( aPos );
RedrawScreen( aPos, aWarp ); RedrawScreen( aPos, aWarpMouseCursor );
} }
else else
{ {
@ -358,12 +369,15 @@ void PCB_BASE_FRAME::CursorGoto( const wxPoint& aPos, bool aWarp )
m_canvas->CrossHairOff( &dc ); m_canvas->CrossHairOff( &dc );
SetCrossHairPosition( aPos ); SetCrossHairPosition( aPos );
if( aWarp ) if( aWarpMouseCursor )
m_canvas->MoveCursorToCrossHair(); m_canvas->MoveCursorToCrossHair();
} }
// Be sure cross hair cursor is ON:
m_canvas->CrossHairOn( &dc ); m_canvas->CrossHairOn( &dc );
m_canvas->CrossHairOn( &dc ); m_canvas->CrossHairOn( &dc );
} }
}
// Virtual function // Virtual function

View File

@ -5,9 +5,9 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2017 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -68,6 +68,21 @@ DIALOG_DRC_CONTROL::~DIALOG_DRC_CONTROL()
{ {
m_config->Write( TestMissingCourtyardKey, m_cbCourtyardMissing->GetValue() ); m_config->Write( TestMissingCourtyardKey, m_cbCourtyardMissing->GetValue() );
m_config->Write( TestFootprintCourtyardKey, m_cbCourtyardOverlap->GetValue() ); m_config->Write( TestFootprintCourtyardKey, m_cbCourtyardOverlap->GetValue() );
// Disonnect events
m_ClearanceListBox->Disconnect( ID_CLEARANCE_LIST, wxEVT_LEFT_DCLICK,
wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnLeftDClickClearance ), NULL, this );
m_ClearanceListBox->Disconnect( ID_CLEARANCE_LIST, wxEVT_RIGHT_UP,
wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnRightUpClearance ), NULL, this );
m_UnconnectedListBox->Disconnect( ID_UNCONNECTED_LIST, wxEVT_LEFT_DCLICK,
wxMouseEventHandler( DIALOG_DRC_CONTROL::
OnLeftDClickUnconnected ), NULL, this );
m_UnconnectedListBox->Disconnect( ID_UNCONNECTED_LIST, wxEVT_RIGHT_UP,
wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnRightUpUnconnected ), NULL, this );
this->Disconnect( wxEVT_MENU, wxCommandEventHandler( DIALOG_DRC_CONTROL::OnPopupMenu ), NULL, this );
} }
void DIALOG_DRC_CONTROL::OnActivateDlg( wxActivateEvent& event ) void DIALOG_DRC_CONTROL::OnActivateDlg( wxActivateEvent& event )
@ -119,6 +134,9 @@ void DIALOG_DRC_CONTROL::InitValues()
wxMouseEventHandler( wxMouseEventHandler(
DIALOG_DRC_CONTROL::OnRightUpUnconnected ), NULL, this ); DIALOG_DRC_CONTROL::OnRightUpUnconnected ), NULL, this );
this->Connect( wxEVT_MENU, wxCommandEventHandler( DIALOG_DRC_CONTROL::OnPopupMenu ), NULL, this );
m_DeleteCurrentMarkerButton->Enable( false ); m_DeleteCurrentMarkerButton->Enable( false );
DisplayDRCValues(); DisplayDRCValues();
@ -369,8 +387,10 @@ void DIALOG_DRC_CONTROL::OnLeftDClickClearance( wxMouseEvent& event )
if( item ) if( item )
{ {
m_brdEditor->CursorGoto( item->GetPointA() ); // When selecting a item, center it on GAL and just move the graphic
m_brdEditor->GetGalCanvas()->GetView()->SetCenter( VECTOR2D( item->GetPointA() ) ); // cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), true, center );
if( !IsModal() ) if( !IsModal() )
{ {
@ -391,7 +411,7 @@ void DIALOG_DRC_CONTROL::OnPopupMenu( wxCommandEvent& event )
{ {
int source = event.GetId(); int source = event.GetId();
const DRC_ITEM* item = 0; const DRC_ITEM* item = nullptr;
wxPoint pos; wxPoint pos;
int selection; int selection;
@ -425,8 +445,10 @@ void DIALOG_DRC_CONTROL::OnPopupMenu( wxCommandEvent& event )
if( item ) if( item )
{ {
m_brdEditor->CursorGoto( pos ); // When selecting a item, center it on GAL and just move the graphic
m_brdEditor->GetGalCanvas()->GetView()->SetCenter( VECTOR2D( item->GetPointA() ) ); // cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( pos, true, center );
if( !IsModal() ) if( !IsModal() )
Show( false ); Show( false );
@ -436,8 +458,6 @@ void DIALOG_DRC_CONTROL::OnPopupMenu( wxCommandEvent& event )
void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event ) void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event )
{ {
event.Skip();
// popup menu to go to either of the items listed in the DRC_ITEM. // popup menu to go to either of the items listed in the DRC_ITEM.
int selection = m_UnconnectedListBox->GetSelection(); int selection = m_UnconnectedListBox->GetSelection();
@ -464,8 +484,6 @@ void DIALOG_DRC_CONTROL::OnRightUpUnconnected( wxMouseEvent& event )
void DIALOG_DRC_CONTROL::OnRightUpClearance( wxMouseEvent& event ) void DIALOG_DRC_CONTROL::OnRightUpClearance( wxMouseEvent& event )
{ {
event.Skip();
// popup menu to go to either of the items listed in the DRC_ITEM. // popup menu to go to either of the items listed in the DRC_ITEM.
int selection = m_ClearanceListBox->GetSelection(); int selection = m_ClearanceListBox->GetSelection();
@ -506,8 +524,10 @@ void DIALOG_DRC_CONTROL::OnLeftDClickUnconnected( wxMouseEvent& event )
const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection ); const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection );
if( item ) if( item )
{ {
m_brdEditor->CursorGoto( item->GetPointA() ); // When selecting a item, center it on GAL and just move the graphic
m_brdEditor->GetGalCanvas()->GetView()->SetCenter( VECTOR2D( item->GetPointA() ) ); // cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), true, center );
if( !IsModal() ) if( !IsModal() )
{ {
@ -534,6 +554,7 @@ void DIALOG_DRC_CONTROL::OnChangingMarkerList( wxNotebookEvent& event )
m_UnconnectedListBox->SetSelection( -1 ); m_UnconnectedListBox->SetSelection( -1 );
} }
void DIALOG_DRC_CONTROL::OnMarkerSelectionEvent( wxCommandEvent& event ) void DIALOG_DRC_CONTROL::OnMarkerSelectionEvent( wxCommandEvent& event )
{ {
int selection = event.GetSelection(); int selection = event.GetSelection();
@ -548,8 +569,10 @@ void DIALOG_DRC_CONTROL::OnMarkerSelectionEvent( wxCommandEvent& event )
const DRC_ITEM* item = m_ClearanceListBox->GetItem( selection ); const DRC_ITEM* item = m_ClearanceListBox->GetItem( selection );
if( item ) if( item )
{ {
m_brdEditor->CursorGoto( item->GetPointA(), false ); // When selecting a item, center it on GAL and just move the graphic
m_brdEditor->GetGalCanvas()->GetView()->SetCenter( VECTOR2D( item->GetPointA() ) ); // cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), false, center );
RedrawDrawPanel(); RedrawDrawPanel();
} }
} }
@ -572,8 +595,10 @@ void DIALOG_DRC_CONTROL::OnUnconnectedSelectionEvent( wxCommandEvent& event )
const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection ); const DRC_ITEM* item = m_UnconnectedListBox->GetItem( selection );
if( item ) if( item )
{ {
m_brdEditor->CursorGoto( item->GetPointA(), false ); // When selecting a item, center it on GAL and just move the graphic
m_brdEditor->GetGalCanvas()->GetView()->SetCenter( VECTOR2D( item->GetPointA() ) ); // cursor in legacy mode gives the best result
bool center = m_brdEditor->IsGalCanvasActive() ? true : false;
m_brdEditor->FocusOnLocation( item->GetPointA(), false, center );
RedrawDrawPanel(); RedrawDrawPanel();
} }
} }

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017) // C++ code generated with wxFormBuilder (version Jul 2 2017)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#include "dialog_drclistbox.h" #include "dialog_drclistbox.h"
@ -249,7 +249,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
m_panelClearanceListBox->SetSizer( bSizeClearanceBox ); m_panelClearanceListBox->SetSizer( bSizeClearanceBox );
m_panelClearanceListBox->Layout(); m_panelClearanceListBox->Layout();
bSizeClearanceBox->Fit( m_panelClearanceListBox ); bSizeClearanceBox->Fit( m_panelClearanceListBox );
m_Notebook->AddPage( m_panelClearanceListBox, _("Problems / Markers"), false ); m_Notebook->AddPage( m_panelClearanceListBox, _("Problems / Markers"), true );
m_panelUnconnectedBox = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panelUnconnectedBox = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerUnconnectedBox; wxBoxSizer* bSizerUnconnectedBox;
bSizerUnconnectedBox = new wxBoxSizer( wxVERTICAL ); bSizerUnconnectedBox = new wxBoxSizer( wxVERTICAL );
@ -263,7 +263,7 @@ DIALOG_DRC_CONTROL_BASE::DIALOG_DRC_CONTROL_BASE( wxWindow* parent, wxWindowID i
m_panelUnconnectedBox->SetSizer( bSizerUnconnectedBox ); m_panelUnconnectedBox->SetSizer( bSizerUnconnectedBox );
m_panelUnconnectedBox->Layout(); m_panelUnconnectedBox->Layout();
bSizerUnconnectedBox->Fit( m_panelUnconnectedBox ); bSizerUnconnectedBox->Fit( m_panelUnconnectedBox );
m_Notebook->AddPage( m_panelUnconnectedBox, _("Unconnected"), true ); m_Notebook->AddPage( m_panelUnconnectedBox, _("Unconnected"), false );
m_ErrorMsgs->Add( m_Notebook, 1, wxEXPAND | wxALL, 5 ); m_ErrorMsgs->Add( m_Notebook, 1, wxEXPAND | wxALL, 5 );

View File

@ -2848,7 +2848,7 @@
<object class="notebookpage" expanded="0"> <object class="notebookpage" expanded="0">
<property name="bitmap"></property> <property name="bitmap"></property>
<property name="label">Problems / Markers</property> <property name="label">Problems / Markers</property>
<property name="select">0</property> <property name="select">1</property>
<object class="wxPanel" expanded="0"> <object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
@ -3022,7 +3022,7 @@
<object class="notebookpage" expanded="0"> <object class="notebookpage" expanded="0">
<property name="bitmap"></property> <property name="bitmap"></property>
<property name="label">Unconnected</property> <property name="label">Unconnected</property>
<property name="select">1</property> <property name="select">0</property>
<object class="wxPanel" expanded="0"> <object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>

View File

@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Nov 22 2017) // C++ code generated with wxFormBuilder (version Jul 2 2017)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO "NOT" EDIT THIS FILE!
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
#ifndef __DIALOG_DRC_BASE_H__ #ifndef __DIALOG_DRC_BASE_H__
@ -11,6 +11,7 @@
#include <wx/artprov.h> #include <wx/artprov.h>
#include <wx/xrc/xmlres.h> #include <wx/xrc/xmlres.h>
#include <wx/intl.h> #include <wx/intl.h>
class DIALOG_SHIM;
class DRCLISTBOX; class DRCLISTBOX;
#include "dialog_shim.h" #include "dialog_shim.h"

View File

@ -2,8 +2,8 @@
* This program source code file is part of KICAD, a free EDA CAD application. * This program source code file is part of KICAD, a free EDA CAD application.
* *
* Copyright (C) 2012 Marco Mattila <marcom99@gmail.com> * Copyright (C) 2012 Marco Mattila <marcom99@gmail.com>
* Copyright (C) 2006 Jean-Pierre Charras <jean-pierre.charras@gipsa-lab.inpg.fr> * Copyright (C) 2018 Jean-Pierre Charras jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 Kicad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2018 Kicad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -128,10 +128,9 @@ void DIALOG_FIND::onButtonFindItemClick( wxCommandEvent& aEvent )
if( foundItem ) if( foundItem )
{ {
parent->SetCurItem( foundItem ); parent->SetCurItem( foundItem );
parent->FocusOnLocation( pos, !m_NoMouseWarpCheckBox->IsChecked(), true );
msg.Printf( _( "\"%s\" found" ), GetChars( searchString ) ); msg.Printf( _( "\"%s\" found" ), GetChars( searchString ) );
parent->SetStatusText( msg ); parent->SetStatusText( msg );
parent->CursorGoto( pos, !m_NoMouseWarpCheckBox->IsChecked() );
} }
else else
{ {
@ -166,10 +165,9 @@ void DIALOG_FIND::onButtonFindMarkerClick( wxCommandEvent& aEvent )
if( foundItem ) if( foundItem )
{ {
parent->SetCurItem( foundItem ); parent->SetCurItem( foundItem );
parent->FocusOnLocation( pos, !m_NoMouseWarpCheckBox->IsChecked() );
msg = _( "Marker found" ); msg = _( "Marker found" );
parent->SetStatusText( msg ); parent->SetStatusText( msg );
parent->CursorGoto( pos, !m_NoMouseWarpCheckBox->IsChecked() );
} }
else else
{ {