Skip to content

47 improve inspected point visualization #58

Merged
merged 12 commits into from
Nov 5, 2025

Conversation

franmagn
Copy link
Member

@franmagn franmagn commented Nov 4, 2025

Issue number

Closes #47

Description

  • added height, lat and long data of the point in the "Measurement" section of the sidebar
  • removed all unused values from the "Measurement" section of the sidebar, keeping only "point source id", "accepted", "TVU" and "THU" of the old values
  • added a label displaying the name of the saved measurement on the potree renderer canvas, for each measurement tool implemented in potree (exception made for volumes). It follows the point/measurement value as it is moved, and correctly gets deleted with the deletion of the point/measurement value. The label is placed in the most convenient position related to the measurement tool used (e.g. in the centre of an Area mesurement, or in the middle of the line measuring the distance between 2 points), and has a white background that should improve visibility with different colorings of the datasets.

Testing steps

To test the changes, try to add some points on the renderer area and check the values int the Measurement section of the sidebar while moving them, and also check the displaying of the labels in the potree render area, they should match the names in the sidebar. Try also to test different tools, as they all have their personalized label name, following the names present in the Measurement section of the sidebar, and to change the color of the datasets where the points sit, to test the visibility of the labels.

Screenshots (optional)

Summary by CodeRabbit

  • New Features

    • On-canvas measurement labels with toggleable display modes (values, names, hide) and per-measurement overlays
    • Display of latitude, longitude and elevation where available; improved label positioning and updates
  • Bug Fixes

    • Overlays reliably update and clean up on camera/mouse/resize and measurement changes; mounting safeguards added
  • Style

    • Scoped table zebra styling refined; new public CSS classes for label visuals and overlay container

pruned the table with all the values related to the point selected, in order to delete all unused and useless attributes while keeping origianl behaviour
fixed a graphic bug that made not possible to see x,y and z coordinates on other measurement tools sections in the sidebar, and that showed Latitude, Longitude and Elevation in those sections
…into 47-improve-inspected-point-visualization
…ud on the globe

add a simple label with the name of the measured object, taken from the sidebar measurement list. It automatically gets removed once the measured object is removed, and it moves with the moving of the points.
made labels come up faster after a movement, not requiring a camera update anymore
add background to make the labels visible even while displaying black or white datasets
@franmagn franmagn linked an issue Nov 4, 2025 that may be closed by this pull request
@coderabbit
Copy link

coderabbit bot commented Nov 4, 2025

Walkthrough

Adds scoped table zebra-striping rules and two new CSS classes for on-canvas labels. Extends the measurements panel to create/manage per-measurement overlay labels, project 3D positions to screen space, update positions on camera/mouse/resize events, and manage overlay lifecycle and mounted state.

Changes

Cohort / File(s) Summary
CSS Styling Updates
src/MeasurementControl/measurementsPanel.css
Replaced global #measurements_list tr:nth-child(even) with scoped #measurements_list table.measurement_value_table tr.alt-even td; added tr.alt-odd td fallback; added public classes .measurement-canvas-label and .measurement-label-overlay for on-canvas label visuals and overlay container.
Measurement Panel Logic & Overlay
src/MeasurementControl/measurementsPanel.js
Imported ecef/wgs84; extended lastSelection with type; added overlay container and overlayMap; implemented projectToScreen, getMeasurementRepresentativePosition, createOrUpdateMeasurementCanvasLabel, updateOverlayPositions; integrated overlay creation/cleanup into list rebuild and measurement add/remove flows; added mounted flag (data-mp-mounted) and guards; wired camera/mouse/resize and marker/point move events; added display modes (VALUES/NAMES/HIDE) and lat/lon/elev insertion logic.

Sequence Diagram

sequenceDiagram
    participant Viewer as Viewer/Renderer
    participant Panel as Measurements Panel
    participant Overlay as Overlay DOM
    participant Camera as Camera

    rect rgb(240,248,255)
    note over Panel: Initialization & mount
    Viewer->>Panel: initMeasurementsPanel(viewer)
    Panel->>Overlay: create overlay div, attach to render area
    Panel->>Panel: set data-mp-mounted flag
    end

    rect rgb(235,255,235)
    note over Panel: Measurement added/updated
    Panel->>Panel: rebuild measurement list
    Panel->>Overlay: createOrUpdateMeasurementCanvasLabel(measurement)
    Overlay->>Overlay: store label & metadata
    end

    rect rgb(255,250,240)
    note over Camera: Interaction/viewport updates
    Camera->>Panel: camera_changed / render / resize / marker_moved
    Panel->>Overlay: updateOverlayPositions()
    Overlay->>Overlay: getRepresentativePosition() -> projectToScreen()
    Overlay->>Overlay: update DOM position & visibility
    end

    rect rgb(255,240,245)
    note over Panel: Removal / cleanup
    Panel->>Overlay: remove overlay label for deleted measurement
    Overlay->>Panel: prune internal map
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Pay attention to:
    • Overlay lifecycle, DOM attachment and cleanup to avoid memory/DOM leaks
    • Correctness of projectToScreen and coordinate transforms (ecef/wgs84/proj4)
    • Event listener registration/deregistration for camera, resize, marker/point moves
    • Mounted-state guards and conditional post-processing

Possibly related PRs

Suggested reviewers

  • kleinc
  • adriahso

Poem

🐇 I hop to the canvas, labels in tow,

Names perch on pixels where the soft lights glow.
Centroid or single, I point where they lie,
Stripes keep their order while the cameras fly.
A tiny rabbit cheers — overlay dreams hop by!

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title '47 improve inspected point visualization' accurately reflects the main change of improving point visualization with on-canvas labels and enhanced sidebar information.
Description check ✅ Passed The pull request description covers all required template sections: issue number (#47), detailed description of changes, and comprehensive testing steps with optional screenshots omitted.
Linked Issues check ✅ Passed All code changes directly address the three objectives from issue #47: visible on-canvas labels (implemented via overlay system), height/lat/lon data in sidebar (insertLatLonRows), and removal of unused sidebar values (pruneMeasurementRows).
Out of Scope Changes check ✅ Passed All changes are scoped to improving point visualization through CSS styling for labels, JavaScript overlay management, and sidebar value display—no unrelated functionality modifications detected.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 47-improve-inspected-point-visualization

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Member

@tobiaobr tobiaobr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shows the point measurement as expected, didnt see any unintended interactions. lgtm 🔥

Copy link
Member

@adriahso adriahso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that sometimes the measurement name blocks for the value. Maybe we can make it so that the user can toggle between value, name and hiding both?

now it is not possible to see both name labels and value labels of the measurements, and it's possible to switch between these visualization thanks to two new buttons. There is also the possibility to hide both with a third button, all in the same section of the sidebar
@franmagn
Copy link
Member Author

franmagn commented Nov 5, 2025

I see that sometimes the measurement name blocks for the value. Maybe we can make it so that the user can toggle between value, name and hiding both?

Thanks for the suggestion! Just done that!

Copy link

@coderabbit coderabbit bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0016d6d and 4ada576.

📒 Files selected for processing (2)
  • src/MeasurementControl/measurementsPanel.css (3 hunks)
  • src/MeasurementControl/measurementsPanel.js (17 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-29T13:42:18.000Z
Learnt from: kleinc
Repo: TDT4290-group-4/MolloyExplorer PR: 52
File: src/AnnotationControl/annotationPanel.css:30-31
Timestamp: 2025-10-29T13:42:18.000Z
Learning: In src/AnnotationControl/annotationPanel.css, the .annotation-edit-textarea element intentionally has both background and color set to #636262, making the text invisible. This is the intended design per kleinc's preference.

Applied to files:

  • src/MeasurementControl/measurementsPanel.css
🧬 Code graph analysis (1)
src/MeasurementControl/measurementsPanel.js (3)
src/potreeViewer.js (3)
  • viewer (23-25)
  • e (41-41)
  • el (223-223)
src/CoordinateShowing/coordinateShowing.js (1)
  • lon (38-42)
src/AcceptedFiltering/threePanels.js (1)
  • $ (199-199)

 into 47-improve-inspected-point-visualization
Copy link

@coderabbit coderabbit bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/MeasurementControl/measurementsPanel.js (1)

709-723: Fix className to match stylesheet (unresolved from past review).

The past review correctly identified that the className should be 'attrRow' (not 'attr-row') to match the existing stylesheet selectors. This issue remains unresolved.

Apply this diff:

     const createRowNode = (id, label, value) => {
       const row = document.createElement('tr')
       row.id = id
-      row.className = 'attr-row'
+      row.className = 'attrRow'
       const tdLabel = document.createElement('td')
🧹 Nitpick comments (1)
src/MeasurementControl/measurementsPanel.js (1)

485-570: Extract duplicated looksLikeNumber helper.

The looksLikeNumber helper function is defined identically in both roundCoordinates (lines 424-428) and pruneMeasurementRows (lines 512-518). Extract it to a shared helper at the function scope to reduce duplication.

Define once at the top level of initMeasurementsPanel:

 export function initMeasurementsPanel(viewer) {
   const lastSelection = { uuid: null, label: '', type: null }
+  // Helper to detect if a string represents a number
+  const looksLikeNumber = (s) => {
+    if (!s) return false
+    const cleaned = (s + '').replace(/[^0-9+\-.,eE]/g, '').replace(/,+/g, '')
+    return /[-+]?\d*\.?\d+(e[-+]?\d+)?/.test(cleaned)
+  }

Then remove the duplicate definitions in both functions.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4ada576 and e382e64.

📒 Files selected for processing (2)
  • src/MeasurementControl/measurementsPanel.css (2 hunks)
  • src/MeasurementControl/measurementsPanel.js (17 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/MeasurementControl/measurementsPanel.css
🧰 Additional context used
🧬 Code graph analysis (1)
src/MeasurementControl/measurementsPanel.js (3)
src/potreeViewer.js (3)
  • viewer (21-23)
  • e (39-39)
  • el (234-234)
src/CoordinateShowing/coordinateShowing.js (1)
  • lon (38-42)
src/Filter/filter.js (1)
  • $ (206-206)
🔇 Additional comments (9)
src/MeasurementControl/measurementsPanel.js (9)

1-2: LGTM: Import statements for coordinate transformation.

The ecef and wgs84 imports are appropriately used later for lat/lon/elevation calculations via proj4.


124-166: Verify canvas dimensions to prevent NaN coordinates.

The screen projection function should guard against zero-width or zero-height canvases, which could produce NaN coordinates and cause layout issues.

Consider adding dimension guards:

       const canvas =
         (viewer && viewer.renderer && viewer.renderer.domElement) ||
         document.querySelector('#potree_render_area canvas')
       if (!canvas) return null
       const w = canvas.clientWidth || canvas.width
       const h = canvas.clientHeight || canvas.height
+      if (!w || !h || w <= 0 || h <= 0) return null
       const x = (vec3.x * 0.5 + 0.5) * w
       const y = (-vec3.y * 0.5 + 0.5) * h

411-483: Approve coordinate rounding with mounted flag guard.

The function correctly gates processing to only run when the properties panel is mounted for single-point measurements, and handles multiple coordinate table formats.


777-795: LGTM: Type tracking for mounted flag gating.

Storing the measurement type in lastSelection enables the mounted flag logic to correctly gate post-processing to single-point measurements only.


888-896: LGTM: Overlay label creation integrated with list rebuild.

The overlay labels are created/updated in sync with the measurement list, ensuring consistency between the sidebar and on-canvas labels.


924-936: LGTM: Proper cleanup of removed measurement overlays.

The cleanup logic correctly removes overlay labels for measurements that no longer exist and updates positions for remaining labels.


964-980: LGTM: Movement event listeners update overlay positions.

The event listeners correctly update overlay label positions when markers/points are moved, using requestAnimationFrame for efficient rendering.


1076-1086: LGTM: Camera and resize listeners maintain overlay positions.

The event listeners correctly update overlay label positions when the camera moves or the window resizes, ensuring labels stay aligned with their measurements.


1291-1337: LGTM: Display mode toggling with dual event handling.

The display mode logic correctly toggles between VALUES (numeric labels), NAMES (measurement names), and HIDE (no labels) modes. The dual event handling approach (jQuery events + direct click listener) provides good compatibility.

fixed behaviour after deleting measurements. Now UI is immediately refreshed, not needing anymore to move the camera position to see the labels of deleted points disappear
Copy link

@coderabbit coderabbit bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/MeasurementControl/measurementsPanel.js (1)

704-716: Keep using the existing .attrRow styling hook.

The new Latitude/Longitude/Elevation rows still use className = 'attr-row', so they miss the .attrRow rules that style the rest of the measurement rows. Please switch back to the original class name so the rows inherit the expected look.

-      row.className = 'attr-row'
+      row.className = 'attrRow'
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e382e64 and e269d39.

📒 Files selected for processing (2)
  • src/MeasurementControl/measurementsPanel.css (2 hunks)
  • src/MeasurementControl/measurementsPanel.js (18 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/MeasurementControl/measurementsPanel.css
🧰 Additional context used
🧬 Code graph analysis (1)
src/MeasurementControl/measurementsPanel.js (2)
src/potreeViewer.js (3)
  • viewer (21-23)
  • e (39-39)
  • el (234-234)
src/CoordinateShowing/coordinateShowing.js (1)
  • lon (38-42)

Copy link
Member

@adriahso adriahso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@franmagn franmagn merged commit 9f67143 into dev Nov 5, 2025
2 checks passed
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve inspected point visualization
3 participants