Ejemplo n.º 1
0
Archivo: app.py Proyecto: EFinley/Cura
	def afterSplashCallback(self):
		#These imports take most of the time and thus should be done after showing the splashscreen
		from Cura.gui import mainWindow
		from Cura.gui import configWizard

		#If we haven't run it before, run the configuration wizard.
		if profile.getPreference('machine_type') == 'unknown':
			if platform.system() == "Darwin":
				#Check if we need to copy our examples
				exampleFile = os.path.expanduser('~/CuraExamples/UltimakerRobot_support.stl')
				if not os.path.isfile(exampleFile):
					try:
						os.makedirs(os.path.dirname(exampleFile))
					except:
						pass
					for filename in glob.glob(os.path.normpath(os.path.join(resources.resourceBasePath, 'example', '*.*'))):
						shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
					profile.putPreference('lastFile', exampleFile)
			configWizard.configWizard()

		#Hide the splashscreen before showing the main window.
		if self.splash is not None:
			self.splash.Show(False)
		self.mainWindow = mainWindow.mainWindow()

		setFullScreenCapable(self.mainWindow)
Ejemplo n.º 2
0
	def OnSettingChange(self, e):
		if self.type == 'profile':
			profile.putProfileSetting(self.configName, self.GetValue())
		else:
			profile.putPreference(self.configName, self.GetValue())
		result = validators.SUCCESS
		msgs = []
		for validator in self.validators:
			res, err = validator.validate()
			if res == validators.ERROR:
				result = res
			elif res == validators.WARNING and result != validators.ERROR:
				result = res
			if res != validators.SUCCESS:
				msgs.append(err)
		ctrl = self.ctrl
		if isinstance(ctrl, floatspin.FloatSpin):
			ctrl = ctrl.GetTextCtrl()
		if result == validators.ERROR:
			ctrl.SetBackgroundColour('Red')
		elif result == validators.WARNING:
			ctrl.SetBackgroundColour('Yellow')
		else:
			ctrl.SetBackgroundColour(self.defaultBGColour)
		ctrl.Refresh()

		self.validationMsg = '\n'.join(msgs)
		self.panel.main.UpdatePopup(self)
Ejemplo n.º 3
0
	def OnDropFiles(self, files):
		#if len(files) > 0:
			#profile.setPluginConfig([])
			#self.updateProfileToControls()
		profile.putPreference('lastFile', files[0])
		gcodeFilename = None
		for filename in files:
			self.addToModelMRU(filename)
			ext = filename[filename.rfind('.')+1:].upper()
			if ext == 'G' or ext == 'GCODE':
				gcodeFilename = filename
		if gcodeFilename is not None:
			if self.scene._gcode is not None:
				self.scene._gcode = None
				for layerVBOlist in self.scene._gcodeVBOs:
					for vbo in layerVBOlist:
						self.scene.glReleaseList.append(vbo)
				self.scene._gcodeVBOs = []
			self.scene._gcode = gcodeInterpreter.gcode()
			self.scene._gcodeFilename = gcodeFilename
			self.scene.printButton.setBottomText('')
			self.scene.setModelView(4)
			self.scene.printButton.setDisabled(False)
			self.scene.OnSliceDone(gcodeFilename)
			self.scene.OnViewChange()
		else:
			if self.scene.getModelView() == 4:
				self.scene.setModelView(0)
				self.scene.OnViewChange()
			self.scene.loadScene(files)
Ejemplo n.º 4
0
	def onOneAtATimeSwitch(self, e):
		profile.putPreference('oneAtATime', self.oneAtATime.IsChecked())
		if self.oneAtATime.IsChecked() and profile.getMachineSettingFloat('extruder_head_size_height') < 1:
			wx.MessageBox(_('For "One at a time" printing, you need to have entered the correct head size and gantry height in the machine settings'), _('One at a time warning'), wx.OK | wx.ICON_WARNING)
		self.scene.updateProfileToControls()
		self.scene._scene.pushFree()
		self.scene.sceneUpdated()
Ejemplo n.º 5
0
	def onOneAtATimeSwitch(self, e):
		profile.putPreference('oneAtATime', self.oneAtATime.IsChecked())
		if self.oneAtATime.IsChecked() and profile.getMachineSettingFloat('extruder_head_size_height') < 1:
			wx.MessageBox(_('For "One at a time" printing, you need to have entered the correct head size and gantry height in the machine settings'), _('One at a time warning'), wx.OK | wx.ICON_WARNING)
		self.scene.updateProfileToControls()
		self.scene._scene.pushFree()
		self.scene.sceneUpdated()
Ejemplo n.º 6
0
	def loadData(self, data, profileType):
		for setting, value in data.items():
			if profileType == 'preference':
				profile.putPreference(setting, value)
			elif profileType == 'profile':
				profile.putProfileSetting(setting, value)
		self._callback()
def main():
	parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
	parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
		help="Load settings from a profile ini file")
	parser.add_option("-r", "--print", action="store", type="string", dest="printfile",
		help="Open the printing interface, instead of the normal cura interface.")
	parser.add_option("-p", "--profile", action="store", type="string", dest="profile",
		help="Internal option, do not use!")
	parser.add_option("-s", "--slice", action="store_true", dest="slice",
		help="Slice the given files instead of opening them in Cura")
	(options, args) = parser.parse_args()

	if options.profile is not None:
		profile.loadGlobalProfileFromString(options.profile)
	if options.profileini is not None:
		profile.loadGlobalProfile(options.profileini)

	if options.printfile is not None:
		from Cura.gui import printWindow
		printWindow.startPrintInterface(options.printfile)
	elif options.slice is not None:
		from Cura.util import sliceRun
		sliceRun.runSlice(args)
	else:
		#Place any unused arguments as last file, so Cura starts with opening those files.
		if len(args) > 0:
			profile.putPreference('lastFile', '^ '.join(args))

		#Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy.
		from Cura.gui import app
		app.CuraApp(args).MainLoop()
Ejemplo n.º 8
0
	def checkAuthorizationThread(self):
		wx.CallAfter(self._indicatorWindow.showBusy, _("Checking token"))
		if not self._ym.isAuthorized():
			wx.CallAfter(self._indicatorWindow.Hide)
			if not self._ym.isHostReachable():
				wx.CallAfter(wx.MessageBox, _("Failed to contact YouMagine.com"), _("YouMagine error."), wx.OK | wx.ICON_ERROR)
				return
			wx.CallAfter(self._getAuthorizationWindow.Show)
			lastTriedClipboard = ''
			while not self._ym.isAuthorized():
				time.sleep(0.1)
				if self._getAuthorizationWindow.abort:
					wx.CallAfter(self._getAuthorizationWindow.Destroy)
					return
				#TODO: Bug, this should not be called from a python thread but a wx.Timer (wx.TheClipboard does not function from threads on Linux)
				clipboard = getClipboardText()
				if len(clipboard) == 20:
					if clipboard != lastTriedClipboard and re.match('[a-zA-Z0-9]*', clipboard):
						lastTriedClipboard = clipboard
						self._ym.setAuthToken(clipboard)
			profile.putPreference('youmagine_token', self._ym.getAuthToken())
			wx.CallAfter(self._getAuthorizationWindow.Hide)
			wx.CallAfter(self._getAuthorizationWindow.Destroy)
			wx.MessageBox(_("Cura is now authorized to share on YouMagine"), _("YouMagine."), wx.OK | wx.ICON_INFORMATION)
		wx.CallAfter(self._indicatorWindow.Hide)

		#TODO: Would you like to create a new design or add the model to an existing design?
		wx.CallAfter(self._newDesignWindow.Show)
Ejemplo n.º 9
0
def main():
	parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
	parser.add_option("-i", "--ini", action="store", type="string", dest="profileini",
		help="Load settings from a profile ini file")
	parser.add_option("-P", "--project", action="store_true", dest="openprojectplanner",
		help="Open the project planner")
	parser.add_option("-F", "--flat", action="store_true", dest="openflatslicer",
		help="Open the 2D SVG slicer (unfinished)")
	parser.add_option("-r", "--print", action="store", type="string", dest="printfile",
		help="Open the printing interface, instead of the normal cura interface.")
	parser.add_option("-p", "--profile", action="store", type="string", dest="profile",
		help="Internal option, do not use!")
	parser.add_option("-s", "--slice", action="store_true", dest="slice",
		help="Slice the given files instead of opening them in Cura")
	(options, args) = parser.parse_args()

	if options.profile is not None:
		profile.loadGlobalProfileFromString(options.profile)
	if options.profileini is not None:
		profile.loadGlobalProfile(options.profileini)

	if options.openprojectplanner is not None:
		from Cura.gui import projectPlanner
		projectPlanner.main()
	elif options.openflatslicer is not None:
		from Cura.gui import flatSlicerWindow
		flatSlicerWindow.main()
	elif options.printfile is not None:
		from Cura.gui import printWindow
		printWindow.startPrintInterface(options.printfile)
	elif options.slice is not None:
		from Cura.util import sliceRun
		sliceRun.runSlice(args)
	else:
		if len(args) > 0:
			profile.putPreference('lastFile', ';'.join(args))

		import wx._core
		from Cura.gui import splashScreen

		class CuraApp(wx.App):
			def MacOpenFile(self, path):
				try:
					pass
				except Exception as e:
					warnings.warn("File at {p} cannot be read: {e}".format(p=path, e=str(e)))

		def mainWindowRunCallback(splash):
			from Cura.gui import mainWindow
			if splash is not None:
				splash.Show(False)
			mainWindow.main()

		app = CuraApp(False)
		# Apple discourages usage of splash screens on a mac.
		if sys.platform.startswith('darwin'):
			mainWindowRunCallback(None)
		else:
			splashScreen.splashScreen(mainWindowRunCallback)
		app.MainLoop()
Ejemplo n.º 10
0
    def OnSettingChange(self, e):
        if self.type == "profile":
            profile.putProfileSetting(self.configName, self.GetValue())
        else:
            profile.putPreference(self.configName, self.GetValue())
        result = validators.SUCCESS
        msgs = []
        for validator in self.validators:
            res, err = validator.validate()
            if res == validators.ERROR:
                result = res
            elif res == validators.WARNING and result != validators.ERROR:
                result = res
            if res != validators.SUCCESS:
                msgs.append(err)
        if result == validators.ERROR:
            self.ctrl.SetBackgroundColour("Red")
        elif result == validators.WARNING:
            self.ctrl.SetBackgroundColour("Yellow")
        else:
            self.ctrl.SetBackgroundColour(self.defaultBGColour)
        self.ctrl.Refresh()

        self.validationMsg = "\n".join(msgs)
        self.panel.main.UpdatePopup(self)
Ejemplo n.º 11
0
    def __init__(self, parent):
        super(UltimakerCalibrateStepsPerEPage, self).__init__(parent, "Ultimaker Calibration")

        if profile.getPreference("steps_per_e") == "0":
            profile.putPreference("steps_per_e", "865.888")

        self.AddText("Calibrating the Steps Per E requires some manual actions.")
        self.AddText("First remove any filament from your machine.")
        self.AddText("Next put in your filament so the tip is aligned with the\ntop of the extruder drive.")
        self.AddText("We'll push the filament 100mm")
        self.extrudeButton = self.AddButton("Extrude 100mm filament")
        self.AddText("Now measure the amount of extruded filament:\n(this can be more or less then 100mm)")
        self.lengthInput, self.saveLengthButton = self.AddTextCtrlButton("100", "Save")
        self.AddText("This results in the following steps per E:")
        self.stepsPerEInput = self.AddTextCtrl(profile.getPreference("steps_per_e"))
        self.AddText("You can repeat these steps to get better calibration.")
        self.AddSeperator()
        self.AddText(
            "If you still have filament in your printer which needs\nheat to remove, press the heat up button below:"
        )
        self.heatButton = self.AddButton("Heatup for filament removal")

        self.saveLengthButton.Bind(wx.EVT_BUTTON, self.OnSaveLengthClick)
        self.extrudeButton.Bind(wx.EVT_BUTTON, self.OnExtrudeClick)
        self.heatButton.Bind(wx.EVT_BUTTON, self.OnHeatClick)
Ejemplo n.º 12
0
    def __init__(self, parent):
        super(UltimakerCalibrateStepsPerEPage,
              self).__init__(parent, "Ultimaker Calibration")

        if profile.getPreference('steps_per_e') == '0':
            profile.putPreference('steps_per_e', '865.888')

        self.AddText(
            "Calibrating the Steps Per E requires some manual actions.")
        self.AddText("First remove any filament from your machine.")
        self.AddText(
            "Next put in your filament so the tip is aligned with the\ntop of the extruder drive."
        )
        self.AddText("We'll push the filament 100mm")
        self.extrudeButton = self.AddButton("Extrude 100mm filament")
        self.AddText(
            "Now measure the amount of extruded filament:\n(this can be more or less then 100mm)"
        )
        self.lengthInput, self.saveLengthButton = self.AddTextCtrlButton(
            '100', 'Save')
        self.AddText("This results in the following steps per E:")
        self.stepsPerEInput = self.AddTextCtrl(
            profile.getPreference('steps_per_e'))
        self.AddText("You can repeat these steps to get better calibration.")
        self.AddSeperator()
        self.AddText(
            "If you still have filament in your printer which needs\nheat to remove, press the heat up button below:"
        )
        self.heatButton = self.AddButton("Heatup for filament removal")

        self.saveLengthButton.Bind(wx.EVT_BUTTON, self.OnSaveLengthClick)
        self.extrudeButton.Bind(wx.EVT_BUTTON, self.OnExtrudeClick)
        self.heatButton.Bind(wx.EVT_BUTTON, self.OnHeatClick)
Ejemplo n.º 13
0
	def StoreData(self):
		profile.putPreference('machine_width', self.machineWidth.GetValue())
		profile.putPreference('machine_depth', self.machineDepth.GetValue())
		profile.putPreference('machine_height', self.machineHeight.GetValue())
		profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue())
		profile.putProfileSetting('wall_thickness', float(profile.getProfileSettingFloat('nozzle_size')) * 2)
		profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue()))
		profile.putPreference('machine_center_is_zero', str(self.HomeAtCenter.GetValue()))
Ejemplo n.º 14
0
 def StoreData(self):
     profile.putPreference("machine_width", self.machineWidth.GetValue())
     profile.putPreference("machine_depth", self.machineDepth.GetValue())
     profile.putPreference("machine_height", self.machineHeight.GetValue())
     profile.putProfileSetting("nozzle_size", self.nozzleSize.GetValue())
     profile.putProfileSetting("wall_thickness", float(profile.getProfileSettingFloat("nozzle_size")) * 2)
     profile.putPreference("has_heated_bed", str(self.heatedBed.GetValue()))
     profile.putPreference("machine_center_is_zero", str(self.HomeAtCenter.GetValue()))
Ejemplo n.º 15
0
	def _update(self, e):
		for button in self._print_profile_options:
			if button.GetValue():
				profile.putPreference('simpleModeProfile', button.base_filename)
		for button in self._print_material_options:
			if button.GetValue():
				profile.putPreference('simpleModeMaterial', button.base_filename)
		self._callback()
Ejemplo n.º 16
0
 def OnDropFiles(self, filenames):
     for filename in filenames:
         item = ProjectObject(self, filename)
         profile.putPreference('lastFile', item.filename)
         self.list.append(item)
         self.selection = item
         self._updateListbox()
     self.OnListSelect(None)
     self.glCanvas.Refresh()
	def OnDropFiles(self, filenames):
		for filename in filenames:
			item = ProjectObject(self, filename)
			profile.putPreference('lastFile', item.filename)
			self.list.append(item)
			self.selection = item
			self._updateListbox()
		self.OnListSelect(None)
		self.preview.Refresh()
Ejemplo n.º 18
0
	def toggleAdvanced(self, e):

		if profile.getPreference('show_advanced') == 'True':
			profile.putPreference('show_advanced', 'False')
		else:
			profile.putPreference('show_advanced', 'True')
		self.scene.updateAdvancedModeButtonPositions()
		self.scene._drawGui()
		self.scene._OnSize(e)
Ejemplo n.º 19
0
 def onOneAtATimeSwitch(self, e):
     profile.putPreference('oneAtATime', self.oneAtATime.IsChecked())
     if self.oneAtATime.IsChecked() and profile.getMachineSetting('machine_type').startswith('BCN3D'):
         wx.MessageBox(_('At BCN3D we do not recommend printing with the "One at a time" option. Proceed with care.'), _('One at a time warning'), wx.OK | wx.ICON_WARNING)
     if self.oneAtATime.IsChecked() and profile.getMachineSettingFloat('extruder_head_size_height') < 1:
         wx.MessageBox(_('For "One at a time" printing, you need to have entered the correct head size and gantry height in the machine settings'), _('One at a time warning'), wx.OK | wx.ICON_WARNING)
     self.scene.updateProfileToControls()
     self.scene._scene.pushFree()
     self.scene.sceneUpdated()
Ejemplo n.º 20
0
	def _loadModels(self, filelist):
		self.filelist = filelist
		self.SetTitle('Cura - %s - %s' % (version.getVersion(), filelist[-1]))
		profile.putPreference('lastFile', ';'.join(self.filelist))
		self.preview3d.loadModelFiles(self.filelist, True)
		self.preview3d.setViewMode("Normal")
		
		# Update the Model MRU
		for idx in xrange(0, len(self.filelist)):
			self.addToModelMRU(self.filelist[idx])
Ejemplo n.º 21
0
    def _loadModels(self, filelist):
        self.filelist = filelist
        self.SetTitle('Cura - %s - %s' % (version.getVersion(), filelist[-1]))
        profile.putPreference('lastFile', ';'.join(self.filelist))
        self.preview3d.loadModelFiles(self.filelist, True)
        self.preview3d.setViewMode("Normal")

        # Update the Model MRU
        for idx in xrange(0, len(self.filelist)):
            self.addToModelMRU(self.filelist[idx])
Ejemplo n.º 22
0
	def OnAddModel(self, e):
		dlg=wx.FileDialog(self, "Open file to batch prepare", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE)
		dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
		if dlg.ShowModal() == wx.ID_OK:
			for filename in dlg.GetPaths():
				profile.putPreference('lastFile', filename)
				self.list.append(filename)
				self.selection = filename
				self._updateListbox()
		dlg.Destroy()
Ejemplo n.º 23
0
 def _update(self, e):
     for button in self._print_profile_options:
         if button.GetValue():
             profile.putPreference('simpleModeProfile',
                                   button.base_filename)
     for button in self._print_material_options:
         if button.GetValue():
             profile.putPreference('simpleModeMaterial',
                                   button.base_filename)
     self._callback()
Ejemplo n.º 24
0
	def OnAddModel(self, e):
		dlg=wx.FileDialog(self, "Open file to batch prepare", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE)
		dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
		if dlg.ShowModal() == wx.ID_OK:
			for filename in dlg.GetPaths():
				profile.putPreference('lastFile', filename)
				self.list.append(filename)
				self.selection = filename
				self._updateListbox()
		dlg.Destroy()
Ejemplo n.º 25
0
	def OnNormalSwitch(self, e):
		profile.putPreference('startMode', 'Normal')
		dlg = wx.MessageDialog(self, _("Copy the settings from quickprint to your full settings?\n(This will overwrite any full setting modifications you have)"), _("Profile copy"), wx.YES_NO | wx.ICON_QUESTION)
		result = dlg.ShowModal() == wx.ID_YES
		dlg.Destroy()
		if result:
			profile.resetProfile()
			for k, v in self.simpleSettingsPanel.getSettingOverrides().items():
				profile.putProfileSetting(k, v)
			self.updateProfileToAllControls()
		self.updateSliceMode()
Ejemplo n.º 26
0
 def StoreData(self):
     profile.putPreference('machine_width', self.machineWidth.GetValue())
     profile.putPreference('machine_depth', self.machineDepth.GetValue())
     profile.putPreference('machine_height', self.machineHeight.GetValue())
     profile.putProfileSetting('nozzle_size', self.nozzleSize.GetValue())
     profile.putProfileSetting(
         'wall_thickness',
         float(profile.getProfileSettingFloat('nozzle_size')) * 2)
     profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue()))
     profile.putPreference('machine_center_is_zero',
                           str(self.HomeAtCenter.GetValue()))
Ejemplo n.º 27
0
	def OnNormalSwitch(self, e):
		profile.putPreference('startMode', 'Normal')
		dlg = wx.MessageDialog(self, _("Copy the settings from quickprint to your full settings?\n(This will overwrite any full setting modifications you have)"), _("Profile copy"), wx.YES_NO | wx.ICON_QUESTION)
		result = dlg.ShowModal() == wx.ID_YES
		dlg.Destroy()
		if result:
			profile.resetProfile()
			for k, v in self.simpleSettingsPanel.getSettingOverrides().items():
				profile.putProfileSetting(k, v)
			self.updateProfileToAllControls()
		self.updateSliceMode()
Ejemplo n.º 28
0
	def OnModelMRU(self, e):
		fileNum = e.GetId() - self.ID_MRU_MODEL1
		path = self.modelFileHistory.GetHistoryFile(fileNum)
		# Update Model MRU
		self.modelFileHistory.AddFileToHistory(path)  # move up the list
		self.config.SetPath("/ModelMRU")
		self.modelFileHistory.Save(self.config)
		self.config.Flush()
		# Load Model
		profile.putPreference('lastFile', path)
		filelist = [ path ]
		self.scene.loadScene(filelist)
Ejemplo n.º 29
0
	def _update(self, e):
		profile.putPreference('active_nozzle', float(self.nozzle_size_combo.GetStringSelection()))
		profile.putProfileSetting('nozzle_size', float(self.nozzle_size_combo.GetStringSelection()))
		for button in self._print_profile_options:
			if button.GetValue():
				profile.putPreference('simpleModeProfile', button.base_filename)
		for button in self._print_material_options:
			if button.GetValue():
				profile.putPreference('simpleModeMaterial', button.base_filename)
		profile.putPreference('simpleModePlatformAdhesion', self.platform_adhesion_combo.GetSelection())
		profile.putPreference('simpleModeSupportType', self.platform_adhesion_combo.GetSelection())
		self._callback()
Ejemplo n.º 30
0
	def _showOpenDialog(self, title, wildcard = meshLoader.wildcardFilter()):
		dlg=wx.FileDialog(self, title, os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
		dlg.SetWildcard(wildcard)
		if dlg.ShowModal() == wx.ID_OK:
			filename = dlg.GetPath()
			dlg.Destroy()
			if not(os.path.exists(filename)):
				return False
			profile.putPreference('lastFile', filename)
			return filename
		dlg.Destroy()
		return False
Ejemplo n.º 31
0
 def OnModelMRU(self, e):
     fileNum = e.GetId() - self.ID_MRU_MODEL1
     path = self.modelFileHistory.GetHistoryFile(fileNum)
     # Update Model MRU
     self.modelFileHistory.AddFileToHistory(path)  # move up the list
     self.config.SetPath("/ModelMRU")
     self.modelFileHistory.Save(self.config)
     self.config.Flush()
     # Load Model
     profile.putPreference('lastFile', path)
     filelist = [path]
     self.scene.loadFiles(filelist)
	def OnAddModel(self, e):
		dlg=wx.FileDialog(self, "Open file to print", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE)
		dlg.SetWildcard(meshLoader.wildcardFilter())
		if dlg.ShowModal() == wx.ID_OK:
			for filename in dlg.GetPaths():
				item = ProjectObject(self, filename)
				profile.putPreference('lastFile', item.filename)
				self.list.append(item)
				self.selection = item
				self._updateListbox()
				self.OnListSelect(None)
		self.preview.Refresh()
		dlg.Destroy()
Ejemplo n.º 33
0
	def loadData(self, data, profileType):
		# Get the support settings user has set
		raft = profile.getProfileSetting('platform_adhesion')
		support = profile.getProfileSetting('support')
		for setting, value in data.items():
			if profileType == 'preference':
				profile.putPreference(setting, value)
			elif profileType == 'profile':
				profile.putProfileSetting(setting, value)
		# Add support preferences at the end to make sure they're not written over to 'None'
		profile.putProfileSetting('platform_adhesion', raft)
		profile.putProfileSetting('support', support)
		self.normalSettingsPanel.updateProfileToControls()
Ejemplo n.º 34
0
def main():
    parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
    parser.add_option("-i",
                      "--ini",
                      action="store",
                      type="string",
                      dest="profileini",
                      help="Load settings from a profile ini file")
    parser.add_option(
        "-r",
        "--print",
        action="store",
        type="string",
        dest="printfile",
        help=
        "Open the printing interface, instead of the normal cura interface.")
    parser.add_option("-p",
                      "--profile",
                      action="store",
                      type="string",
                      dest="profile",
                      help="Internal option, do not use!")
    parser.add_option(
        "-s",
        "--slice",
        action="store_true",
        dest="slice",
        help="Slice the given files instead of opening them in Cura")
    (options, args) = parser.parse_args()

    if options.profile is not None:
        profile.loadGlobalProfileFromString(options.profile)
    if options.profileini is not None:
        profile.loadGlobalProfile(options.profileini)

    if options.printfile is not None:
        from Cura.gui import printWindow
        printWindow.startPrintInterface(options.printfile)
    elif options.slice is not None:
        from Cura.util import sliceRun
        sliceRun.runSlice(args)
    else:
        #Place any unused arguments as last file, so Cura starts with opening those files.
        if len(args) > 0:
            profile.putPreference('lastFile', ';'.join(args))
            profile.putProfileSetting('model_matrix', '1,0,0,0,1,0,0,0,1')
            profile.setPluginConfig([])

        #Do not import anything from Cura.gui before this spot, as the above code also needs to run in pypy.
        from Cura.gui import app
        app.CuraApp().MainLoop()
Ejemplo n.º 35
0
	def _update(self, e):
		profile_name = self._getActiveProfileName()
		material_name = self._getActiveMaterialName()
		nozzle_name = self._getActiveNozzleSizeName()
		if profile_name is None:
			try:
				self._print_profile_options[1].SetValue(True)
				profile_name = self._getActiveProfileName()
			except:
				print("Max : Array index error :", sys.exc_info()[0])

		if material_name is None:
			if len(self._print_material_options) > 0:
				self._print_material_options[0].SetValue(True)
				material_name = self._getActiveMaterialName()
			else:
				material_name = ''
		if nozzle_name is None:
			if len(self._print_nozzle_options) > 0:
				self._print_nozzle_options[0].SetValue(True)
				nozzle_name = self._getActiveNozzleSizeName()
			else:
				nozzle_name = ''

		profile.putPreference('simpleModeProfile', profile_name)
		profile.putPreference('simpleModeMaterial', material_name)
		profile.putPreference('simpleModeNozzle', nozzle_name)
		profile.putPreference('simpleModePlatformAdhesion', self.platform_adhesion_combo.GetSelection())

		self._updateAvailableOptions()
		self._callback()
Ejemplo n.º 36
0
 def OnLoadModel(self, e):
     dlg = wx.FileDialog(
         self,
         "Open file to print",
         os.path.split(profile.getPreference("lastFile"))[0],
         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
     )
     dlg.SetWildcard(meshLoader.wildcardFilter())
     if dlg.ShowModal() == wx.ID_OK:
         self.filelist = [dlg.GetPath()]
         profile.putPreference("lastFile", ";".join(self.filelist))
         self.preview3d.loadModelFiles(self.filelist, True)
         self.preview3d.setViewMode("Normal")
     dlg.Destroy()
    def _update(self, e):
        profile_name = self._getActiveProfileName()
        material_name = self._getActiveMaterialName()
        nozzle_name = self._getActiveNozzleSizeName()
        if profile_name is None:
            self._print_profile_options[1].SetValue(True)
            profile_name = self._getActiveProfileName()

        if material_name is None:
            if len(self._print_material_options) > 0:
                self._print_material_options[0].SetValue(True)
                material_name = self._getActiveMaterialName()
            else:
                material_name = ''
        if nozzle_name is None:
            if len(self._print_nozzle_options) > 0:
                self._print_nozzle_options[0].SetValue(True)
                nozzle_name = self._getActiveNozzleSizeName()
            else:
                nozzle_name = ''

        profile.putPreference('simpleModeProfile', profile_name)
        profile.putPreference('simpleModeMaterial', material_name)
        profile.putPreference('simpleModeNozzle', nozzle_name)
        profile.putPreference('simpleModePlatformAdhesion',
                              self.platform_adhesion_combo.GetSelection())

        self._updateAvailableOptions()
        self._callback()
Ejemplo n.º 38
0
def main():
	if profile.getPreference('machine_type') == 'unknown':
		if platform.system() == "Darwin":
			#Check if we need to copy our examples
			exampleFile = os.path.expanduser('~/CuraExamples/UltimakerRobot_support.stl')
			if not os.path.isfile(exampleFile):
				try:
					os.makedirs(os.path.dirname(exampleFile))
				except:
					pass
				for filename in glob.glob(os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'example', '*.*'))):
					shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
				profile.putPreference('lastFile', exampleFile)
		configWizard.configWizard()
	mainWindow()
Ejemplo n.º 39
0
 def onOneAtATimeSwitch(self, e):
     profile.putPreference('oneAtATime', self.oneAtATime.IsChecked())
     if self.oneAtATime.IsChecked() and profile.getMachineSetting(
             'machine_type').startswith('BCN3D'):
         wx.MessageBox(
             _('At BCN3D we do not recommend printing with the "One at a time" option. Proceed with care.'
               ), _('One at a time warning'), wx.OK | wx.ICON_WARNING)
     if self.oneAtATime.IsChecked(
     ) and profile.getMachineSettingFloat('extruder_head_size_height') < 1:
         wx.MessageBox(
             _('For "One at a time" printing, you need to have entered the correct head size and gantry height in the machine settings'
               ), _('One at a time warning'), wx.OK | wx.ICON_WARNING)
     self.scene.updateProfileToControls()
     self.scene._scene.pushFree()
     self.scene.sceneUpdated()
Ejemplo n.º 40
0
	def OnPageFinished(self, e):
		print "Configuration wizard finished..."
		name = self.configurationPage.printersPanel.name
		extruder_amount = self.configurationPage.optionsPanel.extruder_amount
		nozzle_size = self.configurationPage.optionsPanel.nozzle_size

		xml_file = name.lower() + '.xml'
		if name in ['Magis'] and not nozzle_size == 0.4:
			xml_file = name.lower() + '_' + str(nozzle_size) + '.xml'
		if name in ['DiscoEasy200', 'DiscoUltimate', 'Perso2020'] and int(extruder_amount) == 2:
			xml_file = name.lower() + '_dual.xml'
		profile.putPreference('xml_file', xml_file)

		if self.parent is not None:
			self.parent.ReloadSettingPanels()
Ejemplo n.º 41
0
 def _showOpenDialog(self, title, wildcard=meshLoader.wildcardFilter()):
     dlg = wx.FileDialog(self,
                         title,
                         os.path.split(
                             profile.getPreference('lastFile'))[0],
                         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
     dlg.SetWildcard(wildcard)
     if dlg.ShowModal() == wx.ID_OK:
         filename = dlg.GetPath()
         dlg.Destroy()
         if not (os.path.exists(filename)):
             return False
         profile.putPreference('lastFile', filename)
         return filename
     dlg.Destroy()
     return False
Ejemplo n.º 42
0
	def OnNormalSwitch(self, e):
		profile.putPreference('startMode', 'Normal')
		dlg = wx.MessageDialog(self, _("Copy the settings from quickprint to your full settings?\n(This will overwrite any full setting modifications you have)"), _("Profile copy"), wx.YES_NO | wx.ICON_QUESTION)
		result = dlg.ShowModal() == wx.ID_YES
		dlg.Destroy()
		if result:
			profile.resetProfile()
			for k, v in self.simpleSettingsPanel.getSettingOverrides().items():
				if profile.getMachineSetting('machine_type').startswith('ultimaker2+'):
					if k == 'nozzle_size':
						v = round(float(v) * 1.14, 2)
					if k == 'wall_thickness':
						v = round(float(v) * 1.14, 1)
				profile.putProfileSetting(k, v)
			self.updateProfileToAllControls()
		self.updateSliceMode()
Ejemplo n.º 43
0
    def OnBrowseSDRootFolder(self, e):
        path = profile.getPreference('sdcard_rootfolder')
        if path == '':
            path = os.path.expanduser('~/Documents')
            if not os.path.exists(path):
                path = ''

        dlg = wx.DirDialog(self, _("Select replication root folder"), path)
        if dlg.ShowModal() != wx.ID_OK:
            dlg.Destroy()
            return

        profile.putPreference('sdcard_rootfolder', dlg.GetPath())
        dlg.Destroy()
        self.Close()
        self.parent.OnPreferences(None)
	def OnBrowseSDRootFolder(self, e):
		path = profile.getPreference('sdcard_rootfolder')
		if path == '':
			path = os.path.expanduser('~/Documents')
			if not os.path.exists(path):
				path = ''

		dlg=wx.DirDialog(self, _("Select replication root folder"), path)
		if dlg.ShowModal() != wx.ID_OK:
			dlg.Destroy()
			return

		profile.putPreference('sdcard_rootfolder', dlg.GetPath())
		dlg.Destroy()
		self.Close()
		self.parent.OnPreferences(None)
Ejemplo n.º 45
0
 def OnAddModel(self, e):
     dlg = wx.FileDialog(
         self,
         "Open file to print",
         os.path.split(profile.getPreference('lastFile'))[0],
         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE)
     dlg.SetWildcard(meshLoader.wildcardFilter())
     if dlg.ShowModal() == wx.ID_OK:
         for filename in dlg.GetPaths():
             item = ProjectObject(self, filename)
             profile.putPreference('lastFile', item.filename)
             self.list.append(item)
             self.selection = item
             self._updateListbox()
             self.OnListSelect(None)
     self.glCanvas.Refresh()
     dlg.Destroy()
Ejemplo n.º 46
0
	def StoreData(self):
		profile.putPreference('ultimaker_extruder_upgrade', str(self.springExtruder.GetValue()))
		profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue()))
		if self.dualExtrusion.GetValue():
			profile.putPreference('extruder_amount', '2')
		else:
			profile.putPreference('extruder_amount', '1')
		if profile.getPreference('ultimaker_extruder_upgrade') == 'True':
			profile.putProfileSetting('retraction_enable', 'True')
		else:
			profile.putProfileSetting('retraction_enable', 'False')
Ejemplo n.º 47
0
 def StoreData(self):
     profile.putPreference('ultimaker_extruder_upgrade',
                           str(self.springExtruder.GetValue()))
     profile.putPreference('has_heated_bed', str(self.heatedBed.GetValue()))
     if self.dualExtrusion.GetValue():
         profile.putPreference('extruder_amount', '2')
     else:
         profile.putPreference('extruder_amount', '1')
     if profile.getPreference('ultimaker_extruder_upgrade') == 'True':
         profile.putProfileSetting('retraction_enable', 'True')
     else:
         profile.putProfileSetting('retraction_enable', 'False')
Ejemplo n.º 48
0
 def OnNormalSwitch(self, e):
     profile.putPreference('startMode', 'Normal')
     dlg = wx.MessageDialog(
         self,
         _("Copy the settings from quickprint to your full settings?\n(This will overwrite any full setting modifications you have)"
           ), _("Profile copy"), wx.YES_NO | wx.ICON_QUESTION)
     result = dlg.ShowModal() == wx.ID_YES
     dlg.Destroy()
     if result:
         profile.resetProfile()
         for k, v in self.simpleSettingsPanel.getSettingOverrides().items():
             if profile.getMachineSetting('machine_type').startswith(
                     'ultimaker2+'):
                 if k == 'nozzle_size':
                     v = round(float(v) * 1.14, 2)
                 if k == 'wall_thickness':
                     v = round(float(v) * 1.14, 1)
             profile.putProfileSetting(k, v)
         self.updateProfileToAllControls()
     self.updateSliceMode()
Ejemplo n.º 49
0
    def __init__(self, parent=None, firstTime=True):
        super(ConfigWizard, self).__init__(parent, -1,
                                           _("Configuration wizard"))

        self.parent = parent
        if firstTime:
            profile.putPreference('xml_file', 'discovery200.xml')

        frameicon = wx.Icon(resources.getPathForImage('cura.ico'),
                            wx.BITMAP_TYPE_ICO)
        self.SetIcon(frameicon)

        self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGED, self.OnPageChanged)
        self.Bind(wx.wizard.EVT_WIZARD_FINISHED, self.OnPageFinished)

        self.configurationPage = ConfigurationPage(self, firstTime)

        #self.FitToPage(self.configurationPage)
        self.GetPageAreaSizer().Add(self.configurationPage)
        self.RunWizard(self.configurationPage)
        self.Destroy()
Ejemplo n.º 50
0
    def OnPageFinished(self, e):
        print "Configuration wizard finished..."
        disco_addons_printers = self.configurationPage.optionsPanel.disco_addons_printers
        multinozzle_printers = self.configurationPage.optionsPanel.multinozzle_printers
        name = self.configurationPage.printersPanel.name
        extruder_amount = self.configurationPage.optionsPanel.extruder_amount
        machine_width = self.configurationPage.optionsPanel.machine_width
        nozzle_size = self.configurationPage.optionsPanel.nozzle_size

        if name in disco_addons_printers:
            machine_width = 205 if machine_width < 205 else machine_width
        profile.putMachineSetting('machine_width', machine_width)

        xml_file = name.lower() + '.xml'
        if name in multinozzle_printers and not nozzle_size == 0.4:
            xml_file = name.lower() + '_' + str(nozzle_size) + '.xml'
        if name in disco_addons_printers and int(extruder_amount) == 2:
            xml_file = name.lower() + '_dual.xml'
        profile.putPreference('xml_file', xml_file)

        if self.parent is not None:
            self.parent.ReloadSettingPanels()
Ejemplo n.º 51
0
	def showLoadModel(self, button = 1):
		if button == 1:
			dlg=wx.FileDialog(self, 'Open 3D model', os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE)
			dlg.SetWildcard(meshLoader.loadWildcardFilter() + "|GCode file (*.gcode)|*.g;*.gcode;*.G;*.GCODE")
			if dlg.ShowModal() != wx.ID_OK:
				dlg.Destroy()
				return
			filenames = dlg.GetPaths()
			dlg.Destroy()
			if len(filenames) < 1:
				return False
			profile.putPreference('lastFile', filenames[0])
			gcodeFilename = None
			for filename in filenames:
				self.GetParent().GetParent().GetParent().addToModelMRU(filename)
				ext = filename[filename.rfind('.')+1:].upper()
				if ext == 'G' or ext == 'GCODE':
					gcodeFilename = filename
			if gcodeFilename is not None:
				if self._gcode is not None:
					self._gcode = None
					for layerVBOlist in self._gcodeVBOs:
						for vbo in layerVBOlist:
							self.glReleaseList.append(vbo)
					self._gcodeVBOs = []
				self._gcode = gcodeInterpreter.gcode()
				self._gcodeFilename = gcodeFilename
				self.printButton.setBottomText('')
				self.viewSelection.setValue(4)
				self.printButton.setDisabled(False)
				self.OnViewChange()
			else:
				if self.viewSelection.getValue() == 4:
					self.viewSelection.setValue(0)
					self.OnViewChange()
				self.loadScene(filenames)
Ejemplo n.º 52
0
	def afterSplashCallback(self):
		#These imports take most of the time and thus should be done after showing the splashscreen
		import webbrowser
		from Cura.gui import mainWindow
		from Cura.gui import configWizard
		from Cura.gui import newVersionDialog
		from Cura.util import profile
		from Cura.util import resources
		from Cura.util import version

		resources.setupLocalization(profile.getPreference('language'))  # it's important to set up localization at very beginning to install _

		#If we do not have preferences yet, try to load it from a previous Cura install
		if profile.getMachineSetting('machine_type') == 'unknown':
			try:
				otherCuraInstalls = profile.getAlternativeBasePaths()
				otherCuraInstalls.sort()
				if len(otherCuraInstalls) > 0:
					profile.loadPreferences(os.path.join(otherCuraInstalls[-1], 'preferences.ini'))
					profile.loadProfile(os.path.join(otherCuraInstalls[-1], 'current_profile.ini'))
			except:
				import traceback
				print traceback.print_exc()

		#If we haven't run it before, run the configuration wizard.
		if profile.getMachineSetting('machine_type') == 'unknown':
			if platform.system() == "Windows":
				exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'UltimakerRobot_support.stl'))
			else:
				#Check if we need to copy our examples
				exampleFile = os.path.expanduser('~/CuraExamples/UltimakerRobot_support.stl')
				if not os.path.isfile(exampleFile):
					try:
						os.makedirs(os.path.dirname(exampleFile))
					except:
						pass
					for filename in glob.glob(os.path.normpath(os.path.join(resources.resourceBasePath, 'example', '*.*'))):
						shutil.copy(filename, os.path.join(os.path.dirname(exampleFile), os.path.basename(filename)))
			self.loadFiles = [exampleFile]
			if self.splash is not None:
				self.splash.Show(False)
			configWizard.configWizard()

		if profile.getPreference('check_for_updates') == 'True':
			newVersion = version.checkForNewerVersion()
			if newVersion is not None:
				if self.splash is not None:
					self.splash.Show(False)
				if wx.MessageBox(_("A new version of Cura is available, would you like to download?"), _("New version available"), wx.YES_NO | wx.ICON_INFORMATION) == wx.YES:
					webbrowser.open(newVersion)
					return
		if profile.getMachineSetting('machine_name') == '':
			return
		self.mainWindow = mainWindow.mainWindow()
		if self.splash is not None:
			self.splash.Show(False)
		self.SetTopWindow(self.mainWindow)
		self.mainWindow.Show()
		self.mainWindow.OnDropFiles(self.loadFiles)
		if profile.getPreference('last_run_version') != version.getVersion(False):
			profile.putPreference('last_run_version', version.getVersion(False))
			#newVersionDialog.newVersionDialog().Show()

		setFullScreenCapable(self.mainWindow)

		if sys.platform.startswith('darwin'):
			wx.CallAfter(self.StupidMacOSWorkaround)
Ejemplo n.º 53
0
    def afterSplashCallback(self):
        #These imports take most of the time and thus should be done after showing the splashscreen
        import webbrowser
        from Cura.gui import mainWindow
        from Cura.gui import configWizard
        from Cura.gui import newVersionDialog
        from Cura.util import profile
        from Cura.util import resources
        from Cura.util import version

        resources.setupLocalization(
            profile.getPreference('language')
        )  # it's important to set up localization at very beginning to install _

        #If we do not have preferences yet, try to load it from a previous Cura install
        # Don't look for old versions
        '''
		if profile.getMachineSetting('machine_type') == 'unknown':
			try:
				otherCuraInstalls = profile.getAlternativeBasePaths()
				for path in otherCuraInstalls[::-1]:
					try:
						print 'Loading old settings from %s' % (path)
						profile.loadPreferences(os.path.join(path, 'preferences.ini'))
						profile.loadProfile(os.path.join(path, 'current_profile.ini'))
						break
					except:
						import traceback
						print traceback.print_exc()
			except:
				import traceback
				print traceback.print_exc()
		'''

        #If we haven't run it before, run the configuration wizard.
        if profile.getMachineSetting('machine_type') == 'unknown':
            #Check if we need to copy our examples
            exampleFile = os.path.normpath(
                os.path.join(resources.resourceBasePath, 'example',
                             '3DK-printing-sample.STL'))

            self.loadFiles = [exampleFile]
            if self.splash is not None:
                self.splash.Show(False)
            configWizard.ConfigWizard()

        if profile.getPreference('check_for_updates') == 'NOPE':
            newVersion = version.checkForNewerVersion()
            if newVersion is not None:
                if self.splash is not None:
                    self.splash.Show(False)
                if wx.MessageBox(
                        _("A new version of Cura is available, would you like to download?"
                          ), _("New version available"),
                        wx.YES_NO | wx.ICON_INFORMATION) == wx.YES:
                    webbrowser.open(newVersion)
                    return
        if profile.getMachineSetting('machine_name') == '':
            return
        self.mainWindow = mainWindow.mainWindow()
        if self.splash is not None:
            self.splash.Show(False)
        self.SetTopWindow(self.mainWindow)
        self.mainWindow.Show()
        self.mainWindow.OnDropFiles(self.loadFiles)
        if profile.getPreference('last_run_version') != version.getVersion(
                False):
            profile.putPreference('last_run_version',
                                  version.getVersion(False))
            newVersionDialog.newVersionDialog().Show()

        setFullScreenCapable(self.mainWindow)

        if sys.platform.startswith('darwin'):
            wx.CallAfter(self.StupidMacOSWorkaround)
Ejemplo n.º 54
0
    def OnClose(self, e):
        profile.saveProfile(profile.getDefaultProfilePath(), True)

        # Save the window position, size & state from the preferences file
        profile.putPreference('window_maximized', self.IsMaximized())
        if not self.IsMaximized() and not self.IsIconized():
            (posx, posy) = self.GetPosition()
            profile.putPreference('window_pos_x', posx)
            profile.putPreference('window_pos_y', posy)
            (width, height) = self.GetSize()
            profile.putPreference('window_width', width)
            profile.putPreference('window_height', height)

            # Save normal sash position.  If in normal mode (!simple mode), get last position of sash before saving it...
            isSimple = profile.getPreference('startMode') == 'Simple'
            if not isSimple:
                self.normalSashPos = self.splitter.GetSashPosition()
            profile.putPreference('window_normal_sash', self.normalSashPos)

        #HACK: Set the paint function of the glCanvas to nothing so it won't keep refreshing. Which can keep wxWidgets from quiting.
        print "Closing down"
        self.scene.OnPaint = lambda e: e
        self.scene._engine.cleanup()
        self.Destroy()
Ejemplo n.º 55
0
 def OnNormalSwitch(self, e):
     profile.putPreference('startMode', 'Normal')
     self.updateSliceMode()
Ejemplo n.º 56
0
 def OnSimpleSwitch(self, e):
     profile.putPreference('startMode', 'Simple')
     self.updateSliceMode()
Ejemplo n.º 57
0
	def OnSimpleSwitch(self, e):
		profile.putPreference('startMode', 'Simple')
		profile.putProfileSetting('nozzle_size', profile.getPreference("active_nozzle"))
		self.updateSliceMode()
Ejemplo n.º 58
0
 def OnDropFiles(self, filenames):
     for filename in filenames:
         profile.putPreference('lastFile', filename)
         self.list.append(filename)
         self.selection = filename
         self._updateListbox()