MachineSettingsAction.qml 41 KB

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