1 from Cura.util.settings import lulzbot_mini_settings, \
2 lulzbot_taz4_settings, \
3 lulzbot_taz5_nozzle35_settings
5 import ConfigParser as configparser
6 from Cura.util import profile
7 from Cura.util import resources
9 class SimpleModeSettings(object):
10 # Set the Quickprint settings:
12 # Settings Format : Dictionary[machine_type] = machine_settings
13 # Dictionary[None] = other_machine_settings
15 # Machine settings Format : List of setting dictionaries
16 # Setting dictionary Format: Dictionary['Material'] = material ini filename
17 # Dictionary['Profile'] = profile ini filename
18 # Dictionary['Options'] = list of other options ini filenames
19 # Dictionary['Ini'] = Ini filename to load from extra/ subdir
20 # Dictionary['Settings'] = Option settings
21 # Option settings format : List of tuples ('profile setting', 'value')
22 # ('profile setting', callable function)
24 # settings['prusa_i3'] = [
25 # {'Material': '1_pla', 'Profile': '2_normal', 'Ini': 'normal_pla'},
26 # {'Material': '2_abs', 'Profile': '1_high', 'Ini': 'prusa_i3/high_abs'},
27 # {'Material': '1_pla', 'Options': ['brim', 'support'],
28 # 'Settings': [('support', _('Everywhere')), ('platform_adhesion', 'Brim')]
33 # All the settings in the list of machine settings will be checked. For
34 # each of those settings, the list of options will be verified and only the
35 # settings in which all the options match will be applied.
36 # The 'Settings' key in the dictionary will contain the settings to apply.
37 # Those settings will be a a list a tuples of key:value in which the value
38 # can be a callable function for greater control
40 # For example, a Dictionary with only 'Settings' will always be applied
41 # while a setting with {'Brim':True} will only be applied if the printBrim
42 # option is enabled, and settings with {'MaterialABS':True, 'TypeHigh':False}
43 # will only be applied for Low and Normal quality prints in ABS
45 settings = {"lulzbot_mini": lulzbot_mini_settings,
46 "lulzbot_TAZ_4": lulzbot_taz4_settings,
47 "lulzbot_TAZ_5_nozzle35": lulzbot_taz5_nozzle35_settings,
52 def getSimpleSettings(profile_setting, material_setting, other_settings):
54 machine_type = profile.getMachineSetting('machine_type')
55 if SimpleModeSettings.settings.has_key(machine_type):
56 machine_settings = SimpleModeSettings.settings[machine_type]
58 machine_settings = SimpleModeSettings.settings[None]
60 for setting_dict in machine_settings:
61 settings = setting_dict.get('Settings', None)
62 ini = setting_dict.get('Ini', None)
63 print_material = setting_dict.get('Material', None)
64 print_profile = setting_dict.get('Profile', None)
65 print_others = setting_dict.get('Options', None)
66 # Check if the material/profile/other options match the settings
67 if (print_material is None or print_material == material_setting) and \
68 (print_profile is None or print_profile == profile_setting) and \
69 (print_others is None or len(set(print_others)) == len(set(print_others).intersection(set(other_settings)))):
72 if len(item) != 2 or not profile.isProfileSetting(item[0]):
74 if hasattr(item[1], '__call__'):
75 simple_settings[item[0]] = item[1]()
77 simple_settings[item[0]] = item[1]
79 ini_file = resources.getSimpleModeIniFiles('extra', ini + '.ini')
81 cp = configparser.ConfigParser()
83 for setting in profile.settingsList:
84 if setting.isProfile() or setting.isAlteration():
85 if cp.has_option('profile', setting.getName()):
86 simple_settings[setting.getName()] = cp.get('profile', setting.getName())
88 return simple_settings