Example #1
0
 def minScaleWidthWithBounds(self, unitSet, unitPlant, softMin, softMax):
     result = 0
     i = 0
     numeralChars = 0
     letterChars = 0
     maxLengthSoftMin = 0
     maxLengthSoftMax = 0
     minValue = 0.0
     maxValue = 0.0
     
     # value number of chars (always use max) 
     #+ kMaxDisplayDigitsToRightOfDecimal + 1
     numeralChars = kMaxDisplayDigitsToLeftOfDecimal
     # unit string number of chars (get max for set) 
     letterChars = uunits.maxUnitStringLengthForSet(unitSet)
     # bounds number of chars (use actual bounds, but calculate max for set) 
     maxLengthSoftMin = 0
     maxLengthSoftMax = 0
     for i in range(1, uunits.GetLastUnitEnumInUnitSet(unitSet)):
         minValue = uunits.Convert(unitSet, unitPlant, i, softMin)
         maxValue = uunits.Convert(unitSet, unitPlant, i, softMax)
         maxLengthSoftMin = umath.intMax(maxLengthSoftMin, len(usupport.digitValueString(minValue)))
         maxLengthSoftMax = umath.intMax(maxLengthSoftMax, len(usupport.digitValueString(maxValue)))
     numeralChars = numeralChars + maxLengthSoftMin + maxLengthSoftMax
     # calc min scale width from number of chars 
     result = self.formTextWidth("i") * letterChars + self.formTextWidth("1") * numeralChars + kBetweenGap * 3 + kLeftRightGap * 2
     return result
Example #2
0
 def minScaleWidthWithoutBounds(self, unitSet, unitPlant):
     result = 0
     numeralChars = 0
     letterChars = 0
     
     # value number of chars (always use max) 
     #+ kMaxDisplayDigitsToRightOfDecimal + 1
     numeralChars = kMaxDisplayDigitsToLeftOfDecimal
     # unit string number of chars (get max for set) 
     letterChars = uunits.maxUnitStringLengthForSet(unitSet)
     # calc min scale width from number of chars 
     result = self.formTextWidth("i") * letterChars + self.formTextWidth("1") * numeralChars + kBetweenGap + kLeftRightGap * 2
     return result