On Mon, Feb 22, 2010 at 6:00 PM, Tim Vandermeersch
tim.vandermeersch@gmail.com wrote:
Hi,
On Mon, Feb 22, 2010 at 4:01 PM, Mickaël Gadroy
mickael.gadroy@univ-reims.fr wrote:
Hi all,
I work in Python, and I try to render text with a plugin of extension
type. I have begun
to write a static text with :
def performAction(self, action, glwidget):
self.emit(SIGNAL(“message(const QString&)”), “Hello World Signal …”)
glwidget.painter.drawText( 50, 50, “Hello world !” )
glwidget.updateGeometry()
return None
The signal works, but I have no “Hello World !”.
With a engine plugin, it works no problem (thanks to documentation) :
def renderOpaque(self, pd):
pd.painter.drawText( 50, 50, “Hello world” )
So, must I load/reload engine in my extension to render a text ?
Another possibilities to render a text in extension plugin ?
Is there a limitation in a plugin of extension type ?
It’s not possible to draw anything from an extension since there is no
paint function or something similar which gets called when the screen
is refreshed. In other words, you can’t use a painter outside an
Engine (or Tool::paint). For future versions we may want extensions to
be able to draw things. There are a number of cases where this would
be useful.
It might be possible to add this functionality to python extensions
now without breaking anything. I would have to add a new function to
GLWidget to make it aware of extensions so it can call
PythonExtension::paint() when an Extension is a PythonExtension
(qobject_cast)… (For future versions we can add the virtual
Extension::paint() function but this willbreak ABI.)
Does anyone have objections to me adding this?
Since this wasn’t a lot of work, I already implemented it. (See github)
The following script now works as expected:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from numpy import *
import Avogadro
always use ‘Extension’ for class name
class Extension(QObject):
def init(self):
QObject.init(self)
def name(self):
return “Painting from a PythonExtension example”
def description(self):
return “Example python extension showing new paint ability.”
def actions(self):
actions =
return actions
def performAction(self, action, glwidget):
return
def paint(self, glwidget):
glwidget.painter.drawText( 50, 50, “Hello world !” )
Tim
Cheers,
Tim
Regards,
Mickaël Gadroy
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
Avogadro-devel mailing list
Avogadro-devel@lists.sourceforge.net
avogadro-devel List Signup and Options