Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation cube seems to get wrong mouse coordinates when built with qt6 #13494

Closed
2 tasks done
greyltc opened this issue Apr 16, 2024 · 17 comments · Fixed by #14159
Closed
2 tasks done

Navigation cube seems to get wrong mouse coordinates when built with qt6 #13494

greyltc opened this issue Apr 16, 2024 · 17 comments · Fixed by #14159

Comments

@greyltc
Copy link
Contributor

greyltc commented Apr 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Problem description

The navigation cube and all associated controls up there in the top right corner of the render view do not respond to clicks.

Full version info

[code]
OS: Arch Linux (GNOME/gnome)
Word size of FreeCAD: 64-bit
Version: 0.21.2.33771 (Git)
Build type: Release
Branch: makepkg
Hash: b9bfa5c5507506e4515816414cd27f4851d00489
Python 3.11.8, Qt 6.7.0, Coin 4.0.2, Vtk 9.3.0, OCC 7.7.2
Locale: English/United States (en_US)
[/code]

Subproject(s) affected?

None

Anything else?

Intel Arc GPU, Linux 6.8.5, gnome 46.0 desktop, i915 driver. Tested with all four combinations of {X11,Wayland} & Use software OpenGL {True,False}.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@maxwxyz
Copy link
Collaborator

maxwxyz commented Apr 16, 2024

Left or right click? Are you using a mouse, touch pad, touchscreeen?
Can you also try it in the weekly builds: https://github.com/FreeCAD/FreeCAD-Bundle/releases/tag/weekly-builds

@maxwxyz maxwxyz added Missing: feedback If feedback is requested Navigation Cube labels Apr 16, 2024
@greyltc
Copy link
Contributor Author

greyltc commented Apr 16, 2024

Mouse. Neither left nor right clicking works. I'll see if I can get a weekly build going and report back shortly.

@greyltc
Copy link
Contributor Author

greyltc commented Apr 16, 2024

@maxwxyz Okay, I've built and tested whatever commit that latest weekly build you linked there is based on (a4dd600). The cube's behavior has changed in that now the cube and associated controls highlight whenever my pointer hovers over them, but still nothing up there responds in any way to any left or right mouse clicks/click+drag or anything at all. See attached video:
Screencast from 2024-04-16 11-33-00.webm I can't quite figure out why/when the cursor decides to change between a hand and an arrow. Right clicking brings up the menu as shown.

OS: Arch Linux (GNOME/gnome)
Word size of FreeCAD: 64-bit
Version: 0.22.0dev.36874 (Git)
Build type: Release
Branch: makepkg
Hash: a4dd600ec6d5a53a9960cd9f8693d7d307b9e359
Python 3.11.8, Qt 6.7.0, Coin 4.0.2, Vtk 9.3.0, OCC 7.7.2
Locale: English/United States (en_US)

@maxwxyz maxwxyz added Missing: confirmation Missing confirmation from other testers Help wanted labels Apr 16, 2024
@maxwxyz
Copy link
Collaborator

maxwxyz commented Apr 16, 2024

I cannot reproduce on my system and never heard about this behavior. Could you try temporarily rename your user.cfg file?

@greyltc
Copy link
Contributor Author

greyltc commented Apr 16, 2024

mv ~/.config/FreeCAD/ ~/.config/FreeCAD.bak then relaunch freecad did not impact the issue.

I've got this issue on multiple machines (desktops and laptops). Granted, these are all pretty similar setups: Arch Linux, gnome desktop environment, intel graphics, freecad from official Arch repos (and now the one test I did where I built from a4dd600)

@greyltc
Copy link
Contributor Author

greyltc commented Apr 16, 2024

Wait a sec. This is probably just a duplicate of #13303

@maxwxyz
Copy link
Collaborator

maxwxyz commented Apr 16, 2024

@xtemp09
Copy link
Contributor

xtemp09 commented Apr 16, 2024

@greyltc, yes, it's a duplicate.

@maxwxyz maxwxyz closed this as not planned Won't fix, can't repro, duplicate, stale Apr 16, 2024
@adrianinsaval
Copy link
Member

I consider this issue to be better at describing the navicube issue than the above and would advise to have this one open and close the other one instead.

@Rexbas would you have any clue why the navicube doesn't properly register mouse events when built with qt6?

@adrianinsaval adrianinsaval changed the title clicking on the navigation cube does nothing Navigation cube seems to get wrong mouse coordinates when built with qt6 Apr 22, 2024
@adrianinsaval adrianinsaval added 3rd party: Qt 6 Issue related to Qt 6 and removed Missing: confirmation Missing confirmation from other testers Missing: feedback If feedback is requested labels Apr 22, 2024
@Rexbas
Copy link
Contributor

Rexbas commented Apr 23, 2024

I have no idea but I am trying to compile with qt6 right now.

@Rexbas
Copy link
Contributor

Rexbas commented Apr 23, 2024

It seems that the behavior of glReadPixels(...) is different but I don't know why or how to fix it.

glReadPixels(2 * x + m_CubeWidgetSize, 2 * y + m_CubeWidgetSize, 1, 1,
GL_RGBA, GL_UNSIGNED_BYTE, &pixels);

@maxwxyz maxwxyz reopened this Apr 23, 2024
@adrianinsaval
Copy link
Member

could it be related to dpi scaling?

@Rexbas
Copy link
Contributor

Rexbas commented Apr 24, 2024

Don't know if it is dpi scaling.

If I write the QtGLFramebufferObject to a file by inserting this code:

auto img = m_PickingFramebuffer->toImage();
img.save(QString::fromStdString("test.png"));

here:

Then with qt5 I get this:
navicubeqt5
It might be hard to see but it is the navigation cube in dark red on a black background. This image is 800x800 pixels when I set navigation cube size to 400.

But with qt6 I get this:
navicubeqt6
This is also a 800x800 image but the content of the image is clearly not right.

So I think something is wrong with QtGLFramebufferObject* m_PickingFramebuffer. I don't know how to fix.

@YakoYakoYokuYoku
Copy link
Contributor

I'm currently investigating this issue, from my observations this is split in two problems. One is that there's no mouse interaction with the navigation cube, so this means that at least one of SoQt or Qt6 is the culprit. The other is that reading from the framebuffer object returns invalid data, @Rexbas from what I can check is that QOpenGLFramebufferObject hasn't changed its semantics essentially since Qt5, so it must another thing.

@YakoYakoYokuYoku
Copy link
Contributor

Could be related coin3d/soqt#80.

@Rexbas
Copy link
Contributor

Rexbas commented May 12, 2024

I think it is one problem. The mouse interaction with the navigation cube is not working because it can't decide which face is hovered/selected in NaviCubeImplementation::pickFace which is caused by the different behavior in the frame buffer.

@YakoYakoYokuYoku
Copy link
Contributor

Good news @Rexbas! I've found the reason why this happens. It turns out that what Qt has done might be correct and we are doing things wrong. By calling glGetError in gdb I've noticed that when we draw the cube faces in NaviCubeImplementation::drawNaviCube an OpenGL stack overflow occurs, hence why you're getting a corrupted read on the framebuffer object.

// cube faces
for (const auto& pair : m_Faces) {
auto f = pair.second;
if (f.type == ShapeId::Button)
continue;
auto pickId = pair.first;
if (pickMode) {
glColor3ub(static_cast<GLubyte>(pickId), 0, 0);
}
else {
QColor& c = m_HiliteId == pickId ? m_HiliteColor : m_BaseColor;
glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF() * opacity);
}
glVertexPointer(3, GL_FLOAT, 0, f.vertexArray.data());
glDrawArrays(GL_TRIANGLE_FAN, 0, f.vertexArray.size());
}

The only culprit I can point out is glVertexPointer, as it was when that function is called that GL_STACK_OVERFLOW is produced plus it was deprecated and not included with other fixed functions with OpenGL 2.0 and onwards. Exactly why this happens with Qt6, I don't know, but I'm certain that this is due to glVertexPointer. The solution would be to use something else like glVertexAttribPointer or VBOs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants