chiark / gitweb /
WIP: Add material_types combobox to quickprint profile
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Tue, 1 Sep 2015 21:02:23 +0000 (17:02 -0400)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Tue, 1 Sep 2015 21:02:23 +0000 (17:02 -0400)
Cura/gui/simpleMode.py
Cura/util/profile.py
Cura/util/resources.py

index 7142ab3e4ebc49d8739f84d68e9e89cf992ba731..f34d31d492d34a181a868a9a570b20e1dc3d4031 100644 (file)
@@ -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:
index 080310c8b7bce8f215aab59313c915c4c9c33288..e71018f470a6e486a31f98cb5d1407020519998a 100644 (file)
@@ -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."))
index c0ce5f367b934e2bdf85f746128e7bf9bd56f265..0841711e0fe98cb52ff23b98d50f7cf5e32baea4 100644 (file)
@@ -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):