Blocks of windows in CreateWindow

Questions about BrainVisa usage and installation

Moderators: denghien, riviere

Post Reply
Manik
Posts: 99
Joined: Fri Mar 05, 2004 1:00 pm
Location: INSERM U836, Grenoble

Blocks of windows in CreateWindow

Post by Manik »

Hi,

in a BrainVisa (development version) process, I wanted to create of few windows grouped in a single block.
I wonder whether I understand the Anatomist Commands help correctly :

I tried to create some windows in a loop :

a.createWindow("Sagittal", block = 2)
a.createWindow("Axial", block = 2)
a.createWindow("3D", block = 2)

I get the first two windows in a block, and the last one alone.
Here is the output of my program

Window open, type = 'Sagittal', block = 2

Window open, type = 'Axial', block = 2

Window open, type = '3D', block = 2


And in history.ana :

*BEGIN TREE EXECUTE

*BEGIN TREE CreateWindow
block 2
res_pointer 1
type Sagittal

*END

*END
# tree 1.0

*BEGIN TREE EXECUTE

*BEGIN TREE CreateWindow
block 2
res_pointer 3
type Axial

*END

*END
# tree 1.0

*BEGIN TREE EXECUTE

*BEGIN TREE CreateWindow
block 5
res_pointer 4
type 3D

*END

*END

Is it an error in my program ?
Manik Bhattacharjee
INSERM U836
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Hi Manik,

OK, the doc is not very clear on this point (even I didn't remember how it works). I have added a note in Anatomist doc.
What happens is that the block number is an ID like objects, windows and other Anatomist elements IDs, thay are shared in a common namespace, so you shouldn't use a number already in use for something else, nor use an ID that BrainVisa may allocate later for a new object.
You can reserve a new ID using Anatomist.getNewBlockId():

Code: Select all

a = Anatomist.anatomist()
bid = a.getNewBlockId()

a.createWindow("Sagittal", block = bid)
a.createWindow("Axial", block = bid)
a.createWindow("3D", block = bid)
...and everything will work just fine...

Denis
Manik
Posts: 99
Joined: Fri Mar 05, 2004 1:00 pm
Location: INSERM U836, Grenoble

Post by Manik »

Ok thanks, it works fine now.

But I have some problems related to this one :

- if my program closes the windows, I still have the block window (empty) displayed. Should I destroy it with closeWindow too ?

- if the user closes the block window, how can I notice this from BrainVisa ? Because right now, my BV process tries to close the windows of the block, which may have been closed by the user; this leads to an Anatomist crash.
I should probably use the callback functions, but when the closeWindow event is raised, how can I know which windows and which blocks are closed ?
Manik Bhattacharjee
INSERM U836
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Hi Manik,

If I remember well, I have not done anything yet to close block widgets. It's somewhere on the TODO list... But we can assume it be implemented as an extension of the DeleteElement command.

If the user closes the block widget, every window in is closed too, and BrainVisa is informed (Anatomist sends an event notification when windows are closed). The block itself will do the same but does not at the moment.

All this is not finished...

Denis
Manik
Posts: 99
Joined: Fri Mar 05, 2004 1:00 pm
Location: INSERM U836, Grenoble

Post by Manik »

Ok, thank you for the information, for now I will just tell the user not to close the block windows without using my BV process :wink:
Please inform me when this is ok, or tell me if I can do something.
Have a merry Christmas !
Manik Bhattacharjee
INSERM U836
User avatar
riviere
Site Admin
Posts: 1361
Joined: Tue Jan 06, 2004 12:21 pm
Location: CEA NeuroSpin, Saint Aubin, France
Contact:

Post by riviere »

Hi Manik,

OK, I have added more tests in anatomist commands to check if elements are still living before using them: in DeleteElements, things are systematically checked before being deleted and blocks are handled now (this avoids double deletions and anatomist crashes). In CreateWindow, if the block ID corresponds to a deleted block (invalid widget), a new block should be recreated with this ID. (I haven't checked the modifs myself, so tell me).
I have still to do the event when a block is closed by the user.

Denis
Post Reply