CuraApplication.py 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  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.Math.Vector import Vector
  7. from UM.Math.Quaternion import Quaternion
  8. from UM.Math.AxisAlignedBox import AxisAlignedBox
  9. from UM.Math.Matrix import Matrix
  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.ReadMeshJob import ReadMeshJob
  14. from UM.Logger import Logger
  15. from UM.Preferences import Preferences
  16. from UM.JobQueue import JobQueue
  17. from UM.SaveFile import SaveFile
  18. from UM.Scene.Selection import Selection
  19. from UM.Scene.GroupDecorator import GroupDecorator
  20. from UM.Settings.Validator import Validator
  21. from UM.Message import Message
  22. from UM.i18n import i18nCatalog
  23. from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation
  24. from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation
  25. from UM.Operations.GroupedOperation import GroupedOperation
  26. from UM.Operations.SetTransformOperation import SetTransformOperation
  27. from UM.Operations.TranslateOperation import TranslateOperation
  28. from cura.SetParentOperation import SetParentOperation
  29. from cura.SliceableObjectDecorator import SliceableObjectDecorator
  30. from cura.BlockSlicingDecorator import BlockSlicingDecorator
  31. from UM.Settings.SettingDefinition import SettingDefinition, DefinitionPropertyType
  32. from UM.Settings.ContainerRegistry import ContainerRegistry
  33. from UM.Settings.SettingFunction import SettingFunction
  34. from . import PlatformPhysics
  35. from . import BuildVolume
  36. from . import CameraAnimation
  37. from . import PrintInformation
  38. from . import CuraActions
  39. from . import ZOffsetDecorator
  40. from . import CuraSplashScreen
  41. from . import CameraImageProvider
  42. from . import MachineActionManager
  43. import cura.Settings
  44. from PyQt5.QtCore import QUrl, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
  45. from UM.FlameProfiler import pyqtSlot
  46. from PyQt5.QtGui import QColor, QIcon
  47. from PyQt5.QtWidgets import QMessageBox
  48. from PyQt5.QtQml import qmlRegisterUncreatableType, qmlRegisterSingletonType, qmlRegisterType
  49. import sys
  50. import os.path
  51. import numpy
  52. import copy
  53. import urllib.parse
  54. import os
  55. numpy.seterr(all="ignore")
  56. try:
  57. from cura.CuraVersion import CuraVersion, CuraBuildType
  58. except ImportError:
  59. CuraVersion = "master" # [CodeStyle: Reflecting imported value]
  60. CuraBuildType = ""
  61. class CuraApplication(QtApplication):
  62. class ResourceTypes:
  63. QmlFiles = Resources.UserType + 1
  64. Firmware = Resources.UserType + 2
  65. QualityInstanceContainer = Resources.UserType + 3
  66. MaterialInstanceContainer = Resources.UserType + 4
  67. VariantInstanceContainer = Resources.UserType + 5
  68. UserInstanceContainer = Resources.UserType + 6
  69. MachineStack = Resources.UserType + 7
  70. ExtruderStack = Resources.UserType + 8
  71. Q_ENUMS(ResourceTypes)
  72. def __init__(self):
  73. Resources.addSearchPath(os.path.join(QtApplication.getInstallPrefix(), "share", "cura", "resources"))
  74. if not hasattr(sys, "frozen"):
  75. Resources.addSearchPath(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "resources"))
  76. self._open_file_queue = [] # Files to open when plug-ins are loaded.
  77. # Need to do this before ContainerRegistry tries to load the machines
  78. SettingDefinition.addSupportedProperty("settable_per_mesh", DefinitionPropertyType.Any, default = True, read_only = True)
  79. SettingDefinition.addSupportedProperty("settable_per_extruder", DefinitionPropertyType.Any, default = True, read_only = True)
  80. # this setting can be changed for each group in one-at-a-time mode
  81. SettingDefinition.addSupportedProperty("settable_per_meshgroup", DefinitionPropertyType.Any, default = True, read_only = True)
  82. SettingDefinition.addSupportedProperty("settable_globally", DefinitionPropertyType.Any, default = True, read_only = True)
  83. # From which stack the setting would inherit if not defined per object (handled in the engine)
  84. # AND for settings which are not settable_per_mesh:
  85. # which extruder is the only extruder this setting is obtained from
  86. SettingDefinition.addSupportedProperty("limit_to_extruder", DefinitionPropertyType.Function, default = "-1")
  87. # For settings which are not settable_per_mesh and not settable_per_extruder:
  88. # A function which determines the glabel/meshgroup value by looking at the values of the setting in all (used) extruders
  89. SettingDefinition.addSupportedProperty("resolve", DefinitionPropertyType.Function, default = None, depends_on = "value")
  90. SettingDefinition.addSettingType("extruder", None, str, Validator)
  91. SettingFunction.registerOperator("extruderValues", cura.Settings.ExtruderManager.getExtruderValues)
  92. SettingFunction.registerOperator("extruderValue", cura.Settings.ExtruderManager.getExtruderValue)
  93. SettingFunction.registerOperator("resolveOrValue", cura.Settings.ExtruderManager.getResolveOrValue)
  94. ## Add the 4 types of profiles to storage.
  95. Resources.addStorageType(self.ResourceTypes.QualityInstanceContainer, "quality")
  96. Resources.addStorageType(self.ResourceTypes.VariantInstanceContainer, "variants")
  97. Resources.addStorageType(self.ResourceTypes.MaterialInstanceContainer, "materials")
  98. Resources.addStorageType(self.ResourceTypes.UserInstanceContainer, "user")
  99. Resources.addStorageType(self.ResourceTypes.ExtruderStack, "extruders")
  100. Resources.addStorageType(self.ResourceTypes.MachineStack, "machine_instances")
  101. ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.QualityInstanceContainer)
  102. ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.VariantInstanceContainer)
  103. ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.MaterialInstanceContainer)
  104. ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.UserInstanceContainer)
  105. ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.ExtruderStack)
  106. ContainerRegistry.getInstance().addResourceType(self.ResourceTypes.MachineStack)
  107. ## Initialise the version upgrade manager with Cura's storage paths.
  108. import UM.VersionUpgradeManager #Needs to be here to prevent circular dependencies.
  109. UM.VersionUpgradeManager.VersionUpgradeManager.getInstance().setCurrentVersions(
  110. {
  111. ("quality", UM.Settings.InstanceContainer.Version): (self.ResourceTypes.QualityInstanceContainer, "application/x-uranium-instancecontainer"),
  112. ("machine_stack", UM.Settings.ContainerStack.Version): (self.ResourceTypes.MachineStack, "application/x-uranium-containerstack"),
  113. ("extruder_train", UM.Settings.ContainerStack.Version): (self.ResourceTypes.ExtruderStack, "application/x-uranium-extruderstack"),
  114. ("preferences", UM.Preferences.Version): (Resources.Preferences, "application/x-uranium-preferences"),
  115. ("user", UM.Settings.InstanceContainer.Version): (self.ResourceTypes.UserInstanceContainer, "application/x-uranium-instancecontainer")
  116. }
  117. )
  118. self._currently_loading_files = []
  119. self._non_sliceable_extensions = []
  120. self._machine_action_manager = MachineActionManager.MachineActionManager()
  121. self._machine_manager = None # This is initialized on demand.
  122. self._setting_inheritance_manager = None
  123. self._additional_components = {} # Components to add to certain areas in the interface
  124. super().__init__(name = "cura", version = CuraVersion, buildtype = CuraBuildType)
  125. self.setWindowIcon(QIcon(Resources.getPath(Resources.Images, "cura-icon.png")))
  126. self.setRequiredPlugins([
  127. "CuraEngineBackend",
  128. "MeshView",
  129. "LayerView",
  130. "STLReader",
  131. "SelectionTool",
  132. "CameraTool",
  133. "GCodeWriter",
  134. "LocalFileOutputDevice"
  135. ])
  136. self._physics = None
  137. self._volume = None
  138. self._output_devices = {}
  139. self._print_information = None
  140. self._previous_active_tool = None
  141. self._platform_activity = False
  142. self._scene_bounding_box = AxisAlignedBox.Null
  143. self._job_name = None
  144. self._center_after_select = False
  145. self._camera_animation = None
  146. self._cura_actions = None
  147. self._started = False
  148. self._message_box_callback = None
  149. self._message_box_callback_arguments = []
  150. self._i18n_catalog = i18nCatalog("cura")
  151. self.getController().getScene().sceneChanged.connect(self.updatePlatformActivity)
  152. self.getController().toolOperationStopped.connect(self._onToolOperationStopped)
  153. Resources.addType(self.ResourceTypes.QmlFiles, "qml")
  154. Resources.addType(self.ResourceTypes.Firmware, "firmware")
  155. self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Loading machines..."))
  156. # Add empty variant, material and quality containers.
  157. # Since they are empty, they should never be serialized and instead just programmatically created.
  158. # We need them to simplify the switching between materials.
  159. empty_container = ContainerRegistry.getInstance().getEmptyInstanceContainer()
  160. empty_variant_container = copy.deepcopy(empty_container)
  161. empty_variant_container._id = "empty_variant"
  162. empty_variant_container.addMetaDataEntry("type", "variant")
  163. ContainerRegistry.getInstance().addContainer(empty_variant_container)
  164. empty_material_container = copy.deepcopy(empty_container)
  165. empty_material_container._id = "empty_material"
  166. empty_material_container.addMetaDataEntry("type", "material")
  167. ContainerRegistry.getInstance().addContainer(empty_material_container)
  168. empty_quality_container = copy.deepcopy(empty_container)
  169. empty_quality_container._id = "empty_quality"
  170. empty_quality_container.setName("Not supported")
  171. empty_quality_container.addMetaDataEntry("quality_type", "normal")
  172. empty_quality_container.addMetaDataEntry("type", "quality")
  173. ContainerRegistry.getInstance().addContainer(empty_quality_container)
  174. empty_quality_changes_container = copy.deepcopy(empty_container)
  175. empty_quality_changes_container._id = "empty_quality_changes"
  176. empty_quality_changes_container.addMetaDataEntry("type", "quality_changes")
  177. ContainerRegistry.getInstance().addContainer(empty_quality_changes_container)
  178. with ContainerRegistry.getInstance().lockFile():
  179. ContainerRegistry.getInstance().load()
  180. Preferences.getInstance().addPreference("cura/active_mode", "simple")
  181. Preferences.getInstance().addPreference("cura/recent_files", "")
  182. Preferences.getInstance().addPreference("cura/categories_expanded", "")
  183. Preferences.getInstance().addPreference("cura/jobname_prefix", True)
  184. Preferences.getInstance().addPreference("view/center_on_select", False)
  185. Preferences.getInstance().addPreference("mesh/scale_to_fit", True)
  186. Preferences.getInstance().addPreference("mesh/scale_tiny_meshes", True)
  187. Preferences.getInstance().addPreference("cura/dialog_on_project_save", True)
  188. Preferences.getInstance().addPreference("cura/asked_dialog_on_project_save", False)
  189. for key in [
  190. "dialog_load_path", # dialog_save_path is in LocalFileOutputDevicePlugin
  191. "dialog_profile_path",
  192. "dialog_material_path"]:
  193. Preferences.getInstance().addPreference("local_file/%s" % key, os.path.expanduser("~/"))
  194. Preferences.getInstance().setDefault("local_file/last_used_type", "text/x-gcode")
  195. Preferences.getInstance().setDefault("general/visible_settings", """
  196. machine_settings
  197. resolution
  198. layer_height
  199. shell
  200. wall_thickness
  201. top_bottom_thickness
  202. z_seam_x
  203. z_seam_y
  204. infill
  205. infill_sparse_density
  206. material
  207. material_print_temperature
  208. material_bed_temperature
  209. material_diameter
  210. material_flow
  211. retraction_enable
  212. speed
  213. speed_print
  214. speed_travel
  215. acceleration_print
  216. acceleration_travel
  217. jerk_print
  218. jerk_travel
  219. travel
  220. cooling
  221. cool_fan_enabled
  222. support
  223. support_enable
  224. support_extruder_nr
  225. support_type
  226. support_interface_density
  227. platform_adhesion
  228. adhesion_type
  229. adhesion_extruder_nr
  230. brim_width
  231. raft_airgap
  232. layer_0_z_overlap
  233. raft_surface_layers
  234. dual
  235. prime_tower_enable
  236. prime_tower_size
  237. prime_tower_position_x
  238. prime_tower_position_y
  239. meshfix
  240. blackmagic
  241. print_sequence
  242. infill_mesh
  243. experimental
  244. """.replace("\n", ";").replace(" ", ""))
  245. JobQueue.getInstance().jobFinished.connect(self._onJobFinished)
  246. self.applicationShuttingDown.connect(self.saveSettings)
  247. self.engineCreatedSignal.connect(self._onEngineCreated)
  248. self._recent_files = []
  249. files = Preferences.getInstance().getValue("cura/recent_files").split(";")
  250. for f in files:
  251. if not os.path.isfile(f):
  252. continue
  253. self._recent_files.append(QUrl.fromLocalFile(f))
  254. def _onEngineCreated(self):
  255. self._engine.addImageProvider("camera", CameraImageProvider.CameraImageProvider())
  256. ## A reusable dialogbox
  257. #
  258. showMessageBox = pyqtSignal(str, str, str, str, int, int, arguments = ["title", "text", "informativeText", "detailedText", "buttons", "icon"])
  259. def messageBox(self, title, text, informativeText = "", detailedText = "", buttons = QMessageBox.Ok, icon = QMessageBox.NoIcon, callback = None, callback_arguments = []):
  260. self._message_box_callback = callback
  261. self._message_box_callback_arguments = callback_arguments
  262. self.showMessageBox.emit(title, text, informativeText, detailedText, buttons, icon)
  263. @pyqtSlot(int)
  264. def messageBoxClosed(self, button):
  265. if self._message_box_callback:
  266. self._message_box_callback(button, *self._message_box_callback_arguments)
  267. self._message_box_callback = None
  268. self._message_box_callback_arguments = []
  269. showPrintMonitor = pyqtSignal(bool, arguments = ["show"])
  270. ## Cura has multiple locations where instance containers need to be saved, so we need to handle this differently.
  271. #
  272. # Note that the AutoSave plugin also calls this method.
  273. def saveSettings(self):
  274. if not self._started: # Do not do saving during application start
  275. return
  276. # Lock file for "more" atomically loading and saving to/from config dir.
  277. with ContainerRegistry.getInstance().lockFile():
  278. for instance in ContainerRegistry.getInstance().findInstanceContainers():
  279. if not instance.isDirty():
  280. continue
  281. try:
  282. data = instance.serialize()
  283. except NotImplementedError:
  284. continue
  285. except Exception:
  286. Logger.logException("e", "An exception occurred when serializing container %s", instance.getId())
  287. continue
  288. mime_type = ContainerRegistry.getMimeTypeForContainer(type(instance))
  289. file_name = urllib.parse.quote_plus(instance.getId()) + "." + mime_type.preferredSuffix
  290. instance_type = instance.getMetaDataEntry("type")
  291. path = None
  292. if instance_type == "material":
  293. path = Resources.getStoragePath(self.ResourceTypes.MaterialInstanceContainer, file_name)
  294. elif instance_type == "quality" or instance_type == "quality_changes":
  295. path = Resources.getStoragePath(self.ResourceTypes.QualityInstanceContainer, file_name)
  296. elif instance_type == "user":
  297. path = Resources.getStoragePath(self.ResourceTypes.UserInstanceContainer, file_name)
  298. elif instance_type == "variant":
  299. path = Resources.getStoragePath(self.ResourceTypes.VariantInstanceContainer, file_name)
  300. elif instance_type == "definition_changes":
  301. path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
  302. if path:
  303. instance.setPath(path)
  304. with SaveFile(path, "wt") as f:
  305. f.write(data)
  306. for stack in ContainerRegistry.getInstance().findContainerStacks():
  307. self.saveStack(stack)
  308. def saveStack(self, stack):
  309. if not stack.isDirty():
  310. return
  311. try:
  312. data = stack.serialize()
  313. except NotImplementedError:
  314. return
  315. except Exception:
  316. Logger.logException("e", "An exception occurred when serializing container %s", stack.getId())
  317. return
  318. mime_type = ContainerRegistry.getMimeTypeForContainer(type(stack))
  319. file_name = urllib.parse.quote_plus(stack.getId()) + "." + mime_type.preferredSuffix
  320. stack_type = stack.getMetaDataEntry("type", None)
  321. path = None
  322. if not stack_type or stack_type == "machine":
  323. path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
  324. elif stack_type == "extruder_train":
  325. path = Resources.getStoragePath(self.ResourceTypes.ExtruderStack, file_name)
  326. if path:
  327. stack.setPath(path)
  328. with SaveFile(path, "wt") as f:
  329. f.write(data)
  330. @pyqtSlot(str, result = QUrl)
  331. def getDefaultPath(self, key):
  332. default_path = Preferences.getInstance().getValue("local_file/%s" % key)
  333. return QUrl.fromLocalFile(default_path)
  334. @pyqtSlot(str, str)
  335. def setDefaultPath(self, key, default_path):
  336. Preferences.getInstance().setValue("local_file/%s" % key, default_path)
  337. ## Handle loading of all plugin types (and the backend explicitly)
  338. # \sa PluginRegistery
  339. def _loadPlugins(self):
  340. self._plugin_registry.addType("profile_reader", self._addProfileReader)
  341. self._plugin_registry.addType("profile_writer", self._addProfileWriter)
  342. self._plugin_registry.addPluginLocation(os.path.join(QtApplication.getInstallPrefix(), "lib", "cura"))
  343. if not hasattr(sys, "frozen"):
  344. self._plugin_registry.addPluginLocation(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "plugins"))
  345. self._plugin_registry.loadPlugin("ConsoleLogger")
  346. self._plugin_registry.loadPlugin("CuraEngineBackend")
  347. self._plugin_registry.loadPlugins()
  348. if self.getBackend() == None:
  349. raise RuntimeError("Could not load the backend plugin!")
  350. self._plugins_loaded = True
  351. def addCommandLineOptions(self, parser):
  352. super().addCommandLineOptions(parser)
  353. parser.add_argument("file", nargs="*", help="Files to load after starting the application.")
  354. def run(self):
  355. self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Setting up scene..."))
  356. controller = self.getController()
  357. controller.setActiveView("SolidView")
  358. controller.setCameraTool("CameraTool")
  359. controller.setSelectionTool("SelectionTool")
  360. t = controller.getTool("TranslateTool")
  361. if t:
  362. t.setEnabledAxis([ToolHandle.XAxis, ToolHandle.YAxis,ToolHandle.ZAxis])
  363. Selection.selectionChanged.connect(self.onSelectionChanged)
  364. root = controller.getScene().getRoot()
  365. # The platform is a child of BuildVolume
  366. self._volume = BuildVolume.BuildVolume(root)
  367. self.getRenderer().setBackgroundColor(QColor(245, 245, 245))
  368. self._physics = PlatformPhysics.PlatformPhysics(controller, self._volume)
  369. camera = Camera("3d", root)
  370. camera.setPosition(Vector(-80, 250, 700))
  371. camera.setPerspective(True)
  372. camera.lookAt(Vector(0, 0, 0))
  373. controller.getScene().setActiveCamera("3d")
  374. self.getController().getTool("CameraTool").setOrigin(Vector(0, 100, 0))
  375. self._camera_animation = CameraAnimation.CameraAnimation()
  376. self._camera_animation.setCameraTool(self.getController().getTool("CameraTool"))
  377. self.showSplashMessage(self._i18n_catalog.i18nc("@info:progress", "Loading interface..."))
  378. # Initialise extruder so as to listen to global container stack changes before the first global container stack is set.
  379. cura.Settings.ExtruderManager.getInstance()
  380. qmlRegisterSingletonType(cura.Settings.MachineManager, "Cura", 1, 0, "MachineManager", self.getMachineManager)
  381. qmlRegisterSingletonType(cura.Settings.SettingInheritanceManager, "Cura", 1, 0, "SettingInheritanceManager", self.getSettingInheritanceManager)
  382. qmlRegisterSingletonType(MachineActionManager.MachineActionManager, "Cura", 1, 0, "MachineActionManager", self.getMachineActionManager)
  383. self.setMainQml(Resources.getPath(self.ResourceTypes.QmlFiles, "Cura.qml"))
  384. self._qml_import_paths.append(Resources.getPath(self.ResourceTypes.QmlFiles))
  385. self.initializeEngine()
  386. if self._engine.rootObjects:
  387. self.closeSplash()
  388. for file in self.getCommandLineOption("file", []):
  389. self._openFile(file)
  390. for file_name in self._open_file_queue: #Open all the files that were queued up while plug-ins were loading.
  391. self._openFile(file_name)
  392. self._started = True
  393. self.exec_()
  394. def getMachineManager(self, *args):
  395. if self._machine_manager is None:
  396. self._machine_manager = cura.Settings.MachineManager.createMachineManager()
  397. return self._machine_manager
  398. def getSettingInheritanceManager(self, *args):
  399. if self._setting_inheritance_manager is None:
  400. self._setting_inheritance_manager = cura.Settings.SettingInheritanceManager.createSettingInheritanceManager()
  401. return self._setting_inheritance_manager
  402. ## Get the machine action manager
  403. # We ignore any *args given to this, as we also register the machine manager as qml singleton.
  404. # It wants to give this function an engine and script engine, but we don't care about that.
  405. def getMachineActionManager(self, *args):
  406. return self._machine_action_manager
  407. ## Handle Qt events
  408. def event(self, event):
  409. if event.type() == QEvent.FileOpen:
  410. if self._plugins_loaded:
  411. self._openFile(event.file())
  412. else:
  413. self._open_file_queue.append(event.file())
  414. return super().event(event)
  415. ## Get print information (duration / material used)
  416. def getPrintInformation(self):
  417. return self._print_information
  418. ## Registers objects for the QML engine to use.
  419. #
  420. # \param engine The QML engine.
  421. def registerObjects(self, engine):
  422. engine.rootContext().setContextProperty("Printer", self)
  423. engine.rootContext().setContextProperty("CuraApplication", self)
  424. self._print_information = PrintInformation.PrintInformation()
  425. engine.rootContext().setContextProperty("PrintInformation", self._print_information)
  426. self._cura_actions = CuraActions.CuraActions(self)
  427. engine.rootContext().setContextProperty("CuraActions", self._cura_actions)
  428. qmlRegisterUncreatableType(CuraApplication, "Cura", 1, 0, "ResourceTypes", "Just an Enum type")
  429. qmlRegisterType(cura.Settings.ExtrudersModel, "Cura", 1, 0, "ExtrudersModel")
  430. qmlRegisterType(cura.Settings.ContainerSettingsModel, "Cura", 1, 0, "ContainerSettingsModel")
  431. qmlRegisterSingletonType(cura.Settings.ProfilesModel, "Cura", 1, 0, "ProfilesModel", cura.Settings.ProfilesModel.createProfilesModel)
  432. qmlRegisterType(cura.Settings.QualityAndUserProfilesModel, "Cura", 1, 0, "QualityAndUserProfilesModel")
  433. qmlRegisterType(cura.Settings.UserProfilesModel, "Cura", 1, 0, "UserProfilesModel")
  434. qmlRegisterType(cura.Settings.MaterialSettingsVisibilityHandler, "Cura", 1, 0, "MaterialSettingsVisibilityHandler")
  435. qmlRegisterType(cura.Settings.QualitySettingsModel, "Cura", 1, 0, "QualitySettingsModel")
  436. qmlRegisterType(cura.Settings.MachineNameValidator, "Cura", 1, 0, "MachineNameValidator")
  437. qmlRegisterSingletonType(cura.Settings.ContainerManager, "Cura", 1, 0, "ContainerManager", cura.Settings.ContainerManager.createContainerManager)
  438. # As of Qt5.7, it is necessary to get rid of any ".." in the path for the singleton to work.
  439. actions_url = QUrl.fromLocalFile(os.path.abspath(Resources.getPath(CuraApplication.ResourceTypes.QmlFiles, "Actions.qml")))
  440. qmlRegisterSingletonType(actions_url, "Cura", 1, 0, "Actions")
  441. engine.rootContext().setContextProperty("ExtruderManager", cura.Settings.ExtruderManager.getInstance())
  442. for path in Resources.getAllResourcesOfType(CuraApplication.ResourceTypes.QmlFiles):
  443. type_name = os.path.splitext(os.path.basename(path))[0]
  444. if type_name in ("Cura", "Actions"):
  445. continue
  446. qmlRegisterType(QUrl.fromLocalFile(path), "Cura", 1, 0, type_name)
  447. def onSelectionChanged(self):
  448. if Selection.hasSelection():
  449. if self.getController().getActiveTool():
  450. # If the tool has been disabled by the new selection
  451. if not self.getController().getActiveTool().getEnabled():
  452. # Default
  453. self.getController().setActiveTool("TranslateTool")
  454. else:
  455. if self._previous_active_tool:
  456. self.getController().setActiveTool(self._previous_active_tool)
  457. if not self.getController().getActiveTool().getEnabled():
  458. self.getController().setActiveTool("TranslateTool")
  459. self._previous_active_tool = None
  460. else:
  461. # Default
  462. self.getController().setActiveTool("TranslateTool")
  463. if Preferences.getInstance().getValue("view/center_on_select"):
  464. self._center_after_select = True
  465. else:
  466. if self.getController().getActiveTool():
  467. self._previous_active_tool = self.getController().getActiveTool().getPluginId()
  468. self.getController().setActiveTool(None)
  469. def _onToolOperationStopped(self, event):
  470. if self._center_after_select:
  471. self._center_after_select = False
  472. self._camera_animation.setStart(self.getController().getTool("CameraTool").getOrigin())
  473. self._camera_animation.setTarget(Selection.getSelectedObject(0).getWorldPosition())
  474. self._camera_animation.start()
  475. requestAddPrinter = pyqtSignal()
  476. activityChanged = pyqtSignal()
  477. sceneBoundingBoxChanged = pyqtSignal()
  478. @pyqtProperty(bool, notify = activityChanged)
  479. def getPlatformActivity(self):
  480. return self._platform_activity
  481. @pyqtProperty(str, notify = sceneBoundingBoxChanged)
  482. def getSceneBoundingBoxString(self):
  483. return self._i18n_catalog.i18nc("@info", "%(width).1f x %(depth).1f x %(height).1f mm") % {'width' : self._scene_bounding_box.width.item(), 'depth': self._scene_bounding_box.depth.item(), 'height' : self._scene_bounding_box.height.item()}
  484. def updatePlatformActivity(self, node = None):
  485. count = 0
  486. scene_bounding_box = None
  487. is_block_slicing_node = False
  488. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  489. if type(node) is not SceneNode or (not node.getMeshData() and not node.callDecoration("getLayerData")):
  490. continue
  491. if node.callDecoration("isBlockSlicing"):
  492. is_block_slicing_node = True
  493. count += 1
  494. if not scene_bounding_box:
  495. scene_bounding_box = node.getBoundingBox()
  496. else:
  497. other_bb = node.getBoundingBox()
  498. if other_bb is not None:
  499. scene_bounding_box = scene_bounding_box + node.getBoundingBox()
  500. print_information = self.getPrintInformation()
  501. if print_information:
  502. print_information.setPreSliced(is_block_slicing_node)
  503. if not scene_bounding_box:
  504. scene_bounding_box = AxisAlignedBox.Null
  505. if repr(self._scene_bounding_box) != repr(scene_bounding_box) and scene_bounding_box.isValid():
  506. self._scene_bounding_box = scene_bounding_box
  507. self.sceneBoundingBoxChanged.emit()
  508. self._platform_activity = True if count > 0 else False
  509. self.activityChanged.emit()
  510. # Remove all selected objects from the scene.
  511. @pyqtSlot()
  512. def deleteSelection(self):
  513. if not self.getController().getToolsEnabled():
  514. return
  515. removed_group_nodes = []
  516. op = GroupedOperation()
  517. nodes = Selection.getAllSelectedObjects()
  518. for node in nodes:
  519. op.addOperation(RemoveSceneNodeOperation(node))
  520. group_node = node.getParent()
  521. if group_node and group_node.callDecoration("isGroup") and group_node not in removed_group_nodes:
  522. remaining_nodes_in_group = list(set(group_node.getChildren()) - set(nodes))
  523. if len(remaining_nodes_in_group) == 1:
  524. removed_group_nodes.append(group_node)
  525. op.addOperation(SetParentOperation(remaining_nodes_in_group[0], group_node.getParent()))
  526. op.addOperation(RemoveSceneNodeOperation(group_node))
  527. op.push()
  528. ## Remove an object from the scene.
  529. # Note that this only removes an object if it is selected.
  530. @pyqtSlot("quint64")
  531. def deleteObject(self, object_id):
  532. if not self.getController().getToolsEnabled():
  533. return
  534. node = self.getController().getScene().findObject(object_id)
  535. if not node and object_id != 0: # Workaround for tool handles overlapping the selected object
  536. node = Selection.getSelectedObject(0)
  537. if node:
  538. op = GroupedOperation()
  539. op.addOperation(RemoveSceneNodeOperation(node))
  540. group_node = node.getParent()
  541. if group_node:
  542. # Note that at this point the node has not yet been deleted
  543. if len(group_node.getChildren()) <= 2 and group_node.callDecoration("isGroup"):
  544. op.addOperation(SetParentOperation(group_node.getChildren()[0], group_node.getParent()))
  545. op.addOperation(RemoveSceneNodeOperation(group_node))
  546. op.push()
  547. ## Create a number of copies of existing object.
  548. @pyqtSlot("quint64", int)
  549. def multiplyObject(self, object_id, count):
  550. node = self.getController().getScene().findObject(object_id)
  551. if not node and object_id != 0: # Workaround for tool handles overlapping the selected object
  552. node = Selection.getSelectedObject(0)
  553. if node:
  554. current_node = node
  555. # Find the topmost group
  556. while current_node.getParent() and current_node.getParent().callDecoration("isGroup"):
  557. current_node = current_node.getParent()
  558. op = GroupedOperation()
  559. for _ in range(count):
  560. new_node = copy.deepcopy(current_node)
  561. op.addOperation(AddSceneNodeOperation(new_node, current_node.getParent()))
  562. op.push()
  563. ## Center object on platform.
  564. @pyqtSlot("quint64")
  565. def centerObject(self, object_id):
  566. node = self.getController().getScene().findObject(object_id)
  567. if not node and object_id != 0: # Workaround for tool handles overlapping the selected object
  568. node = Selection.getSelectedObject(0)
  569. if not node:
  570. return
  571. if node.getParent() and node.getParent().callDecoration("isGroup"):
  572. node = node.getParent()
  573. if node:
  574. op = SetTransformOperation(node, Vector())
  575. op.push()
  576. ## Select all nodes containing mesh data in the scene.
  577. @pyqtSlot()
  578. def selectAll(self):
  579. if not self.getController().getToolsEnabled():
  580. return
  581. Selection.clear()
  582. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  583. if type(node) is not SceneNode:
  584. continue
  585. if not node.getMeshData() and not node.callDecoration("isGroup"):
  586. continue # Node that doesnt have a mesh and is not a group.
  587. if node.getParent() and node.getParent().callDecoration("isGroup"):
  588. continue # Grouped nodes don't need resetting as their parent (the group) is resetted)
  589. if not node.isSelectable():
  590. continue # i.e. node with layer data
  591. Selection.add(node)
  592. ## Delete all nodes containing mesh data in the scene.
  593. @pyqtSlot()
  594. def deleteAll(self):
  595. Logger.log("i", "Clearing scene")
  596. if not self.getController().getToolsEnabled():
  597. return
  598. nodes = []
  599. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  600. if type(node) is not SceneNode:
  601. continue
  602. if (not node.getMeshData() and not node.callDecoration("getLayerData")) and not node.callDecoration("isGroup"):
  603. continue # Node that doesnt have a mesh and is not a group.
  604. if node.getParent() and node.getParent().callDecoration("isGroup"):
  605. continue # Grouped nodes don't need resetting as their parent (the group) is resetted)
  606. nodes.append(node)
  607. if nodes:
  608. op = GroupedOperation()
  609. for node in nodes:
  610. op.addOperation(RemoveSceneNodeOperation(node))
  611. op.push()
  612. Selection.clear()
  613. ## Reset all translation on nodes with mesh data.
  614. @pyqtSlot()
  615. def resetAllTranslation(self):
  616. Logger.log("i", "Resetting all scene translations")
  617. nodes = []
  618. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  619. if type(node) is not SceneNode:
  620. continue
  621. if not node.getMeshData() and not node.callDecoration("isGroup"):
  622. continue # Node that doesnt have a mesh and is not a group.
  623. if node.getParent() and node.getParent().callDecoration("isGroup"):
  624. continue # Grouped nodes don't need resetting as their parent (the group) is resetted)
  625. if not node.isSelectable():
  626. continue # i.e. node with layer data
  627. nodes.append(node)
  628. if nodes:
  629. op = GroupedOperation()
  630. for node in nodes:
  631. # Ensure that the object is above the build platform
  632. node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
  633. if node.getBoundingBox():
  634. center_y = node.getWorldPosition().y - node.getBoundingBox().bottom
  635. else:
  636. center_y = 0
  637. op.addOperation(SetTransformOperation(node, Vector(0, center_y, 0)))
  638. op.push()
  639. ## Reset all transformations on nodes with mesh data.
  640. @pyqtSlot()
  641. def resetAll(self):
  642. Logger.log("i", "Resetting all scene transformations")
  643. nodes = []
  644. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  645. if type(node) is not SceneNode:
  646. continue
  647. if not node.getMeshData() and not node.callDecoration("isGroup"):
  648. continue # Node that doesnt have a mesh and is not a group.
  649. if node.getParent() and node.getParent().callDecoration("isGroup"):
  650. continue # Grouped nodes don't need resetting as their parent (the group) is resetted)
  651. if not node.isSelectable():
  652. continue # i.e. node with layer data
  653. nodes.append(node)
  654. if nodes:
  655. op = GroupedOperation()
  656. for node in nodes:
  657. # Ensure that the object is above the build platform
  658. node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
  659. if node.getBoundingBox():
  660. center_y = node.getWorldPosition().y - node.getBoundingBox().bottom
  661. else:
  662. center_y = 0
  663. op.addOperation(SetTransformOperation(node, Vector(0, center_y, 0), Quaternion(), Vector(1, 1, 1)))
  664. op.push()
  665. ## Reload all mesh data on the screen from file.
  666. @pyqtSlot()
  667. def reloadAll(self):
  668. Logger.log("i", "Reloading all loaded mesh data.")
  669. nodes = []
  670. for node in DepthFirstIterator(self.getController().getScene().getRoot()):
  671. if type(node) is not SceneNode or not node.getMeshData():
  672. continue
  673. nodes.append(node)
  674. if not nodes:
  675. return
  676. for node in nodes:
  677. file_name = node.getMeshData().getFileName()
  678. if file_name:
  679. job = ReadMeshJob(file_name)
  680. job._node = node
  681. job.finished.connect(self._reloadMeshFinished)
  682. job.start()
  683. else:
  684. Logger.log("w", "Unable to reload data because we don't have a filename.")
  685. ## Get logging data of the backend engine
  686. # \returns \type{string} Logging data
  687. @pyqtSlot(result = str)
  688. def getEngineLog(self):
  689. log = ""
  690. for entry in self.getBackend().getLog():
  691. log += entry.decode()
  692. return log
  693. recentFilesChanged = pyqtSignal()
  694. @pyqtProperty("QVariantList", notify = recentFilesChanged)
  695. def recentFiles(self):
  696. return self._recent_files
  697. @pyqtSlot("QStringList")
  698. def setExpandedCategories(self, categories):
  699. categories = list(set(categories))
  700. categories.sort()
  701. joined = ";".join(categories)
  702. if joined != Preferences.getInstance().getValue("cura/categories_expanded"):
  703. Preferences.getInstance().setValue("cura/categories_expanded", joined)
  704. self.expandedCategoriesChanged.emit()
  705. expandedCategoriesChanged = pyqtSignal()
  706. @pyqtProperty("QStringList", notify = expandedCategoriesChanged)
  707. def expandedCategories(self):
  708. return Preferences.getInstance().getValue("cura/categories_expanded").split(";")
  709. @pyqtSlot()
  710. def mergeSelected(self):
  711. self.groupSelected()
  712. try:
  713. group_node = Selection.getAllSelectedObjects()[0]
  714. except Exception as e:
  715. Logger.log("d", "mergeSelected: Exception:", e)
  716. return
  717. meshes = [node.getMeshData() for node in group_node.getAllChildren() if node.getMeshData()]
  718. # Compute the center of the objects
  719. object_centers = []
  720. # Forget about the translation that the original objects have
  721. zero_translation = Matrix(data=numpy.zeros(3))
  722. for mesh, node in zip(meshes, group_node.getChildren()):
  723. transformation = node.getLocalTransformation()
  724. transformation.setTranslation(zero_translation)
  725. transformed_mesh = mesh.getTransformed(transformation)
  726. center = transformed_mesh.getCenterPosition()
  727. object_centers.append(center)
  728. if object_centers and len(object_centers) > 0:
  729. middle_x = sum([v.x for v in object_centers]) / len(object_centers)
  730. middle_y = sum([v.y for v in object_centers]) / len(object_centers)
  731. middle_z = sum([v.z for v in object_centers]) / len(object_centers)
  732. offset = Vector(middle_x, middle_y, middle_z)
  733. else:
  734. offset = Vector(0, 0, 0)
  735. # Move each node to the same position.
  736. for mesh, node in zip(meshes, group_node.getChildren()):
  737. transformation = node.getLocalTransformation()
  738. transformation.setTranslation(zero_translation)
  739. transformed_mesh = mesh.getTransformed(transformation)
  740. # Align the object around its zero position
  741. # and also apply the offset to center it inside the group.
  742. node.setPosition(-transformed_mesh.getZeroPosition() - offset)
  743. # Use the previously found center of the group bounding box as the new location of the group
  744. group_node.setPosition(group_node.getBoundingBox().center)
  745. @pyqtSlot()
  746. def groupSelected(self):
  747. # Create a group-node
  748. group_node = SceneNode()
  749. group_decorator = GroupDecorator()
  750. group_node.addDecorator(group_decorator)
  751. group_node.setParent(self.getController().getScene().getRoot())
  752. group_node.setSelectable(True)
  753. center = Selection.getSelectionCenter()
  754. group_node.setPosition(center)
  755. group_node.setCenterPosition(center)
  756. # Move selected nodes into the group-node
  757. Selection.applyOperation(SetParentOperation, group_node)
  758. # Deselect individual nodes and select the group-node instead
  759. for node in group_node.getChildren():
  760. Selection.remove(node)
  761. Selection.add(group_node)
  762. @pyqtSlot()
  763. def ungroupSelected(self):
  764. selected_objects = Selection.getAllSelectedObjects().copy()
  765. for node in selected_objects:
  766. if node.callDecoration("isGroup"):
  767. op = GroupedOperation()
  768. group_parent = node.getParent()
  769. children = node.getChildren().copy()
  770. for child in children:
  771. # Set the parent of the children to the parent of the group-node
  772. op.addOperation(SetParentOperation(child, group_parent))
  773. # Add all individual nodes to the selection
  774. Selection.add(child)
  775. op.push()
  776. # Note: The group removes itself from the scene once all its children have left it,
  777. # see GroupDecorator._onChildrenChanged
  778. def _createSplashScreen(self):
  779. return CuraSplashScreen.CuraSplashScreen()
  780. def _onActiveMachineChanged(self):
  781. pass
  782. fileLoaded = pyqtSignal(str)
  783. def _onFileLoaded(self, job):
  784. nodes = job.getResult()
  785. for node in nodes:
  786. if node is not None:
  787. self.fileLoaded.emit(job.getFileName())
  788. node.setSelectable(True)
  789. node.setName(os.path.basename(job.getFileName()))
  790. op = AddSceneNodeOperation(node, self.getController().getScene().getRoot())
  791. op.push()
  792. self.getController().getScene().sceneChanged.emit(node) #Force scene change.
  793. def _onJobFinished(self, job):
  794. if type(job) is not ReadMeshJob or not job.getResult():
  795. return
  796. f = QUrl.fromLocalFile(job.getFileName())
  797. if f in self._recent_files:
  798. self._recent_files.remove(f)
  799. self._recent_files.insert(0, f)
  800. if len(self._recent_files) > 10:
  801. del self._recent_files[10]
  802. pref = ""
  803. for path in self._recent_files:
  804. pref += path.toLocalFile() + ";"
  805. Preferences.getInstance().setValue("cura/recent_files", pref)
  806. self.recentFilesChanged.emit()
  807. def _reloadMeshFinished(self, job):
  808. # TODO; This needs to be fixed properly. We now make the assumption that we only load a single mesh!
  809. mesh_data = job.getResult()[0].getMeshData()
  810. if mesh_data:
  811. job._node.setMeshData(mesh_data)
  812. else:
  813. Logger.log("w", "Could not find a mesh in reloaded node.")
  814. def _openFile(self, file):
  815. job = ReadMeshJob(os.path.abspath(file))
  816. job.finished.connect(self._onFileLoaded)
  817. job.start()
  818. def _addProfileReader(self, profile_reader):
  819. # TODO: Add the profile reader to the list of plug-ins that can be used when importing profiles.
  820. pass
  821. def _addProfileWriter(self, profile_writer):
  822. pass
  823. @pyqtSlot("QSize")
  824. def setMinimumWindowSize(self, size):
  825. self.getMainWindow().setMinimumSize(size)
  826. def getBuildVolume(self):
  827. return self._volume
  828. additionalComponentsChanged = pyqtSignal(str, arguments = ["areaId"])
  829. @pyqtProperty("QVariantMap", notify = additionalComponentsChanged)
  830. def additionalComponents(self):
  831. return self._additional_components
  832. ## Add a component to a list of components to be reparented to another area in the GUI.
  833. # The actual reparenting is done by the area itself.
  834. # \param area_id \type{str} Identifying name of the area to which the component should be reparented
  835. # \param component \type{QQuickComponent} The component that should be reparented
  836. @pyqtSlot(str, "QVariant")
  837. def addAdditionalComponent(self, area_id, component):
  838. if area_id not in self._additional_components:
  839. self._additional_components[area_id] = []
  840. self._additional_components[area_id].append(component)
  841. self.additionalComponentsChanged.emit(area_id)
  842. @pyqtSlot(str)
  843. def log(self, msg):
  844. Logger.log("d", msg)
  845. @pyqtSlot(QUrl)
  846. def readLocalFile(self, file):
  847. if not file.isValid():
  848. return
  849. scene = self.getController().getScene()
  850. for node in DepthFirstIterator(scene.getRoot()):
  851. if node.callDecoration("isBlockSlicing"):
  852. self.deleteAll()
  853. break
  854. f = file.toLocalFile()
  855. extension = os.path.splitext(f)[1]
  856. filename = os.path.basename(f)
  857. if len(self._currently_loading_files) > 0:
  858. # If a non-slicable file is already being loaded, we prevent loading of any further non-slicable files
  859. if extension.lower() in self._non_sliceable_extensions:
  860. message = Message(
  861. self._i18n_catalog.i18nc("@info:status",
  862. "Only one G-code file can be loaded at a time. Skipped importing {0}",
  863. filename))
  864. message.show()
  865. return
  866. # If file being loaded is non-slicable file, then prevent loading of any other files
  867. extension = os.path.splitext(self._currently_loading_files[0])[1]
  868. if extension.lower() in self._non_sliceable_extensions:
  869. message = Message(
  870. self._i18n_catalog.i18nc("@info:status",
  871. "Can't open any other file if G-code is loading. Skipped importing {0}",
  872. filename))
  873. message.show()
  874. return
  875. self._currently_loading_files.append(f)
  876. if extension in self._non_sliceable_extensions:
  877. self.deleteAll()
  878. job = ReadMeshJob(f)
  879. job.finished.connect(self._readMeshFinished)
  880. job.start()
  881. def _readMeshFinished(self, job):
  882. nodes = job.getResult()
  883. filename = job.getFileName()
  884. self._currently_loading_files.remove(filename)
  885. for node in nodes:
  886. node.setSelectable(True)
  887. node.setName(os.path.basename(filename))
  888. extension = os.path.splitext(filename)[1]
  889. if extension.lower() in self._non_sliceable_extensions:
  890. self.getController().setActiveView("LayerView")
  891. view = self.getController().getActiveView()
  892. view.resetLayerData()
  893. view.setLayer(9999999)
  894. view.calculateMaxLayers()
  895. block_slicing_decorator = BlockSlicingDecorator()
  896. node.addDecorator(block_slicing_decorator)
  897. else:
  898. sliceable_decorator = SliceableObjectDecorator()
  899. node.addDecorator(sliceable_decorator)
  900. scene = self.getController().getScene()
  901. op = AddSceneNodeOperation(node, scene.getRoot())
  902. op.push()
  903. scene.sceneChanged.emit(node)
  904. def addNonSliceableExtension(self, extension):
  905. self._non_sliceable_extensions.append(extension)