[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gchemutils-main] How to draw atoms in the gtk window
From: |
Jean Bréfort |
Subject: |
Re: [Gchemutils-main] How to draw atoms in the gtk window |
Date: |
Sat, 09 Aug 2008 10:08:05 +0200 |
Le samedi 09 août 2008 à 09:36 +0200, Filippo Bovo a écrit :
> My Goal:
> I have an array of vectors. Every vector contains the coordinates in
> the 3d space: x, y, z. I want to plot them in the gtk window.
>
> How do I do this?
>
> Observations:
> 1. The reason I used CrystalAtom class and not simply the
> Atom class is that it has the same basic use of the Atom
> one but has many related member functions. I did not thought
> to miller indexes so I don't want to express the coordinates
> with numbers between 0 and 1.
> To make things simpler I can use Atom class if it is useful to
> explain things better.
> 2. I tried to use the Application class to create a document and
> a related view but if only I include the application.h in the
> file and then compile it I have errors of declaration of
> DATADIR and PACKAGE_BUGREPORT.
You don't need an Application object, unless you derive your own class.
The current API does not easily allow what you want to do. The 3d viewer
doesn't use the gcu::Atom class at the moment for historical reasons but
OpenBabel::OBAtom.
The easiest way for you is to get an xyz file from your data (which
might be in memory) then load it in a GtkChem3DViewer and disply the
widget.
Something as:
char const my_data[] =
"6\n"
"\n"
"O 0.87 0 0\n"
"O 1.73 0.5 0\n"
"O 1.73 1.5 0\n"
"0 0.87 2 0\n"
"O 0 1.5 0 \n"
"O 0.87 0 0 \n";
GtkWidget *w = gtk_chem3d_viewer_new (NULL);
gtk_chem_3d_viewer_set_data (GTK_CHEM3D_VIEWER (w), my_data, "chemical/x-xyz");
gtk_widget_show (w);
Then, you need to add the widget to the appropriate container as usual
in gtk+. I did not test, but it should work ;-)
Note that two of your atoms have the same coordinates which is dubious,
and that OpenBabel will add bonds between neighbor atoms.
Btw, I was thinking that this library would stay unused outside of the
Gnome Chemistry Utils and dropped the devel files from the 0.10 branch.
If you want to go on using it, please tell me, I'll put them back.
If you have specific needs not currently supported, please file as many
bugs reports as necessary.
Best regards,
Jean