hoffstadt / hoffstadt/DearPyGui

Insufficient precision of the get_plot_mouse_pos()

Open
#1,847 5 comments 1 reaction 0 assignees View on GitHub
type: improvement
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

## Version of Dear PyGui

Version: 1.6.2
Operating System: Windows 10

## My Issue/Question

Function `dpg.get_plot_mouse_pos()` does not return coordinates with sufficient precision. The mouse position is [stored in the mvContext](https://github.com/hoffstadt/DearPyGui/blob/9989e6f184794901a4a59c2f8cf26e4724289d2e/src/mvContext.h#L58) as **float**. Such precision is insufficient for time axis storing timestamps. The precision should be fixed also [here](https://github.com/hoffstadt/DearPyGui/blob/9989e6f184794901a4a59c2f8cf26e4724289d2e/src/mvPlotting.cpp#L2055) and [here](https://github.com/hoffstadt/DearPyGui/blob/9989e6f184794901a4a59c2f8cf26e4724289d2e/src/mvMetricsWindow.cpp#L169).

## To Reproduce

Steps to reproduce the behavior:
1. Run the code below.
2. Move the mouse pointer horizontally over the graph area.
3. Watch the coordinates in the command line output (the x-coordinate is not changing, it is always 1658792448.0)

## Expected behavior

The first ("x") coordinate should change between 1658792466.0 and 1658792466.999 according to mouse move.

## Standalone, minimal, complete and verifiable example

```python
import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport()
dpg.setup_dearpygui()

def mouse_move_callback():
print(dpg.get_plot_mouse_pos())

with dpg.handler_registry():
dpg.add_mouse_move_handler(callback=mouse_move_callback)

with dpg.window(tag="Primary"):
with dpg.plot(height=-1, width=-1):
dpg.add_plot_axis(dpg.mvXAxis, time=True)
with dpg.plot_axis(dpg.mvYAxis):
dpg.add_scatter_series([1658792466, 1658792467], [0, 1])

dpg.show_viewport()
dpg.set_primary_window("Primary", True)
dpg.start_dearpygui()
dpg.destroy_context()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.