Redraw selection halos after zooming.

Fixes: lp:1838869
* https://bugs.launchpad.net/kicad/+bug/1838869
This commit is contained in:
Jeff Young 2019-08-08 10:06:53 +01:00
parent 726bceecfd
commit 8db8119564
7 changed files with 55 additions and 52 deletions

View File

@ -575,8 +575,11 @@ void VIEW::SetMirror( bool aMirrorX, bool aMirrorY )
}
void VIEW::SetScale( double aScale, const VECTOR2D& aAnchor )
void VIEW::SetScale( double aScale, VECTOR2D aAnchor )
{
if( aAnchor == VECTOR2D( 0, 0 ) )
aAnchor = m_center;
VECTOR2D a = ToScreen( aAnchor );
if( aScale < m_minScale )

View File

@ -40,7 +40,7 @@
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <tools/ee_actions.h>
#include <tools/ee_selection_tool.h>
LIB_ALIAS* SchGetLibAlias( const LIB_ID& aLibId, SYMBOL_LIB_TABLE* aLibTable, PART_LIB* aCacheLib,
wxWindow* aParent, bool aShowErrorMsg )
@ -399,6 +399,20 @@ void SCH_BASE_FRAME::RefreshItem( EDA_ITEM* aItem, bool isAddOrDelete )
}
void SCH_BASE_FRAME::RefreshSelection()
{
if( m_toolManager )
{
EE_SELECTION_TOOL* selectionTool = m_toolManager->GetTool<EE_SELECTION_TOOL>();
SELECTION& selection = selectionTool->GetSelection();
KIGFX::SCH_VIEW* view = GetCanvas()->GetView();
for( EDA_ITEM* item : selection )
view->Update( item, KIGFX::REPAINT );
}
}
void SCH_BASE_FRAME::AddToScreen( EDA_ITEM* aItem, SCH_SCREEN* aScreen )
{
auto screen = aScreen;

View File

@ -319,6 +319,11 @@ public:
*/
void RefreshItem( EDA_ITEM* aItem, bool isAddOrDelete = false );
/**
* Mark selected items for refresh.
*/
void RefreshSelection();
/**
* Mark all items for refresh.
*/

View File

@ -228,10 +228,9 @@ float SCH_PAINTER::getShadowWidth()
{
const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix();
if( matrix.GetScale().x > 20 )
return (float) fabs( matrix.GetScale().x * 5 );
else
return (float) fabs( matrix.GetScale().x * 4 );
// For best visuals the selection width must be a cross between the zoom level and the
// default line width.
return (float) ( ( fabs( matrix.GetScale().x * 5.5 ) + GetDefaultLineThickness() ) / 2.0 );
}

View File

@ -68,6 +68,16 @@ SCH_VIEW::~SCH_VIEW()
}
void SCH_VIEW::SetScale( double aScale, VECTOR2D aAnchor )
{
VIEW::SetScale( aScale, aAnchor );
//Redraw selection halos since their width is dependant on zoom
if( m_frame )
m_frame->RefreshSelection();
}
void SCH_VIEW::ResizeSheetWorkingArea( SCH_SCREEN* aScreen )
{
const PAGE_INFO& page_info = aScreen->GetPageSettings();
@ -156,20 +166,6 @@ void SCH_VIEW::AddToPreview( EDA_ITEM* aItem, bool aTakeOwnership )
}
void SCH_VIEW::ShowSelectionArea( bool aShow )
{
if( aShow )
{
// Reset seleciton area so the previous one doesn't flash before the first
// mouse move updates it
m_selectionArea->SetOrigin( VECTOR2I() );
m_selectionArea->SetEnd( VECTOR2I() );
}
SetVisible( m_selectionArea.get(), aShow );
}
void SCH_VIEW::ShowPreview( bool aShow )
{
SetVisible( m_preview.get(), aShow );

View File

@ -42,21 +42,21 @@ class SCH_BASE_FRAME;
constexpr double SCH_WORLD_UNIT = 0.001;
static const LAYER_NUM SCH_LAYER_ORDER[] =
{
LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY,
LAYER_ERC_ERR, LAYER_ERC_WARN,
LAYER_REFERENCEPART, LAYER_VALUEPART, LAYER_FIELDS,
LAYER_JUNCTION, LAYER_NOCONNECT,
LAYER_HIERLABEL,
LAYER_WIRE, LAYER_BUS,
LAYER_DEVICE,
LAYER_NOTES,
LAYER_SHEET,
LAYER_SELECTION_SHADOWS,
LAYER_DEVICE_BACKGROUND,
LAYER_SHEET_BACKGROUND,
LAYER_WORKSHEET
};
{
LAYER_GP_OVERLAY, LAYER_SELECT_OVERLAY,
LAYER_ERC_ERR, LAYER_ERC_WARN,
LAYER_REFERENCEPART, LAYER_VALUEPART, LAYER_FIELDS,
LAYER_JUNCTION, LAYER_NOCONNECT,
LAYER_HIERLABEL,
LAYER_WIRE, LAYER_BUS,
LAYER_DEVICE,
LAYER_NOTES,
LAYER_SHEET,
LAYER_SELECTION_SHADOWS,
LAYER_DEVICE_BACKGROUND,
LAYER_SHEET_BACKGROUND,
LAYER_WORKSHEET
};
namespace KIGFX
@ -84,16 +84,13 @@ public:
// Call it to set new draw area limits (max working and draw area size)
void ResizeSheetWorkingArea( SCH_SCREEN *aScreen );
KIGFX::PREVIEW::SELECTION_AREA* GetSelectionArea() const { return m_selectionArea.get(); }
KIGFX::VIEW_GROUP* GetPreview() const { return m_preview.get(); }
void ClearPreview();
void AddToPreview( EDA_ITEM* aItem, bool aTakeOwnership = true );
void ShowSelectionArea( bool aShow = true );
void ShowPreview( bool aShow = true );
void SetScale( double aScale, VECTOR2D aAnchor = { 0, 0 } ) override;
/**
* Clear the hide flag of all items in the view
*/

View File

@ -241,17 +241,6 @@ public:
return m_mirrorY;
}
/**
* Function SetScale()
* Sets the scaling factor. Scale = 1 corresponds to the real world size of the objects
* (depending on correct GAL unit length & DPI settings).
* @param aScale: the scalefactor
*/
virtual void SetScale( double aScale )
{
SetScale( aScale, m_center );
}
/**
* Function SetScale()
* Sets the scaling factor, zooming around a given anchor point.
@ -259,7 +248,7 @@ public:
* @param aAnchor: the zooming anchor point
* @param aScale: the scale factor
*/
virtual void SetScale( double aScale, const VECTOR2D& aAnchor );
virtual void SetScale( double aScale, VECTOR2D aAnchor = { 0, 0 } );
/**
* Function GetScale()