gchemutils-main
[Top][All Lists]
Advanced

[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 11:23:34 +0200

Le samedi 09 août 2008 à 10:54 +0200, Filippo Bovo a écrit :
> Thank you very much!!!
> I will try this algorithm this afternoon, then I will say if it works.
>  
> ( Oh, two atoms have the same coordinates...the last has to be 0 0.5
> 0...a copy and paste mistake! :-) )
> 
> The reason I use this program is that I'm doing a university work
> on hexagonal and cubic ice simulations and properties and I was trying
> to rappresent them in a window to have some images (the coordinates I
> wrote in the email are the coordinates of a regular hexagon...just to
> have something to plot in the window).

Ths easiest way is to use Gnome Crystal. I join a file for cubic ice I
use with my students. If you are able to install by yourself a 0.9.x
version, you might also import cif files.

> I have some other short questions:
>      1. How can I rappresent a bond (i.e.: the bonds that the oxygen
>         has with the two hydorgen atoms) in the window?

Just add the hydrogen atoms, the framework adds the bonds automatically.

>      1. How can I save the image I have in the window in a format
>         like .jpg?

Use Gnome Crystal, it has this feature. Otherwise, You might use the
gcu::CrystalDoc class, add atoms and bonds, and you can use the
GLView::SaveAsImage method, but its much easier to use the existing
program.

>      1. You said that this library would stay unused outside of the
>         Gnome Chemistry Utils. So which library would you suggest me
>         to use?

I don't say it should stay unused, but nobody tried to use it for years
except me for GChemPaint, so that I thought it was not useful to keep
installing the development files now that GChemPaint is included in the
tarball (0.9.x or later), so that packagers life might be a bit easier.
If anybody wants to use it, I can easily restore the functionality (just
need to add the pc file (for pkg-config)).

> Thank you very much for the answers!! 
>  
> Best regards,
>  Filippo
> 
>  
> On 09/08/2008, Jean Bréfort <address@hidden> wrote: 
>         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
>         
>         
> 

Attachment: glace-Ic.gcrystal
Description: application/gcrystal


reply via email to

[Prev in Thread] Current Thread [Next in Thread]