imgui-vtk icon indicating copy to clipboard operation
imgui-vtk copied to clipboard

The mouse coordinates passed to VTK are incorrect for docker branch

Open chenghongyao opened this issue 11 months ago • 1 comments

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);

chenghongyao avatar Mar 13 '24 09:03 chenghongyao

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.

rajkundu avatar Mar 14 '24 04:03 rajkundu