chiark / gitweb /
Warn if the flow rate is out of normal range.
authordaid <daid303@gmail.com>
Wed, 17 Jul 2013 08:59:27 +0000 (10:59 +0200)
committerdaid <daid303@gmail.com>
Wed, 17 Jul 2013 08:59:27 +0000 (10:59 +0200)
Cura/util/profile.py
Cura/util/validators.py

index 0fe27476acc057df021928a2895d6aa97433bf6e..4e2c32392398b554e0a7aa5e8b421aacad2acd21 100644 (file)
@@ -338,6 +338,8 @@ setting('window_width', '-1', float, 'preference', 'hidden')
 setting('window_height', '-1', float, 'preference', 'hidden')
 setting('window_normal_sash', '320', float, 'preference', 'hidden')
 
+validators.warningAbove(settingsDictionary['filament_flow'], 150, "More flow then 150% is rare and usually not recommended.")
+validators.warningBelow(settingsDictionary['filament_flow'], 50, "More flow then 50% is rare and usually not recommended.")
 validators.warningAbove(settingsDictionary['layer_height'], lambda : (float(getProfileSetting('nozzle_size')) * 80.0 / 100.0), "Thicker layers then %.2fmm (80%% nozzle size) usually give bad results and are not recommended.")
 validators.wallThicknessValidator(settingsDictionary['wall_thickness'])
 validators.warningAbove(settingsDictionary['print_speed'], 150.0, "It is highly unlikely that your machine can achieve a printing speed above 150mm/s")
index ed4262cf704c891d4365b77e77ceb0f3e50c0fd9..d68aaf1d841d1e8ec6a0d8dff10f1797b36dbbb5 100644 (file)
@@ -66,6 +66,27 @@ class warningAbove(object):
                        #We already have an error by the int/float validator in this case.
                        return SUCCESS, ''
 
+class warningBelow(object):
+       def __init__(self, setting, minValueForWarning, warningMessage):
+               self.setting = setting
+               self.setting._validators.append(self)
+               self.minValueForWarning = minValueForWarning
+               self.warningMessage = warningMessage
+
+       def validate(self):
+               try:
+                       f = float(eval(self.setting.getValue().replace(',','.'), {}, {}))
+                       if isinstance(self.minValueForWarning, types.FunctionType):
+                               if f <= self.minValueForWarning():
+                                       return WARNING, self.warningMessage % (self.minValueForWarning())
+                       else:
+                               if f <= self.minValueForWarning:
+                                       return WARNING, self.warningMessage
+                       return SUCCESS, ''
+               except (ValueError, SyntaxError, TypeError):
+                       #We already have an error by the int/float validator in this case.
+                       return SUCCESS, ''
+
 class wallThicknessValidator(object):
        def __init__(self, setting):
                self.setting = setting