(&mut self, device: &Device, queue: &Queue, state: &PlotState)
| 1506 | } |
| 1507 | } |
| 1508 | |
| 1509 | // Create marker buffer if we have any |
| 1510 | if !marker_writer.is_empty() { |
| 1511 | let data = marker_writer.as_slice(); |
| 1512 | let marker_count = (data.len() / 36) as u32; // 36 bytes per marker instance |
| 1513 | self.buffers.highlight_markers = Some(VertexBuffer { |
| 1514 | buffer: device.create_buffer(&BufferDescriptor { |
| 1515 | label: Some("highlight markers vb"), |
| 1516 | size: data.len() as u64, |
| 1517 | usage: BufferUsages::VERTEX | BufferUsages::COPY_DST, |
| 1518 | mapped_at_creation: false, |
| 1519 | }), |
| 1520 | vertex_count: marker_count, |
| 1521 | }); |
| 1522 | if let Some(vb) = &self.buffers.highlight_markers { |
| 1523 | queue.write_buffer(&vb.buffer, 0, data); |
| 1524 | } |
| 1525 | } |
| 1526 | } |
| 1527 | |
| 1528 | fn rebuild_crosshairs(&mut self, device: &Device, queue: &Queue, state: &PlotState) { |
| 1529 | self.buffers.crosshairs = None; |
| 1530 | |
| 1531 | if !state.crosshairs_enabled { |
| 1532 | return; |
| 1533 | } |
| 1534 | |
| 1535 | let w = self.bounds_w.max(1) as f32; |
| 1536 | let h = self.bounds_h.max(1) as f32; |
| 1537 | if w <= 1.0 || h <= 1.0 { |
| 1538 | return; |
| 1539 | } |
| 1540 | |
| 1541 | // Check if cursor is within bounds |
| 1542 | let pos = state.crosshairs_position * self.scale_factor; |
| 1543 | if pos.x < 0.0 || pos.y < 0.0 || pos.x > w || pos.y > h { |
| 1544 | return; |
| 1545 | } |
| 1546 | |
| 1547 | // Convert cursor position to clip coordinates |
| 1548 | let cursor_clip = self.screen_to_clip(pos.x, pos.y); |
| 1549 | |
| 1550 | let mut data: Vec<f32> = Vec::new(); |
| 1551 | |
| 1552 | // Horizontal line (left to right through cursor) |
| 1553 | let left = [-1.0, cursor_clip[1]]; |
| 1554 | let right = [1.0, cursor_clip[1]]; |
| 1555 | |
| 1556 | // Vertical line (top to bottom through cursor) |
| 1557 | let top = [cursor_clip[0], 1.0]; |
| 1558 | let bottom = [cursor_clip[0], -1.0]; |
| 1559 | |
| 1560 | // Add horizontal line vertices |
| 1561 | data.extend_from_slice(&left); |
| 1562 | data.extend_from_slice(&CROSSHAIR_RGBA); |
| 1563 | data.extend_from_slice(&right); |
| 1564 | data.extend_from_slice(&CROSSHAIR_RGBA); |
| 1565 |
no test coverage detected