From 8ade22e986452aac95b75232db2260edc0d1b10a Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Tue, 1 Sep 2015 17:02:23 -0400 Subject: [PATCH] WIP: Add material_types combobox to quickprint profile --- Cura/gui/simpleMode.py | 47 +++++++++++++++++++++++++++++++++++++++--- Cura/util/profile.py | 5 +++-- Cura/util/resources.py | 5 +++++ 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Cura/gui/simpleMode.py b/Cura/gui/simpleMode.py index 7142ab3e..f34d31d4 100644 --- a/Cura/gui/simpleMode.py +++ b/Cura/gui/simpleMode.py @@ -19,6 +19,22 @@ class simpleModePanel(wx.Panel): materials = resources.getSimpleModeMaterials() + self.material_types = {} + self.material_types[_("Others")] = [] + for material in materials: + if material.disabled: + continue + if len(material.types) == 0: + self.material_types[_("Others")].append(material) + for type in material.types: + if self.material_types.has_key(type): + self.material_types[type].append(material) + else: + self.material_types[type] = [material] + + if len(self.material_types[_("Others")]) == 0: + del self.material_types[_("Others")] + # Create material buttons self.printMaterialPanel = wx.Panel(self) selectedMaterial = None @@ -47,11 +63,36 @@ class simpleModePanel(wx.Panel): self.printMaterialPanel.Show(len(self._print_material_options) > 1 and \ self._print_material_options[0].profile.always_visible) + # Create material types combobox + self.printMaterialTypesPanel = wx.Panel(self) + selectedMaterialType = None + for material_type in self.material_types: + if profile.getProfileSetting('simpleModeMaterialType') == material_type and \ + selectedMaterial.profile in self.material_types[material_type]: + selectedMaterialType = material_type + + if selectedMaterialType is None: + if len(selectedMaterial.profile.types) == 0: + selectedMaterialType = _("Others") + else: + selectedMaterialType = selectedMaterial.profile.types[0] + + self.printTypePanel = wx.Panel(self) sizer = wx.GridBagSizer() self.SetSizer(sizer) + sb = wx.StaticBox(self.printMaterialTypesPanel, label=_("Material types:")) + boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL) + boxsizer.SetMinSize((80, 20)) + combobox = wx.ComboBox(self.printMaterialTypesPanel, -1, selectedMaterialType, + choices=self.material_types.keys(), style=wx.CB_READONLY) + boxsizer.Add(combobox) + self.printMaterialTypesPanel.SetSizer(wx.BoxSizer(wx.VERTICAL)) + self.printMaterialTypesPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND) + sizer.Add(self.printMaterialTypesPanel, (0,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP) + sb = wx.StaticBox(self.printMaterialPanel, label=_("Material:")) boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL) boxsizer.SetMinSize((80, 20)) @@ -59,20 +100,20 @@ class simpleModePanel(wx.Panel): boxsizer.Add(button) self.printMaterialPanel.SetSizer(wx.BoxSizer(wx.VERTICAL)) self.printMaterialPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND) - sizer.Add(self.printMaterialPanel, (0,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP) + sizer.Add(self.printMaterialPanel, (1,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP) sb = wx.StaticBox(self.printTypePanel, label=_("Select a quickprint profile:")) boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL) boxsizer.SetMinSize((180, 20)) self.printTypePanel.SetSizer(wx.BoxSizer(wx.VERTICAL)) self.printTypePanel.GetSizer().Add(boxsizer, flag=wx.EXPAND) - sizer.Add(self.printTypePanel, (1,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP) + sizer.Add(self.printTypePanel, (2,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP) self.printOptionsBox = wx.StaticBox(self, label=_("Other options:")) boxsizer = wx.StaticBoxSizer(self.printOptionsBox, wx.VERTICAL) boxsizer.SetMinSize((100, 20)) - sizer.Add(boxsizer, (2,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP) + sizer.Add(boxsizer, (3,0), border=10, flag=wx.EXPAND|wx.RIGHT|wx.LEFT|wx.TOP) self.printOptionsSizer = boxsizer for button in self._print_material_options: diff --git a/Cura/util/profile.py b/Cura/util/profile.py index 080310c8..e71018f4 100644 --- a/Cura/util/profile.py +++ b/Cura/util/profile.py @@ -482,8 +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, 'hidden', 'hidden') -setting('simpleModeMaterial', '1_pla', str, 'hidden', 'hidden') +setting('simpleModeProfile', 'Standard', str, 'hidden', 'hidden') +setting('simpleModeMaterial', 'PLA', str, 'hidden', 'hidden') +setting('simpleModeMaterialType', 'Beginner', 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.")) diff --git a/Cura/util/resources.py b/Cura/util/resources.py index c0ce5f36..0841711e 100644 --- a/Cura/util/resources.py +++ b/Cura/util/resources.py @@ -204,7 +204,12 @@ class PrintMaterial(ProfileIni): self.profiles = [] self.options = [] + self.types = [] + types = self._getProfileInfo(self.ini, 'material_types') + if types != None: + for type in types.split('|'): + self.types.append(type.strip()) self.parseDirectory(self.path) def parseDirectory(self, path): -- 2.30.2