cmlibs / zinc

Source code repository for OpenCMISS-Zinc
Mozilla Public License 2.0
15 stars 18 forks source link

Scene getSpectrumDataRange not valid for time variation while Scene begin/endChange #229

Open rchristie opened 2 years ago

rchristie commented 2 years ago

Problem situation was in Field Fitter Step; the timekeeper setTime wasn't getting through and all times returned the range for time 0:

    with ChangeManager(scene):
        # add data field and spectrum to some graphics

        for time in reversed(times): 
                timekeeper.setTime(time)
                result, vMin, vMax = scene.getSpectrumDataRange(Scenefilter(), defaultSpectrum, componentCount)
                if componentCount > 1:
                    vMin = vMin[0]
                    vMax = vMax[0]
                if minFieldValue is None:
                    minFieldValue = vMin
                    maxFieldValue = vMax
                else:
                    if vMin < minFieldValue:
                        minFieldValue = vMin
                    if vMax > maxFieldValue:
                        maxFieldValue = vMax
            spectrumcomponent = defaultSpectrum.getFirstSpectrumcomponent()
            spectrumcomponent.setRangeMinimum(minFieldValue)
            spectrumcomponent.setRangeMaximum(maxFieldValue)

Workaround is to put the for-time loop outside the ChangeManager.