Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selection of structures results in thick black lines #1930

Open
hpretl opened this issue Nov 18, 2024 · 5 comments
Open

Selection of structures results in thick black lines #1930

hpretl opened this issue Nov 18, 2024 · 5 comments
Labels
Milestone

Comments

@hpretl
Copy link

hpretl commented Nov 18, 2024

When I use KLayout 0.29.8 inside a Docker VM based on Ubuntu 22.04LTS, and when I am on a Arm-based Mac (not happening on Intel-based Macs) then I get a thick black selection frame when clicking on a layout structure:

image

Interestingly, when I hover the mouse over a structure, there is also a black line indicating a to-be selected layout structure, but this black “frame” looks OK:

image

@klayoutmatthias Any idea what is going on? The problem is that this thick black border on selected items is really annoying, as it overlays other things that would be necessary to see. All other graphical elements in KLayout look fine, just this selection border is too wide.

As a side note, turning off “with halo” or playing around with line width in the Setup Selection does not help.

@martinjankoehler
Copy link
Contributor

martinjankoehler commented Nov 18, 2024

FYI, I can also reproduce it using VNC (instead of X11).

Bildschirmfoto 2024-11-18 um 20 20 11

It also seems those settings are ignored:

  • Line Width
  • Vertex Size
  • With Halo

whereas Color and Marker fill work.

Bildschirmfoto 2024-11-18 um 20 59 30

@martinjankoehler
Copy link
Contributor

martinjankoehler commented Nov 19, 2024

Hey @klayoutmatthias,

I did some printf-Logging around

int line_width = m_line_width < 0 ? mp_view->default_marker_line_width () : m_line_width;

Diff:

diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc
index 2f08d2289..a7bf71037 100644
--- a/src/laybasic/laybasic/layMarker.cc
+++ b/src/laybasic/laybasic/layMarker.cc
@@ -329,6 +329,10 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay:
   int dither_pattern = m_dither_pattern < 0 ? mp_view->default_dither_pattern () : m_dither_pattern;
   int line_style = m_line_style < 0 ? mp_view->default_line_style () : m_line_style;
 
+
+  printf("layMarker.cc: line_width=%d, vertex_size=%d, halo=%d\n", 
+         line_width, vertex_size, halo);
+
   if (halo) {
 
     std::vector <lay::ViewOp> ops;

After clicking a shape, I get:

layMarker.cc: line_width=255, vertex_size=255, halo=1
layMarker.cc: line_width=255, vertex_size=255, halo=1
layMarker.cc: line_width=1, vertex_size=0, halo=0
layMarker.cc: line_width=255, vertex_size=255, halo=1

Sometimes after a single-click (no selection -> selection), I even get more events:

layMarker.cc: line_width=1, vertex_size=0, halo=0
layMarker.cc: line_width=1, vertex_size=0, halo=0
layMarker.cc: line_width=255, vertex_size=255, halo=1
layMarker.cc: line_width=255, vertex_size=255, halo=1
layMarker.cc: line_width=1, vertex_size=0, halo=0
layMarker.cc: line_width=255, vertex_size=255, halo=1

255 / 0xFF looks suspicious.

@martinjankoehler
Copy link
Contributor

Compiler warning hints at the reason:

../../../src/laybasic/laybasic/layMarker.cc: In member function \u2018void lay::MarkerBase::get_bitmaps(const lay::Viewport&, lay::ViewObjectCanvas&, lay::CanvasPlane*&, lay::CanvasPlane*&, lay::CanvasPlane*&, lay::CanvasPlane*&)\u2019:
../../../src/laybasic/laybasic/layMarker.cc:326:33: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  326 |   int line_width = m_line_width < 0 ? mp_view->default_marker_line_width () : m_line_width;
      |                    ~~~~~~~~~~~~~^~~
../../../src/laybasic/laybasic/layMarker.cc:327:35: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  327 |   int vertex_size = m_vertex_size < 0 ? mp_view->default_marker_vertex_size () : m_vertex_size;
      |                     ~~~~~~~~~~~~~~^~~
../../../src/laybasic/laybasic/layMarker.cc:328:22: warning: comparison is always false due to limited range of data type [-Wtype-limits]
  328 |   bool halo = m_halo < 0 ? mp_view->default_marker_halo () : (m_halo != 0);
      |               ~~~~~~~^~~

@martinjankoehler
Copy link
Contributor

martinjankoehler commented Nov 19, 2024

Root Cause:
MarkerBase::m_line_width should be int, not char!

Bildschirmfoto 2024-11-19 um 18 15 16

After applying this fix, it works:
Bildschirmfoto 2024-11-19 um 18 18 15

@klayoutmatthias
Copy link
Collaborator

Some problems like the signed vs. unsigned char never get resolved ... I usually avoid using char for integers, but this case escaped me. All my gccs, clangs and MSVCs treat it as signed on Windows and Linux.

I even get this warning from clang:

c.x:14:
char c;
c = 128;

gives:
x.c:14:7: warning: implicit conversion from 'int' to 'char' changes value from 128 to -128 [-Wconstant-conversion]

which is rather suggesting that char is signed.

Anyway, problem is fixed. Thanks for the PR.

Matthias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants