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