OpenChemistry / avogadroapp

Avogadro is an advanced molecular editor designed for cross-platform use in computational chemistry, molecular modeling, bioinformatics, materials science, and related areas.
https://two.avogadro.cc/
BSD 3-Clause "New" or "Revised" License
182 stars 69 forks source link

Avogadro2's main window incomplete #167

Closed sagitter closed 3 years ago

sagitter commented 3 years ago

Hi all.

Desktop version:

Describe the bug Screenshot from 2021-06-04 23-01-23

Additional question avogadro2-libs-1.94.0 now provides molequeue in bundle; molequeue will be separately developed or will be always followed inside avogadro2-libs?

ghutchis commented 3 years ago

Set a background color, and you should be good. Unfortunately, previous versions seemed to set an alpha and its saved in the settings... I'll see if i can code something, but if you set a color, it should work (and remember).

ghutchis commented 3 years ago

As far as Molequeue, it's separately developed. Part of 1.94 removes the dependency.

sagitter commented 3 years ago

Set a background color, and you should be good. Unfortunately, previous versions seemed to set an alpha and its saved in the settings... I'll see if i can code something, but if you set a color, it should work (and remember).

It's working. Looks like an issue related to Wayland, using QT_QPA_PLATFORM=xcb helps to render Avogadro2 working.

$ avogadro2
QSocketNotifier: Can only be used with threads started with QThread
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
drew-parsons commented 3 years ago

I'm getting this error now with a linux build of avogadro2 (1.9.4) on Debian.

Setting a background colour as you suggested works around the problem.

I don't think it's related to Wayland. I've disabled Wayland on my system (since it doesn't support video apps, needed in covid times), so launching from Gnome in X11 (Xorg).

There must be a way of initializing (or stopping transparency from initializing) without this transparency. Qt windows aren't normally transparent like this. What changed in regards to window gui configuration between 1.9.3 and 1.9.4?

In principle the default background should be black, from QColor(0,0,0,1.0) in

QColor color = settings.value("backgroundColor", QColor(0,0,0,1.0)).value<QColor>();

For reference, Qt docs are here

Looks like there's a possible inconsistency in the alpha value. The API says it should be an integer, default 255. But avogadro uses a float value 1.0. I'm not sure if the QColour API changed, but it looks as if floating value 1.0 was intended to mean "100%" opacity, equivalent to a=255. Instead it's getting set as a=1, meaning "mostly transparent". Qt's meaning for alpha is explained here. They do provide methods int alpha() and qreal alphaF(). Perhaps in the past Qt provided a QColor(int,int,int,qreal) instantiator, but removed it because of this kind of problematic casting to QColor(int,int,int,int)

I recommend just letting Qt use its own default (a=255), and set avogadro's background to QColor(0,0,0) without the transparency value.

drew-parsons commented 3 years ago

I suspect this might also fix #108 (although it might be a rendering rather than a transparency problem).

drew-parsons commented 3 years ago

There's a separate transparency issue with the selection tool. With version 1.9.4, when a box is drawn using the cursor to select some atoms, the box has some transparency so any windows underneath the avogadro app become visible. Likewise the pale blue halo around selected atoms exposes the underlying windows.

This problem is less black & white than the background colour issue - the selection halo should be transparent within the app! But it shouldn't expose windows outside the app.

I haven't been able to identify what's controlling it. There's nothing immediately obvious like there was for the backgroundColor setting. The only transparency control I can see in avogadrolibs/avogadro/qtplugins/selectiontools is mesh->setOpacity(180). There's also selectedSpheres->setOpacity(0.42) in qtplugins/ballandstick.

mquevill commented 3 years ago

I was going to open an issue on my own, but then found your comment. This is definitely a separate issue from the transparency of the background color, since it does not depend on the background at all. I opened #173 to track this separate issue better.

ghutchis commented 3 years ago

This should now be fixed by https://github.com/OpenChemistry/avogadrolibs/pull/656