Esempio n. 1
0
    def autoScale(self, maxSteps, x1, x2):  #, stepSize):
        print "plouf autoScale"
        if (x1 > x2):
            y = x2.copy()
            x2 = x1
            x1 = y

        interval = QwtDoubleInterval(x1 / pow(10.0, lowerMargin()),
                                     x2 * pow(10.0, upperMargin()))

        logRef = 1.0
        if reference() > LOG_MIN / 2:
            logRef = min(reference(), LOG_MAX / 2)

        if testAttribute(QwtScaleEngine.Symmetric):
            delta = max(interval.maxValue() / logRef,
                        logRef / interval.minValue())
            interval.setInterval(logRef / delta, logRef * delta)

        if testAttribute(QwtScaleEngine.IncludeReference):
            interval = interval.extend(logRef)

        interval = interval.limited(LOG_MIN, LOG_MAX)

        if interval.width() == 0.0:
            interval = self.buildInterval(interval.minValue())

        stepSize = self.divideInterval(
            self.log10(interval).width(), max(maxNumSteps, 1))
        stepSize = max(stepSize, 1.0)

        if not testAttribute(QwtScaleEngine.Floating):
            interval = self.align(interval, stepSize)

        x1 = interval.minValue()
        x2 = interval.maxValue()

        if testAttribute(QwtScaleEngine.Inverted):
            y = x2.copy()
            x2 = x1
            x1 = y
            stepSize = -stepSize

        return (x1, x2, stepSize)
Esempio n. 2
0
    def divideScale(self, x1, x2, maxMajSteps, maxMinSteps, stepSize=0.0):
        print "plouf divideScale", x1, x2, maxMajSteps, maxMinSteps, stepSize
        #return QwtScaleDiv(0.,1.,[1,2,3],[],[])

        interval = QwtDoubleInterval(x1, x2).normalized().limited(
            LOG_MIN, LOG_MAX)

        if interval.width() <= 0:
            return QwtScaleDiv()

        if interval.maxValue() / interval.minValue() < 10.0:
            # scale width is less than one decade -> build linear scale
            linearScaler = QwtLinearScaleEngine()
            linearScaler.setAttributes(self.attributes())
            linearScaler.setReference(self.reference())
            linearScaler.setMargins(self.lowerMargin(), self.upperMargin())
            return linearScaler.divideScale(x1, x2, maxMajSteps, maxMinSteps,
                                            stepSize)

        stepSize = abs(stepSize)
        if stepSize == 0.:
            maxMajSteps = max(maxMajSteps, 1)

            stepSize = self.divideInterval(
                self.log10(interval).width(), maxMajSteps)
            stepSize = max(stepSize, 1.)  # major step must be >= 1 decade

        scaleDiv = QwtScaleDiv()
        if stepSize <> 0.:
            ticks = self.buildTicks(interval, stepSize, maxMinSteps)
            scaleDiv = QwtScaleDiv(interval, ticks[QwtScaleDiv.MajorTick],
                                   ticks[QwtScaleDiv.MediumTick],
                                   ticks[QwtScaleDiv.MinorTick])

        if x1 > x2:
            scaleDiv.invert()

        print scaleDiv.ticks(QwtScaleDiv.MajorTick)
        print scaleDiv.ticks(QwtScaleDiv.MediumTick)
        print scaleDiv.ticks(QwtScaleDiv.MinorTick)
        print "plouf finished divideScale"

        return scaleDiv
Esempio n. 3
0
	def autoScale(self, maxSteps, x1, x2):#, stepSize):
		print("plouf autoScale")
		if ( x1 > x2 ):
			y = x2.copy()
			x2 = x1
			x1 = y
		
		interval = QwtDoubleInterval(x1 / pow(10.0, lowerMargin()), x2 * pow(10.0, upperMargin()) )
		
		logRef = 1.0
		if reference() > LOG_MIN / 2:
			logRef = min(reference(), LOG_MAX/2)
		
		if testAttribute(QwtScaleEngine.Symmetric):
			delta = max(interval.maxValue() / logRef, logRef / interval.minValue())
			interval.setInterval(logRef / delta, logRef * delta)
		
		if testAttribute(QwtScaleEngine.IncludeReference):
			interval = interval.extend(logRef)
		
		interval = interval.limited(LOG_MIN, LOG_MAX)
		
		if interval.width() == 0.0:
			interval = self.buildInterval(interval.minValue())
		
		stepSize = self.divideInterval(self.log10(interval).width(), max(maxNumSteps, 1))
		stepSize = max(stepSize, 1.0)
		
		if not testAttribute(QwtScaleEngine.Floating):
			interval = self.align(interval, stepSize)
		
		x1 = interval.minValue()
		x2 = interval.maxValue()
		
		if testAttribute(QwtScaleEngine.Inverted):
			y = x2.copy()
			x2 = x1
			x1 = y
			stepSize = -stepSize
		
		return (x1, x2, stepSize)
Esempio n. 4
0
	def divideScale(self, x1, x2, maxMajSteps, maxMinSteps, stepSize = 0.0):
		print("plouf divideScale", x1, x2, maxMajSteps, maxMinSteps, stepSize)
		#return QwtScaleDiv(0.,1.,[1,2,3],[],[])
		
		interval = QwtDoubleInterval(x1, x2).normalized().limited(LOG_MIN, LOG_MAX)
		
		if interval.width() <= 0 :
			return QwtScaleDiv()
		
		if interval.maxValue() / interval.minValue() < 10.0:
			# scale width is less than one decade -> build linear scale
			linearScaler = QwtLinearScaleEngine()
			linearScaler.setAttributes(self.attributes())
			linearScaler.setReference(self.reference())
			linearScaler.setMargins(self.lowerMargin(), self.upperMargin())
			return linearScaler.divideScale(x1, x2, maxMajSteps, maxMinSteps, stepSize)
		
		stepSize = abs(stepSize)
		if stepSize == 0.:
			maxMajSteps = max(maxMajSteps, 1)

			stepSize = self.divideInterval(self.log10(interval).width(), maxMajSteps)
			stepSize = max(stepSize, 1.) # major step must be >= 1 decade
		
		scaleDiv = QwtScaleDiv()
		if stepSize != 0.:
			ticks = self.buildTicks(interval, stepSize, maxMinSteps)
			scaleDiv = QwtScaleDiv(interval, ticks[QwtScaleDiv.MajorTick], ticks[QwtScaleDiv.MediumTick], ticks[QwtScaleDiv.MinorTick])
		
		if x1 > x2:
			scaleDiv.invert()
		
		print(scaleDiv.ticks(QwtScaleDiv.MajorTick))
		print(scaleDiv.ticks(QwtScaleDiv.MediumTick))
		print(scaleDiv.ticks(QwtScaleDiv.MinorTick))
		print("plouf finished divideScale")
		
		return scaleDiv