Skip to content

[Feature] Distance Measurement Tool #158

@brenocq

Description

@brenocq

Feature description
Users may need to verify dimensions or analyze the spatial relationship between specific areas of a plot. This feature proposes a Measurement Tool that allows users to determine the precise distance between two points on the plot's bounding box planes.

Workflow:

  1. Activation: The user activates the tool via the Plot Context Menu (e.g., Right-click -> "Measure").
  2. Selection: The user clicks a point on any visible plane (grid) of the plot box to set Point A.
  3. Measurement: The user clicks a second point on any visible plane to set Point B.
  4. Feedback:
    • Markers appear at both points.
    • A line connects Point A and Point B.
    • A tooltip or overlay displays the $\Delta X$, $\Delta Y$, $\Delta Z$, and the Euclidean distance (Length) between the points.
  5. Cancellation/Reset: Pressing ESC or right-clicking cancels the operation or clears the current measurement.

Constraints:

  • Initially, point selection is restricted to the plot box planes (XY, XZ, YZ faces).
  • The tool calculates distances based on the plot coordinates, not screen pixels.

Tasks

  • Internal State (implot3d_internal.h)
    • Add state variables to ImPlot3DPlot to track the measurement status:
      • MeasureMode (Enum: None, SelectingP1, SelectingP2, Finished).
      • MeasureP1 and MeasureP2 (ImPlot3DPoint).
  • User Interface (implot3d.cpp)
    • Add a "Measure" menu item to ShowPlotContextMenu to toggle the mode.
  • Input Handling (implot3d.cpp)
    • In HandleInput, implement logic to detect mouse clicks when MeasureMode is active.
    • Utilize GetMouseOverPlane and PixelsToPlotPlane to calculate the 3D coordinate of the mouse cursor projected onto the hovered plot face.
    • Update MeasureP1 and MeasureP2 on click events.
  • Rendering (implot3d.cpp)
    • Render circles at MeasureP1 (and MeasureP2 if set).
    • Render a line connecting the two points.
    • Render a text tooltip or overlay box displaying:
      • dX: ...
      • dY: ...
      • dZ: ...
      • Len: ...
  • Demo (implot3d_demo.cpp)
    • Add a demonstration of the tool in the implot3d_demo.cpp (can be implicitly tested via the context menu on existing plots).

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:mediumMedium prioritystatus:todoTask identified but not startedtype:featNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions