MaterialsView.qml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. // Copyright (c) 2022 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.15
  5. import QtQuick.Dialogs 1.2
  6. import QtQuick.Layouts 1.3
  7. import UM 1.5 as UM
  8. import Cura 1.0 as Cura
  9. import ".." // Access to ReadOnlyTextArea.qml
  10. Item
  11. {
  12. id: base
  13. property QtObject properties
  14. property var currentMaterialNode: null
  15. property bool editingEnabled: false
  16. property string currency: UM.Preferences.getValue("cura/currency") ? UM.Preferences.getValue("cura/currency") : "€"
  17. property real firstColumnWidth: (width * 0.50) | 0
  18. property real secondColumnWidth: (width * 0.40) | 0
  19. property string containerId: ""
  20. property var materialPreferenceValues: UM.Preferences.getValue("cura/material_settings") ? JSON.parse(UM.Preferences.getValue("cura/material_settings")) : {}
  21. property var materialManagementModel: CuraApplication.getMaterialManagementModel()
  22. property double spoolLength: calculateSpoolLength()
  23. property real costPerMeter: calculateCostPerMeter()
  24. signal resetSelectedMaterial()
  25. property bool reevaluateLinkedMaterials: false
  26. property string linkedMaterialNames:
  27. {
  28. if (reevaluateLinkedMaterials)
  29. {
  30. reevaluateLinkedMaterials = false;
  31. }
  32. if (!base.containerId || !base.editingEnabled || !base.currentMaterialNode)
  33. {
  34. return "";
  35. }
  36. var linkedMaterials = Cura.ContainerManager.getLinkedMaterials(base.currentMaterialNode, true);
  37. if (linkedMaterials.length == 0)
  38. {
  39. return "";
  40. }
  41. return linkedMaterials.join(", ");
  42. }
  43. function getApproximateDiameter(diameter)
  44. {
  45. return Math.round(diameter);
  46. }
  47. // This trick makes sure to make all fields lose focus so their onEditingFinished will be triggered
  48. // and modified values will be saved. This can happen when a user changes a value and then closes the
  49. // dialog directly.
  50. //
  51. // Please note that somehow this callback is ONLY triggered when visible is false.
  52. onVisibleChanged:
  53. {
  54. if (!visible)
  55. {
  56. base.focus = false;
  57. }
  58. }
  59. UM.TabRow
  60. {
  61. id: pageSelectorTabRow
  62. UM.TabRowButton
  63. {
  64. text: catalog.i18nc("@title", "Information")
  65. property string activeView: "information" //To determine which page gets displayed.
  66. }
  67. UM.TabRowButton
  68. {
  69. text: catalog.i18nc("@label", "Print settings")
  70. property string activeView: "settings"
  71. }
  72. }
  73. Rectangle
  74. {
  75. color: UM.Theme.getColor("main_background")
  76. anchors
  77. {
  78. top: pageSelectorTabRow.bottom
  79. topMargin: -UM.Theme.getSize("default_lining").width
  80. left: parent.left
  81. right: parent.right
  82. bottom: parent.bottom
  83. }
  84. border.width: UM.Theme.getSize("default_lining").width
  85. border.color: UM.Theme.getColor("thick_lining")
  86. ScrollView
  87. {
  88. id: informationPage
  89. anchors
  90. {
  91. fill: parent
  92. topMargin: UM.Theme.getSize("thin_margin").height
  93. bottomMargin: UM.Theme.getSize("thin_margin").height
  94. leftMargin: UM.Theme.getSize("thin_margin").width
  95. rightMargin: UM.Theme.getSize("thin_margin").width
  96. }
  97. ScrollBar.vertical: UM.ScrollBar
  98. {
  99. parent: informationPage
  100. anchors
  101. {
  102. top: parent.top
  103. right: parent.right
  104. bottom: parent.bottom
  105. }
  106. }
  107. ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
  108. clip: true
  109. visible: pageSelectorTabRow.currentItem.activeView === "information"
  110. property real columnWidth: Math.floor(width / 2 - UM.Theme.getSize("narrow_margin").width)
  111. property real rowHeight: UM.Theme.getSize("setting_control").height
  112. Column
  113. {
  114. width: informationPage.width
  115. spacing: UM.Theme.getSize("narrow_margin").height
  116. Cura.MessageDialog
  117. {
  118. id: confirmDiameterChangeDialog
  119. title: catalog.i18nc("@title:window", "Confirm Diameter Change")
  120. text: catalog.i18nc("@label (%1 is a number)", "The new filament diameter is set to %1 mm, which is not compatible with the current extruder. Do you wish to continue?".arg(new_diameter_value))
  121. standardButtons: Dialog.Yes | Dialog.No
  122. property var new_diameter_value: null
  123. property var old_diameter_value: null
  124. property var old_approximate_diameter_value: null
  125. onAccepted:
  126. {
  127. base.setMetaDataEntry("approximate_diameter", old_approximate_diameter_value, getApproximateDiameter(new_diameter_value).toString());
  128. base.setMetaDataEntry("properties/diameter", properties.diameter, new_diameter_value);
  129. // CURA-6868 Make sure to update the extruder to user a diameter-compatible material.
  130. Cura.MachineManager.updateMaterialWithVariant()
  131. base.resetSelectedMaterial()
  132. }
  133. onRejected:
  134. {
  135. base.properties.diameter = old_diameter_value;
  136. diameterSpinBox.value = Qt.binding(function() { return base.properties.diameter })
  137. }
  138. }
  139. Row
  140. {
  141. spacing: UM.Theme.getSize("narrow_margin").width
  142. UM.Label
  143. {
  144. height: informationPage.rowHeight
  145. width: informationPage.columnWidth
  146. text: catalog.i18nc("@label", "Display Name")
  147. }
  148. Cura.TextField
  149. {
  150. id: displayNameTextField;
  151. width: informationPage.columnWidth;
  152. text: properties.name;
  153. enabled: base.editingEnabled;
  154. onEditingFinished: base.updateMaterialDisplayName(properties.name, text)
  155. }
  156. }
  157. Row
  158. {
  159. spacing: UM.Theme.getSize("narrow_margin").width
  160. UM.Label
  161. {
  162. height: informationPage.rowHeight
  163. width: informationPage.columnWidth
  164. text: catalog.i18nc("@label", "Brand")
  165. }
  166. Cura.TextField
  167. {
  168. id: brandTextField
  169. width: informationPage.columnWidth
  170. text: properties.brand
  171. enabled: base.editingEnabled
  172. onEditingFinished: base.updateMaterialBrand(properties.brand, text)
  173. }
  174. }
  175. Row
  176. {
  177. spacing: UM.Theme.getSize("narrow_margin").width
  178. UM.Label
  179. {
  180. height: informationPage.rowHeight
  181. width: informationPage.columnWidth
  182. text: catalog.i18nc("@label", "Material Type")
  183. }
  184. Cura.TextField
  185. {
  186. id: materialTypeField
  187. width: informationPage.columnWidth
  188. text: properties.material
  189. enabled: base.editingEnabled
  190. onEditingFinished: base.updateMaterialType(properties.material, text)
  191. }
  192. }
  193. Row
  194. {
  195. spacing: UM.Theme.getSize("narrow_margin").width
  196. UM.Label
  197. {
  198. height: informationPage.rowHeight
  199. width: informationPage.columnWidth
  200. verticalAlignment: Qt.AlignVCenter; text: catalog.i18nc("@label", "Color")
  201. }
  202. Row
  203. {
  204. width: informationPage.columnWidth
  205. spacing: Math.round(UM.Theme.getSize("default_margin").width / 2)
  206. // color indicator square
  207. Item
  208. {
  209. id: colorSelector
  210. anchors.verticalCenter: parent.verticalCenter
  211. width: colorSelectorBackground.width + 2 * UM.Theme.getSize("narrow_margin").width
  212. height: colorSelectorBackground.height + 2 * UM.Theme.getSize("narrow_margin").height
  213. Rectangle
  214. {
  215. id: colorSelectorBackground
  216. color: properties.color_code
  217. width: UM.Theme.getSize("icon_indicator").width
  218. height: UM.Theme.getSize("icon_indicator").height
  219. radius: width / 2
  220. anchors.centerIn: parent
  221. }
  222. // open the color selection dialog on click
  223. MouseArea
  224. {
  225. anchors.fill: parent
  226. onClicked: colorDialog.open()
  227. enabled: base.editingEnabled
  228. }
  229. }
  230. // pretty color name text field
  231. Cura.TextField
  232. {
  233. id: colorLabel;
  234. width: parent.width - colorSelector.width - parent.spacing
  235. text: properties.color_name;
  236. enabled: base.editingEnabled
  237. onEditingFinished: base.setMetaDataEntry("color_name", properties.color_name, text)
  238. }
  239. // popup dialog to select a new color
  240. // if successful it sets the properties.color_code value to the new color
  241. Cura.ColorDialog
  242. {
  243. id: colorDialog
  244. title: catalog.i18nc("@title", "Material color picker")
  245. color: properties.color_code
  246. onAccepted: base.setMetaDataEntry("color_code", properties.color_code, color)
  247. }
  248. }
  249. }
  250. UM.Label
  251. {
  252. width: parent.width
  253. height: parent.rowHeight
  254. font: UM.Theme.getFont("default_bold")
  255. verticalAlignment: Qt.AlignVCenter
  256. text: catalog.i18nc("@label", "Properties")
  257. }
  258. Row
  259. {
  260. height: parent.rowHeight
  261. spacing: UM.Theme.getSize("narrow_margin").width
  262. UM.Label
  263. {
  264. height: informationPage.rowHeight
  265. width: informationPage.columnWidth
  266. text: catalog.i18nc("@label", "Density")
  267. }
  268. Cura.SpinBox
  269. {
  270. enabled: base.editingEnabled
  271. id: densitySpinBox
  272. width: informationPage.columnWidth
  273. value: properties.density
  274. decimals: 2
  275. suffix: " g/cm³"
  276. stepSize: 0.01
  277. onEditingFinished: base.setMetaDataEntry("properties/density", properties.density, value)
  278. onValueChanged: updateCostPerMeter()
  279. }
  280. }
  281. Row
  282. {
  283. height: parent.rowHeight
  284. spacing: UM.Theme.getSize("narrow_margin").width
  285. UM.Label
  286. {
  287. height: informationPage.rowHeight
  288. width: informationPage.columnWidth
  289. text: catalog.i18nc("@label", "Diameter")
  290. }
  291. Cura.SpinBox
  292. {
  293. enabled: base.editingEnabled
  294. id: diameterSpinBox
  295. width: informationPage.columnWidth
  296. value: properties.diameter
  297. decimals: 2
  298. suffix: " mm"
  299. stepSize: 0.01
  300. onEditingFinished:
  301. {
  302. // This does not use a SettingPropertyProvider, because we need to make the change to all containers
  303. // which derive from the same base_file
  304. var old_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/diameter");
  305. var old_approximate_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "approximate_diameter");
  306. var new_approximate_diameter = getApproximateDiameter(value);
  307. if (new_approximate_diameter != Cura.ExtruderManager.getActiveExtruderStack().approximateMaterialDiameter)
  308. {
  309. confirmDiameterChangeDialog.old_diameter_value = old_diameter;
  310. confirmDiameterChangeDialog.new_diameter_value = value;
  311. confirmDiameterChangeDialog.old_approximate_diameter_value = old_approximate_diameter;
  312. confirmDiameterChangeDialog.open()
  313. }
  314. else {
  315. base.setMetaDataEntry("approximate_diameter", old_approximate_diameter, getApproximateDiameter(value).toString());
  316. base.setMetaDataEntry("properties/diameter", properties.diameter, value);
  317. }
  318. }
  319. onValueChanged: updateCostPerMeter()
  320. }
  321. }
  322. Row
  323. {
  324. height: parent.rowHeight
  325. spacing: UM.Theme.getSize("narrow_margin").width
  326. UM.Label
  327. {
  328. height: informationPage.rowHeight
  329. width: informationPage.columnWidth
  330. text: catalog.i18nc("@label", "Filament Cost")
  331. }
  332. Cura.SpinBox
  333. {
  334. id: spoolCostSpinBox
  335. width: informationPage.columnWidth
  336. value: base.getMaterialPreferenceValue(properties.guid, "spool_cost")
  337. to: 100000000
  338. editable: true
  339. prefix: base.currency + " "
  340. decimals: 2
  341. onValueChanged:
  342. {
  343. base.setMaterialPreferenceValue(properties.guid, "spool_cost", parseFloat(value))
  344. updateCostPerMeter()
  345. }
  346. }
  347. }
  348. Row
  349. {
  350. height: parent.rowHeight
  351. spacing: UM.Theme.getSize("narrow_margin").width
  352. UM.Label
  353. {
  354. height: informationPage.rowHeight
  355. width: informationPage.columnWidth
  356. text: catalog.i18nc("@label", "Filament weight")
  357. }
  358. Cura.SpinBox
  359. {
  360. id: spoolWeightSpinBox
  361. width: informationPage.columnWidth
  362. value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"))
  363. stepSize: 100
  364. to: 10000
  365. editable: true
  366. suffix: " g"
  367. onValueChanged:
  368. {
  369. base.setMaterialPreferenceValue(properties.guid, "spool_weight", parseFloat(value))
  370. updateCostPerMeter()
  371. }
  372. }
  373. }
  374. Row
  375. {
  376. height: parent.rowHeight
  377. spacing: UM.Theme.getSize("narrow_margin").width
  378. UM.Label
  379. {
  380. height: informationPage.rowHeight
  381. width: informationPage.columnWidth
  382. text: catalog.i18nc("@label", "Filament length")
  383. }
  384. UM.Label
  385. {
  386. width: informationPage.columnWidth
  387. text: "~ %1 m".arg(Math.round(base.spoolLength))
  388. height: informationPage.rowHeight
  389. }
  390. }
  391. Row
  392. {
  393. height: parent.rowHeight
  394. spacing: UM.Theme.getSize("narrow_margin").width
  395. UM.Label
  396. {
  397. height: informationPage.rowHeight
  398. width: informationPage.columnWidth
  399. text: catalog.i18nc("@label", "Cost per Meter")
  400. }
  401. UM.Label
  402. {
  403. height: informationPage.rowHeight
  404. width: informationPage.columnWidth
  405. text: "~ %1 %2/m".arg(base.costPerMeter.toFixed(2)).arg(base.currency)
  406. }
  407. }
  408. UM.Label
  409. {
  410. height: parent.rowHeight
  411. width: informationPage.width
  412. text: catalog.i18nc("@label", "This material is linked to %1 and shares some of its properties.").arg(base.linkedMaterialNames)
  413. wrapMode: Text.WordWrap
  414. visible: unlinkMaterialButton.visible
  415. }
  416. Cura.SecondaryButton
  417. {
  418. id: unlinkMaterialButton
  419. text: catalog.i18nc("@label", "Unlink Material")
  420. visible: base.linkedMaterialNames != ""
  421. onClicked:
  422. {
  423. Cura.ContainerManager.unlinkMaterial(base.currentMaterialNode)
  424. base.reevaluateLinkedMaterials = true
  425. }
  426. }
  427. UM.Label
  428. {
  429. width: informationPage.width
  430. height: parent.rowHeight
  431. text: catalog.i18nc("@label", "Description")
  432. }
  433. ReadOnlyTextArea
  434. {
  435. text: properties.description
  436. width: informationPage.width
  437. height: 0.4 * informationPage.width
  438. wrapMode: Text.WordWrap
  439. readOnly: !base.editingEnabled
  440. onEditingFinished: base.setMetaDataEntry("description", properties.description, text)
  441. }
  442. UM.Label
  443. {
  444. width: informationPage.width
  445. height: parent.rowHeight
  446. text: catalog.i18nc("@label", "Adhesion Information")
  447. }
  448. ReadOnlyTextArea
  449. {
  450. text: properties.adhesion_info
  451. width: informationPage.width
  452. height: 0.4 * informationPage.width
  453. wrapMode: Text.WordWrap
  454. readOnly: !base.editingEnabled
  455. onEditingFinished: base.setMetaDataEntry("adhesion_info", properties.adhesion_info, text)
  456. }
  457. }
  458. }
  459. Column
  460. {
  461. visible: pageSelectorTabRow.currentItem.activeView === "settings"
  462. spacing: UM.Theme.getSize("narrow_margin").height
  463. anchors.fill: parent
  464. anchors.topMargin: UM.Theme.getSize("thin_margin").height
  465. anchors.bottomMargin: UM.Theme.getSize("thin_margin").height
  466. anchors.leftMargin: UM.Theme.getSize("thin_margin").width
  467. anchors.rightMargin: UM.Theme.getSize("thin_margin").width
  468. ScrollBar.vertical: UM.ScrollBar {}
  469. clip: true
  470. Repeater
  471. {
  472. model: UM.SettingDefinitionsModel
  473. {
  474. containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
  475. visibilityHandler: Cura.MaterialSettingsVisibilityHandler { }
  476. expanded: ["*"]
  477. }
  478. delegate: UM.TooltipArea
  479. {
  480. width: childrenRect.width
  481. height: childrenRect.height
  482. UM.TooltipArea
  483. {
  484. anchors.fill: parent
  485. text: model.description
  486. }
  487. UM.Label
  488. {
  489. id: label
  490. width: base.firstColumnWidth;
  491. height: spinBox.height + UM.Theme.getSize("default_lining").height
  492. text: model.label
  493. elide: Text.ElideRight
  494. verticalAlignment: Qt.AlignVCenter
  495. }
  496. Cura.SpinBox
  497. {
  498. id: spinBox
  499. anchors.left: label.right
  500. value:
  501. {
  502. // In case the setting is not in the material...
  503. if (!isNaN(parseFloat(materialPropertyProvider.properties.value)))
  504. {
  505. return parseFloat(materialPropertyProvider.properties.value);
  506. }
  507. // ... we search in the variant, and if it is not there...
  508. if (!isNaN(parseFloat(variantPropertyProvider.properties.value)))
  509. {
  510. return parseFloat(variantPropertyProvider.properties.value);
  511. }
  512. // ... then look in the definition container.
  513. if (!isNaN(parseFloat(machinePropertyProvider.properties.value)))
  514. {
  515. return parseFloat(machinePropertyProvider.properties.value);
  516. }
  517. return 0;
  518. }
  519. width: base.secondColumnWidth
  520. suffix: " " + model.unit
  521. to: 99999
  522. decimals: model.unit == "mm" ? 2 : 0
  523. onEditingFinished: materialPropertyProvider.setPropertyValue("value", value)
  524. }
  525. UM.ContainerPropertyProvider
  526. {
  527. id: materialPropertyProvider
  528. containerId: base.containerId
  529. watchedProperties: [ "value" ]
  530. key: model.key
  531. }
  532. UM.ContainerPropertyProvider
  533. {
  534. id: variantPropertyProvider
  535. containerId: Cura.MachineManager.activeStack.variant.id
  536. watchedProperties: [ "value" ]
  537. key: model.key
  538. }
  539. UM.ContainerPropertyProvider
  540. {
  541. id: machinePropertyProvider
  542. containerId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.definition.id: ""
  543. watchedProperties: ["value"]
  544. key: model.key
  545. }
  546. }
  547. }
  548. }
  549. }
  550. function updateCostPerMeter()
  551. {
  552. base.spoolLength = calculateSpoolLength(diameterSpinBox.value, densitySpinBox.value, spoolWeightSpinBox.value);
  553. base.costPerMeter = calculateCostPerMeter(spoolCostSpinBox.value);
  554. }
  555. function calculateSpoolLength(diameter, density, spoolWeight)
  556. {
  557. if(!diameter)
  558. {
  559. diameter = properties.diameter;
  560. }
  561. if(!density)
  562. {
  563. density = properties.density;
  564. }
  565. if(!spoolWeight)
  566. {
  567. spoolWeight = base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"));
  568. }
  569. if (diameter == 0 || density == 0 || spoolWeight == 0)
  570. {
  571. return 0;
  572. }
  573. var area = Math.PI * Math.pow(diameter / 2, 2); // in mm2
  574. var volume = (spoolWeight / density); // in cm3
  575. return volume / area; // in m
  576. }
  577. function calculateCostPerMeter(spoolCost)
  578. {
  579. if(!spoolCost)
  580. {
  581. spoolCost = base.getMaterialPreferenceValue(properties.guid, "spool_cost");
  582. }
  583. if (spoolLength == 0)
  584. {
  585. return 0;
  586. }
  587. return spoolCost / spoolLength;
  588. }
  589. // Tiny convenience function to check if a value really changed before trying to set it.
  590. function setMetaDataEntry(entry_name, old_value, new_value)
  591. {
  592. if (old_value != new_value)
  593. {
  594. Cura.ContainerManager.setContainerMetaDataEntry(base.currentMaterialNode, entry_name, new_value)
  595. // make sure the UI properties are updated as well since we don't re-fetch the entire model here
  596. // When the entry_name is something like properties/diameter, we take the last part of the entry_name
  597. var list = entry_name.split("/")
  598. var key = list[list.length - 1]
  599. properties[key] = new_value
  600. }
  601. }
  602. function setMaterialPreferenceValue(material_guid, entry_name, new_value)
  603. {
  604. if(!(material_guid in materialPreferenceValues))
  605. {
  606. materialPreferenceValues[material_guid] = {};
  607. }
  608. if(entry_name in materialPreferenceValues[material_guid] && materialPreferenceValues[material_guid][entry_name] == new_value)
  609. {
  610. // value has not changed
  611. return;
  612. }
  613. if (entry_name in materialPreferenceValues[material_guid] && new_value.toString() == 0)
  614. {
  615. // no need to store a 0, that's the default, so remove it
  616. materialPreferenceValues[material_guid].delete(entry_name);
  617. if (!(materialPreferenceValues[material_guid]))
  618. {
  619. // remove empty map
  620. materialPreferenceValues.delete(material_guid);
  621. }
  622. }
  623. if (new_value.toString() != 0)
  624. {
  625. // store new value
  626. materialPreferenceValues[material_guid][entry_name] = new_value;
  627. }
  628. // store preference
  629. UM.Preferences.setValue("cura/material_settings", JSON.stringify(materialPreferenceValues));
  630. }
  631. function getMaterialPreferenceValue(material_guid, entry_name, default_value)
  632. {
  633. if(material_guid in materialPreferenceValues && entry_name in materialPreferenceValues[material_guid])
  634. {
  635. return materialPreferenceValues[material_guid][entry_name];
  636. }
  637. default_value = default_value | 0;
  638. return default_value;
  639. }
  640. // update the display name of the material
  641. function updateMaterialDisplayName(old_name, new_name)
  642. {
  643. // don't change when new name is the same
  644. if (old_name == new_name)
  645. {
  646. return
  647. }
  648. // update the values
  649. base.materialManagementModel.setMaterialName(base.currentMaterialNode, new_name)
  650. properties.name = new_name
  651. }
  652. // update the type of the material
  653. function updateMaterialType(old_type, new_type)
  654. {
  655. base.setMetaDataEntry("material", old_type, new_type)
  656. properties.material = new_type
  657. }
  658. // update the brand of the material
  659. function updateMaterialBrand(old_brand, new_brand)
  660. {
  661. base.setMetaDataEntry("brand", old_brand, new_brand)
  662. properties.brand = new_brand
  663. }
  664. }