MachineSettingsAction.qml 37 KB

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