Vibrations plot

I want to add a plot visualization to the vibrations dialog, sort of
an IR-esque transmittance vs. wavenumber deal in a simple KPlotWidget.
Maybe put in a way to load a tsv and overlay an actual spectra, then
export a pdf, etc.

I haven’t noticed a lot of KDE-derived widgets (maybe I’m just looking
in the wrong places?), so I want to check if adding in a KPlotWidget
would be a problem. Another option (more powerful) is to use the qwt
libraries, but that would for sure tack on some dependencies, and I’m
not sure if qwt is windows-safe.

Geoff – I know you’ve been working on most of the vibrations code, so
I want to check with you and see if you had started on anything like
this yet. (Before I sink too much time into it :slight_smile: )

Dave

David Lonie wrote:

I want to add a plot visualization to the vibrations dialog, sort of
an IR-esque transmittance vs. wavenumber deal in a simple KPlotWidget.
Maybe put in a way to load a tsv and overlay an actual spectra, then
export a pdf, etc.

Sounds good - we have been discussing the need to add the facility to
plot data in Avogadro. This is a general need that should be addressed
for several different areas. It is a shame Qt doesn’t have a lightweight
plotting widget already…

I haven’t noticed a lot of KDE-derived widgets (maybe I’m just looking
in the wrong places?), so I want to check if adding in a KPlotWidget
would be a problem. Another option (more powerful) is to use the qwt
libraries, but that would for sure tack on some dependencies, and I’m
not sure if qwt is windows-safe.

We are primarily a Qt4 application and currently have no KDE derived
classes in Avogadro. I would like to add an optional KDE dependency that
would use the KDE classes if Avogadro were compiled that way but they
would never be required. Qwt is one possibility but I was not happy with
the layout of the plots in all honesty (and am not sure how easy it
would be to compile on Windows).

Geoff – I know you’ve been working on most of the vibrations code, so
I want to check with you and see if you had started on anything like
this yet. (Before I sink too much time into it :slight_smile: )

Geoff may be slow to communicate, but as far as I have seen he has been
concentrating on the animation and hasn’t mentioned anything about
plots. There is a general need for a lightweight plotting widget in
Avogadro. It would be nice if the dependency were not too big, that said
there is always the possibility of adding optional dependencies for the
bigger deps, so at least we can still compile Avogadro on other
platforms and then work on getting those features working on the
alternate platforms.

Thanks,

Marcus

On Mar 8, 2009, at 6:51 PM, Marcus D. Hanwell wrote:

Qwt is one possibility but I was not happy with
the layout of the plots in all honesty (and am not sure how easy it
would be to compile on Windows).

Marcus is right that I haven’t wanted to do plotting. So if you’re
interested David, be my guest!

My thought is we can draw some inspiration from Qwt and KPlotWidget,
but I think we can probably implement most of what we want as a
subclass of QGraphicsView – remember that Qwt has a lot of code for
other things and was originally written for older versions of Qt.

I mean, basically what we want first is a simple QGraphicsView that
just plots a scatterplot – work out the min/max for x- and y-axes,
then draw it. IMHO, one of the key things with Avogadro development is
that we try to start small and simple, get things to work, then add
features as needed. :slight_smile:

Geoff may be slow to communicate,

Yes, I have a new baby, so things will be busy for at least the next
few weeks. But I do check messages periodically.

Cheers,
-Geoff

Am Sunday 08 March 2009 23:51:37 schrieb Marcus D. Hanwell:

David Lonie wrote:

I want to add a plot visualization to the vibrations dialog, sort of
an IR-esque transmittance vs. wavenumber deal in a simple KPlotWidget.
Maybe put in a way to load a tsv and overlay an actual spectra, then
export a pdf, etc.

Sounds good - we have been discussing the need to add the facility to
plot data in Avogadro. This is a general need that should be addressed
for several different areas. It is a shame Qt doesn’t have a lightweight
plotting widget already…

I haven’t noticed a lot of KDE-derived widgets (maybe I’m just looking
in the wrong places?), so I want to check if adding in a KPlotWidget
would be a problem.

Reading the source of KPlotWidget:

svn cat
svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs/kdeui/plotting/kplotwidget.h

svn cat
svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs/kdeui/plotting/kplotwidget.cpp

it seems that it only depends on Qt-code (beside some EXPORT-magic for
symbols). So a copy of the code might be an option. The code seems very
finished, only 2 commits in 2008. So synching from time to time seems
possible.

Carsten

On Monday 09 March 2009 08:30:16 Carsten Niehaus wrote:

Am Sunday 08 March 2009 23:51:37 schrieb Marcus D. Hanwell:

David Lonie wrote:

I want to add a plot visualization to the vibrations dialog, sort of
an IR-esque transmittance vs. wavenumber deal in a simple KPlotWidget.
Maybe put in a way to load a tsv and overlay an actual spectra, then
export a pdf, etc.

Sounds good - we have been discussing the need to add the facility to
plot data in Avogadro. This is a general need that should be addressed
for several different areas. It is a shame Qt doesn’t have a lightweight
plotting widget already…

I haven’t noticed a lot of KDE-derived widgets (maybe I’m just looking
in the wrong places?), so I want to check if adding in a KPlotWidget
would be a problem.

Reading the source of KPlotWidget:

svn cat
svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs/kdeui/plotting/kplotwidget
.h

svn cat
svn://anonsvn.kde.org/home/kde/trunk/KDE/kdelibs/kdeui/plotting/kplotwidget
.cpp

it seems that it only depends on Qt-code (beside some EXPORT-magic for
symbols). So a copy of the code might be an option. The code seems very
finished, only 2 commits in 2008. So synching from time to time seems
possible.

That does sound like the best way to handle it. I’ll start writing the dialog
using KPlotWidget, but I’ll likely need some pointers as to how to move the
kplotwidget.* code into avogadro. Would it just be a matter of copying the
files from the kde tree into libavogadro/src/plot (or similar) and putting a
note in the files about where they came from?

Dave

On Mar 20, 2009, at 9:48 AM, David Lonie wrote:

Would it just be a matter of copying the
files from the kde tree into libavogadro/src/plot (or similar) and
putting a
note in the files about where they came from?

Yes. That should be sufficient.

-Geoff

I’ve sent this to both lists, since there seems to be a bug in openbabel, but I noticed and can replicate it in avogadro:

In libavogadro/src/extensions/vibrationdialog.cpp, add some debug output after the frequencies and intensities are loaded in setMolecule, e.g:

// OK, we have valid vibrations, so add them to the table
vector<double> frequencies = m_vibrations->GetFrequencies();
vector<double> intensities = m_vibrations->GetIntensities();
qDebug() << "size intensities   " << intensities.size();
qDebug() << "size frequencies   " << frequencies.size();

Recompile and open methane.out in testfiles, then open the vibration extension. Output shows:

size intensities 12
size frequencies 9

Shouldn’t these be the same?

Dave

On Sun, Mar 22, 2009 at 5:08 PM, David Lonie loniedavid@gmail.com wrote:

I’ve sent this to both lists, since there seems to be a bug in openbabel, but I noticed and can replicate it in avogadro:

In libavogadro/src/extensions/vibrationdialog.cpp, add some debug output after the frequencies and intensities are loaded in setMolecule, e.g:

// OK, we have valid vibrations, so add them to the table
vector frequencies = m_vibrations->GetFrequencies();
vector intensities = m_vibrations->GetIntensities();
qDebug() << "size intensities " << intensities.size();
qDebug() << "size frequencies " << frequencies.size();

Recompile and open methane.out in testfiles, then open the vibration extension. Output shows:

size intensities 12
size frequencies 9

Shouldn’t these be the same?

Dave

I did a bit more digging, and here are the frequencies:

0 1575.73
1 1581.4
2 1584.19
3 1718.85
4 1723.36
5 2710.59
6 2770.6
7 2775.4
8 2778.94

And the intensities:

0 0
1 13.763
2 12.309
3 12.408
4 0
5 0.005
6 0.005
7 0.009
8 0
9 51.922
10 48.934
11 48.648

Those zeros shouldn’t be there. In the methane.out file, the
vibrational mode data is arranged in three groups of three, so it
looks like there is an extra zero being thrown in when each row is
being read. This is using the 2.2.x branch of svn openbabel and trunk
avogadro.

Please cc me if replying on openbabel-discuss, I’ve not actually joined it :wink:

Dave

On Mar 22, 2009, at 6:08 PM, David Lonie wrote:

I’ve sent this to both lists, since there seems to be a bug in
openbabel, but I noticed and can replicate it in avogadro:

Recompile and open methane.out in testfiles, then open the vibration
extension. Output shows:

size intensities 12
size frequencies 9

OK, so that’s in the Open Babel code for Q-Chem output files. I’ll
take a look.

Thanks for the heads-up.

Cheers,
-Geoff

On Sun, Mar 8, 2009 at 5:51 PM, Marcus D. Hanwell marcus@cryos.org wrote:

we have been discussing the need to add the facility to plot
data in Avogadro. This is a general need that should be addressed for
several different areas.

It’s been brought up on IRC, but I thought I’d drop a note here to let
others know that <avogadro/plotwidget.h> is in trunk. It is based on
the KPlot* KDE widget family (Thanks to Carsten for the idea, and
also to Tim for helping me sort out the problems I had with adding to avo). It’s
got plenty of features and is easily modifiable. An example of the
general feel of widget can be seen in the vibrations extension in trunk.

Have fun!

Dave