From 3103e3dc4ca4e8e633a753b33b497b9af2d740c7 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 19 Mar 2018 22:25:55 -0400 Subject: [PATCH] DRC: Center zoom on marker location, not DRC item start location For some DRC checks, the location of the marker is not the location of the first item in the resulting DRC_ITEM, so centering the screen on PointA of the DRC_ITEM can be confusing. --- common/marker_base.cpp | 2 ++ include/drc_item.h | 9 +++++++++ pcbnew/dialogs/dialog_drc.cpp | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/common/marker_base.cpp b/common/marker_base.cpp index b03abc4794..8e4f44951c 100644 --- a/common/marker_base.cpp +++ b/common/marker_base.cpp @@ -137,6 +137,7 @@ void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos, m_Pos = aMarkerPos; m_drc.SetData( aErrorCode, aText, bText, aPos, bPos ); + m_drc.SetParent( this ); } @@ -146,6 +147,7 @@ void MARKER_BASE::SetData( int aErrorCode, const wxPoint& aMarkerPos, m_Pos = aMarkerPos; m_drc.SetData( aErrorCode, aText, aPos ); + m_drc.SetParent( this ); } diff --git a/include/drc_item.h b/include/drc_item.h index 4ea40f33a2..813ee433c7 100644 --- a/include/drc_item.h +++ b/include/drc_item.h @@ -27,6 +27,8 @@ #include +class MARKER_BASE; + /** * Class DRC_ITEM @@ -51,6 +53,9 @@ protected: bool m_hasSecondItem; ///< true when 2 items create a DRC/ERC error, false if only one item bool m_noCoordinate; + /// The marker this item belongs to, if any + MARKER_BASE* m_parent; + public: DRC_ITEM() @@ -58,6 +63,7 @@ public: m_ErrorCode = 0; m_hasSecondItem = false; m_noCoordinate = false; + m_parent = nullptr; } DRC_ITEM( int aErrorCode, @@ -127,6 +133,9 @@ public: m_hasSecondItem = true; } + void SetParent( MARKER_BASE* aMarker ) { m_parent = aMarker; } + + MARKER_BASE* GetParent() const { return m_parent; } bool HasSecondItem() const { return m_hasSecondItem; } diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 034def5339..06718f41da 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -392,10 +392,15 @@ void DIALOG_DRC_CONTROL::OnLeftDClickClearance( wxMouseEvent& event ) 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( item->GetPointA(), true, center ); + m_brdEditor->FocusOnLocation( pos, true, center ); if( !IsModal() ) { @@ -575,10 +580,15 @@ void DIALOG_DRC_CONTROL::OnMarkerSelectionEvent( wxCommandEvent& event ) 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( item->GetPointA(), false, center ); + m_brdEditor->FocusOnLocation( pos, false, center ); RedrawDrawPanel(); } }