From: daid Date: Wed, 17 Jul 2013 08:59:27 +0000 (+0200) Subject: Warn if the flow rate is out of normal range. X-Git-Tag: 13.10~120 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=cdf64ba4fffe082621f032b35612afdb39ea8428;p=cura.git Warn if the flow rate is out of normal range. --- diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 0fe27476..4e2c3239 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -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") diff --git a/Cura/util/validators.py b/Cura/util/validators.py index ed4262cf..d68aaf1d 100644 --- a/Cura/util/validators.py +++ b/Cura/util/validators.py @@ -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