Hello,
A couple of things. First you should check "if windowPopup" because
otherwise it falls over (which is what happened when I ran the macro from
the EditMacros dialog). (Complain and return "if not windowPopup".)
Secondly, because of the windowPopup.contourLevelsUp() you are going to
raise the visible spectra twice (when the rest of the code is working), so
that if block should go.
Now the reason the rest of that code is not working is that you need to
import Util. So
from ccpnmr.analysis import Util
Otherwise you are getting an exception (because it does not know what Util
is) which is going down a black hole because of the try/except/pass.
Regards, Wayne
On Thu, 20 Sep 2007, Jeremy Craven wrote:
> Hi
>
> I am looking at a titration and am trying to figure out how to keep
> control of the contour level viewed in the spectra across the series. I
> want a way to change the contour level on all of them in one fell swoop.
>
> I found the macro ContourLevelsUp ("e" or is it "r" ?)
>
> But that seems to only change it for the spectra that I happen to have
> clicked "ON" onthe spectrum tabs at that moment.
>
> Am I missing something ?
>
> So I thought I would try to write my own (as a macro writing exercise as
> well). My attempt is:
>
> def raiseAllContoursMappedToWindow(argServer = None, windowPopup = None):
>
> # this differs from the contourLevelsUp macro because it does it to ALL the spectra mapped to window
>
> # (I hope) so all points in titration stay in lock step, wheterh viewed or not
>
> print "-----"
>
> if argServer and not windowPopup:
>
> windowPopup = argServer.getCurrentWindowPopup()
>
> if windowPopup:
>
> windowPopup.contourLevelsUp()
>
> views = windowPopup.getSpectrumViews()
>
> for view in views:
>
> try:
>
> spectrum = view.dataSource
>
> (baseLevel, numberLevels, levelChanger, changeMode) = Util.getSpectrumLevelValues(spectrum)
>
> if changeMode == 0:
>
> if levelChanger <= 1:
>
> continue
>
> else:
>
> if levelChanger <= 0:
>
> continue
>
> changeSpectrumContourLevels(spectrum, levelChanger, changeMode)
>
> except:
>
> pass
>
>
> Which is two functions cobbled together into one, and then I changed
>
> getActiveSpectrumViews
>
> to
>
> getSpectrumViews
>
> but it still only seems to change the levels of the clicked ON spectra.
>
> Can anyone help me ?
>
> Also is the "levelChanger" parameter set in one of the popups.
>
> Have lots more thoughts on this topic but will leave this email at that.
>
> Cheers
>
> Jeremy
>
> --
> *********************************************************************************
>
> Dr C. Jeremy Craven
> Department of Molecular Biology and Biotechnology
> University of Sheffield,
> Firth Court, Western Bank
> S10 2TN Sheffield UK
>
> e-mail: [log in to unmask]
> http://www.nmr.group.shef.ac.uk/CJC.html
>
> Phone: x24323
> >From outside Sheffield: 0114 222 4323
> >From outside UK: +44 114 2224323
> Fax: 0114 272 2800
>
> *********************************************************************************
>
|