Exemple #1
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)
Exemple #2
0
	def __init__(self, port = None, baudrate = None, callbackObject = None):
		if port == None:
			port = profile.getPreference('serial_port')
		if baudrate == None:
			if profile.getPreference('serial_baud') == 'AUTO':
				baudrate = 0
			else:
				baudrate = int(profile.getPreference('serial_baud'))
		if callbackObject == None:
			callbackObject = MachineComPrintCallback()

		self._port = port
		self._baudrate = baudrate
		self._callback = callbackObject
		self._state = self.STATE_NONE
		self._serial = None
		self._baudrateDetectList = baudrateList()
		self._baudrateDetectRetry = 0
		self._temp = 0
		self._bedTemp = 0
		self._targetTemp = 0
		self._bedTargetTemp = 0
		self._gcodeList = None
		self._gcodePos = 0
		self._commandQueue = queue.Queue()
		self._logQueue = queue.Queue(256)
		self._feedRateModifier = {}
		self._currentZ = -1
		self._heatupWaitStartTime = 0
		self._heatupWaitTimeLost = 0.0
		self._printStartTime100 = None
		
		self.thread = threading.Thread(target=self._monitor)
		self.thread.daemon = True
		self.thread.start()
Exemple #3
0
    def __init__(self, port=None, baudrate=None, callbackObject=None):
        if port == None:
            port = profile.getPreference('serial_port')
        if baudrate == None:
            if profile.getPreference('serial_baud') == 'AUTO':
                baudrate = 0
            else:
                baudrate = int(profile.getPreference('serial_baud'))
        if callbackObject == None:
            callbackObject = MachineComPrintCallback()

        self._port = port
        self._baudrate = baudrate
        self._callback = callbackObject
        self._state = self.STATE_NONE
        self._serial = None
        self._baudrateDetectList = baudrateList()
        self._baudrateDetectRetry = 0
        self._temp = 0
        self._bedTemp = 0
        self._targetTemp = 0
        self._bedTargetTemp = 0
        self._gcodeList = None
        self._gcodePos = 0
        self._commandQueue = queue.Queue()
        self._logQueue = queue.Queue(256)
        self._feedRateModifier = {}
        self._currentZ = -1
        self._heatupWaitStartTime = 0
        self._heatupWaitTimeLost = 0.0
        self._printStartTime100 = None

        self.thread = threading.Thread(target=self._monitor)
        self.thread.daemon = True
        self.thread.start()
Exemple #4
0
	def OnSlice(self, e):
		dlg=wx.FileDialog(self, "Save project gcode file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
		dlg.SetWildcard("GCode file (*.gcode)|*.gcode")
		if dlg.ShowModal() != wx.ID_OK:
			dlg.Destroy()
			return
		resultFilename = dlg.GetPath()
		dlg.Destroy()

		put = profile.setTempOverride
		oldProfile = profile.getGlobalProfileString()
		
		if self.printMode == 0:
			fileList = []
			positionList = []
			for item in self.list:
				fileList.append(item.filename)
				if profile.getPreference('machine_center_is_zero') == 'True':
					pos = [item.centerX - self.machineSize[0] / 2, item.centerY - self.machineSize[1] / 2]
				else:
					pos = [item.centerX, item.centerY]
				positionList.append(pos + (item.mesh.matrix * item.scale).reshape((9,)).tolist())
			sliceCommand = sliceRun.getSliceCommand(resultFilename, fileList, positionList)
		else:
			self._saveCombinedSTL(resultFilename + "_temp_.stl")
			sliceCommand = sliceRun.getSliceCommand(resultFilename, [resultFilename + "_temp_.stl"], [profile.getMachineCenterCoords()])

		pspw = ProjectSliceProgressWindow(sliceCommand, resultFilename, len(self.list))
		pspw.Centre()
		pspw.Show(True)
Exemple #5
0
	def OnCopyToSD(self, e):
		for f in self.filenameList:
			exportFilename = sliceRun.getExportFilename(f)
			filename = os.path.basename(exportFilename)
			if profile.getPreference('sdshortnames') == 'True':
				filename = sliceRun.getShortFilename(filename)
			shutil.copy(exportFilename, os.path.join(profile.getPreference('sdpath'), filename))
 def OnCopyToSD(self, e):
     if profile.getPreference('sdpath') == '':
         wx.MessageBox(
             "You need to configure your SD card drive first before you can copy files to it.\nOpening the preferences now.",
             'No SD card drive.', wx.OK | wx.ICON_INFORMATION)
         prefDialog = preferencesDialog.preferencesDialog(self.GetParent())
         prefDialog.Centre()
         prefDialog.Show(True)
         if profile.getPreference('sdpath') == '':
             print "No path set"
             return
     exportFilename = sliceRun.getExportFilename(self.filelist[0])
     filename = os.path.basename(exportFilename)
     if profile.getPreference('sdshortnames') == 'True':
         filename = sliceRun.getShortFilename(filename)
     try:
         shutil.copy(
             exportFilename,
             os.path.join(profile.getPreference('sdpath'), filename))
     except:
         self.GetParent().preview3d.ShowWarningPopup(
             "Failed to copy file to SD card.")
         return
     self.GetParent().preview3d.ShowWarningPopup(
         "Copy finished, safely remove SD card?", self.OnSafeRemove)
Exemple #7
0
	def OnCopyToSD(self, e):
		for f in self.filenameList:
			exportFilename = sliceRun.getExportFilename(f)
			filename = os.path.basename(exportFilename)
			if profile.getPreference('sdshortnames') == 'True':
				filename = sliceRun.getShortFilename(filename)
			shutil.copy(exportFilename, os.path.join(profile.getPreference('sdpath'), filename))
Exemple #8
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)
Exemple #9
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.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.mainWindow.Show()
		self.mainWindow.OnDropFiles(self.loadFiles)

		setFullScreenCapable(self.mainWindow)
Exemple #10
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.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', 'lugo-hand2.stl'))
			else:
				#Check if we need to copy our examples
				exampleFile = os.path.expanduser('~/CuraExamples/lugo-hand2.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.mainWindow.Show()
		self.mainWindow.OnDropFiles(self.loadFiles)

		setFullScreenCapable(self.mainWindow)
Exemple #11
0
def baudrateList():
	ret = [250000, 230400, 115200, 57600, 38400, 19200, 9600]
	if profile.getPreference('serial_baud_auto') != '':
		prev = int(profile.getPreference('serial_baud_auto'))
		if prev in ret:
			ret.remove(prev)
			ret.insert(0, prev)
	return ret
Exemple #12
0
def baudrateList():
    ret = [250000, 230400, 115200, 57600, 38400, 19200, 9600]
    if profile.getPreference('serial_baud_auto') != '':
        prev = int(profile.getPreference('serial_baud_auto'))
        if prev in ret:
            ret.remove(prev)
            ret.insert(0, prev)
    return ret
Exemple #13
0
	def OnAddNewMachine(self, e):
		self.Hide()
		wasSimple = profile.getPreference('startMode') == 'Simple'
		configWizard.ConfigWizard(True)
		isSimple = profile.getPreference('startMode') == 'Simple'
		self.Show()
		self.reloadSettingPanels(isSimple != wasSimple)
		self.updateMachineMenu()
Exemple #14
0
	def OnAddNewMachine(self, e):
		self.Hide()
		wasSimple = profile.getPreference('startMode') == 'Simple'
		configWizard.ConfigWizard(True)
		isSimple = profile.getPreference('startMode') == 'Simple'
		self.Show()
		self.reloadSettingPanels(isSimple != wasSimple)
		self.updateMachineMenu()
    def __init__(self, mainWindow, parent, filelist):
        wx.Panel.__init__(self, parent, -1)
        self.mainWindow = mainWindow
        self.filelist = filelist
        self.abort = False

        box = wx.StaticBox(self, -1, filelist[0])
        self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

        self.statusText = wx.StaticText(self, -1, "Starting...")
        self.progressGauge = wx.Gauge(self, -1)
        self.progressGauge.SetRange(10000 * len(filelist))
        self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
        self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER)
        self.sizer.Add(self.progressGauge, 2)
        self.sizer.Add(self.abortButton, 0)

        self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

        self.SetSizer(mainSizer)
        self.prevStep = 'start'
        self.totalDoneFactor = 0.0
        self.startTime = time.time()
        if profile.getPreference('save_profile') == 'True':
            profile.saveGlobalProfile(
                self.filelist[0][:self.filelist[0].rfind('.')] +
                "_profile.ini")
        center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
        outputFilename = sliceRun.getExportFilename(self.filelist[0])

        if profile.getPreference('filename_prompt') == 'True' or (
                os.path.exists(outputFilename)
                and profile.getPreference('file_overwrite_prompt') == 'True'):
            style = wx.FD_SAVE
            if profile.getPreference('file_overwrite_prompt') == 'True':
                style = style | wx.FD_OVERWRITE_PROMPT
            dlg = wx.FileDialog(self,
                                "Select gcode file to save",
                                os.path.split(outputFilename)[0],
                                os.path.split(outputFilename)[1],
                                style=style)
            dlg.SetWildcard("gcode files (*.gcode, *.g)|*.gcode;*.g")
            if dlg.ShowModal() != wx.ID_OK:
                dlg.Destroy()
                self.abort = True
                self.statusText.SetLabel("Aborted by user.")
                return
            outputFilename = dlg.GetPath()
            dlg.Destroy()

        cmdList = [
            sliceRun.getSliceCommand(outputFilename, ['|'.join(self.filelist)],
                                     [center])
        ]
        self.thread = WorkerThread(self, filelist, cmdList)
Exemple #16
0
    def updateSliceMode(self, changedMode=True):
        isSimple = profile.getPreference('startMode') == 'Simple'

        self.normalSettingsPanel.Show(not isSimple)
        self.simpleSettingsPanel.Show(isSimple)
        self.leftPane.Layout()

        for i in self.normalModeOnlyItems:
            i.Enable(not isSimple)
        if isSimple:
            self.switchToQuickprintMenuItem.Check()
        else:
            self.switchToNormalMenuItem.Check()

        # Set splitter sash position & size
        if isSimple:
            # Save normal mode sash (only if we changed mode from normal
            # to simple)
            if changedMode:
                self.normalSashPos = self.splitter.GetSashPosition()

            # Change location of sash to width of quick mode pane
            self.simpleSettingsPanel.Layout()
            self.simpleSettingsPanel.Fit()
            (width, height) = self.simpleSettingsPanel.GetSizer().GetSize()
            if width > 0:
                self.splitter.SetSashPosition(width, True)
            else:
                self.splitter.SizeWindows()

            # Disable sash
            self.splitter.SetSashSize(0)
        else:
            # Only change the sash position if we changed mode from simple
            if changedMode:
                self.splitter.SetSashPosition(self.normalSashPos, True)

            # Enabled sash
            self.splitter.SetSashSize(4)
        self.defaultFirmwareInstallMenuItem.Enable(
            firmwareInstall.getDefaultFirmware() is not None)
        if profile.getMachineSetting('machine_type').startswith('ultimaker2') or \
           profile.getMachineSetting('machine_type').startswith('lulzbot_'):
            self.bedLevelWizardMenuItem.Enable(False)
            self.headOffsetWizardMenuItem.Enable(False)
        else:
            self.bedLevelWizardMenuItem.Enable(True)
            self.headOffsetWizardMenuItem.Enable(False)
            self.oneAtATime.Enable(True)
            if profile.getPreference('oneAtATime') == 'True':
                self.oneAtATime.Check(True)
            else:
                self.allAtOnceItem.Check(True)
        if int(profile.getMachineSetting('extruder_amount')) < 2:
            self.headOffsetWizardMenuItem.Enable(False)
        self.scene.updateProfileToControls()
        self.scene._scene.pushFree()
Exemple #17
0
	def updateSliceMode(self, changedMode = True):
		isSimple = profile.getPreference('startMode') == 'Simple'

		self.normalSettingsPanel.Show(not isSimple)
		self.simpleSettingsPanel.Show(isSimple)
		self.leftPane.Layout()

		for i in self.normalModeOnlyItems:
			i.Enable(not isSimple)
		if isSimple:
			self.switchToQuickprintMenuItem.Check()
		else:
			self.switchToNormalMenuItem.Check()

		# Set splitter sash position & size
		if isSimple:
			# Save normal mode sash (only if we changed mode from normal
			# to simple)
			if changedMode:
				self.normalSashPos = self.splitter.GetSashPosition()

			# Change location of sash to width of quick mode pane
			self.simpleSettingsPanel.Layout()
			self.simpleSettingsPanel.Fit()
			(width, height) = self.simpleSettingsPanel.GetSizer().GetSize()
			if width > 0:
				self.splitter.SetSashPosition(width, True)
			else:
				self.splitter.SizeWindows()

			# Disable sash
			self.splitter.SetSashSize(0)
		else:
			# Only change the sash position if we changed mode from simple
			if changedMode:
				self.splitter.SetSashPosition(self.normalSashPos, True)

			# Enabled sash
			self.splitter.SetSashSize(4)
		self.defaultFirmwareInstallMenuItem.Enable(firmwareInstall.getDefaultFirmware() is not None)
		if profile.getMachineSetting('machine_type').startswith('ultimaker2') or \
		   profile.getMachineSetting('machine_type').startswith('lulzbot_'):
			self.bedLevelWizardMenuItem.Enable(False)
			self.headOffsetWizardMenuItem.Enable(False)
		else:
			self.bedLevelWizardMenuItem.Enable(True)
			self.headOffsetWizardMenuItem.Enable(False)
			self.oneAtATime.Enable(True)
			if profile.getPreference('oneAtATime') == 'True':
				self.oneAtATime.Check(True)
			else:
				self.allAtOnceItem.Check(True)
		if int(profile.getMachineSetting('extruder_amount')) < 2:
			self.headOffsetWizardMenuItem.Enable(False)
		self.scene.updateProfileToControls()
		self.scene._scene.pushFree()
    def __init__(self, mainWindow, parent, filelist):
        wx.Panel.__init__(self, parent, -1)
        self.mainWindow = mainWindow
        self.filelist = filelist
        self.abort = False

        box = wx.StaticBox(self, -1, filelist[0])
        self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

        self.statusText = wx.StaticText(self, -1, "Starting...")
        self.progressGauge = wx.Gauge(self, -1)
        self.progressGauge.SetRange(10000 * len(filelist))
        self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
        self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER)
        self.sizer.Add(self.progressGauge, 2)
        self.sizer.Add(self.abortButton, 0)

        self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

        self.SetSizer(mainSizer)
        self.prevStep = "start"
        self.totalDoneFactor = 0.0
        self.startTime = time.time()
        if profile.getPreference("save_profile") == "True":
            profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind(".")] + "_profile.ini")
        center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
        outputFilename = sliceRun.getExportFilename(self.filelist[0])

        if profile.getPreference("filename_prompt") == "True" or (
            os.path.exists(outputFilename) and profile.getPreference("file_overwrite_prompt") == "True"
        ):
            style = wx.FD_SAVE
            if profile.getPreference("file_overwrite_prompt") == "True":
                style = style | wx.FD_OVERWRITE_PROMPT
            dlg = wx.FileDialog(
                self,
                "Select gcode file to save",
                os.path.split(outputFilename)[0],
                os.path.split(outputFilename)[1],
                style=style,
            )
            dlg.SetWildcard("gcode files (*.gcode, *.g)|*.gcode;*.g")
            if dlg.ShowModal() != wx.ID_OK:
                dlg.Destroy()
                self.abort = True
                self.statusText.SetLabel("Aborted by user.")
                return
            outputFilename = dlg.GetPath()
            dlg.Destroy()

        cmdList = [sliceRun.getSliceCommand(outputFilename, ["|".join(self.filelist)], [center])]
        self.thread = WorkerThread(self, filelist, cmdList)
Exemple #19
0
def getDefaultFirmware():
	if profile.getPreference('machine_type') == 'ultimaker':
		if profile.getPreferenceFloat('extruder_amount') > 1:
			return None
		if profile.getPreference('has_heated_bed') == 'True':
			return None
		if sys.platform.startswith('linux'):
			return resources.getPathForFirmware("ultimaker_115200.hex")
		else:
			return resources.getPathForFirmware("ultimaker_250000.hex")
	return None
	def OnSafeRemove(self):
		if platform.system() == "Windows":
			cmd = '"%s" %s>NUL' % (os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'EjectMedia.exe')), profile.getPreference('sdpath'))
		elif platform.system() == "Darwin":
			cmd = "diskutil eject '%s' > /dev/null 2>&1" % (profile.getPreference('sdpath'))
		else:
			cmd = "umount '%s' > /dev/null 2>&1" % (profile.getPreference('sdpath'))
		if os.system(cmd):
			self.GetParent().preview3d.ShowWarningPopup("Safe remove failed.")
		else:
			self.GetParent().preview3d.ShowWarningPopup("You can now eject the card.")
Exemple #21
0
	def OnCustomFirmware(self, e):
		if profile.getPreference('machine_type') == 'ultimaker':
			wx.MessageBox(language.getText('Warning: Installing a custom firmware does not guarantee that you machine will function correctly, and could damage your machine.'), language.getText('Firmware update'), wx.OK | wx.ICON_EXCLAMATION)
		dlg=wx.FileDialog(self, language.getText("Open firmware to upload"), os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
		dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX")
		if dlg.ShowModal() == wx.ID_OK:
			filename = dlg.GetPath()
			if not(os.path.exists(filename)):
				return
			#For some reason my Ubuntu 10.10 crashes here.
			firmwareInstall.InstallFirmware(filename)
Exemple #22
0
	def OnCustomFirmware(self, e):
		if profile.getPreference('machine_type') == 'ultimaker':
			wx.MessageBox('Warning: Installing a custom firmware does not garantee that you machine will function correctly, and could damage your machine.', 'Firmware update', wx.OK | wx.ICON_EXCLAMATION)
		dlg=wx.FileDialog(self, "Open firmware to upload", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
		dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX")
		if dlg.ShowModal() == wx.ID_OK:
			filename = dlg.GetPath()
			if not(os.path.exists(filename)):
				return
			#For some reason my Ubuntu 10.10 crashes here.
			firmwareInstall.InstallFirmware(filename)
Exemple #23
0
def startPrintInterface(filename):
	#startPrintInterface is called from the main script when we want the printer interface to run in a separate process.
	# It needs to run in a separate process, as any running python code blocks the GCode sender python code (http://wiki.python.org/moin/GlobalInterpreterLock).
	app = wx.App(False)
	if profile.getPreference('language') is not None:
		language.switchTo(profile.getPreference('language'))
	printWindowHandle = printWindow()
	printWindowHandle.Show(True)
	printWindowHandle.Raise()
	printWindowHandle.OnConnect(None)
	t = threading.Thread(target=printWindowHandle.LoadGCodeFile, args=(filename,))
	t.daemon = True
	t.start()
	app.MainLoop()
Exemple #24
0
	def __init__(self, parent):
		wx.Panel.__init__(self, parent,-1)

		self.alterationFileList = ['start.gcode', 'end.gcode', 'nextobject.gcode', 'replace.csv']
		if int(profile.getPreference('extruder_amount')) > 1:
			self.alterationFileList.append('switchExtruder.gcode')
		self.currentFile = None

		#self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB)
		#self.textArea.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
		self.textArea = gcodeTextArea.GcodeTextArea(self)
		self.list = wx.ListBox(self, choices=self.alterationFileList, style=wx.LB_SINGLE)
		self.list.SetSelection(0)
		self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list)
		self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea)
		self.textArea.Bind(wx.stc.EVT_STC_CHANGE, self.OnFocusLost, self.textArea)
		
		sizer = wx.GridBagSizer()
		sizer.Add(self.list, (0,0), span=(1,1), flag=wx.EXPAND)
		sizer.Add(self.textArea, (0,1), span=(1,1), flag=wx.EXPAND)
		sizer.AddGrowableCol(1)
		sizer.AddGrowableRow(0)
		self.SetSizer(sizer)
		
		self.loadFile(self.alterationFileList[self.list.GetSelection()])
		self.currentFile = self.list.GetSelection()
Exemple #25
0
    def __init__(self, filename=None, port=None):
        super(InstallFirmware, self).__init__(parent=None,
                                              title="Firmware install",
                                              size=(250, 100))
        if port is None:
            port = profile.getPreference('serial_port')
        if filename is None:
            filename = getDefaultFirmware()
        if filename is None:
            wx.MessageBox(
                'I am sorry, but Cura does not ship with a default firmware for your machine configuration.',
                'Firmware update', wx.OK | wx.ICON_ERROR)
            self.Destroy()
            return

        sizer = wx.BoxSizer(wx.VERTICAL)

        self.progressLabel = wx.StaticText(self, -1, 'Reading firmware...')
        sizer.Add(self.progressLabel, 0, flag=wx.ALIGN_CENTER)
        self.progressGauge = wx.Gauge(self, -1)
        sizer.Add(self.progressGauge, 0, flag=wx.EXPAND)
        self.okButton = wx.Button(self, -1, 'Ok')
        self.okButton.Disable()
        self.okButton.Bind(wx.EVT_BUTTON, self.OnOk)
        sizer.Add(self.okButton, 0, flag=wx.ALIGN_CENTER)
        self.SetSizer(sizer)

        self.filename = filename
        self.port = port

        threading.Thread(target=self.OnRun).start()

        self.ShowModal()
        self.Destroy()
        return
Exemple #26
0
    def __init__(self, parent, callback):
        wx.Panel.__init__(self, parent, -1)

        self.callback = callback
        self.alterationFileList = ['start.gcode', 'end.gcode'
                                   ]  #, 'nextobject.gcode', 'replace.csv'
        if int(profile.getPreference('extruder_amount')) > 1:
            self.alterationFileList += ['start2.gcode', 'end2.gcode']
        self.currentFile = None

        self.textArea = gcodeTextArea.GcodeTextArea(self)
        self.list = wx.ListBox(self,
                               choices=self.alterationFileList,
                               style=wx.LB_SINGLE)
        self.list.SetSelection(0)
        self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list)
        self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea)
        self.textArea.Bind(wx.stc.EVT_STC_CHANGE, self.OnFocusLost,
                           self.textArea)

        sizer = wx.GridBagSizer()
        sizer.Add(self.list, (0, 0), span=(5, 1), flag=wx.EXPAND)
        sizer.Add(self.textArea, (5, 0), span=(5, 1), flag=wx.EXPAND)
        sizer.AddGrowableCol(0)
        sizer.AddGrowableRow(0)
        sizer.AddGrowableRow(5)
        sizer.AddGrowableRow(6)
        sizer.AddGrowableRow(7)
        self.SetSizer(sizer)

        self.loadFile(self.alterationFileList[self.list.GetSelection()])
        self.currentFile = self.list.GetSelection()
Exemple #27
0
    def updateSliceMode(self):
        isSimple = profile.getPreference('startMode') == 'Simple'

        self.normalSettingsPanel.Show(not isSimple)
        self.simpleSettingsPanel.Show(isSimple)
        self.leftPane.Layout()

        for i in self.normalModeOnlyItems:
            i.Enable(not isSimple)
        if isSimple:
            self.switchToQuickprintMenuItem.Check()
        else:
            self.switchToNormalMenuItem.Check()

        # Set splitter sash position & size
        if isSimple:
            # Save normal mode sash
            self.normalSashPos = self.splitter.GetSashPosition()

            # Change location of sash to width of quick mode pane
            (width, height) = self.simpleSettingsPanel.GetSizer().GetSize()
            self.splitter.SetSashPosition(width, True)

            # Disable sash
            self.splitter.SetSashSize(0)
        else:
            self.splitter.SetSashPosition(self.normalSashPos, True)
            # Enabled sash
            self.splitter.SetSashSize(4)
        # self.defaultFirmwareInstallMenuItem.Enable(firmwareInstall.getDefaultFirmware() is not None)
        # if profile.getMachineSetting('machine_type') == 'ultimaker2':
        # 	self.bedLevelWizardMenuItem.Enable(False)
        # 	self.headOffsetWizardMenuItem.Enable(False)
        self.scene.updateProfileToControls()
Exemple #28
0
    def afterSplashCallback(self):
        #These imports take most of the time and thus should be done after showing the splashscreen
        from Cura.gui import configWizard
        from Cura.util import profile
        from Cura.util import resources
        # it's important to set up localization at very beginning to install
        language = profile.getPreference('language')
        resources.setupLocalization(language)

        if self.splash is not None:
            self.splash.Show(False)
            self.splash = None

        #If we haven't run it before, run the configuration wizard.
        if profile.getMachineSetting('machine_name') == '':
            configWizard.ConfigWizard()
            #Check if we need to copy our examples
            exampleFile = os.path.normpath(
                os.path.join(resources.resourceBasePath, 'example',
                             'dagoma.stl'))
            self.loadFiles = [exampleFile]

        from Cura.gui import mainWindow
        self.mainWindow = mainWindow.mainWindow()
        self.SetTopWindow(self.mainWindow)
        self.mainWindow.Show()
        self.mainWindow.OnDropFiles(self.loadFiles)

        setFullScreenCapable(self.mainWindow)

        if sys.platform.startswith('darwin'):
            from Cura.gui.util import macosFramesWorkaround as mfw
            wx.CallAfter(mfw.StupidMacOSWorkaround)
Exemple #29
0
	def __init__(self, parent, callback):
		wx.Panel.__init__(self, parent,-1)

		self.callback = callback
		self.alterationFileList = ['start.gcode', 'end.gcode']#, 'nextobject.gcode', 'replace.csv'
		if int(profile.getPreference('extruder_amount')) > 1:
			self.alterationFileList += ['start2.gcode', 'end2.gcode']
		self.currentFile = None

		self.textArea = gcodeTextArea.GcodeTextArea(self)
		self.list = wx.ListBox(self, choices=self.alterationFileList, style=wx.LB_SINGLE)
		self.list.SetSelection(0)
		self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list)
		self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea)
		self.textArea.Bind(wx.stc.EVT_STC_CHANGE, self.OnFocusLost, self.textArea)
		
		sizer = wx.GridBagSizer()
		sizer.Add(self.list, (0,0), span=(5,1), flag=wx.EXPAND)
		sizer.Add(self.textArea, (5,0), span=(5,1), flag=wx.EXPAND)
		sizer.AddGrowableCol(0)
		sizer.AddGrowableRow(0)
		sizer.AddGrowableRow(5)
		sizer.AddGrowableRow(6)
		sizer.AddGrowableRow(7)
		self.SetSizer(sizer)
		
		self.loadFile(self.alterationFileList[self.list.GetSelection()])
		self.currentFile = self.list.GetSelection()
Exemple #30
0
def machineIsConnected():
	port = profile.getPreference('serial_port')
	if port == 'AUTO':
		return len(serialList(True)) > 0
	if platform.system() == "Windows":
		return port in serialList()
	return os.path.isfile(port)
	def OnClose(self, e):
		profile.saveGlobalProfile(profile.getDefaultProfilePath())

		# 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 keeps wxWidgets from quiting.
		print "Closing down"
		self.scene.OnPaint = lambda e : e
		#self.scene._slicer.cleanup()
		profile.putPreference('selectedFile', '')
		self.Destroy()
	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()
Exemple #33
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':
			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'))
			#Check if we need to copy our examples
			exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'UltimakerRobot_support.stl'))

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

		if profile.getMachineSetting('machine_name') == '':
			return
		self.mainWindow = mainWindow.mainWindow()

		if self.splash is not None:
			pass
			# 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):
		# 	print(2)
		# 	profile.putPreference('last_run_version', version.getVersion(False))
		# 	newVersionDialog.newVersionDialog().Show()

		setFullScreenCapable(self.mainWindow)

		if sys.platform.startswith('darwin'):
			wx.CallAfter(self.StupidMacOSWorkaround)
Exemple #34
0
	def OnSaveProfile(self, e):
		dlg=wx.FileDialog(self, "Select profile file to save", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
		dlg.SetWildcard("ini files (*.ini)|*.ini")
		if dlg.ShowModal() == wx.ID_OK:
			profileFile = dlg.GetPath()
			profile.saveProfile(profileFile)
		dlg.Destroy()
Exemple #35
0
	def simpleModeUpdated(self):
		self.leftPane.Layout()
		if profile.getPreference('startMode') == 'Simple':
			# Change location of sash to width of quick mode pane
			(width, height) = self.simpleSettingsPanel.GetSizer().GetSize()
			self.splitter.SetSashPosition(width, True)
		self.scene.sceneUpdated()
Exemple #36
0
 def OnCutMesh(self, e):
     dlg = wx.FileDialog(
         self,
         "Open file to cut",
         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:
         filename = dlg.GetPath()
         model = meshLoader.loadMesh(filename)
         pd = wx.ProgressDialog(
             "Splitting model.",
             "Splitting model into multiple parts.",
             model.vertexCount,
             self,
             wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME | wx.PD_SMOOTH,
         )
         parts = model.splitToParts(pd.Update)
         for part in parts:
             partFilename = filename[: filename.rfind(".")] + "_part%d.stl" % (parts.index(part))
             stl.saveAsSTL(part, partFilename)
             item = ProjectObject(self, partFilename)
             self.list.append(item)
             self.selection = item
             self._updateListbox()
             self.OnListSelect(None)
         pd.Destroy()
     self.preview.Refresh()
     dlg.Destroy()
Exemple #37
0
	def updateSliceMode(self):
		isSimple = profile.getPreference('startMode') == 'Simple'

		self.normalSettingsPanel.Show(not isSimple)
		self.simpleSettingsPanel.Show(isSimple)
		self.leftPane.Layout()

		for i in self.normalModeOnlyItems:
			i.Enable(not isSimple)
		self.switchToQuickprintMenuItem.Enable(not isSimple)
		self.switchToNormalMenuItem.Enable(isSimple)

		# Set splitter sash position & size
		if isSimple:
			# Save normal mode sash
			self.normalSashPos = self.splitter.GetSashPosition()
			
			# Change location of sash to width of quick mode pane 
			(width, height) = self.simpleSettingsPanel.GetSizer().GetSize() 
			self.splitter.SetSashPosition(width, True)
			
			# Disable sash
			self.splitter.SetSashSize(0)
		else:
			self.splitter.SetSashPosition(self.normalSashPos, True)
			# Enabled sash
			self.splitter.SetSashSize(4)
Exemple #38
0
    def updateSliceMode(self):
        isSimple = profile.getPreference('startMode') == 'Simple'

        self.normalSettingsPanel.Show(not isSimple)
        self.simpleSettingsPanel.Show(isSimple)
        self.leftPane.Layout()

        for i in self.normalModeOnlyItems:
            i.Enable(not isSimple)
        self.switchToQuickprintMenuItem.Enable(not isSimple)
        self.switchToNormalMenuItem.Enable(isSimple)

        # Set splitter sash position & size
        if isSimple:
            # Save normal mode sash
            self.normalSashPos = self.splitter.GetSashPosition()

            # Change location of sash to width of quick mode pane
            (width, height) = self.simpleSettingsPanel.GetSizer().GetSize()
            self.splitter.SetSashPosition(width, True)

            # Disable sash
            self.splitter.SetSashSize(0)
        else:
            self.splitter.SetSashPosition(self.normalSashPos, True)
            # Enabled sash
            self.splitter.SetSashSize(4)
Exemple #39
0
 def OnLoadProfileFromGcode(self, e):
     dlg = wx.FileDialog(
         self,
         "Select gcode file to load profile from",
         os.path.split(profile.getPreference("lastFile"))[0],
         style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
     )
     dlg.SetWildcard("gcode files (*.gcode)|*.gcode;*.g")
     if dlg.ShowModal() == wx.ID_OK:
         gcodeFile = dlg.GetPath()
         f = open(gcodeFile, "r")
         hasProfile = False
         for line in f:
             if line.startswith(";CURA_PROFILE_STRING:"):
                 profile.loadGlobalProfileFromString(line[line.find(":") + 1 :].strip())
                 hasProfile = True
         if hasProfile:
             self.updateProfileToControls()
         else:
             wx.MessageBox(
                 "No profile found in GCode file.\nThis feature only works with GCode files made by Cura 12.07 or newer.",
                 "Profile load error",
                 wx.OK | wx.ICON_INFORMATION,
             )
     dlg.Destroy()
Exemple #40
0
	def __init__(self, filename = None, port = None):
		super(InstallFirmware, self).__init__(parent=None, title="Firmware install", size=(250, 100))
		if port is None:
			port = profile.getPreference('serial_port')
		if filename is None:
			filename = getDefaultFirmware()
		if filename is None:
			wx.MessageBox('I am sorry, but Cura does not ship with a default firmware for your machine configuration.', 'Firmware update', wx.OK | wx.ICON_ERROR)
			self.Destroy()
			return

		sizer = wx.BoxSizer(wx.VERTICAL)
		
		self.progressLabel = wx.StaticText(self, -1, 'Reading firmware...')
		sizer.Add(self.progressLabel, 0, flag=wx.ALIGN_CENTER)
		self.progressGauge = wx.Gauge(self, -1)
		sizer.Add(self.progressGauge, 0, flag=wx.EXPAND)
		self.okButton = wx.Button(self, -1, 'Ok')
		self.okButton.Disable()
		self.okButton.Bind(wx.EVT_BUTTON, self.OnOk)
		sizer.Add(self.okButton, 0, flag=wx.ALIGN_CENTER)
		self.SetSizer(sizer)
		
		self.filename = filename
		self.port = port
		
		threading.Thread(target=self.OnRun).start()
		
		self.ShowModal()
		self.Destroy()
		return
Exemple #41
0
def getDefaultFirmware():
	if profile.getPreference('machine_type') == 'ultimaker':
		if sys.platform.startswith('linux'):
			return resources.getPathForFirmware("ultimaker_115200.hex")
		else:
			return resources.getPathForFirmware("ultimaker_250000.hex")
	return None
Exemple #42
0
    def OnLoadProfileFromGcode(self, e):
        dlg = wx.FileDialog(self,
                            _("Select gcode file to load profile from"),
                            os.path.split(
                                profile.getPreference('lastFile'))[0],
                            style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
        dlg.SetWildcard(
            "gcode files (*%s)|*%s;*%s" %
            (profile.getGCodeExtension(), profile.getGCodeExtension(),
             profile.getGCodeExtension()[0:2]))
        if dlg.ShowModal() == wx.ID_OK:
            gcodeFile = dlg.GetPath()
            f = open(gcodeFile, 'r')
            hasProfile = False
            for line in f:
                if line.startswith(';CURA_PROFILE_STRING:'):
                    profile.setProfileFromString(line[line.find(':') +
                                                      1:].strip())

                    if ';{profile_string}' not in profile.getAlterationFile(
                            'end.gcode'):
                        profile.setAlterationFile(
                            'end.gcode',
                            profile.getAlterationFile('end.gcode') +
                            '\n;{profile_string}')
                    hasProfile = True
            if hasProfile:
                self.updateProfileToAllControls()
            else:
                wx.MessageBox(
                    _("No profile found in GCode file.\nThis feature only works with GCode files made by Cura 12.07 or newer."
                      ), _("Profile load error"), wx.OK | wx.ICON_INFORMATION)
        dlg.Destroy()
def machineIsConnected():
    port = profile.getPreference('serial_port')
    if port == 'AUTO':
        return len(serialList(True)) > 0
    if platform.system() == "Windows":
        return port in serialList()
    return os.path.isfile(port)
	def __init__(self, mainWindow, parent, filelist):
		wx.Panel.__init__(self, parent, -1)
		self.mainWindow = mainWindow
		self.filelist = filelist
		self.abort = False
		
		box = wx.StaticBox(self, -1, filelist[0])
		self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)

		mainSizer = wx.BoxSizer(wx.VERTICAL) 
		mainSizer.Add(self.sizer, 0, flag=wx.EXPAND)

		self.statusText = wx.StaticText(self, -1, "Starting...")
		self.progressGauge = wx.Gauge(self, -1)
		self.progressGauge.SetRange(10000 * len(filelist))
		self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
		self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER )
		self.sizer.Add(self.progressGauge, 2)
		self.sizer.Add(self.abortButton, 0)

		self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)

		self.SetSizer(mainSizer)
		self.prevStep = 'start'
		self.totalDoneFactor = 0.0
		self.startTime = time.time()
		if profile.getPreference('save_profile') == 'True':
			profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind('.')] + "_profile.ini")
		center = profile.getMachineCenterCoords() + profile.getObjectMatrix()
		cmdList = [sliceRun.getSliceCommand(sliceRun.getExportFilename(self.filelist[0]), ['|'.join(self.filelist)], [center])]
		self.thread = WorkerThread(self, filelist, cmdList)
	def OnMouseUp(self, e):
		if e.LeftIsDown() or e.MiddleIsDown() or e.RightIsDown():
			return
		if self._mouseState == 'dragOrClick':
			if e.GetButton() == 1:
				self._selectObject(self._focusObj)
			if e.GetButton() == 3:
					menu = wx.Menu()
					if self._focusObj is not None:
						self.Bind(wx.EVT_MENU, lambda e: self._deleteObject(self._focusObj), menu.Append(-1, 'Delete'))
						self.Bind(wx.EVT_MENU, self.OnMultiply, menu.Append(-1, 'Multiply'))
						self.Bind(wx.EVT_MENU, self.OnSplitObject, menu.Append(-1, 'Split'))
					if self._selectedObj != self._focusObj and self._focusObj is not None and int(profile.getPreference('extruder_amount')) > 1:
						self.Bind(wx.EVT_MENU, self.OnMergeObjects, menu.Append(-1, 'Dual extrusion merge'))
					if len(self._scene.objects()) > 0:
						self.Bind(wx.EVT_MENU, self.OnDeleteAll, menu.Append(-1, 'Delete all'))
					if menu.MenuItemCount > 0:
						self.PopupMenu(menu)
					menu.Destroy()
		elif self._mouseState == 'dragObject' and self._selectedObj is not None:
			self._scene.pushFree()
			self.sceneUpdated()
		elif self._mouseState == 'tool':
			if self.tempMatrix is not None and self._selectedObj is not None:
				self._selectedObj.applyMatrix(self.tempMatrix)
				self._scene.pushFree()
				self._selectObject(self._selectedObj)
			self.tempMatrix = None
			self.tool.OnDragEnd()
			self.sceneUpdated()
		self._mouseState = None
Exemple #46
0
	def simpleModeUpdated(self):
		self.leftPane.Layout()
		if profile.getPreference('startMode') == 'Simple':
			# Change location of sash to width of quick mode pane
			(width, height) = self.simpleSettingsPanel.GetSizer().GetSize()
			self.splitter.SetSashPosition(width, True)
		self.scene.sceneUpdated()
    def __init__(self, resultFilename):
		self.resultFilename = resultFilename
		wx.Frame.__init__(self, wx.GetApp().TopWindow, title=self.title, size = (315,130),style=wx.DEFAULT_DIALOG_STYLE)
		self.panel = wx.Panel(self)

		#self.panel.SetBackgroundColour(wx.Colour(73,73,75))
		vbox = wx.BoxSizer(wx.VERTICAL)
		hbox = wx.BoxSizer(wx.HORIZONTAL)
		text = "Would you like to copy the sliced file to SD card: [" + profile.getPreference('sdpath') + "]?"
		qq22=wx.StaticText(self.panel,-1, text)
		font2 = wx.Font(9, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
		qq22.SetFont(font2)
		qq22.SetForegroundColour((0,0,0)) # set text color
        
		btn1 = wx.Button(self.panel, label='Ok', size=(70, 30))
		btn1.SetForegroundColour(wx.Colour(73,73,75))
		btn1.Bind(wx.EVT_BUTTON,self.doit)
        
		btn2 = wx.Button(self.panel, label='Cancel', size=(70, 30))
		btn2.SetForegroundColour(wx.Colour(73,73,75))
		btn2.Bind(wx.EVT_BUTTON,self.close)
        
		hbox.Add(btn2, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.RIGHT, border = 10)
		hbox.Add(btn1, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.LEFT, border = 10)
        
		vbox.Add(qq22, 1, wx.ALIGN_CENTER_HORIZONTAL| wx.TOP, 10)
		vbox.Add(hbox, 1, wx.ALIGN_CENTER_HORIZONTAL| wx.TOP, 10)
		self.panel.SetSizer(vbox)
		self.Show()
Exemple #48
0
    def updateHeadSize(self, obj=None):
        xMin = profile.getMachineSettingFloat('extruder_head_size_min_x')
        xMax = profile.getMachineSettingFloat('extruder_head_size_max_x')
        yMin = profile.getMachineSettingFloat('extruder_head_size_min_y')
        yMax = profile.getMachineSettingFloat('extruder_head_size_max_y')
        gantryHeight = profile.getMachineSettingFloat(
            'extruder_head_size_height')
        objectSink = profile.getProfileSettingFloat("object_sink")

        self._leftToRight = xMin < xMax
        self._frontToBack = yMin < yMax
        self._headSizeOffsets[0] = min(xMin, xMax)
        self._headSizeOffsets[1] = min(yMin, yMax)
        self._gantryHeight = gantryHeight
        self._oneAtATime = self._gantryHeight > 0 and profile.getPreference(
            'oneAtATime') == 'True'
        for obj in self._objectList:
            if obj.getSize()[2] - objectSink > self._gantryHeight:
                self._oneAtATime = False

        headArea = numpy.array(
            [[-xMin, -yMin], [xMax, -yMin], [xMax, yMax], [-xMin, yMax]],
            numpy.float32)

        if obj is None:
            for obj in self._objectList:
                obj.setHeadArea(headArea, self._headSizeOffsets)
        else:
            obj.setHeadArea(headArea, self._headSizeOffsets)
Exemple #49
0
 def OnSaveProject(self, e):
     dlg = wx.FileDialog(self,
                         "Save project file",
                         os.path.split(
                             profile.getPreference('lastFile'))[0],
                         style=wx.FD_SAVE)
     dlg.SetWildcard("Project files (*.curaproject)|*.curaproject")
     if dlg.ShowModal() == wx.ID_OK:
         cp = ConfigParser.ConfigParser()
         i = 0
         for item in self.list:
             section = 'model_%d' % (i)
             cp.add_section(section)
             cp.set(section, 'filename', item.filename.encode("utf-8"))
             cp.set(section, 'centerX', str(item.centerX))
             cp.set(section, 'centerY', str(item.centerY))
             cp.set(section, 'scale', str(item.scale))
             cp.set(section, 'rotate', str(item.rotate))
             cp.set(section, 'flipX', str(item.flipX))
             cp.set(section, 'flipY', str(item.flipY))
             cp.set(section, 'flipZ', str(item.flipZ))
             cp.set(section, 'swapXZ', str(item.swapXZ))
             cp.set(section, 'swapYZ', str(item.swapYZ))
             cp.set(section, 'extruder', str(item.extruder + 1))
             if item.profile != None:
                 cp.set(section, 'profile', item.profile)
             i += 1
         cp.write(open(dlg.GetPath(), "w"))
     dlg.Destroy()
Exemple #50
0
 def OnCutMesh(self, e):
     dlg = wx.FileDialog(self,
                         "Open file to cut",
                         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:
         filename = dlg.GetPath()
         model = meshLoader.loadMesh(filename)
         pd = wx.ProgressDialog(
             'Splitting model.', 'Splitting model into multiple parts.',
             model.vertexCount, self,
             wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME | wx.PD_SMOOTH)
         parts = model.splitToParts(pd.Update)
         for part in parts:
             partFilename = filename[:filename.rfind(
                 '.')] + "_part%d.stl" % (parts.index(part))
             stl.saveAsSTL(part, partFilename)
             item = ProjectObject(self, partFilename)
             self.list.append(item)
             self.selection = item
             self._updateListbox()
             self.OnListSelect(None)
         pd.Destroy()
     self.glCanvas.Refresh()
     dlg.Destroy()
Exemple #51
0
def serialList(forAutoDetect=False):
	baselist=[]
	if platform.system() == "Windows":
		try:
			key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM")
			i=0
			while True:
				values = _winreg.EnumValue(key, i)
				if not forAutoDetect or 'USBSER' in values[0]:
					baselist+=[values[1]]
				i+=1
		except:
			pass
	if forAutoDetect:
		baselist = baselist + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob("/dev/tty.usb*") + glob.glob("/dev/cu.usb*")
		baselist = filter(lambda s: not 'Bluetooth' in s, baselist)
	else:
		baselist = baselist + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') + glob.glob("/dev/tty.usb*") + glob.glob("/dev/cu.*") + glob.glob("/dev/rfcomm*")
	prev = profile.getPreference('serial_port_auto')
	if prev in baselist:
		baselist.remove(prev)
		baselist.insert(0, prev)
	if version.isDevVersion() and not forAutoDetect:
		baselist.append('VIRTUAL')
	return baselist
	def OnSaveProject(self, e):
		dlg=wx.FileDialog(self, "Save project file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
		dlg.SetWildcard("Project files (*.curaproject)|*.curaproject")
		if dlg.ShowModal() == wx.ID_OK:
			cp = ConfigParser.ConfigParser()
			i = 0
			for item in self.list:
				section = 'model_%d' % (i)
				cp.add_section(section)
				cp.set(section, 'filename', item.filename.encode("utf-8"))
				cp.set(section, 'centerX', str(item.centerX))
				cp.set(section, 'centerY', str(item.centerY))
				cp.set(section, 'scale', str(item.scale))
				cp.set(section, 'rotate', str(item.rotate))
				cp.set(section, 'flipX', str(item.flipX))
				cp.set(section, 'flipY', str(item.flipY))
				cp.set(section, 'flipZ', str(item.flipZ))
				cp.set(section, 'swapXZ', str(item.swapXZ))
				cp.set(section, 'swapYZ', str(item.swapYZ))
				cp.set(section, 'extruder', str(item.extruder+1))
				if item.profile != None:
					cp.set(section, 'profile', item.profile)
				i += 1
			cp.write(open(dlg.GetPath(), "w"))
		dlg.Destroy()
def serialList(forAutoDetect=False):
    baselist = []
    if platform.system() == "Windows":
        try:
            key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,
                                  "HARDWARE\\DEVICEMAP\\SERIALCOMM")
            i = 0
            while True:
                values = _winreg.EnumValue(key, i)
                if not forAutoDetect or 'USBSER' in values[0]:
                    baselist += [values[1]]
                i += 1
        except:
            pass
    if forAutoDetect:
        baselist = baselist + glob.glob('/dev/ttyUSB*') + glob.glob(
            '/dev/ttyACM*') + glob.glob("/dev/tty.usb*") + glob.glob(
                "/dev/cu.usb*")
        baselist = filter(lambda s: not 'Bluetooth' in s, baselist)
    else:
        baselist = baselist + glob.glob('/dev/ttyUSB*') + glob.glob(
            '/dev/ttyACM*') + glob.glob("/dev/tty.usb*") + glob.glob(
                "/dev/cu.*") + glob.glob("/dev/rfcomm*")
    prev = profile.getPreference('serial_port_auto')
    if prev in baselist:
        baselist.remove(prev)
        baselist.insert(0, prev)
    if version.isDevVersion() and not forAutoDetect:
        baselist.append('VIRTUAL')
    return baselist
	def __init__(self, parent):
		super(preferencesDialog, self).__init__(None, title="Project Planner Preferences", style=wx.DEFAULT_DIALOG_STYLE)
		
		self.parent = parent
		wx.EVT_CLOSE(self, self.OnClose)

		self.panel = configBase.configPanelBase(self)
		extruderAmount = int(profile.getPreference('extruder_amount'))
		
		left, right, main = self.panel.CreateConfigPanel(self)
		configBase.TitleRow(left, 'Machine head size')
		c = configBase.SettingRow(left, 'Head size - X towards home (mm)', 'extruder_head_size_min_x', '0', 'Size of your printer head in the X direction, on the Ultimaker your fan is in this direction.', type = 'preference')
		validators.validFloat(c, 0.1)
		c = configBase.SettingRow(left, 'Head size - X towards end (mm)', 'extruder_head_size_max_x', '0', 'Size of your printer head in the X direction.', type = 'preference')
		validators.validFloat(c, 0.1)
		c = configBase.SettingRow(left, 'Head size - Y towards home (mm)', 'extruder_head_size_min_y', '0', 'Size of your printer head in the Y direction.', type = 'preference')
		validators.validFloat(c, 0.1)
		c = configBase.SettingRow(left, 'Head size - Y towards end (mm)', 'extruder_head_size_max_y', '0', 'Size of your printer head in the Y direction.', type = 'preference')
		validators.validFloat(c, 0.1)
		c = configBase.SettingRow(left, 'Head gantry height (mm)', 'extruder_head_size_height', '0', 'The tallest object height that will always fit under your printers gantry system when the printer head is at the lowest Z position.', type = 'preference')
		validators.validFloat(c)
		
		self.okButton = wx.Button(left, -1, 'Ok')
		left.GetSizer().Add(self.okButton, (left.GetSizer().GetRows(), 1))
		self.okButton.Bind(wx.EVT_BUTTON, self.OnClose)
		
		self.MakeModal(True)
		main.Fit()
		self.Fit()
Exemple #55
0
	def OnSaveProfile(self, e):
		dlg=wx.FileDialog(self, "Select profile file to save", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
		dlg.SetWildcard("ini files (*.ini)|*.ini")
		if dlg.ShowModal() == wx.ID_OK:
			profileFile = dlg.GetPath()
			profile.saveGlobalProfile(profileFile)
		dlg.Destroy()
Exemple #56
0
    def updateHeadSize(self, obj=None):
        xMin = profile.getMachineSettingFloat('extruder_head_size_min_x')
        xMax = profile.getMachineSettingFloat('extruder_head_size_max_x')
        yMin = profile.getMachineSettingFloat('extruder_head_size_min_y')
        yMax = profile.getMachineSettingFloat('extruder_head_size_max_y')
        gantryHeight = profile.getMachineSettingFloat(
            'extruder_head_size_height')
        objectSink = profile.getProfileSettingFloat("object_sink")
        if profile.getPreference('startMode') == 'Simple':
            objectSink = float(
                profile.settingsDictionary["object_sink"].getDefault())

        self._leftToRight = xMin < xMax
        self._frontToBack = yMin < yMax
        self._headSizeOffsets[0] = min(xMin, xMax)
        self._headSizeOffsets[1] = min(yMin, yMax)
        self._gantryHeight = gantryHeight

        printOneAtATime = profile.getPreference('oneAtATime') == 'True'
        self._oneAtATime = self._gantryHeight > 0 and printOneAtATime
        if self._oneAtATime:
            if not self._lastOneAtATime:
                #print mode was changed by user. We need to reset that value to test with current scene content
                self._lastResultOneAtATime = True

            for objIter in self._objectList:
                if objIter.getSize()[2] - objectSink > self._gantryHeight:
                    self._oneAtATime = False
                    if self._lastResultOneAtATime:
                        if self._sceneView:
                            self._sceneView.notification.message(
                                "Object must be shorter than {}mm for this printer/tool head. Reduce object size or swap to \"All at once\" mode. "
                                .format(self._gantryHeight))
                        break

        self._lastResultOneAtATime = self._oneAtATime
        self._lastOneAtATime = printOneAtATime

        headArea = numpy.array(
            [[-xMin, -yMin], [xMax, -yMin], [xMax, yMax], [-xMin, yMax]],
            numpy.float32)

        if obj is None:
            for obj in self._objectList:
                obj.setHeadArea(headArea, self._headSizeOffsets)
        else:
            obj.setHeadArea(headArea, self._headSizeOffsets)
 def OnSafeRemove(self):
     if platform.system() == "Windows":
         cmd = '"%s" %s>NUL' % (os.path.abspath(
             os.path.join(
                 os.path.dirname(__file__), '..',
                 'EjectMedia.exe')), profile.getPreference('sdpath'))
     elif platform.system() == "Darwin":
         cmd = "diskutil eject '%s' > /dev/null 2>&1" % (
             profile.getPreference('sdpath'))
     else:
         cmd = "umount '%s' > /dev/null 2>&1" % (
             profile.getPreference('sdpath'))
     if os.system(cmd):
         self.GetParent().preview3d.ShowWarningPopup("Safe remove failed.")
     else:
         self.GetParent().preview3d.ShowWarningPopup(
             "You can now eject the card.")
Exemple #58
0
	def updateProfileToControls(self):
		"Update the configuration wx controls to show the new configuration settings"
		for setting in self.settingControlList:
			if setting.type == 'profile':
				setting.SetValue(profile.getProfileSetting(setting.configName))
			else:
				setting.SetValue(profile.getPreference(setting.configName))
		self.Update()