From 612411a87bbf15362118f5c7e7a4e70103feed10 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 1 Oct 2020 17:52:01 +0100 Subject: [PATCH] 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 --- common/preview_items/arc_assistant.cpp | 13 ++++--------- common/preview_items/ruler_item.cpp | 9 ++++++--- common/preview_items/two_point_assistant.cpp | 19 +++---------------- include/preview_items/arc_assistant.h | 4 ++-- 4 files changed, 15 insertions(+), 30 deletions(-) diff --git a/common/preview_items/arc_assistant.cpp b/common/preview_items/arc_assistant.cpp index 81ea0b4f53..5f5bc807b8 100644 --- a/common/preview_items/arc_assistant.cpp +++ b/common/preview_items/arc_assistant.cpp @@ -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 ); } diff --git a/common/preview_items/ruler_item.cpp b/common/preview_items/ruler_item.cpp index b44e436d0e..bd8034bb83 100644 --- a/common/preview_items/ruler_item.cpp +++ b/common/preview_items/ruler_item.cpp @@ -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; } diff --git a/common/preview_items/two_point_assistant.cpp b/common/preview_items/two_point_assistant.cpp index eca1460c19..f720d6e0cf 100644 --- a/common/preview_items/two_point_assistant.cpp +++ b/common/preview_items/two_point_assistant.cpp @@ -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; } diff --git a/include/preview_items/arc_assistant.h b/include/preview_items/arc_assistant.h index e9e8f8e874..a9a54b6279 100644 --- a/include/preview_items/arc_assistant.h +++ b/include/preview_items/arc_assistant.h @@ -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; }