trlsmax / imgui-vtk

test on how to integrate vtk into glfw + imgui project
MIT License
107 stars 26 forks source link

The mouse coordinates passed to VTK are incorrect for docker branch #20

Open chenghongyao opened 6 months ago

chenghongyao commented 6 months ago

as the title say, check the code

    ImGuiIO& io = ImGui::GetIO(); (void)io;
    io.ConfigWindowsMoveFromTitleBarOnly = true; // don't drag window when clicking on image.
    ImVec2 viewportPos = ImGui::GetCursorStartPos();

    double xpos = static_cast<double>(io.MousePos[0]) - static_cast<double>(viewportPos.x);
    double ypos = static_cast<double>(io.MousePos[1]) - static_cast<double>(viewportPos.y);

and it cause some issue when using vtkPointPicker, i use this code instead, and everything seems fine

    ImGuiIO& io = ImGui::GetIO(); (void)io;
    io.ConfigWindowsMoveFromTitleBarOnly = true; // don't drag window when clicking on image.
    ImVec2 viewportPos = ImGui::GetCursorStartPos();
        ImVec2 winPos = ImGui::GetWindowPos();

    double xpos = static_cast<double>(io.MousePos[0])  - winPos.x - static_cast<double>(viewportPos.x);
    double ypos = static_cast<double>(io.MousePos[1])  - winPos.y - static_cast<double>(viewportPos.y);
rajkundu commented 6 months ago

This seems very possible, but we should also look at how to integrate this fix into PR #19 as well. I unfortunately can't work on this easily for a little while but will try to whenever I have time.