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.
This commit is contained in:
Jon Evans 2018-03-19 22:25:55 -04:00
parent b40bf4c0ea
commit 3103e3dc4c
3 changed files with 23 additions and 2 deletions

View File

@ -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 );
}

View File

@ -27,6 +27,8 @@
#include <macros.h>
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; }

View File

@ -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();
}
}