kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #33243
Re: [PATCH] Ensure DrawRectangle() stroke outline will always be visible
Please use the new attached patch instead of the first one I sent; the old
one failed to include the change to selection_area.cpp
On Mon, Jan 15, 2018 at 11:09 PM, Jon Evans <jon@xxxxxxxxxxxxx> wrote:
> SELECTION_AREA::ViewDraw() doesn't set the line width. I thought about
> fixing it by adding a call to set some kind of arbitrary width, but decided
> to do it a different way to be more generally applicable. Despite my
> saying that, this is still more of a workaround than a real fix.
>
> Note that this is probably a topic that wants future thought after V5:
> There is currently no easy way to draw things in screen space rather than
> world space. Maybe I will think about how to add an easy-to-use mechanism
> to the GAL to accomplish this. Sometimes you really just want a line that
> is 1px wide ;-)
>
> Fixes: https://bugs.launchpad.net/kicad/+bug/1743242
>
> -Jon
>
From 89b8266b3c92f6f92c65e597e2289354d08dc0e4 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Mon, 15 Jan 2018 23:05:16 -0500
Subject: [PATCH] Ensure DrawRectangle() stroke outline will always be visible
Fixes: lp:1743242
* https://bugs.launchpad.net/kicad/+bug/1743242
---
common/gal/opengl/opengl_gal.cpp | 3 +++
common/preview_items/selection_area.cpp | 1 +
2 files changed, 4 insertions(+)
diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp
index 608c11714..9b4654446 100644
--- a/common/gal/opengl/opengl_gal.cpp
+++ b/common/gal/opengl/opengl_gal.cpp
@@ -688,6 +688,9 @@ void OPENGL_GAL::DrawRectangle( const VECTOR2D& aStartPoint, const VECTOR2D& aEn
// Stroke the outline
if( isStrokeEnabled )
{
+ // Ensure stroke will be visible at current zoom
+ lineWidth = std::max( lineWidth, ( 1.01 / worldScale ) );
+
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
std::deque<VECTOR2D> pointList;
diff --git a/common/preview_items/selection_area.cpp b/common/preview_items/selection_area.cpp
index 7cb5f48e8..fdb9e7d83 100644
--- a/common/preview_items/selection_area.cpp
+++ b/common/preview_items/selection_area.cpp
@@ -120,6 +120,7 @@ void SELECTION_AREA::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
gal.SetIsStroke( true );
gal.SetIsFill( true );
+ gal.SetLineWidth( 1.0 );
// Set the stroke color to indicate window or crossing selection
gal.SetStrokeColor( ( m_origin.x <= m_end.x ) ? scheme.outline_l2r : scheme.outline_r2l );
--
2.14.1
References