MachineSettingsAction.qml 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.2
  4. import QtQuick.Controls 1.1
  5. import QtQuick.Layouts 1.1
  6. import QtQuick.Window 2.1
  7. import UM 1.2 as UM
  8. import Cura 1.0 as Cura
  9. Cura.MachineAction
  10. {
  11. id: base
  12. property var extrudersModel: Cura.ExtrudersModel{} // Do not retrieve the Model from a backend. Otherwise the tabs
  13. // in tabView will not removed/updated. Probably QML bug
  14. property int extruderTabsCount: 0
  15. property var activeMachineId: Cura.MachineManager.activeMachine != null ? Cura.MachineManager.activeMachine.id : ""
  16. Connections
  17. {
  18. target: base.extrudersModel
  19. onModelChanged:
  20. {
  21. var extruderCount = base.extrudersModel.count;
  22. base.extruderTabsCount = extruderCount;
  23. }
  24. }
  25. Connections
  26. {
  27. target: dialog ? dialog : null
  28. ignoreUnknownSignals: true
  29. // Any which way this action dialog is dismissed, make sure it is properly finished
  30. onNextClicked: finishAction()
  31. onBackClicked: finishAction()
  32. onAccepted: finishAction()
  33. onRejected: finishAction()
  34. onClosing: finishAction()
  35. }
  36. function finishAction()
  37. {
  38. forceActiveFocus();
  39. manager.onFinishAction();
  40. }
  41. anchors.fill: parent;
  42. Item
  43. {
  44. id: machineSettingsAction
  45. anchors.fill: parent;
  46. UM.I18nCatalog { id: catalog; name: "cura"; }
  47. Label
  48. {
  49. id: pageTitle
  50. width: parent.width
  51. text: catalog.i18nc("@title", "Machine Settings")
  52. wrapMode: Text.WordWrap
  53. font.pointSize: 18;
  54. }
  55. TabView
  56. {
  57. id: settingsTabs
  58. height: parent.height - y
  59. width: parent.width
  60. anchors.left: parent.left
  61. anchors.top: pageTitle.bottom
  62. anchors.topMargin: UM.Theme.getSize("default_margin").height
  63. property real columnWidth: Math.round((width - 3 * UM.Theme.getSize("default_margin").width) / 2)
  64. property real labelColumnWidth: Math.round(columnWidth / 2)
  65. Tab
  66. {
  67. title: catalog.i18nc("@title:tab", "Printer");
  68. anchors.margins: UM.Theme.getSize("default_margin").width
  69. Column
  70. {
  71. spacing: UM.Theme.getSize("default_margin").height
  72. Row
  73. {
  74. width: parent.width
  75. spacing: UM.Theme.getSize("default_margin").height
  76. Column
  77. {
  78. width: settingsTabs.columnWidth
  79. spacing: UM.Theme.getSize("default_lining").height
  80. Label
  81. {
  82. text: catalog.i18nc("@label", "Printer Settings")
  83. font.bold: true
  84. }
  85. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  86. Loader
  87. {
  88. id: buildAreaWidthField
  89. sourceComponent: numericTextFieldWithUnit
  90. property string settingKey: "machine_width"
  91. property string label: catalog.i18nc("@label", "X (Width)")
  92. property string unit: catalog.i18nc("@label", "mm")
  93. property bool forceUpdateOnChange: true
  94. }
  95. Loader
  96. {
  97. id: buildAreaDepthField
  98. sourceComponent: numericTextFieldWithUnit
  99. property string settingKey: "machine_depth"
  100. property string label: catalog.i18nc("@label", "Y (Depth)")
  101. property string unit: catalog.i18nc("@label", "mm")
  102. property bool forceUpdateOnChange: true
  103. }
  104. Loader
  105. {
  106. id: buildAreaHeightField
  107. sourceComponent: numericTextFieldWithUnit
  108. property string settingKey: "machine_height"
  109. property string label: catalog.i18nc("@label", "Z (Height)")
  110. property string unit: catalog.i18nc("@label", "mm")
  111. property bool forceUpdateOnChange: true
  112. }
  113. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  114. Loader
  115. {
  116. id: shapeComboBox
  117. sourceComponent: comboBoxWithOptions
  118. property string settingKey: "machine_shape"
  119. property string label: catalog.i18nc("@label", "Build plate shape")
  120. property bool forceUpdateOnChange: true
  121. }
  122. Loader
  123. {
  124. id: centerIsZeroCheckBox
  125. sourceComponent: simpleCheckBox
  126. property string settingKey: "machine_center_is_zero"
  127. property string label: catalog.i18nc("@option:check", "Origin at center")
  128. property bool forceUpdateOnChange: true
  129. }
  130. Loader
  131. {
  132. id: heatedBedCheckBox
  133. sourceComponent: simpleCheckBox
  134. property var settingKey: "machine_heated_bed"
  135. property string label: catalog.i18nc("@option:check", "Heated bed")
  136. property bool forceUpdateOnChange: true
  137. }
  138. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  139. Loader
  140. {
  141. id: gcodeFlavorComboBox
  142. sourceComponent: comboBoxWithOptions
  143. property string settingKey: "machine_gcode_flavor"
  144. property string label: catalog.i18nc("@label", "G-code flavor")
  145. property bool forceUpdateOnChange: true
  146. property var afterOnActivate: manager.updateHasMaterialsMetadata
  147. }
  148. }
  149. Column
  150. {
  151. width: settingsTabs.columnWidth
  152. spacing: UM.Theme.getSize("default_lining").height
  153. Label
  154. {
  155. text: catalog.i18nc("@label", "Printhead Settings")
  156. font.bold: true
  157. }
  158. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  159. Loader
  160. {
  161. id: printheadXMinField
  162. sourceComponent: headPolygonTextField
  163. property string label: catalog.i18nc("@label", "X min")
  164. property string tooltip: catalog.i18nc("@tooltip", "Distance from the left of the printhead to the center of the nozzle. Used to prevent colissions between previous prints and the printhead when printing \"One at a Time\".")
  165. property string axis: "x"
  166. property string side: "min"
  167. }
  168. Loader
  169. {
  170. id: printheadYMinField
  171. sourceComponent: headPolygonTextField
  172. property string label: catalog.i18nc("@label", "Y min")
  173. property string tooltip: catalog.i18nc("@tooltip", "Distance from the front of the printhead to the center of the nozzle. Used to prevent colissions between previous prints and the printhead when printing \"One at a Time\".")
  174. property string axis: "y"
  175. property string side: "min"
  176. }
  177. Loader
  178. {
  179. id: printheadXMaxField
  180. sourceComponent: headPolygonTextField
  181. property string label: catalog.i18nc("@label", "X max")
  182. property string tooltip: catalog.i18nc("@tooltip", "Distance from the right of the printhead to the center of the nozzle. Used to prevent colissions between previous prints and the printhead when printing \"One at a Time\".")
  183. property string axis: "x"
  184. property string side: "max"
  185. }
  186. Loader
  187. {
  188. id: printheadYMaxField
  189. sourceComponent: headPolygonTextField
  190. property string label: catalog.i18nc("@label", "Y max")
  191. property string tooltip: catalog.i18nc("@tooltip", "Distance from the rear of the printhead to the center of the nozzle. Used to prevent colissions between previous prints and the printhead when printing \"One at a Time\".")
  192. property string axis: "y"
  193. property string side: "max"
  194. }
  195. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  196. Loader
  197. {
  198. id: gantryHeightField
  199. sourceComponent: numericTextFieldWithUnit
  200. property string settingKey: "gantry_height"
  201. property string label: catalog.i18nc("@label", "Gantry height")
  202. property string unit: catalog.i18nc("@label", "mm")
  203. property string tooltip: catalog.i18nc("@tooltip", "The height difference between the tip of the nozzle and the gantry system (X and Y axes). Used to prevent collisions between previous prints and the gantry when printing \"One at a Time\".")
  204. property bool forceUpdateOnChange: true
  205. }
  206. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  207. UM.TooltipArea
  208. {
  209. height: childrenRect.height
  210. width: childrenRect.width
  211. text: machineExtruderCountProvider.properties.description
  212. visible: extruderCountModel.count >= 2
  213. Row
  214. {
  215. spacing: UM.Theme.getSize("default_margin").width
  216. Label
  217. {
  218. text: catalog.i18nc("@label", "Number of Extruders")
  219. elide: Text.ElideRight
  220. width: Math.max(0, settingsTabs.labelColumnWidth)
  221. anchors.verticalCenter: extruderCountComboBox.verticalCenter
  222. }
  223. ComboBox
  224. {
  225. id: extruderCountComboBox
  226. model: ListModel
  227. {
  228. id: extruderCountModel
  229. Component.onCompleted:
  230. {
  231. for(var i = 0; i < manager.definedExtruderCount; i++)
  232. {
  233. extruderCountModel.append({text: String(i + 1), value: i});
  234. }
  235. }
  236. }
  237. Connections
  238. {
  239. target: manager
  240. onDefinedExtruderCountChanged:
  241. {
  242. extruderCountModel.clear();
  243. for(var i = 0; i < manager.definedExtruderCount; ++i)
  244. {
  245. extruderCountModel.append({text: String(i + 1), value: i});
  246. }
  247. }
  248. }
  249. currentIndex: machineExtruderCountProvider.properties.value - 1
  250. onActivated:
  251. {
  252. manager.setMachineExtruderCount(index + 1);
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. Row
  260. {
  261. spacing: UM.Theme.getSize("default_margin").width
  262. anchors.left: parent.left
  263. anchors.right: parent.right
  264. height: parent.height - y
  265. Column
  266. {
  267. height: parent.height
  268. width: settingsTabs.columnWidth
  269. Label
  270. {
  271. text: catalog.i18nc("@label", "Start G-code")
  272. font.bold: true
  273. }
  274. Loader
  275. {
  276. id: machineStartGcodeField
  277. sourceComponent: gcodeTextArea
  278. property int areaWidth: parent.width
  279. property int areaHeight: parent.height - y
  280. property string settingKey: "machine_start_gcode"
  281. property string tooltip: catalog.i18nc("@tooltip", "G-code commands to be executed at the very start.")
  282. }
  283. }
  284. Column {
  285. height: parent.height
  286. width: settingsTabs.columnWidth
  287. Label
  288. {
  289. text: catalog.i18nc("@label", "End G-code")
  290. font.bold: true
  291. }
  292. Loader
  293. {
  294. id: machineEndGcodeField
  295. sourceComponent: gcodeTextArea
  296. property int areaWidth: parent.width
  297. property int areaHeight: parent.height - y
  298. property string settingKey: "machine_end_gcode"
  299. property string tooltip: catalog.i18nc("@tooltip", "G-code commands to be executed at the very end.")
  300. }
  301. }
  302. }
  303. }
  304. }
  305. onCurrentIndexChanged:
  306. {
  307. if(currentIndex > 0)
  308. {
  309. contentItem.forceActiveFocus();
  310. }
  311. }
  312. Repeater
  313. {
  314. id: extruderTabsRepeater
  315. model: base.extruderTabsCount
  316. Tab
  317. {
  318. title: base.extrudersModel.getItem(index).name
  319. anchors.margins: UM.Theme.getSize("default_margin").width
  320. Column
  321. {
  322. spacing: UM.Theme.getSize("default_lining").width
  323. Label
  324. {
  325. text: catalog.i18nc("@label", "Nozzle Settings")
  326. font.bold: true
  327. }
  328. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  329. Loader
  330. {
  331. id: extruderNozzleSizeField
  332. visible: !Cura.MachineManager.hasVariants
  333. sourceComponent: numericTextFieldWithUnit
  334. property string settingKey: "machine_nozzle_size"
  335. property string label: catalog.i18nc("@label", "Nozzle size")
  336. property string unit: catalog.i18nc("@label", "mm")
  337. function afterOnEditingFinished()
  338. {
  339. // Somehow the machine_nozzle_size dependent settings are not updated otherwise
  340. Cura.MachineManager.forceUpdateAllSettings()
  341. }
  342. property bool isExtruderSetting: true
  343. }
  344. Loader
  345. {
  346. id: materialDiameterField
  347. visible: Cura.MachineManager.hasMaterials
  348. sourceComponent: numericTextFieldWithUnit
  349. property string settingKey: "material_diameter"
  350. property string label: catalog.i18nc("@label", "Compatible material diameter")
  351. property string unit: catalog.i18nc("@label", "mm")
  352. property string tooltip: catalog.i18nc("@tooltip", "The nominal diameter of filament supported by the printer. The exact diameter will be overridden by the material and/or the profile.")
  353. function afterOnEditingFinished()
  354. {
  355. if (settingsTabs.currentIndex > 0)
  356. {
  357. manager.updateMaterialForDiameter(settingsTabs.currentIndex - 1)
  358. }
  359. }
  360. function setValueFunction(value)
  361. {
  362. if (settingsTabs.currentIndex > 0)
  363. {
  364. const extruderIndex = index.toString()
  365. Cura.MachineManager.activeMachine.extruders[extruderIndex].compatibleMaterialDiameter = value
  366. }
  367. }
  368. property bool isExtruderSetting: true
  369. }
  370. Loader
  371. {
  372. id: extruderOffsetXField
  373. sourceComponent: numericTextFieldWithUnit
  374. property string settingKey: "machine_nozzle_offset_x"
  375. property string label: catalog.i18nc("@label", "Nozzle offset X")
  376. property string unit: catalog.i18nc("@label", "mm")
  377. property bool isExtruderSetting: true
  378. property bool forceUpdateOnChange: true
  379. property bool allowNegative: true
  380. }
  381. Loader
  382. {
  383. id: extruderOffsetYField
  384. sourceComponent: numericTextFieldWithUnit
  385. property string settingKey: "machine_nozzle_offset_y"
  386. property string label: catalog.i18nc("@label", "Nozzle offset Y")
  387. property string unit: catalog.i18nc("@label", "mm")
  388. property bool isExtruderSetting: true
  389. property bool forceUpdateOnChange: true
  390. property bool allowNegative: true
  391. }
  392. Loader
  393. {
  394. id: extruderCoolingFanNumberField
  395. sourceComponent: numericTextFieldWithUnit
  396. property string settingKey: "machine_extruder_cooling_fan_number"
  397. property string label: catalog.i18nc("@label", "Cooling Fan Number")
  398. property string unit: catalog.i18nc("@label", "")
  399. property bool isExtruderSetting: true
  400. property bool forceUpdateOnChange: true
  401. property bool allowNegative: false
  402. }
  403. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  404. Row
  405. {
  406. spacing: UM.Theme.getSize("default_margin").width
  407. anchors.left: parent.left
  408. anchors.right: parent.right
  409. height: parent.height - y
  410. Column
  411. {
  412. height: parent.height
  413. width: settingsTabs.columnWidth
  414. Label
  415. {
  416. text: catalog.i18nc("@label", "Extruder Start G-code")
  417. font.bold: true
  418. }
  419. Loader
  420. {
  421. id: extruderStartGcodeField
  422. sourceComponent: gcodeTextArea
  423. property int areaWidth: parent.width
  424. property int areaHeight: parent.height - y
  425. property string settingKey: "machine_extruder_start_code"
  426. property bool isExtruderSetting: true
  427. }
  428. }
  429. Column {
  430. height: parent.height
  431. width: settingsTabs.columnWidth
  432. Label
  433. {
  434. text: catalog.i18nc("@label", "Extruder End G-code")
  435. font.bold: true
  436. }
  437. Loader
  438. {
  439. id: extruderEndGcodeField
  440. sourceComponent: gcodeTextArea
  441. property int areaWidth: parent.width
  442. property int areaHeight: parent.height - y
  443. property string settingKey: "machine_extruder_end_code"
  444. property bool isExtruderSetting: true
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. }
  452. }
  453. Component
  454. {
  455. id: simpleCheckBox
  456. UM.TooltipArea
  457. {
  458. height: checkBox.height
  459. width: checkBox.width
  460. text: _tooltip
  461. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false: isExtruderSetting
  462. property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false: forceUpdateOnChange
  463. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  464. UM.SettingPropertyProvider
  465. {
  466. id: propertyProvider
  467. containerStackId: {
  468. if(_isExtruderSetting)
  469. {
  470. if(settingsTabs.currentIndex > 0)
  471. {
  472. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  473. }
  474. return "";
  475. }
  476. return base.activeMachineId
  477. }
  478. key: settingKey
  479. watchedProperties: [ "value", "description" ]
  480. storeIndex: manager.containerIndex
  481. }
  482. CheckBox
  483. {
  484. id: checkBox
  485. text: label
  486. checked: String(propertyProvider.properties.value).toLowerCase() != 'false'
  487. onClicked:
  488. {
  489. propertyProvider.setPropertyValue("value", checked);
  490. if(_forceUpdateOnChange)
  491. {
  492. manager.forceUpdate();
  493. }
  494. }
  495. }
  496. }
  497. }
  498. Component
  499. {
  500. id: numericTextFieldWithUnit
  501. UM.TooltipArea
  502. {
  503. height: childrenRect.height
  504. width: childrenRect.width
  505. text: _tooltip
  506. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false: isExtruderSetting
  507. property bool _allowNegative: (typeof(allowNegative) === 'undefined') ? false : allowNegative
  508. property var _afterOnEditingFinished: (typeof(afterOnEditingFinished) === 'undefined') ? undefined : afterOnEditingFinished
  509. property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false : forceUpdateOnChange
  510. property string _label: (typeof(label) === 'undefined') ? "" : label
  511. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  512. property var _setValueFunction: (typeof(setValueFunction) === 'undefined') ? undefined : setValueFunction
  513. UM.SettingPropertyProvider
  514. {
  515. id: propertyProvider
  516. containerStackId: {
  517. if(_isExtruderSetting)
  518. {
  519. if(settingsTabs.currentIndex > 0)
  520. {
  521. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  522. }
  523. return "";
  524. }
  525. return base.activeMachineId
  526. }
  527. key: settingKey
  528. watchedProperties: [ "value", "description" ]
  529. storeIndex: manager.containerIndex
  530. }
  531. Row
  532. {
  533. spacing: UM.Theme.getSize("default_margin").width
  534. Label
  535. {
  536. text: _label
  537. visible: _label != ""
  538. elide: Text.ElideRight
  539. width: Math.max(0, settingsTabs.labelColumnWidth)
  540. anchors.verticalCenter: textFieldWithUnit.verticalCenter
  541. }
  542. Item
  543. {
  544. width: textField.width
  545. height: textField.height
  546. id: textFieldWithUnit
  547. TextField
  548. {
  549. id: textField
  550. text: {
  551. const value = propertyProvider.properties.value;
  552. return value ? value : "";
  553. }
  554. validator: RegExpValidator { regExp: _allowNegative ? /-?[0-9\.,]{0,6}/ : /[0-9\.,]{0,6}/ }
  555. onEditingFinished:
  556. {
  557. if (propertyProvider && text != propertyProvider.properties.value)
  558. {
  559. // For some properties like the extruder-compatible material diameter, they need to
  560. // trigger many updates, such as the available materials, the current material may
  561. // need to be switched, etc. Although setting the diameter can be done directly via
  562. // the provider, all the updates that need to be triggered then need to depend on
  563. // the metadata update, a signal that can be fired way too often. The update functions
  564. // can have if-checks to filter out the irrelevant updates, but still it incurs unnecessary
  565. // overhead.
  566. // The ExtruderStack class has a dedicated function for this call "setCompatibleMaterialDiameter()",
  567. // and it triggers the diameter update signals only when it is needed. Here it is optionally
  568. // choose to use setCompatibleMaterialDiameter() or other more specific functions that
  569. // are available.
  570. if (_setValueFunction !== undefined)
  571. {
  572. _setValueFunction(text)
  573. }
  574. else
  575. {
  576. propertyProvider.setPropertyValue("value", text)
  577. }
  578. if(_forceUpdateOnChange)
  579. {
  580. manager.forceUpdate()
  581. }
  582. if(_afterOnEditingFinished)
  583. {
  584. _afterOnEditingFinished()
  585. }
  586. }
  587. }
  588. }
  589. Label
  590. {
  591. text: unit
  592. anchors.right: textField.right
  593. anchors.rightMargin: y - textField.y
  594. anchors.verticalCenter: textField.verticalCenter
  595. }
  596. }
  597. }
  598. }
  599. }
  600. Component
  601. {
  602. id: comboBoxWithOptions
  603. UM.TooltipArea
  604. {
  605. height: childrenRect.height
  606. width: childrenRect.width
  607. text: _tooltip
  608. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false : isExtruderSetting
  609. property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false : forceUpdateOnChange
  610. property var _afterOnActivate: (typeof(afterOnActivate) === 'undefined') ? undefined : afterOnActivate
  611. property string _label: (typeof(label) === 'undefined') ? "" : label
  612. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  613. UM.SettingPropertyProvider
  614. {
  615. id: propertyProvider
  616. containerStackId: {
  617. if(_isExtruderSetting)
  618. {
  619. if(settingsTabs.currentIndex > 0)
  620. {
  621. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  622. }
  623. return "";
  624. }
  625. return base.activeMachineId
  626. }
  627. key: settingKey
  628. watchedProperties: [ "value", "options", "description" ]
  629. storeIndex: manager.containerIndex
  630. }
  631. Row
  632. {
  633. spacing: UM.Theme.getSize("default_margin").width
  634. Label
  635. {
  636. text: _label
  637. visible: _label != ""
  638. elide: Text.ElideRight
  639. width: Math.max(0, settingsTabs.labelColumnWidth)
  640. anchors.verticalCenter: comboBox.verticalCenter
  641. }
  642. ComboBox
  643. {
  644. id: comboBox
  645. model: ListModel
  646. {
  647. id: optionsModel
  648. Component.onCompleted:
  649. {
  650. // Options come in as a string-representation of an OrderedDict
  651. var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/);
  652. if(options)
  653. {
  654. options = options[1].split("), (")
  655. for(var i = 0; i < options.length; i++)
  656. {
  657. var option = options[i].substring(1, options[i].length - 1).split("', '")
  658. optionsModel.append({text: option[1], value: option[0]});
  659. }
  660. }
  661. }
  662. }
  663. currentIndex:
  664. {
  665. var currentValue = propertyProvider.properties.value;
  666. var index = 0;
  667. for(var i = 0; i < optionsModel.count; i++)
  668. {
  669. if(optionsModel.get(i).value == currentValue) {
  670. index = i;
  671. break;
  672. }
  673. }
  674. return index
  675. }
  676. onActivated:
  677. {
  678. if(propertyProvider.properties.value != optionsModel.get(index).value)
  679. {
  680. propertyProvider.setPropertyValue("value", optionsModel.get(index).value);
  681. if(_forceUpdateOnChange)
  682. {
  683. manager.forceUpdate();
  684. }
  685. if(_afterOnActivate)
  686. {
  687. _afterOnActivate();
  688. }
  689. }
  690. }
  691. }
  692. }
  693. }
  694. }
  695. Component
  696. {
  697. id: gcodeTextArea
  698. UM.TooltipArea
  699. {
  700. height: gcodeArea.height
  701. width: gcodeArea.width
  702. text: _tooltip
  703. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false : isExtruderSetting
  704. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  705. UM.SettingPropertyProvider
  706. {
  707. id: propertyProvider
  708. containerStackId: {
  709. if(_isExtruderSetting)
  710. {
  711. if(settingsTabs.currentIndex > 0)
  712. {
  713. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  714. }
  715. return "";
  716. }
  717. return base.activeMachineId
  718. }
  719. key: settingKey
  720. watchedProperties: [ "value", "description" ]
  721. storeIndex: manager.containerIndex
  722. }
  723. TextArea
  724. {
  725. id: gcodeArea
  726. width: areaWidth
  727. height: areaHeight
  728. font: UM.Theme.getFont("fixed")
  729. text: (propertyProvider.properties.value) ? propertyProvider.properties.value : ""
  730. onActiveFocusChanged:
  731. {
  732. if(!activeFocus)
  733. {
  734. propertyProvider.setPropertyValue("value", gcodeArea.text)
  735. }
  736. }
  737. Component.onCompleted:
  738. {
  739. wrapMode = TextEdit.NoWrap;
  740. }
  741. }
  742. }
  743. }
  744. Component
  745. {
  746. id: headPolygonTextField
  747. UM.TooltipArea
  748. {
  749. height: textField.height
  750. width: textField.width
  751. text: tooltip
  752. property string _label: (typeof(label) === 'undefined') ? "" : label
  753. Row
  754. {
  755. spacing: UM.Theme.getSize("default_margin").width
  756. Label
  757. {
  758. text: _label
  759. visible: _label != ""
  760. elide: Text.ElideRight
  761. width: Math.max(0, settingsTabs.labelColumnWidth)
  762. anchors.verticalCenter: textFieldWithUnit.verticalCenter
  763. }
  764. Item
  765. {
  766. id: textFieldWithUnit
  767. width: textField.width
  768. height: textField.height
  769. TextField
  770. {
  771. id: textField
  772. text:
  773. {
  774. var polygon = JSON.parse(machineHeadPolygonProvider.properties.value);
  775. var item = (axis == "x") ? 0 : 1
  776. var result = polygon[0][item];
  777. for(var i = 1; i < polygon.length; i++) {
  778. if (side == "min") {
  779. result = Math.min(result, polygon[i][item]);
  780. } else {
  781. result = Math.max(result, polygon[i][item]);
  782. }
  783. }
  784. result = Math.abs(result);
  785. printHeadPolygon[axis][side] = result;
  786. return result;
  787. }
  788. validator: RegExpValidator { regExp: /[0-9\.,]{0,6}/ }
  789. onEditingFinished:
  790. {
  791. printHeadPolygon[axis][side] = parseFloat(textField.text.replace(',','.'));
  792. var polygon = [];
  793. polygon.push([-printHeadPolygon["x"]["min"], printHeadPolygon["y"]["max"]]);
  794. polygon.push([-printHeadPolygon["x"]["min"],-printHeadPolygon["y"]["min"]]);
  795. polygon.push([ printHeadPolygon["x"]["max"], printHeadPolygon["y"]["max"]]);
  796. polygon.push([ printHeadPolygon["x"]["max"],-printHeadPolygon["y"]["min"]]);
  797. var polygon_string = JSON.stringify(polygon);
  798. if(polygon_string != machineHeadPolygonProvider.properties.value)
  799. {
  800. machineHeadPolygonProvider.setPropertyValue("value", polygon_string);
  801. manager.forceUpdate();
  802. }
  803. }
  804. }
  805. Label
  806. {
  807. text: catalog.i18nc("@label", "mm")
  808. anchors.right: textField.right
  809. anchors.rightMargin: y - textField.y
  810. anchors.verticalCenter: textField.verticalCenter
  811. }
  812. }
  813. }
  814. }
  815. }
  816. property var printHeadPolygon:
  817. {
  818. "x": {
  819. "min": 0,
  820. "max": 0,
  821. },
  822. "y": {
  823. "min": 0,
  824. "max": 0,
  825. },
  826. }
  827. UM.SettingPropertyProvider
  828. {
  829. id: machineExtruderCountProvider
  830. containerStackId: base.activeMachineId
  831. key: "machine_extruder_count"
  832. watchedProperties: [ "value", "description" ]
  833. storeIndex: manager.containerIndex
  834. }
  835. UM.SettingPropertyProvider
  836. {
  837. id: machineHeadPolygonProvider
  838. containerStackId: base.activeMachineId
  839. key: "machine_head_with_fans_polygon"
  840. watchedProperties: [ "value" ]
  841. storeIndex: manager.containerIndex
  842. }
  843. }