Skip to content

Commit 035e1e2

Browse files
Improve viewer hover highlighting and fix text rendering (#199)
## Summary - Replace the separate yellow overlay hover highlight with in-place element re-rendering using brighter fill (doubled alpha) and bolder stroke (3px), so the highlight always matches the element's actual shape at every zoom level - Expand `query_point` to check a 3×3 neighbourhood of spatial grid cells, eliminating hover detection misses near cell boundaries - Add edge tolerance (`3px / zoom`) to Polygon and GdsBox hit tests for more reliable hover near edges - Fix text and node elements not rendering when they are the only elements in a spatial grid cell — point bboxes produced zero-size cells that were incorrectly culled ## Test plan - Open a GDS file and hover over elements at various zoom levels — highlight should match element shape exactly - Hover near element edges and cell boundaries — hover should activate reliably - Open a cell containing only text elements — text should be visible - Run `cargo nextest run -p gdsr-viewer` — all 134 tests pass
1 parent c216f41 commit 035e1e2

File tree

4 files changed

+180
-150
lines changed

4 files changed

+180
-150
lines changed

crates/gdsr-viewer/src/app.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ pub struct ViewerApp {
2929
ruler: RulerState,
3030
show_grid: bool,
3131
hovered_element: Option<usize>,
32+
/// Reusable scratch buffer for spatial grid point queries.
33+
query_buf: Vec<u32>,
3234
}
3335

3436
impl Default for ViewerApp {
@@ -43,6 +45,7 @@ impl Default for ViewerApp {
4345
ruler: RulerState::default(),
4446
show_grid: true,
4547
hovered_element: None,
48+
query_buf: Vec::new(),
4649
}
4750
}
4851
}
@@ -341,6 +344,7 @@ impl eframe::App for ViewerApp {
341344
let ruler = &mut self.ruler;
342345
let show_grid = self.show_grid;
343346
let hovered_element = &mut self.hovered_element;
347+
let query_buf = &mut self.query_buf;
344348
egui::CentralPanel::default().show(ctx, |ui| {
345349
let mut empty_cache = std::collections::HashMap::new();
346350
let (elements, spatial_grid, library, tessellation_cache) =
@@ -372,7 +376,7 @@ impl eframe::App for ViewerApp {
372376
*hovered_element = None;
373377
if let Some((wx, wy)) = *mouse_world_pos {
374378
if let Some(grid) = spatial_grid {
375-
let candidates = grid.query_point(wx, wy);
379+
let candidates = grid.query_point(wx, wy, query_buf);
376380
for &idx in candidates.iter().rev() {
377381
if let Some(el) = elements.get(idx as usize) {
378382
if el.hit_test(wx, wy, viewport.zoom) {

0 commit comments

Comments
 (0)