CuraApplication.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. # Copyright (c) 2015 Ultimaker B.V.
  2. # Cura is released under the terms of the AGPLv3 or higher.
  3. from UM.Qt.QtApplication import QtApplication
  4. from UM.Scene.SceneNode import SceneNode
  5. from UM.Scene.Camera import Camera
  6. from UM.Scene.Platform import Platform
  7. from UM.Math.Vector import Vector
  8. from UM.Math.Matrix import Matrix
  9. from UM.Math.Quaternion import Quaternion
  10. from UM.Resources import Resources
  11. from UM.Scene.ToolHandle import ToolHandle
  12. from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
  13. from UM.Mesh.WriteMeshJob import WriteMeshJob
  14. from UM.Mesh.ReadMeshJob import ReadMeshJob
  15. from UM.Logger import Logger
  16. from UM.Preferences import Preferences
  17. from UM.Message import Message
  18. from UM.PluginRegistry import PluginRegistry
  19. from UM.JobQueue import JobQueue
  20. from UM.Math.Polygon import Polygon
  21. from UM.Scene.BoxRenderer import BoxRenderer
  22. from UM.Scene.Selection import Selection
  23. from UM.Scene.GroupDecorator import GroupDecorator
  24. from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation
  25. from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation
  26. from UM.Operations.GroupedOperation import GroupedOperation
  27. from UM.Operations.SetTransformOperation import SetTransformOperation
  28. from UM.i18n import i18nCatalog
  29. from . import PlatformPhysics
  30. from . import BuildVolume
  31. from . import CameraAnimation
  32. from . import PrintInformation
  33. from . import CuraActions
  34. from . import MultiMaterialDecorator
  35. from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty
  36. from PyQt5.QtGui import QColor, QIcon
  37. import platform
  38. import sys
  39. import os
  40. import os.path
  41. import configparser
  42. import numpy
  43. numpy.seterr(all="ignore")
  44. class CuraApplication(QtApplication):
  45. def __init__(self):
  46. Resources.addResourcePath(os.path.join(QtApplication.getInstallPrefix(), "share", "cura"))
  47. if not hasattr(sys, "frozen"):
  48. Resources.addResourcePath(os.path.join(os.path.abspath(os.path.dirname(__file__)), ".."))
  49. super().__init__(name = "cura", version = "master")
  50. self.setWindowIcon(QIcon(Resources.getPath(Resources.ImagesLocation, "cura-icon.png")))
  51. self.setRequiredPlugins([
  52. "CuraEngineBackend",
  53. "MeshView",
  54. "LayerView",
  55. "STLReader",
  56. "SelectionTool",
  57. "CameraTool",
  58. "GCodeWriter",
  59. "LocalFileStorage"
  60. ])
  61. self._physics = None
  62. self._volume = None
  63. self._platform = None
  64. self._output_devices = {}
  65. self._print_information = None
  66. self._i18n_catalog = None
  67. self._previous_active_tool = None
  68. self._platform_activity = False
  69. self.activeMachineChanged.connect(self._onActiveMachineChanged)
  70. Preferences.getInstance().addPreference("cura/active_machine", "")
  71. Preferences.getInstance().addPreference("cura/active_mode", "simple")
  72. Preferences.getInstance().addPreference("cura/recent_files", "")
  73. Preferences.getInstance().addPreference("cura/categories_expanded", "")
  74. JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
  75. self._recent_files = []
  76. files = Preferences.getInstance().getValue("cura/recent_files").split(";")
  77. for f in files:
  78. if not os.path.isfile(f):
  79. continue
  80. self._recent_files.append(QUrl.fromLocalFile(f))
  81. ## Handle loading of all plugin types (and the backend explicitly)
  82. # \sa PluginRegistery
  83. def _loadPlugins(self):
  84. self._plugin_registry.addPluginLocation(os.path.join(QtApplication.getInstallPrefix(), "lib", "cura"))
  85. if not hasattr(sys, "frozen"):
  86. self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins"))
  87. self._plugin_registry.loadPlugins({ "type": "logger"})
  88. self._plugin_registry.loadPlugins({ "type": "storage_device" })
  89. self._plugin_registry.loadPlugins({ "type": "view" })
  90. self._plugin_registry.loadPlugins({ "type": "mesh_reader" })
  91. self._plugin_registry.loadPlugins({ "type": "mesh_writer" })
  92. self._plugin_registry.loadPlugins({ "type": "tool" })
  93. self._plugin_registry.loadPlugins({ "type": "extension" })
  94. self._plugin_registry.loadPlugin("CuraEngineBackend")
  95. def addCommandLineOptions(self, parser):
  96. super().addCommandLineOptions(parser)
  97. parser.add_argument("file", nargs="*", help="Files to load after starting the application.")
  98. def run(self):
  99. self._i18n_catalog = i18nCatalog("cura");
  100. self.addOutputDevice("local_file", {
  101. "id": "local_file",
  102. "function": self._writeToLocalFile,
  103. "description": self._i18n_catalog.i18nc("Save button tooltip", "Save to Disk"),
  104. "shortDescription": self._i18n_catalog.i18nc("Save button tooltip", "Save to Disk"),
  105. "icon": "save",
  106. "priority": 0
  107. })
  108. self.showSplashMessage(self._i18n_catalog.i18nc("Splash screen message", "Setting up scene..."))
  109. controller = self.getController()
  110. controller.setActiveView("MeshView")
  111. controller.setCameraTool("CameraTool")
  112. controller.setSelectionTool("SelectionTool")
  113. t = controller.getTool("TranslateTool")
  114. if t:
  115. t.setEnabledAxis([ToolHandle.XAxis, ToolHandle.ZAxis])
  116. Selection.selectionChanged.connect(self.onSelectionChanged)
  117. root = controller.getScene().getRoot()
  118. self._platform = Platform(root)
  119. self._volume = BuildVolume.BuildVolume(root)
  120. self.getRenderer().setLightPosition(Vector(0, 150, 0))
  121. self.getRenderer().setBackgroundColor(QColor(245, 245, 245))
  122. self._physics = PlatformPhysics.PlatformPhysics(controller, self._volume)
  123. camera = Camera("3d", root)
  124. camera.setPosition(Vector(-150, 150, 300))
  125. camera.setPerspective(True)
  126. camera.lookAt(Vector(0, 0, 0))
  127. self._camera_animation = CameraAnimation.CameraAnimation()
  128. self._camera_animation.setCameraTool(self.getController().getTool("CameraTool"))
  129. controller.getScene().setActiveCamera("3d")
  130. self.showSplashMessage(self._i18n_catalog.i18nc("Splash screen message", "Loading interface..."))
  131. self.setMainQml(Resources.getPath(Resources.QmlFilesLocation, "Cura.qml"))
  132. self.initializeEngine()
  133. self.getStorageDevice("LocalFileStorage").removableDrivesChanged.connect(self._removableDrivesChanged)
  134. if self.getMachines():
  135. active_machine_pref = Preferences.getInstance().getValue("cura/active_machine")
  136. if active_machine_pref:
  137. for machine in self.getMachines():
  138. if machine.getName() == active_machine_pref:
  139. self.setActiveMachine(machine)
  140. if not self.getActiveMachine():
  141. self.setActiveMachine(self.getMachines()[0])
  142. else:
  143. self.requestAddPrinter.emit()
  144. self._removableDrivesChanged()
  145. if self._engine.rootObjects:
  146. self.closeSplash()
  147. for file in self.getCommandLineOption("file", []):
  148. job = ReadMeshJob(os.path.abspath(file))
  149. job.finished.connect(self._onFileLoaded)
  150. job.start()
  151. self.exec_()
  152. def registerObjects(self, engine):
  153. engine.rootContext().setContextProperty("Printer", self)
  154. self._print_information = PrintInformation.PrintInformation()
  155. engine.rootContext().setContextProperty("PrintInformation", self._print_information)
  156. self._cura_actions = CuraActions.CuraActions(self)
  157. engine.rootContext().setContextProperty("CuraActions", self._cura_actions)
  158. def onSelectionChanged(self):
  159. if Selection.hasSelection():
  160. if not self.getController().getActiveTool():
  161. if self._previous_active_tool:
  162. self.getController().setActiveTool(self._previous_active_tool)
  163. self._previous_active_tool = None
  164. else:
  165. self.getController().setActiveTool("TranslateTool")
  166. self._camera_animation.setStart(self.getController().getTool("CameraTool").getOrigin())
  167. self._camera_animation.setTarget(Selection.getSelectedObject(0).getWorldPosition())
  168. self._camera_animation.start()
  169. else:
  170. if self.getController().getActiveTool():
  171. self._previous_active_tool = self.getController().getActiveTool().getPluginId()
  172. self.getController().setActiveTool(None)
  173. else:
  174. self._previous_active_tool = None
  175. requestAddPrinter = pyqtSignal()
  176. activityChanged = pyqtSignal()
  177. @pyqtProperty(bool, notify = activityChanged)
  178. def getPlatformActivity(self):
  179. return self._platform_activity
  180. @pyqtSlot(bool)
  181. def setPlatformActivity(self, activity):
  182. ##Sets the _platform_activity variable on true or false depending on whether there is a mesh on the platform
  183. if activity == True:
  184. self._platform_activity = activity
  185. elif activity == False:
  186. nodes = []
  187. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  188. if type(node) is not SceneNode or not node.getMeshData():
  189. continue
  190. nodes.append(node)
  191. i = 0
  192. for node in nodes:
  193. if not node.getMeshData():
  194. continue
  195. i += 1
  196. if i <= 1: ## i == 0 when the meshes are removed using the deleteAll function; i == 1 when the last remaining mesh is removed using the deleteObject function
  197. self._platform_activity = activity
  198. self.activityChanged.emit()
  199. ## Remove an object from the scene
  200. @pyqtSlot("quint64")
  201. def deleteObject(self, object_id):
  202. object = self.getController().getScene().findObject(object_id)
  203. if not object and object_id != 0: #Workaround for tool handles overlapping the selected object
  204. object = Selection.getSelectedObject(0)
  205. if object:
  206. if object.getParent():
  207. group_node = object.getParent()
  208. if not group_node.callDecoration("isGroup"):
  209. op = RemoveSceneNodeOperation(object)
  210. else:
  211. while group_node.getParent().callDecoration("isGroup"):
  212. group_node = group_node.getParent()
  213. op = RemoveSceneNodeOperation(group_node)
  214. op.push()
  215. self.setPlatformActivity(False)
  216. ## Create a number of copies of existing object.
  217. @pyqtSlot("quint64", int)
  218. def multiplyObject(self, object_id, count):
  219. node = self.getController().getScene().findObject(object_id)
  220. if not node and object_id != 0: #Workaround for tool handles overlapping the selected object
  221. node = Selection.getSelectedObject(0)
  222. if node:
  223. op = GroupedOperation()
  224. for i in range(count):
  225. new_node = SceneNode()
  226. new_node.setMeshData(node.getMeshData())
  227. new_node.setScale(node.getScale())
  228. new_node.translate(Vector((i + 1) * node.getBoundingBox().width, 0, 0))
  229. new_node.setSelectable(True)
  230. op.addOperation(AddSceneNodeOperation(new_node, node.getParent()))
  231. op.push()
  232. ## Center object on platform.
  233. @pyqtSlot("quint64")
  234. def centerObject(self, object_id):
  235. node = self.getController().getScene().findObject(object_id)
  236. if not node and object_id != 0: #Workaround for tool handles overlapping the selected object
  237. node = Selection.getSelectedObject(0)
  238. if node:
  239. op = SetTransformOperation(node, Vector())
  240. op.push()
  241. ## Delete all mesh data on the scene.
  242. @pyqtSlot()
  243. def deleteAll(self):
  244. nodes = []
  245. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  246. if type(node) is not SceneNode or not node.getMeshData():
  247. continue
  248. nodes.append(node)
  249. if nodes:
  250. op = GroupedOperation()
  251. for node in nodes:
  252. op.addOperation(RemoveSceneNodeOperation(node))
  253. op.push()
  254. self.setPlatformActivity(False)
  255. ## Reset all translation on nodes with mesh data.
  256. @pyqtSlot()
  257. def resetAllTranslation(self):
  258. nodes = []
  259. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  260. if type(node) is not SceneNode or not node.getMeshData():
  261. continue
  262. nodes.append(node)
  263. if nodes:
  264. op = GroupedOperation()
  265. for node in nodes:
  266. op.addOperation(SetTransformOperation(node, Vector()))
  267. op.push()
  268. ## Reset all transformations on nodes with mesh data.
  269. @pyqtSlot()
  270. def resetAll(self):
  271. nodes = []
  272. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  273. if type(node) is not SceneNode or not node.getMeshData():
  274. continue
  275. nodes.append(node)
  276. if nodes:
  277. op = GroupedOperation()
  278. for node in nodes:
  279. op.addOperation(SetTransformOperation(node, Vector(), Quaternion(), Vector(1, 1, 1)))
  280. op.push()
  281. ## Reload all mesh data on the screen from file.
  282. @pyqtSlot()
  283. def reloadAll(self):
  284. nodes = []
  285. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  286. if type(node) is not SceneNode or not node.getMeshData():
  287. continue
  288. nodes.append(node)
  289. if not nodes:
  290. return
  291. for node in nodes:
  292. if not node.getMeshData():
  293. continue
  294. file_name = node.getMeshData().getFileName()
  295. if file_name:
  296. job = ReadMeshJob(file_name)
  297. job._node = node
  298. job.finished.connect(self._reloadMeshFinished)
  299. job.start()
  300. ## Get logging data of the backend engine
  301. # \returns \type{string} Logging data
  302. @pyqtSlot(result=str)
  303. def getEngineLog(self):
  304. log = ""
  305. for entry in self.getBackend().getLog():
  306. log += entry.decode()
  307. return log
  308. recentFilesChanged = pyqtSignal()
  309. @pyqtProperty("QVariantList", notify = recentFilesChanged)
  310. def recentFiles(self):
  311. return self._recent_files
  312. @pyqtSlot("QStringList")
  313. def setExpandedCategories(self, categories):
  314. categories = list(set(categories))
  315. categories.sort()
  316. joined = ";".join(categories)
  317. if joined != Preferences.getInstance().getValue("cura/categories_expanded"):
  318. Preferences.getInstance().setValue("cura/categories_expanded", joined)
  319. self.expandedCategoriesChanged.emit()
  320. expandedCategoriesChanged = pyqtSignal()
  321. @pyqtProperty("QStringList", notify = expandedCategoriesChanged)
  322. def expandedCategories(self):
  323. return Preferences.getInstance().getValue("cura/categories_expanded").split(";")
  324. outputDevicesChanged = pyqtSignal()
  325. @pyqtProperty("QVariantMap", notify = outputDevicesChanged)
  326. def outputDevices(self):
  327. return self._output_devices
  328. @pyqtProperty("QStringList", notify = outputDevicesChanged)
  329. def outputDeviceNames(self):
  330. return self._output_devices.keys()
  331. @pyqtSlot(str, result = "QVariant")
  332. def getSettingValue(self, key):
  333. if not self.getActiveMachine():
  334. return None
  335. return self.getActiveMachine().getSettingValueByKey(key)
  336. ## Change setting by key value pair
  337. @pyqtSlot(str, "QVariant")
  338. def setSettingValue(self, key, value):
  339. if not self.getActiveMachine():
  340. return
  341. self.getActiveMachine().setSettingValueByKey(key, value)
  342. @pyqtSlot()
  343. def mergeSelected(self):
  344. self.groupSelected()
  345. try:
  346. group_node = Selection.getAllSelectedObjects()[0]
  347. except Exception as e:
  348. return
  349. multi_material_decorator = MultiMaterialDecorator.MultiMaterialDecorator()
  350. group_node.addDecorator(multi_material_decorator)
  351. # Reset the position of each node
  352. for node in group_node.getChildren():
  353. new_position = node.getPosition()
  354. new_position.setX(0)
  355. new_position.setZ(0)
  356. node.setPosition(new_position)
  357. # Use the previously found center of the group bounding box as the new location of the group
  358. group_node.setPosition((group_node.getBoundingBox().maximum + group_node.getBoundingBox().minimum) / 2)
  359. @pyqtSlot()
  360. def groupSelected(self):
  361. group_node = SceneNode()
  362. group_decorator = GroupDecorator()
  363. group_node.addDecorator(group_decorator)
  364. group_node.setParent(self.getController().getScene().getRoot())
  365. for node in Selection.getAllSelectedObjects():
  366. node.setParent(group_node)
  367. for node in group_node.getChildren():
  368. Selection.remove(node)
  369. Selection.add(group_node)
  370. @pyqtSlot()
  371. def ungroupSelected(self):
  372. ungrouped_nodes = []
  373. selected_objects = Selection.getAllSelectedObjects()[:] #clone the list
  374. for node in selected_objects:
  375. if node.callDecoration("isGroup" ):
  376. children_to_move = []
  377. for child in node.getChildren():
  378. if type(child) is SceneNode:
  379. children_to_move.append(child)
  380. for child in children_to_move:
  381. child.setParent(node.getParent())
  382. Selection.add(child)
  383. child.callDecoration("setConvexHull",None)
  384. node.setParent(None)
  385. ungrouped_nodes.append(node)
  386. for node in ungrouped_nodes:
  387. Selection.remove(node)
  388. ## Add an output device that can be written to.
  389. #
  390. # \param id \type{string} The identifier used to identify the device.
  391. # \param device \type{StorageDevice} A dictionary of device information.
  392. # It should contains the following:
  393. # - function: A function to be called when trying to write to the device. Will be passed the device id as first parameter.
  394. # - description: A translated string containing a description of what happens when writing to the device.
  395. # - icon: The icon to use to represent the device.
  396. # - priority: The priority of the device. The device with the highest priority will be used as the default device.
  397. def addOutputDevice(self, id, device):
  398. self._output_devices[id] = device
  399. self.outputDevicesChanged.emit()
  400. ## Remove output device
  401. # \param id \type{string} The identifier used to identify the device.
  402. # \sa PrinterApplication::addOutputDevice()
  403. def removeOutputDevice(self, id):
  404. if id in self._output_devices:
  405. del self._output_devices[id]
  406. self.outputDevicesChanged.emit()
  407. @pyqtSlot(str)
  408. def writeToOutputDevice(self, device):
  409. self._output_devices[device]["function"](device)
  410. writeToLocalFileRequested = pyqtSignal()
  411. def _writeToLocalFile(self, device):
  412. self.writeToLocalFileRequested.emit()
  413. def _writeToSD(self, device):
  414. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  415. if type(node) is not SceneNode or not node.getMeshData():
  416. continue
  417. try:
  418. path = self.getStorageDevice("LocalFileStorage").getRemovableDrives()[device]
  419. except KeyError:
  420. Logger.log("e", "Tried to write to unknown SD card %s", device)
  421. return
  422. filename = os.path.join(path, node.getName()[0:node.getName().rfind(".")] + ".gcode")
  423. message = Message(self._output_devices[device]["description"], 0, False, -1)
  424. message.show()
  425. job = WriteMeshJob(filename, node.getMeshData())
  426. job._sdcard = device
  427. job._message = message
  428. job.start()
  429. job.finished.connect(self._onWriteToSDFinished)
  430. return
  431. def _removableDrivesChanged(self):
  432. drives = self.getStorageDevice("LocalFileStorage").getRemovableDrives()
  433. for drive in drives:
  434. if drive not in self._output_devices:
  435. self.addOutputDevice(drive, {
  436. "id": drive,
  437. "function": self._writeToSD,
  438. "description": self._i18n_catalog.i18nc("Save button tooltip. {0} is sd card name", "Save to SD Card {0}").format(drive),
  439. "shortDescription": self._i18n_catalog.i18nc("Save button tooltip. {0} is sd card name", "Save to SD Card {0}").format(""),
  440. "icon": "save_sd",
  441. "priority": 1
  442. })
  443. drives_to_remove = []
  444. for device in self._output_devices:
  445. if device not in drives:
  446. if self._output_devices[device]["function"] == self._writeToSD:
  447. drives_to_remove.append(device)
  448. for drive in drives_to_remove:
  449. self.removeOutputDevice(drive)
  450. def _onActiveMachineChanged(self):
  451. machine = self.getActiveMachine()
  452. if machine:
  453. Preferences.getInstance().setValue("cura/active_machine", machine.getName())
  454. self._volume.setWidth(machine.getSettingValueByKey("machine_width"))
  455. self._volume.setHeight(machine.getSettingValueByKey("machine_height"))
  456. self._volume.setDepth(machine.getSettingValueByKey("machine_depth"))
  457. disallowed_areas = machine.getSettingValueByKey("machine_disallowed_areas")
  458. areas = []
  459. if disallowed_areas:
  460. for area in disallowed_areas:
  461. areas.append(Polygon(numpy.array(area, numpy.float32)))
  462. self._volume.setDisallowedAreas(areas)
  463. self._volume.rebuild()
  464. offset = machine.getSettingValueByKey("machine_platform_offset")
  465. if offset:
  466. self._platform.setPosition(Vector(offset[0], offset[1], offset[2]))
  467. else:
  468. self._platform.setPosition(Vector(0.0, 0.0, 0.0))
  469. def _onWriteToSDFinished(self, job):
  470. message = Message(self._i18n_catalog.i18nc("Saved to SD message, {0} is sdcard, {1} is filename", "Saved to SD Card {0} as {1}").format(job._sdcard, job.getFileName()))
  471. message.addAction(
  472. "eject",
  473. self._i18n_catalog.i18nc("Message action", "Eject"),
  474. "eject",
  475. self._i18n_catalog.i18nc("Message action tooltip, {0} is sdcard", "Eject SD Card {0}").format(job._sdcard)
  476. )
  477. job._message.hide()
  478. message._sdcard = job._sdcard
  479. message.actionTriggered.connect(self._onMessageActionTriggered)
  480. message.show()
  481. def _onMessageActionTriggered(self, message, action):
  482. if action == "eject":
  483. self.getStorageDevice("LocalFileStorage").ejectRemovableDrive(message._sdcard)
  484. def _onFileLoaded(self, job):
  485. mesh = job.getResult()
  486. if mesh != None:
  487. node = SceneNode()
  488. node.setSelectable(True)
  489. node.setMeshData(mesh)
  490. node.setName(os.path.basename(job.getFileName()))
  491. op = AddSceneNodeOperation(node, self.getController().getScene().getRoot())
  492. op.push()
  493. def _onJobFinished(self, job):
  494. if type(job) is not ReadMeshJob or not job.getResult():
  495. return
  496. f = QUrl.fromLocalFile(job.getFileName())
  497. if f in self._recent_files:
  498. self._recent_files.remove(f)
  499. self._recent_files.insert(0, f)
  500. if len(self._recent_files) > 10:
  501. del self._recent_files[10]
  502. pref = ""
  503. for path in self._recent_files:
  504. pref += path.toLocalFile() + ";"
  505. Preferences.getInstance().setValue("cura/recent_files", pref)
  506. self.recentFilesChanged.emit()
  507. def _reloadMeshFinished(self, job):
  508. job._node.setMeshData(job.getResult())