1 from __future__ import absolute_import
7 from gui import profile
14 def __init__(self, setting, minValue = None, maxValue = None):
15 self.setting = setting
16 self.setting.validators.append(self)
17 self.minValue = minValue
18 self.maxValue = maxValue
22 f = float(self.setting.GetValue())
23 if self.minValue != None and f < self.minValue:
24 return ERROR, 'This setting should not be below ' + str(self.minValue)
25 if self.maxValue != None and f > self.maxValue:
26 return ERROR, 'This setting should not be above ' + str(self.maxValue)
29 return ERROR, '"' + str(self.setting.GetValue()) + '" is not a valid number'
32 def __init__(self, setting, minValue = None, maxValue = None):
33 self.setting = setting
34 self.setting.validators.append(self)
35 self.minValue = minValue
36 self.maxValue = maxValue
40 f = int(self.setting.GetValue())
41 if self.minValue != None and f < self.minValue:
42 return ERROR, 'This setting should not be below ' + str(self.minValue)
43 if self.maxValue != None and f > self.maxValue:
44 return ERROR, 'This setting should not be above ' + str(self.maxValue)
47 return ERROR, '"' + str(self.setting.GetValue()) + '" is not a valid whole number'
50 def __init__(self, setting, minValueForWarning, warningMessage):
51 self.setting = setting
52 self.setting.validators.append(self)
53 self.minValueForWarning = minValueForWarning
54 self.warningMessage = warningMessage
58 f = float(self.setting.GetValue())
59 if isinstance(self.minValueForWarning, types.FunctionType):
60 if f >= self.minValueForWarning():
61 return WARNING, self.warningMessage % (self.minValueForWarning())
63 if f >= self.minValueForWarning:
64 return WARNING, self.warningMessage
67 #We already have an error by the int/float validator in this case.
70 class wallThicknessValidator():
71 def __init__(self, setting):
72 self.setting = setting
73 self.setting.validators.append(self)
77 wallThickness = float(self.setting.GetValue())
78 nozzleSize = float(profile.getProfileSetting('nozzle_size'))
79 if wallThickness <= nozzleSize * 0.5:
80 return ERROR, 'Trying to print walls thinner then the half of your nozzle size, this will not produce anything usable'
81 if wallThickness <= nozzleSize * 0.85:
82 return WARNING, 'Trying to print walls thinner then the 0.8 * nozzle size. Small chance that this will produce usable results'
83 if wallThickness < nozzleSize:
86 lineCount = int(wallThickness / nozzleSize)
87 lineWidth = wallThickness / lineCount
88 lineWidthAlt = wallThickness / (lineCount + 1)
89 if lineWidth >= nozzleSize * 1.5 and lineWidthAlt <= nozzleSize * 0.85:
90 return WARNING, 'Current selected wall thickness results in a line thickness of ' + str(lineWidthAlt) + 'mm which is not recommended with your nozzle of ' + str(nozzleSize) + 'mm'
93 #We already have an error by the int/float validator in this case.
96 class printSpeedValidator():
97 def __init__(self, setting):
98 self.setting = setting
99 self.setting.validators.append(self)
103 nozzleSize = float(profile.getProfileSetting('nozzle_size'))
104 layerHeight = float(profile.getProfileSetting('layer_height'))
105 printSpeed = float(profile.getProfileSetting('print_speed'))
107 printVolumePerMM = layerHeight * nozzleSize
108 printVolumePerSecond = printVolumePerMM * printSpeed
109 #Using 10mm3 per second with a 0.4mm nozzle (normal max according to Joergen Geerds)
110 maxPrintVolumePerSecond = 10 / (math.pi*(0.2*0.2)) * (math.pi*(nozzleSize/2*nozzleSize/2))
112 if printVolumePerSecond > maxPrintVolumePerSecond:
113 return WARNING, 'You are trying to print more then %.1fmm^3 of filament per second. This might cause filament slipping. (You are printing at %0.1fmm^3 per second)' % (maxPrintVolumePerSecond, printVolumePerSecond)
117 #We already have an error by the int/float validator in this case.