connect self.a.createWindow() to doubleClick
connect self.a.createWindow() to doubleClick
Hi,
I generate an anatomist window using self.a.createWindow.
I'ld like to connect it to "doubleClicked()" to a function.
I tried :
self.firstWindow = self.a.createWindow('Axial')
self.firstWindow.doubleClicked.connect(self.IwantIbilliondollars) and it's not working.
I have tried as well:
self.connect(self.firstWindow,QtCore.SIGNAL('doubleClicked()'),self.IwantIbilliondollars) as well without success.
any Idea ?
(the goal is that when I doubleClick on a marsatlas parcels on the "left window", on the "right window" it opens the mesh texture of the f-tract results for the stimulation in the "double clicked parcel").
I generate an anatomist window using self.a.createWindow.
I'ld like to connect it to "doubleClicked()" to a function.
I tried :
self.firstWindow = self.a.createWindow('Axial')
self.firstWindow.doubleClicked.connect(self.IwantIbilliondollars) and it's not working.
I have tried as well:
self.connect(self.firstWindow,QtCore.SIGNAL('doubleClicked()'),self.IwantIbilliondollars) as well without success.
any Idea ?
(the goal is that when I doubleClick on a marsatlas parcels on the "left window", on the "right window" it opens the mesh texture of the f-tract results for the stimulation in the "double clicked parcel").
- riviere
- Site Admin
- Posts: 1361
- Joined: Tue Jan 06, 2004 12:21 pm
- Location: CEA NeuroSpin, Saint Aubin, France
- Contact:
Re: connect self.a.createWindow() to doubleClick
Hi,
The window is made of several widgets who behave differently to clicks, so it's not the right place to connect a callback. It should rather be set on the 3D widget (the display zone in the window). However Anatomist has its own callbacks system for windows, using Control and Action classes, which manage both contol buttons and callbacks.
See http://brainvisa.info/pyanatomist/sphin ... ls-example for an example, and you may use the Control mouseDoubleClickEventSubscribe() method to connect an action to a double click event.
Denis
The window is made of several widgets who behave differently to clicks, so it's not the right place to connect a callback. It should rather be set on the 3D widget (the display zone in the window). However Anatomist has its own callbacks system for windows, using Control and Action classes, which manage both contol buttons and callbacks.
See http://brainvisa.info/pyanatomist/sphin ... ls-example for an example, and you may use the Control mouseDoubleClickEventSubscribe() method to connect an action to a double click event.
Denis
Re: connect self.a.createWindow() to doubleClick
thanks for the quick answer as usual !
the link doesn't work I'll try anyway but if you have the valid link I am interested
the link doesn't work I'll try anyway but if you have the valid link I am interested
- Yann Cointepas
- Posts: 316
- Joined: Tue Jan 20, 2004 2:56 pm
- Location: Neurospin, Saint Aubin, France
- Contact:
- riviere
- Site Admin
- Posts: 1361
- Joined: Tue Jan 06, 2004 12:21 pm
- Location: CEA NeuroSpin, Saint Aubin, France
- Contact:
Re: connect self.a.createWindow() to doubleClick
The link works now (there was a missing symlink on the web server).
Re: connect self.a.createWindow() to doubleClick
Hi,
I haven't understand how to add the control.
In IntrAnat codes I do:
now I have the object with existing controls, I want to add one:
#it needs a number but I didn't get what this number is
now I have connected the event "leftMouseDoubleClick" to a function in my software, but I still have to define the event right ?
and I don't understand how. something to do with the ControlManager ?
I haven't understand how to add the control.
In IntrAnat codes I do:
Code: Select all
import anatomist.direct.api as testanatomist
cd = anatomist.cpp.ControlDictionary.instance()
Code: Select all
cd.addControl('leftMouseDoubleClick',lambda:self.leftmousedoubleclickeventsubscribe,25)
now I have connected the event "leftMouseDoubleClick" to a function in my software, but I still have to define the event right ?
and I don't understand how. something to do with the ControlManager ?
Code: Select all
cm.anatomist.copp.ControlManager.instance()
cm.addControl( 'QAGLWidget3D', '', '??' )
- riviere
- Site Admin
- Posts: 1361
- Joined: Tue Jan 06, 2004 12:21 pm
- Location: CEA NeuroSpin, Saint Aubin, France
- Contact:
Re: connect self.a.createWindow() to doubleClick
Hi,
A Control corresponds to a complete keyboard/mouse interaction mode, it overrides entirely all events from keyboard and mouse. It is materialized by an icon on the left side of the window. In a Control, you can (and should) plug Actions, which define callback functions which are bound to events in the control.
So you have to define a Control subclass, one or several Action subclasses, and plug actions methods to events in the Control eventAutoSubscription() method.
Then actions and controls classes have to be registered in ActionDictionary and ControlDictionary so that Anatomist knows which controls are available for its windows.
Last, the ControlManager should register the control too, which specifies for which kind of window, and in presence of which type of object (which may be "": any) the control can be activated.
Thus, "cd.addControl" should take as argument a control name, a control creation function (the lambda in the example could be replaced by just the class actually), and the number is a priority number used to sort icons in the toolbar.
Is it clearer ?
Denis
A Control corresponds to a complete keyboard/mouse interaction mode, it overrides entirely all events from keyboard and mouse. It is materialized by an icon on the left side of the window. In a Control, you can (and should) plug Actions, which define callback functions which are bound to events in the control.
So you have to define a Control subclass, one or several Action subclasses, and plug actions methods to events in the Control eventAutoSubscription() method.
Then actions and controls classes have to be registered in ActionDictionary and ControlDictionary so that Anatomist knows which controls are available for its windows.
Last, the ControlManager should register the control too, which specifies for which kind of window, and in presence of which type of object (which may be "": any) the control can be activated.
Thus, "cd.addControl" should take as argument a control name, a control creation function (the lambda in the example could be replaced by just the class actually), and the number is a priority number used to sort icons in the toolbar.
Is it clearer ?
Denis
Re: connect self.a.createWindow() to doubleClick
thanks for the details.
I have succeed to add an icon with the ftract logo for the control. which do nothing for now but I'll try to understand how to do.
how should I do to have the explanation of the control when the mouse goes over the logo ? as for other controls. for now it just says "ftract_control"
if I do:
is there a way to know which "control" I am currently using ? "white arrow" or "paper plane" for example ?
I have succeed to add an icon with the ftract logo for the control. which do nothing for now but I'll try to understand how to do.
how should I do to have the explanation of the control when the mouse goes over the logo ? as for other controls. for now it just says "ftract_control"
if I do:
Code: Select all
import anatomist.direct.api as anatomist
cd = anatomist.cpp.ControlDictionary.instance()
- Attachments
-
- ftract_control_logo.png (12.32 KiB) Viewed 26053 times
Re: connect self.a.createWindow() to doubleClick
is it possible to add the icon to a anatomist windows already created ?
My gui is already generated, with two anatomist windows on it. once the user generate the meshes (ftract results) it would add the icon for the specific controls to navigate on these results:
so at the end of the function generating the results, I do:
no error for now.
and now I'ld like to specify in which anatomist windows the control has to be added.
the two windows are :
I tried this, without success:
My gui is already generated, with two anatomist windows on it. once the user generate the meshes (ftract results) it would add the icon for the specific controls to navigate on these results:
so at the end of the function generating the results, I do:
Code: Select all
import control_ftract
pix = QtGui.QPixmap('/home/b67-belledone/Desktop/epilepsie-manik/Logo-F-TRACT.xpm' )
anatomist.anatomist.cpp.IconDictionary.instance().addIcon('ftract_control', pix)
ad = anatomist.anatomist.cpp.ActionDictionary.instance()
ad.addAction( 'fTract_Action', lambda: control_ftract.fTract_Action() )
cd = anatomist.anatomist.cpp.ControlDictionary.instance()
cd.addControl( 'ftract_control', lambda: control_ftract.ftract_control(), 25 )
cm = anatomist.anatomist.cpp.ControlManager.instance()
and now I'ld like to specify in which anatomist windows the control has to be added.
the two windows are :
Code: Select all
self.sagWindow = self.a.createWindow( 'Sagittal' )
self.axialWindow = self.a.createWindow( 'Axial' )
Code: Select all
cm.addControl( self.sagWindow, '', 'ftract_control' )
*** TypeError: ControlManager.addControl(): arguments did not match any overloaded call:
overload 1: argument 1 has unexpected type 'AWindow'
overload 2: argument 1 has unexpected type 'AWindow'
- riviere
- Site Admin
- Posts: 1361
- Joined: Tue Jan 06, 2004 12:21 pm
- Location: CEA NeuroSpin, Saint Aubin, France
- Contact:
Re: connect self.a.createWindow() to doubleClick
We are using the string translation system of Qt/PyQt for this, using pylupdate / lrelease and linguist tools. It's integrated in our build system so I don't do it by hand. Actually we use a string translation on the control name, which was probably not a good idea because this needs a "translation" even in english to get an explanation string, but this is how it works up to now. pylupdate parses python sources for strings to be translated and generates/updates a .ts file (here, pyanatomist.ts which is in share/anatomist-<ver>/po/<lang>/), then we can edit it using linguist, then "compile" the translated strings using lrelease to build the pyanatomist.qm file which is used in runtime.how should I do to have the explanation of the control when the mouse goes over the logo ?
is there a way to know which "control" I am currently using ?
Code: Select all
win.view().controlSwitch().activeControl()
Code: Select all
win.setControl('SelectionControl')
I don't remember actually. We generally define controls when initializing a plugin or a custom application, not after a window is open. Available controls in a window may then change according to the objects it contains.is it possible to add the icon to a anatomist windows already created ?
Code: Select all
I'ld like to specify in which anatomist windows the control has to be added
As said just before, ControlManager manages controls available for a type of window, not a specific one: its purpose is to provide a (new) window controls compatible with it. So the 1st argument of addControl is a string identifying a window type - technically, more a "view" type, which happens to have this cool name "QAGLWidget3D" in 3D windows )I tried this, without success:
cm.addControl( self.sagWindow, '', 'ftract_control' )