chiark / gitweb /
Fix an issue in version upgrade for TAZ bed size. profile module can't be called...
[cura.git] / Cura / util / profile.py
index 2d68bf38d853011debbdd66c5404f00c44655e83..06c466a3397e3583038b4812740eb1d3c7199499 100644 (file)
@@ -180,6 +180,7 @@ setting('wall_thickness',            0.8, float, 'basic',    _('Quality')).setRa
 setting('retraction_enable',        True, bool,  'basic',    _('Quality')).setExpertSubCategory(_('Retraction')).setLabel(_("Enable retraction"), _("Retract the filament when the nozzle is moving over a none-printed area. Details about the retraction can be configured in the advanced tab."))
 setting('solid_layer_thickness',     0.6, float, 'basic',    _('Fill')).setRange(0).setLabel(_("Bottom/Top thickness (mm)"), _("This controls the thickness of the bottom and top layers, the amount of solid layers put down is calculated by the layer thickness and this value.\nHaving this value a multiple of the layer thickness makes sense. And keep it near your wall thickness to make an evenly strong part."))
 setting('fill_density',               20, float, 'basic',    _('Fill')).setExpertSubCategory(_('Infill')).setRange(0, 100).setLabel(_("Fill Density (%)"), _("This controls how densely filled the insides of your print will be. For a solid part use 100%, for an empty part use 0%. A value around 20% is usually enough.\nThis will not affect the outside of the print and only adjusts how strong the part becomes."))
+setting('perimeter_before_infill',               True, bool, 'basic',    _('Fill')).setLabel(_("Perimeters before Infill"), _("This controls whether the perimeters should be printed before or after the infill. Printing the perimeter after the infill may improve the quality of prints with very low layer heights, while printing the perimeters before the infill will give better results for layer height above 0.1mm"))
 setting('nozzle_size',               0.4, float, 'advanced', _('Machine')).setRange(0.1,10).setLabel(_("Nozzle size (mm)"), _("The nozzle size is very important, this is used to calculate the line width of the infill, and used to calculate the amount of outside wall lines and thickness for the wall thickness you entered in the print settings."))
 setting('print_speed',                50, float, 'basic',    _('Speed and Temperature')).setRange(1).setLabel(_("Print speed (mm/s)"), _("Speed at which printing happens. A well adjusted 3D printer can reach high speeds. However, for high quality prints slower speeds are required. Printing speed depends on a lot of factors. You will be experimenting with optimal settings for this."))
 setting('print_temperature',         210, int,   'basic',    _('Speed and Temperature')).setRange(0,340).setLabel(_("Printing temperature (C)"), _("Temperature used for printing. Set at 0 to pre-heat yourself.\nFor PLA 205C is recommended.\nFor ABS and HIPS 240C is recommended."))
@@ -204,7 +205,7 @@ setting('retraction_speed',         40.0, float, 'advanced', _('Retraction')).se
 setting('retraction_amount',         4.5, float, 'advanced', _('Retraction')).setRange(0).setLabel(_("Distance (mm)"), _("Amount of retraction, set at 0 for no retraction at all. A value between 1 and 2 millimeters provides good results for most materials."))
 setting('retraction_dual_amount',   16.5, float, 'advanced', _('Retraction')).setRange(0).setLabel(_("Dual extrusion switch amount (mm)"), _("Amount of retraction when switching nozzle with dual-extrusion, set at 0 for no retraction at all. A value of 16.0mm seems to generate good results."))
 setting('retraction_min_travel',     1.5, float, 'expert',   _('Retraction')).setRange(0).setLabel(_("Minimum travel (mm)"), _("Minimum amount of travel needed for a retraction to happen at all. This setting is used to prevent from having too many retractions in a small area."))
-setting('retraction_combing',      'All',  [_('Off'),_('All'),_('No Skin')], 'expert', _('Retraction')).setLabel(_("Enable combing"), _("Combing is the act of avoiding holes in the print for the head to travel over. If combing is \'Off\' the printer head moves straight from the start point to the end point and it will always retract.  If \'All\', enable combing on all surfaces.  If \'No Skin\', enable combing on all except skin surfaces."))
+setting('retraction_combing',      'All',  [_('Off'),_('All'),_('No Skin')], 'expert', _('Retraction')).setLabel(_("Combing type"), _("When moving between print areas, combing keeps the print head above already printed areas and skips retraction. This helps reduce stringing and reduces the chance of grinding the filament. If combing is \'Off\' the printer head moves straight from the start point to the end point and it will always retract.  If \'All\', combing is always enabled.  If \'No Skin\', combing will not occur on skin (top/bottom fill layers) surfaces."))
 setting('retraction_minimal_extrusion',0.02, float,'expert', _('Retraction')).setRange(0).setLabel(_("Minimal extrusion before retracting (mm)"), _("The minimal amount of extrusion that needs to be done before retracting again if a retraction needs to happen before this minimal is reached the retraction is ignored.\nThis avoids retracting a lot on the same piece of filament which flattens the filament and causes grinding issues."))
 setting('retraction_hop',            0.0, float, 'expert',   _('Retraction')).setRange(0).setLabel(_("Z hop when retracting (mm)"), _("When a retraction is done, the head is lifted by this amount to travel over the print. A value of 0.075 works well. This feature has a lot of positive effect on delta towers."))
 setting('bottom_thickness',          0.3, float, 'advanced', _('Quality')).setRange(0).setLabel(_("Initial layer thickness (mm)"), _("Layer thickness of the bottom layer. A thicker bottom layer makes sticking to the bed easier. Set to 0.0 to have the bottom layer thickness the same as the other layers."))
@@ -481,9 +482,9 @@ setting('postSwitchExtruder.gcode', """;Switch between the current extruder and
 """, str, 'alteration', 'alteration')
 
 setting('startMode', 'Simple', ['Simple', 'Normal'], 'preference', 'hidden')
-setting('simpleModeProfile', '2_normal', str, 'preference', 'hidden')
-setting('simpleModeMaterial', '1_pla', str, 'preference', 'hidden')
-setting('oneAtATime', 'True', bool, 'preference', 'hidden')
+setting('simpleModeProfile', '2_normal', str, 'hidden', 'hidden')
+setting('simpleModeMaterial', '1_pla', str, 'hidden', 'hidden')
+setting('oneAtATime', 'False', bool, 'preference', 'hidden')
 setting('lastFile', os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'resources', 'example', 'Rocktopus.stl')), str, 'preference', 'hidden')
 setting('save_profile', 'False', bool, 'preference', 'hidden').setLabel(_("Save profile on slice"), _("When slicing save the profile as [stl_file]_profile.ini next to the model."))
 setting('filament_cost_kg', '0', float, 'preference', 'hidden').setLabel(_("Cost (price/kg)"), _("Cost of your filament per kg, to estimate the cost of the final print."))
@@ -497,7 +498,10 @@ def _getMyDocumentsFolder():
                path = os.path.expanduser('~/')
        if not os.path.exists(path):
                path = ''
-
+       try:
+               path = unicode(path)
+       except UnicodeDecodeError:
+               path = ''
        return path
 
 setting('sdcard_rootfolder', _getMyDocumentsFolder(), str, 'preference', 'hidden').setLabel(_("Base folder to replicate on SD card"), _("The specified folder will be used as a base path. Any gcode generated from object coming from within that folder will be automatically saved on the SD card at the same sub-folder. Any object coming from outside of this path will save the gcode on the root folder of the card."))
@@ -512,7 +516,6 @@ setting('model_colour', '#C9E240', str, 'preference', 'hidden').setLabel(_('Mode
 setting('model_colour2', '#CB3030', str, 'preference', 'hidden').setLabel(_('Model colour (2)'), _('Display color for second extruder'))
 setting('model_colour3', '#DDD93C', str, 'preference', 'hidden').setLabel(_('Model colour (3)'), _('Display color for third extruder'))
 setting('model_colour4', '#4550D3', str, 'preference', 'hidden').setLabel(_('Model colour (4)'), _('Display color for forth extruder'))
-setting('printing_window', 'Pronterface UI', ['Basic'], 'preference', 'hidden').setLabel(_('Printing window type'), _('Select the interface used for USB printing.'))
 
 setting('window_maximized', 'True', bool, 'preference', 'hidden')
 setting('window_pos_x', '-1', float, 'preference', 'hidden')
@@ -548,6 +551,8 @@ setting('serial_port_auto', '', str, 'machine', 'hidden')
 setting('serial_baud', 'AUTO', str, 'machine', 'hidden').setLabel(_("Baudrate"), _("Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600"))
 setting('serial_baud_auto', '', int, 'machine', 'hidden')
 
+setting('toolhead', 'Default', str, 'machine', 'hidden').setLabel(_("Installed Tool Head"), _("Which tool head is currently installed. This setting is only used by LulzBot machines."))
+setting('toolhead_shortname', '', str, 'machine', 'hidden')
 setting('extruder_head_size_min_x', '0.0', float, 'machine', 'hidden').setLabel(_("Head size towards X min (mm)"), _("The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head."))
 setting('extruder_head_size_min_y', '0.0', float, 'machine', 'hidden').setLabel(_("Head size towards Y min (mm)"), _("The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head."))
 setting('extruder_head_size_max_x', '0.0', float, 'machine', 'hidden').setLabel(_("Head size towards X max (mm)"), _("The head size when printing multiple objects, measured from the tip of the nozzle towards the outer part of the head."))
@@ -733,11 +738,16 @@ def loadProfile(filename, allMachines = False):
                        section = 'profile'
                        if set.isAlteration():
                                section = 'alterations'
-                       if profileParser.has_option(section, set.getName()):
-                               set.setValue(unicode(profileParser.get(section, set.getName()), 'utf-8', 'replace'))
-       #Upgrade setting from older ini file
-       if getProfileSetting('retraction_combing') == '1':
-               putProfileSetting('retraction_combing', 'All')
+                       setting_name = set.getName()
+                       if profileParser.has_option(section, setting_name):
+                               try:
+                                       setting = profileParser.get(section, setting_name)
+                                       if setting == "Invalid Value":
+                                               raise Exception
+                                       set.setValue(unicode(setting, 'utf-8', 'replace'))
+                                       pass
+                               except:
+                                       set.setValue(set.getDefault())
 
 def saveProfile(filename, allMachines = False):
        """
@@ -916,6 +926,13 @@ def isProfileSetting(name):
                return True
        return False
 
+def isAlterationSetting(name):
+       """ Check if a certain key name is actually a profile value. """
+       global settingsDictionary
+       if name in settingsDictionary and settingsDictionary[name].isAlteration():
+               return True
+       return False
+
 ## Preferences functions
 def getPreferencePath():
        """
@@ -1087,6 +1104,15 @@ def getMachineCount():
                return 1
        return n
 
+def getMachineName(index = None):
+       name = getMachineSetting('machine_name', index)
+       type = getMachineSetting('machine_type', index)
+       if type.startswith('lulzbot_'):
+               toolhead = getMachineSetting('toolhead_shortname', index)
+               if toolhead != '':
+                       return "%s (%s)" % (name, toolhead)
+       return name
+
 def setActiveMachine(index):
        global _selectedMachineIndex
        _selectedMachineIndex = index
@@ -1341,3 +1367,16 @@ def getAlterationFileContents(filename, extruderCount = 1):
                #Append the profile string to the end of the GCode, so we can load it from the GCode file later.
                #postfix = ';CURA_PROFILE_STRING:%s\n' % (getProfileString())
        return unicode(prefix + re.sub("(.)\{([^\}]*)\}", replaceTagMatch, alterationContents).rstrip() + '\n' + postfix).strip().encode('utf-8') + '\n'
+
+def performVersionUpgrade():
+       for n in xrange(0, getMachineCount()):
+               # This is a hack around an issue where the machine type in the wizard
+               # changed and causes some people to have it set to lulzbot_TAZ and some
+               # people have it set to lulzbot_TAZ_4.
+               if getMachineSetting('machine_type', n) == 'lulzbot_TAZ':
+                       putMachineSetting('machine_type', 'lulzbot_TAZ_4', n)
+
+               # Change TAZ print bed so prints are centered when scaled to the max
+               if getMachineSetting('machine_type', n).startswith('lulzbot_TAZ_') and \
+                       getMachineSetting('machine_width', n) == '298':
+                       putMachineSetting('machine_width', '290')