V3d_Viewer HighDPI Scale issue on mouse selection

Hello, I was developing occt on top of Qt and when I open the application on scaled windows (native regulation 4k scaled to %150). I'm unable to click on the shape/mesh because of the scale, I had move mouse away from the shape/mesh able to "highlight" so I can click on it. Basically mouse position inside of viewer also scaled to %150 so I can click exact location. Any idea how can I prevent that ?

Kirill Gavrilov's picture

Depending on OS and GUI framework, HiDPI support might be implemented in different. The backing store (physical resolution of actually rendered content of a window) and logical layout (mouse cursor position, window dimensions and position on the screen) might match each other (Windows/WinAPI) or scaled on HiDPI screens (macOS/Cocoa).

V3d_View by default expects window coordinates defined in physical units, and the same expect AIS_InteractiveContext::MoveTo(). If you experience mismatch between mouse cursor and underlying object in 3D Viewer - check dimensions of your Aspect_Window and cursor coordinates passed to AIS_ViewController / AIS_InteractiveContext. If they defined in different units - you need to perform necessary scaling using APIs provided by your GUI framework. As, for example, is done by Wasm_Window::ProcessMouseEvent() with help of Wasm_Window::ConvertPointToBacking().