Hello,
A few comments. The code in SelectedPeaksPopup.py is probably worth
looking at for this kind of job, to give you an idea of the task at hand.
(Here and from now on the files I mention are located in
ccpnmr1.0/python/ccpnmr/analysis.) In particular the function
setupOrthogForPeak() determines what are the possible windows you can go
to. This uses the function findOrthogonalWindows() in Util.py.
That latter function is rather hard going (so I wouldn't necessarily
recommend reading it) but it returns a list of triples. Each of the
triples = (key, window, location), where key is the descriptive phrase you
see in the pulldown menu describing where you are going to, the window is
the data model window (which is not quite the same as the graphics window)
and location is a dictionary keyed on the axisPanel labels ('x', 'y', 'z1'
for a 3D) giving the peak location.
Now each and every data model window is associated with a unique graphics
window (and vice versa). To go from the data model window to the graphics
window one uses functions in AnalysisPopup.py (see below). (To go in the
other direction is easier, if popup is a graphics window then popup.window
is the correspondong data model window.)
In SelectedPeaksPopup.py the way you go from the window and location
returned by findOrthogonalWindows() to the location in the corresponding
graphics window is to use the function gotoPosition() in AnalysisPopup.py.
In SelectedPeaksPopup.py this is done in the function gotoOrthogPlane()
(the callback function for the "goto position" button) as follows
("position" is what I have been calling "location):
self.guiParent.gotoPosition(window_name = window.name, position=position)
(Most popups have AnalysisPopup as a parent, sometimes in the code you
will see this as self.guiParent and sometimes as self.parent depending on
whether Tim or I wrote the code.)
If you look at the function gotoPosition() in AnalysisPopup.py you will
see that its first line is:
popup = self.getWindowPopup(window_name)
and that is the function that directly gives you the graphics window
(popup) given the window (well, window name). gotoPosition() then just
calls the function of the same name on that popup. Most of the code for
graphics windows popups is in WindowPopup.py but in fact the code for
gotoPosition() is in a superclass of WindowPopup which is in WindowDraw.py
(and in the next release some more WindowPopup code will have migrated to
a new module called WindowBasic.py). You probably don't need to look at
that code.
Now if you want to add further functionality to do with going to a
location in a specific strip you can still use the function gotoPosition()
in AnalysisPopup.py, because that has an optional row and col which you
can specify. For (vertical) strips you would specify the col (this starts
counting from 0, not 1).
Perhaps I should add that given a data model window, the way you figure
out the number of (vertical) strips is to look at:
window.axisPanels[0].axisRegions
and the size of that tuple is the number of strips. (And each element
in that tuple is a data model AxisRegion object which specifies the region
for the corresponding strip.)
I hope this gets you started. (Tim could no doubt add more, he thought up
the gotoPosition functionality.)
Wayne
On Fri, 8 Apr 2005, igor barsukov wrote:
> Hi,
>
> In a macro I need to draw a 3D plane starting from the 2D peak position,
> similar to the Goto position function of the peak selection panel. If I
> have several strips in a window I want to draw the plane in one of them,
> selecting it in the macro, rather than in the window panel. Could
> somebody suggest the functions to use for this.
>
> Cheers
> Igor
>
> --
> Dr. Igor Barsukov
>
> Biological NMR Centre,
> University of Leicester
> PO Box 138,
> University Road,
> Henry Wellcome Building,
> Leicester LE1 9HN
> UK
> E-mail: [log in to unmask]
> Tel: +44 (0)116 229 7098
> FAX: +44 (0)116 229 7053
>
|