Give assistant graphics a max bounding box.

They're only on screen when they're being used, and we don't have
a GAL available to calculate their actual extents from (since their
text scales with zoom).

Fixes https://gitlab.com/kicad/code/kicad/issues/5845
This commit is contained in:
Jeff Young 2020-10-01 17:52:01 +01:00
parent 35e129ed47
commit 612411a87b
4 changed files with 15 additions and 30 deletions

View File

@ -48,14 +48,9 @@ const BOX2I ARC_ASSISTANT::ViewBBox() const
if( m_constructMan.IsReset() )
return tmp;
// just enclose the whle circular area
auto origin = m_constructMan.GetOrigin();
auto radius = m_constructMan.GetRadius();
VECTOR2D rVec( radius, radius );
tmp.SetOrigin( origin + rVec );
tmp.SetEnd( origin - rVec );
tmp.Normalize();
// this is an edit-time artefact; no reason to try and be smart with the bounding box
// (besides, we can't tell the text extents without a view to know what the scale is)
tmp.SetMaximum();
return tmp;
}
@ -153,5 +148,5 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
// place the text next to cursor, on opposite side from radius
DrawTextNextToCursor( aView, m_constructMan.GetLastPoint(),
origin - m_constructMan.GetLastPoint(),
cursorStrings, aLayer == LAYER_GP_OVERLAY );
cursorStrings, aLayer == LAYER_SELECT_OVERLAY );
}

View File

@ -236,9 +236,12 @@ const BOX2I RULER_ITEM::ViewBBox() const
{
BOX2I tmp;
tmp.SetOrigin( m_geomMgr.GetOrigin() );
tmp.SetEnd( m_geomMgr.GetEnd() );
tmp.Normalize();
if( m_geomMgr.GetOrigin() == m_geomMgr.GetEnd() )
return tmp;
// this is an edit-time artefact; no reason to try and be smart with the bounding box
// (besides, we can't tell the text extents without a view to know what the scale is)
tmp.SetMaximum();
return tmp;
}

View File

@ -48,22 +48,9 @@ const BOX2I TWO_POINT_ASSISTANT::ViewBBox() const
if( m_constructMan.IsReset() )
return tmp;
// just enclose the whle circular area
auto origin = m_constructMan.GetOrigin();
auto end = m_constructMan.GetEnd();
if( m_shape == GEOM_SHAPE::SEGMENT || m_shape == GEOM_SHAPE::RECT )
{
tmp.SetOrigin( origin );
tmp.SetEnd( end );
}
else
{
tmp.SetOrigin( origin + end );
tmp.SetEnd( origin - end );
}
tmp.Normalize();
// this is an edit-time artefact; no reason to try and be smart with the bounding box
// (besides, we can't tell the text extents without a view to know what the scale is)
tmp.SetMaximum();
return tmp;
}

View File

@ -44,8 +44,8 @@ namespace PREVIEW
void ViewGetLayers( int aLayers[], int& aCount ) const override
{
aLayers[0] = LAYER_GP_OVERLAY; // Drop shadows
aLayers[1] = LAYER_SELECT_OVERLAY; // Assitant graphics
aLayers[0] = LAYER_SELECT_OVERLAY; // Assitant graphics
aLayers[1] = LAYER_GP_OVERLAY; // Drop shadows
aCount = 2;
}