Avogadro transformation functions in python

Hi

What is the best way to access functions to rotate/translate/zoom a
molecule, in Python. I am creating an interface with a nonstandard input
device, and need direct access to these functions. Help would be very much
appreciated!

Mike

What is the best way to access functions to rotate/translate/zoom a
molecule, in Python. I am creating an interface with a nonstandard
input device, and need direct access to these functions. Help would
be very much appreciated!

I haven’t been following the Python bindings in a while, but I don’t
believe these functions are wrapped yet. (Tim, is there access to this
kind of functionality in the SIP bindings you made?)

One key question is when you say “rotate/translate/zoom a molecule,”
do you mean “change the molecule’s coordinates” or “change the way the
molecule looks on screen?”

Cheers,
-Geoff

Hi

What I really mean, is change the way it looks on screen (ie transform the
entire molecular space). Hope it helps!

On Thu, Aug 28, 2008 at 11:32 PM, Geoffrey Hutchison <
geoff.hutchison@gmail.com> wrote:

What is the best way to access functions to rotate/translate/zoom a

molecule, in Python. I am creating an interface with a nonstandard input
device, and need direct access to these functions. Help would be very much
appreciated!

I haven’t been following the Python bindings in a while, but I don’t
believe these functions are wrapped yet. (Tim, is there access to this kind
of functionality in the SIP bindings you made?)

One key question is when you say “rotate/translate/zoom a molecule,” do you
mean “change the molecule’s coordinates” or “change the way the molecule
looks on screen?”

Cheers,
-Geoff

Michal,

probably what you’re looking for is the Camera class. Look for a camera()
method in GLWidget. The camera class offers methods such as rotate() etc. I
don’t know if the current python bindings have it.

Cheers,
Benoit

On Friday 29 August 2008 00:09:03 Michal Wronski wrote:

Hi

What I really mean, is change the way it looks on screen (ie transform the
entire molecular space). Hope it helps!

On Thu, Aug 28, 2008 at 11:32 PM, Geoffrey Hutchison <

geoff.hutchison@gmail.com> wrote:

What is the best way to access functions to rotate/translate/zoom a

molecule, in Python. I am creating an interface with a nonstandard input
device, and need direct access to these functions. Help would be very
much appreciated!

I haven’t been following the Python bindings in a while, but I don’t
believe these functions are wrapped yet. (Tim, is there access to this
kind of functionality in the SIP bindings you made?)

One key question is when you say “rotate/translate/zoom a molecule,” do
you mean “change the molecule’s coordinates” or “change the way the
molecule looks on screen?”

Cheers,
-Geoff

Hi,

It has been a while since I last build the SIP bindings. However,
IIRC, there is only a wrapper for Vector3d. Adding the needed matrices
shouldn’t be too hard I think. I also don’t think the camera class has
bindings yet, but once again, when you have Eigen wrapped this is
straight forward.

The “hard” part is making SIP, OB’s SWIG bindings and boost::python
work together. For now, you can call GLWidget::current(), which is a
static function, to get the current GLWidget.

Hope this helps, if I have some time left I’ll have a look at the SIP
bindings again.

Cheers,
Tim

On Fri, Aug 29, 2008 at 4:01 AM, Benoît Jacob jacob@math.jussieu.fr wrote:

Michal,

probably what you’re looking for is the Camera class. Look for a camera()
method in GLWidget. The camera class offers methods such as rotate() etc. I
don’t know if the current python bindings have it.

Cheers,
Benoit

On Friday 29 August 2008 00:09:03 Michal Wronski wrote:

Hi

What I really mean, is change the way it looks on screen (ie transform the
entire molecular space). Hope it helps!

On Thu, Aug 28, 2008 at 11:32 PM, Geoffrey Hutchison <

geoff.hutchison@gmail.com> wrote:

What is the best way to access functions to rotate/translate/zoom a

molecule, in Python. I am creating an interface with a nonstandard input
device, and need direct access to these functions. Help would be very
much appreciated!

I haven’t been following the Python bindings in a while, but I don’t
believe these functions are wrapped yet. (Tim, is there access to this
kind of functionality in the SIP bindings you made?)

One key question is when you say “rotate/translate/zoom a molecule,” do
you mean “change the molecule’s coordinates” or “change the way the
molecule looks on screen?”

Cheers,
-Geoff


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options

Hi,

With the new python SIP bindings it is now possible to manipulate the
camera. The biggest change is the addition of support for
Eigen::Vector3d and Eigen::Tranfrom3d. Both are converted
automatically converted to python arrays (from Numeric module), see
the example below…

To build the bindings:

cd sip python configure.py
cd build make
$ sudo make install

Some examples:

import AvoSIP
glwidget = AvoSIP.Avogadro.GLWidget.current()
camera = glwidget.camera()
m = camera.modelview()
print m
array([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0,
0.0], [0.0, 0.0, -10.0, 1.0]], ‘d’)
m[3][2] = -5.0
camera.setModelview(m)
glwidget.update()

from Numeric import *
axis = array([0.0, 1.0, 0.0])
camera.rotate(1.0, axis)
glwidget.update()

Marcus is also working on python bindings using boost::python. Both
can co-exist untill we have decided which one to use…

Tim

On Sat, Aug 30, 2008 at 8:51 PM, Tim Vandermeersch
tim.vandermeersch@gmail.com wrote:

Hi,

It has been a while since I last build the SIP bindings. However,
IIRC, there is only a wrapper for Vector3d. Adding the needed matrices
shouldn’t be too hard I think. I also don’t think the camera class has
bindings yet, but once again, when you have Eigen wrapped this is
straight forward.

The “hard” part is making SIP, OB’s SWIG bindings and boost::python
work together. For now, you can call GLWidget::current(), which is a
static function, to get the current GLWidget.

Hope this helps, if I have some time left I’ll have a look at the SIP
bindings again.

Cheers,
Tim

On Fri, Aug 29, 2008 at 4:01 AM, Benoît Jacob jacob@math.jussieu.fr wrote:

Michal,

probably what you’re looking for is the Camera class. Look for a camera()
method in GLWidget. The camera class offers methods such as rotate() etc. I
don’t know if the current python bindings have it.

Cheers,
Benoit

On Friday 29 August 2008 00:09:03 Michal Wronski wrote:

Hi

What I really mean, is change the way it looks on screen (ie transform the
entire molecular space). Hope it helps!

On Thu, Aug 28, 2008 at 11:32 PM, Geoffrey Hutchison <

geoff.hutchison@gmail.com> wrote:

What is the best way to access functions to rotate/translate/zoom a

molecule, in Python. I am creating an interface with a nonstandard input
device, and need direct access to these functions. Help would be very
much appreciated!

I haven’t been following the Python bindings in a while, but I don’t
believe these functions are wrapped yet. (Tim, is there access to this
kind of functionality in the SIP bindings you made?)

One key question is when you say “rotate/translate/zoom a molecule,” do
you mean “change the molecule’s coordinates” or “change the way the
molecule looks on screen?”

Cheers,
-Geoff


This SF.Net email is sponsored by the Moblin Your Move Developer’s challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/


Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options

Hi,

Thanks for the update:

I have no clue how bindings are made and I was concerned that eigen2’s
expression templates might have made it mode difficult to make bindings. Did
they cause any problem?

Cheers,
Benoit

On Thursday 18 September 2008 03:07:19 Tim Vandermeersch wrote:

Hi,

With the new python SIP bindings it is now possible to manipulate the
camera. The biggest change is the addition of support for
Eigen::Vector3d and Eigen::Tranfrom3d. Both are converted
automatically converted to python arrays (from Numeric module), see
the example below…

To build the bindings:

cd sip python configure.py
cd build make
$ sudo make install

Some examples:

import AvoSIP
glwidget = AvoSIP.Avogadro.GLWidget.current()
camera = glwidget.camera()
m = camera.modelview()
print m

array([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0,
0.0], [0.0, 0.0, -10.0, 1.0]], ‘d’)

m[3][2] = -5.0
camera.setModelview(m)
glwidget.update()

from Numeric import *
axis = array([0.0, 1.0, 0.0])
camera.rotate(1.0, axis)
glwidget.update()

Marcus is also working on python bindings using boost::python. Both
can co-exist untill we have decided which one to use…

Tim

On Sat, Aug 30, 2008 at 8:51 PM, Tim Vandermeersch

tim.vandermeersch@gmail.com wrote:

Hi,

It has been a while since I last build the SIP bindings. However,
IIRC, there is only a wrapper for Vector3d. Adding the needed matrices
shouldn’t be too hard I think. I also don’t think the camera class has
bindings yet, but once again, when you have Eigen wrapped this is
straight forward.

The “hard” part is making SIP, OB’s SWIG bindings and boost::python
work together. For now, you can call GLWidget::current(), which is a
static function, to get the current GLWidget.

Hope this helps, if I have some time left I’ll have a look at the SIP
bindings again.

Cheers,
Tim

On Fri, Aug 29, 2008 at 4:01 AM, Benoît Jacob jacob@math.jussieu.fr
wrote:

Michal,

probably what you’re looking for is the Camera class. Look for a
camera() method in GLWidget. The camera class offers methods such as
rotate() etc. I don’t know if the current python bindings have it.

Cheers,
Benoit

On Friday 29 August 2008 00:09:03 Michal Wronski wrote:

Hi

What I really mean, is change the way it looks on screen (ie transform
the entire molecular space). Hope it helps!

On Thu, Aug 28, 2008 at 11:32 PM, Geoffrey Hutchison <

geoff.hutchison@gmail.com> wrote:

What is the best way to access functions to rotate/translate/zoom a

molecule, in Python. I am creating an interface with a nonstandard
input device, and need direct access to these functions. Help would
be very much appreciated!

I haven’t been following the Python bindings in a while, but I don’t
believe these functions are wrapped yet. (Tim, is there access to
this kind of functionality in the SIP bindings you made?)

One key question is when you say “rotate/translate/zoom a molecule,”
do you mean “change the molecule’s coordinates” or “change the way
the molecule looks on screen?”

Cheers,
-Geoff



Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options

On Thu, Sep 18, 2008 at 5:45 AM, Benoît Jacob jacob@math.jussieu.fr wrote:

Hi,

Thanks for the update:

I have no clue how bindings are made and I was concerned that eigen2’s
expression templates might have made it mode difficult to make bindings. Did
they cause any problem?

There are no real python wrappers around the Eigen template classes.
There is just some conversion code (in C++) to convert them to python
arrays and vice versa. More eigen objects could be added using
eigen.sip as a starting point if other projects based on
Eigen2/Qt4/SIP4 need it.

Cheers,
Benoit

On Thursday 18 September 2008 03:07:19 Tim Vandermeersch wrote:

Hi,

With the new python SIP bindings it is now possible to manipulate the
camera. The biggest change is the addition of support for
Eigen::Vector3d and Eigen::Tranfrom3d. Both are converted
automatically converted to python arrays (from Numeric module), see
the example below…

To build the bindings:

cd sip python configure.py
cd build make
$ sudo make install

Some examples:

import AvoSIP
glwidget = AvoSIP.Avogadro.GLWidget.current()
camera = glwidget.camera()
m = camera.modelview()
print m

array([[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0,
0.0], [0.0, 0.0, -10.0, 1.0]], ‘d’)

m[3][2] = -5.0
camera.setModelview(m)
glwidget.update()

from Numeric import *
axis = array([0.0, 1.0, 0.0])
camera.rotate(1.0, axis)
glwidget.update()

Marcus is also working on python bindings using boost::python. Both
can co-exist untill we have decided which one to use…

Tim

On Sat, Aug 30, 2008 at 8:51 PM, Tim Vandermeersch

tim.vandermeersch@gmail.com wrote:

Hi,

It has been a while since I last build the SIP bindings. However,
IIRC, there is only a wrapper for Vector3d. Adding the needed matrices
shouldn’t be too hard I think. I also don’t think the camera class has
bindings yet, but once again, when you have Eigen wrapped this is
straight forward.

The “hard” part is making SIP, OB’s SWIG bindings and boost::python
work together. For now, you can call GLWidget::current(), which is a
static function, to get the current GLWidget.

Hope this helps, if I have some time left I’ll have a look at the SIP
bindings again.

Cheers,
Tim

On Fri, Aug 29, 2008 at 4:01 AM, Benoît Jacob jacob@math.jussieu.fr
wrote:

Michal,

probably what you’re looking for is the Camera class. Look for a
camera() method in GLWidget. The camera class offers methods such as
rotate() etc. I don’t know if the current python bindings have it.

Cheers,
Benoit

On Friday 29 August 2008 00:09:03 Michal Wronski wrote:

Hi

What I really mean, is change the way it looks on screen (ie transform
the entire molecular space). Hope it helps!

On Thu, Aug 28, 2008 at 11:32 PM, Geoffrey Hutchison <

geoff.hutchison@gmail.com> wrote:

What is the best way to access functions to rotate/translate/zoom a

molecule, in Python. I am creating an interface with a nonstandard
input device, and need direct access to these functions. Help would
be very much appreciated!

I haven’t been following the Python bindings in a while, but I don’t
believe these functions are wrapped yet. (Tim, is there access to
this kind of functionality in the SIP bindings you made?)

One key question is when you say “rotate/translate/zoom a molecule,”
do you mean “change the molecule’s coordinates” or “change the way
the molecule looks on screen?”

Cheers,
-Geoff



Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options

On Thursday 18 September 2008 15:43:10 Tim Vandermeersch wrote:

There are no real python wrappers around the Eigen template classes.
There is just some conversion code (in C++) to convert them to python
arrays and vice versa.

Ah OK. I think you took the right approach.

  • in most cases the user doesn’t need to perform matrix computations anyway,
    since the Avogadro::Camera API provides what is needed.
  • in the few cases where the user needs to perform matrix computations, she
    can still read the matrix coeffs and let python do the math (I’m sure there
    is a python module for matrix math).

More eigen objects could be added using
eigen.sip as a starting point if other projects based on
Eigen2/Qt4/SIP4 need it.

This would be a nightmare: how would the expression templates translate into
python? Eigen is based on the assumption that the compile-time logic really
gets evaluated away at compile-time and thus has zero cost at runtime. It
uses static (=compile-time) polymorphism (=templates) to “script the
compiler”. When translated into python, I suppose that this would instead get
evaluated at runtime and so, I suppose, give terrible results.

(I don’t know anything about how python works, bytecode etc., so I might be
wrong).

Cheers,
Benoit