MachineSettingsAction.qml 37 KB

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