chiark / gitweb /
Make better use of the new settings code.
authordaid303 <daid303@gmail.com>
Wed, 20 Mar 2013 12:38:12 +0000 (13:38 +0100)
committerdaid303 <daid303@gmail.com>
Wed, 20 Mar 2013 12:38:12 +0000 (13:38 +0100)
Cura/gui/configBase.py
Cura/gui/mainWindow.py
Cura/gui/preferencesDialog.py
Cura/util/gcodeInterpreter.py
Cura/util/profile.py

index abb16209cb62c7fd85405d58cce888d2f22545aa..83448e9840df371fdfd75a5e045e39d5546783fb 100644 (file)
@@ -129,7 +129,7 @@ class TitleRow():
                "Add a title row to the configuration panel"
                sizer = panel.GetSizer()
                x = sizer.GetRows()
-               self.title = wx.StaticText(panel, -1, name)
+               self.title = wx.StaticText(panel, -1, name.replace('&', '&&'))
                self.title.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD))
                sizer.Add(self.title, (x,0), (1,3), flag=wx.EXPAND|wx.TOP|wx.LEFT, border=10)
                sizer.Add(wx.StaticLine(panel), (x+1,0), (1,3), flag=wx.EXPAND|wx.LEFT,border=10)
index d9f4ff815db252ebfd0f85b4b9308618f76a0625..570dda7d269cc229e5389ff67183502d813de697 100644 (file)
@@ -532,6 +532,20 @@ class mainWindow(wx.Frame):
 
 class normalSettingsPanel(configBase.configPanelBase):
        "Main user interface window"
+       def _addSettingsToPanels(self, category, left, right):
+               count = len(profile.getSubCategoriesFor(category)) + len(profile.getSettingsForCategory(category))
+
+               p = left
+               n = 0
+               for title in profile.getSubCategoriesFor(category):
+                       n += 1 + len(profile.getSettingsForCategory(category, title))
+                       if n > count / 2:
+                               p = right
+                       configBase.TitleRow(p, title)
+                       for s in profile.getSettingsForCategory(category, title):
+                               if s.checkConditions():
+                                       configBase.SettingRow(p, s.getName())
+
        def __init__(self, parent):
                super(normalSettingsPanel, self).__init__(parent)
 
@@ -541,93 +555,13 @@ class normalSettingsPanel(configBase.configPanelBase):
                self.GetSizer().Add(self.nb, 1, wx.EXPAND)
 
                (left, right, self.printPanel) = self.CreateDynamicConfigTab(self.nb, 'Basic')
-
-               configBase.TitleRow(left, "Quality")
-               c = configBase.SettingRow(left, 'layer_height')
-               #validators.warningAbove(c, lambda : (float(profile.getProfileSetting('nozzle_size')) * 80.0 / 100.0), "Thicker layers then %.2fmm (80%% nozzle size) usually give bad results and are not recommended.")
-               c = configBase.SettingRow(left, 'wall_thickness')
-               #validators.wallThicknessValidator(c)
-               c = configBase.SettingRow(left, 'retraction_enable')
-
-               configBase.TitleRow(left, "Fill")
-               c = configBase.SettingRow(left, 'solid_layer_thickness')
-               c = configBase.SettingRow(left, 'fill_density')
-
-               configBase.TitleRow(right, "Speed && Temperature")
-               c = configBase.SettingRow(right, 'print_speed')
-               #validators.warningAbove(c, 150.0, "It is highly unlikely that your machine can achieve a printing speed above 150mm/s")
-               #validators.printSpeedValidator(c)
-
-               configBase.TitleRow(right, "Temperature")
-               c = configBase.SettingRow(right, 'print_temperature')
-               #validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine, be careful!")
-               if int(profile.getPreference('extruder_amount')) > 1:
-                       c = configBase.SettingRow(right, 'print_temperature2')
-                       #validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine, be careful!")
-               if int(profile.getPreference('extruder_amount')) > 2:
-                       c = configBase.SettingRow(right, "3th nozzle temperature", 'print_temperature3', '0', 'Temperature used for printing with the 3th nozzle. Set at 0 to use the same temperature as for nozzle 1')
-                       validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine, be careful!")
-               if int(profile.getPreference('extruder_amount')) > 3:
-                       c = configBase.SettingRow(right, "4th nozzle temperature", 'print_temperature4', '0', 'Temperature used for printing with the 4th nozzle. Set at 0 to use the same temperature as for nozzle 1')
-                       validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine, be careful!")
-               if profile.getPreference('has_heated_bed') == 'True':
-                       c = configBase.SettingRow(right, "Bed temperature", 'print_bed_temperature', '0', 'Temperature used for the heated printer bed. Set at 0 to pre-heat yourself')
-
-               configBase.TitleRow(right, "Support structure")
-               c = configBase.SettingRow(right, 'support')
-#              c = configBase.SettingRow(right, "Add raft", 'enable_raft', False, 'A raft is a few layers of lines below the bottom of the object. It prevents warping. Full raft settings can be found in the expert settings.\nFor PLA this is usually not required. But if you print with ABS it is almost required.')
-#              if int(profile.getPreference('extruder_amount')) > 1:
-#                      c = configBase.SettingRow(right, "Support dual extrusion", 'support_dual_extrusion', False, 'Print the support material with the 2nd extruder in a dual extrusion setup. The primary extruder will be used for normal material, while the second extruder is used to print support material.')
-
-               configBase.TitleRow(right, "Filament")
-               c = configBase.SettingRow(right, 'filament_diameter')
-               #validators.warningAbove(c, 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
-#              if int(profile.getPreference('extruder_amount')) > 1:
-#                      c = configBase.SettingRow(right, "Diameter (mm)", 'filament_diameter2', '2.89', 'Diameter of your filament for the 2nd nozzle, as accurately as possible.\nIf you cannot measure this value you will have to calibrate it, a higher number means less extrusion, a smaller number generates more extrusion. Use 0 to use the same diameter as for nozzle 1.')
-#                      validators.warningAbove(c, 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
-#              if int(profile.getPreference('extruder_amount')) > 2:
-#                      c = configBase.SettingRow(right, "Diameter (mm)", 'filament_diameter3', '2.89', 'Diameter of your filament for the 3th nozzle, as accurately as possible.\nIf you cannot measure this value you will have to calibrate it, a higher number means less extrusion, a smaller number generates more extrusion. Use 0 to use the same diameter as for nozzle 1.')
-#                      validators.warningAbove(c, 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
-#              if int(profile.getPreference('extruder_amount')) > 3:
-#                      c = configBase.SettingRow(right, "Diameter (mm)", 'filament_diameter4', '2.89', 'Diameter of your filament for the 4th nozzle, as accurately as possible.\nIf you cannot measure this value you will have to calibrate it, a higher number means less extrusion, a smaller number generates more extrusion. Use 0 to use the same diameter as for nozzle 1.')
-#                      validators.warningAbove(c, 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
-#              c = configBase.SettingRow(right, "Packing Density", 'filament_density', '1.00', 'Packing density of your filament. This should be 1.00 for PLA and 0.85 for ABS')
+               self._addSettingsToPanels('basic', left, right)
 
                self.SizeLabelWidths(left, right)
                
                (left, right, self.advancedPanel) = self.CreateDynamicConfigTab(self.nb, 'Advanced')
-               
-               configBase.TitleRow(left, "Machine size")
-               c = configBase.SettingRow(left, 'nozzle_size')
-
-               configBase.TitleRow(left, "Skirt")
-               c = configBase.SettingRow(left, 'skirt_line_count')
-               c = configBase.SettingRow(left, 'skirt_gap')
-
-               configBase.TitleRow(left, "Retraction")
-#              c = configBase.SettingRow(left, "Minimum travel (mm)", 'retraction_min_travel', '5.0', 'Minimum amount of travel needed for a retraction to happen at all. To make sure you do not get a lot of retractions in a small area')
-               c = configBase.SettingRow(left, 'retraction_speed')
-               c = configBase.SettingRow(left, 'retraction_amount')
-#              c = configBase.SettingRow(left, "Extra length on start (mm)", 'retraction_extra', '0.0', 'Extra extrusion amount when restarting after a retraction, to better "Prime" your extruder after retraction.')
-
-               configBase.TitleRow(right, "Speed")
-               c = configBase.SettingRow(right, 'travel_speed')
-               #validators.warningAbove(c, 300.0, "It is highly unlikely that your machine can achieve a travel speed above 300mm/s")
-#              c = configBase.SettingRow(right, "Max Z speed (mm/s)", 'max_z_speed', '1.0', 'Speed at which Z moves are done. When you Z axis is properly lubercated you can increase this for less Z blob.')
-               c = configBase.SettingRow(right, 'bottom_layer_speed')
-
-#              configBase.TitleRow(right, "Cool")
-#              c = configBase.SettingRow(right, "Minimal layer time (sec)", 'cool_min_layer_time', '10', 'Minimum time spend in a layer, gives the layer time to cool down before the next layer is put on top. If the layer will be placed down too fast the printer will slow down to make sure it has spend atleast this amount of seconds printing this layer.')
-#              c = configBase.SettingRow(right, "Enable cooling fan", 'fan_enabled', True, 'Enable the cooling fan during the print. The extra cooling from the cooling fan is essensial during faster prints.')
-
-               configBase.TitleRow(right, "Quality")
-               c = configBase.SettingRow(right, 'bottom_thickness')
-               #validators.validFloat(c, 0.0)
-               #validators.warningAbove(c, lambda : (float(profile.getProfileSetting('nozzle_size')) * 3.0 / 4.0), "A bottom layer of more then %.2fmm (3/4 nozzle size) usually give bad results and is not recommended.")
-               c = configBase.SettingRow(right, 'object_sink')
-               #validators.validFloat(c, 0.0)
-#              configBase.settingNotify(c, lambda : self.GetParent().GetParent().GetParent().preview3d.Refresh())
-#              c = configBase.SettingRow(right, "Duplicate outlines", 'enable_skin', False, 'Skin prints the outer lines of the prints twice, each time with half the thickness. This gives the illusion of a higher print quality.')
+
+               self._addSettingsToPanels('advanced', left, right)
 
                self.SizeLabelWidths(left, right)
 
index 5744dc0115a0a732bc440f1f7adbcd271856b017..3ef3fc1a903ed7774042f5f2e718fdcb92384eb4 100644 (file)
@@ -44,7 +44,7 @@ class preferencesDialog(wx.Frame):
                        c = configBase.SettingRow(left, 'Model colour (%d)' % (i+1), 'model_colour%d' % (i+1), wx.Colour(0,0,0), '', type = 'preference')
 
                configBase.TitleRow(right, 'Filament settings')
-               c = configBase.SettingRow(right, 'Density (kg/m3)', 'filament_density', '1300', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.', type = 'preference')
+               c = configBase.SettingRow(right, 'Density (kg/m3)', 'filament_physical_density', '1300', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.', type = 'preference')
                validators.validFloat(c, 500.0, 3000.0)
                c = configBase.SettingRow(right, 'Cost (price/kg)', 'filament_cost_kg', '0', 'Cost of your filament per kg, to estimate the cost of the final print.', type = 'preference')
                validators.validFloat(c, 0.0)
index 19b68acec4d25b557c3e657eba4545c96cf029d7..6c7cebd10bf4fe6a58dc4d9b1265eb0b31fcf368 100644 (file)
@@ -37,7 +37,7 @@ class gcode(object):
                #Calculates the weight of the filament in kg
                radius = float(profile.getProfileSetting('filament_diameter')) / 2
                volumeM3 = (self.extrusionAmount * (math.pi * radius * radius)) / (1000*1000*1000)
-               return volumeM3 * profile.getPreferenceFloat('filament_density')
+               return volumeM3 * profile.getPreferenceFloat('filament_physical_density')
        
        def calculateCost(self):
                cost_kg = profile.getPreferenceFloat('filament_cost_kg')
index 9123c81bbd22f09d28beb1e3be912816d29a8993..264970fcb56ba6f001075497de86cd5a78b83d0f 100644 (file)
@@ -25,6 +25,7 @@ class setting(object):
                self._category = category
                self._subcategory = subcategory
                self._validators = []
+               self._conditions = []
 
                if type is types.FloatType:
                        validators.validFloat(self)
@@ -54,6 +55,12 @@ class setting(object):
        def getTooltip(self):
                return self._tooltip
 
+       def getCategory(self):
+               return self._category
+
+       def getSubCategory(self):
+               return self._subcategory
+
        def isPreference(self):
                return self._category == 'preference'
 
@@ -91,6 +98,15 @@ class setting(object):
                                msgs.append(err)
                return result, '\n'.join(msgs)
 
+       def addCondition(self, conditionFunction):
+               self._conditions.append(conditionFunction)
+
+       def checkConditions(self):
+               for condition in self._conditions:
+                       if not condition():
+                               return False
+               return True
+
 #########################################################
 ## Settings
 #########################################################
@@ -235,7 +251,7 @@ setting('extruder_offset_x2', '0.0', float, 'preference', 'hidden')
 setting('extruder_offset_y2', '0.0', float, 'preference', 'hidden')
 setting('extruder_offset_x3', '0.0', float, 'preference', 'hidden')
 setting('extruder_offset_y3', '0.0', float, 'preference', 'hidden')
-setting('filament_density', '1300', float, 'preference', 'hidden')
+setting('filament_physical_density', '1300', float, 'preference', 'hidden')
 setting('steps_per_e', '0', float, 'preference', 'hidden')
 setting('serial_port', 'AUTO', str, 'preference', 'hidden')
 setting('serial_port_auto', '', str, 'preference', 'hidden')
@@ -268,10 +284,52 @@ 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['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")
+validators.printSpeedValidator(settingsDictionary['print_speed'])
+validators.warningAbove(settingsDictionary['print_temperature'], 260.0, "Temperatures above 260C could damage your machine, be careful!")
+validators.warningAbove(settingsDictionary['print_temperature2'], 260.0, "Temperatures above 260C could damage your machine, be careful!")
+validators.warningAbove(settingsDictionary['print_temperature3'], 260.0, "Temperatures above 260C could damage your machine, be careful!")
+validators.warningAbove(settingsDictionary['print_temperature4'], 260.0, "Temperatures above 260C could damage your machine, be careful!")
+validators.warningAbove(settingsDictionary['filament_diameter'], 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
+validators.warningAbove(settingsDictionary['filament_diameter2'], 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
+validators.warningAbove(settingsDictionary['filament_diameter3'], 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
+validators.warningAbove(settingsDictionary['filament_diameter4'], 3.5, "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm.")
+validators.warningAbove(settingsDictionary['travel_speed'], 300.0, "It is highly unlikely that your machine can achieve a travel speed above 300mm/s")
+validators.warningAbove(settingsDictionary['bottom_thickness'], lambda : (float(getProfileSetting('nozzle_size')) * 3.0 / 4.0), "A bottom layer of more then %.2fmm (3/4 nozzle size) usually give bad results and is not recommended.")
+
+#Conditions for multiple extruders
+settingsDictionary['print_temperature2'].addCondition(lambda : int(getPreference('extruder_amount')) > 1)
+settingsDictionary['print_temperature3'].addCondition(lambda : int(getPreference('extruder_amount')) > 2)
+settingsDictionary['print_temperature4'].addCondition(lambda : int(getPreference('extruder_amount')) > 3)
+settingsDictionary['filament_diameter2'].addCondition(lambda : int(getPreference('extruder_amount')) > 1)
+settingsDictionary['filament_diameter3'].addCondition(lambda : int(getPreference('extruder_amount')) > 2)
+settingsDictionary['filament_diameter4'].addCondition(lambda : int(getPreference('extruder_amount')) > 3)
+settingsDictionary['support_dual_extrusion'].addCondition(lambda : int(getPreference('extruder_amount')) > 1)
+#Heated bed
+settingsDictionary['print_bed_temperature'].addCondition(lambda : getPreference('has_heated_bed') == 'True')
+
 #########################################################
 ## Profile and preferences functions
 #########################################################
 
+def getSubCategoriesFor(category):
+       done = {}
+       ret = []
+       for s in settingsList:
+               if s.getCategory() == category and not s.getSubCategory() in done:
+                       done[s.getSubCategory()] = True
+                       ret.append(s.getSubCategory())
+       return ret
+
+def getSettingsForCategory(category, subCategory = None):
+       ret = []
+       for s in settingsList:
+               if s.getCategory() == category and (subCategory is None or s.getSubCategory() == subCategory):
+                       ret.append(s)
+       return ret
+
 ## Profile functions
 def getBasePath():
        if platform.system() == "Windows":