MachineSettingsAction.qml 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  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;
  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. height: childrenRect.height
  208. width: childrenRect.width
  209. text: machineExtruderCountProvider.properties.description
  210. Row
  211. {
  212. spacing: UM.Theme.getSize("default_margin").width
  213. Label
  214. {
  215. text: catalog.i18nc("@label", "Number of Extruders")
  216. elide: Text.ElideRight
  217. width: Math.max(0, settingsTabs.labelColumnWidth)
  218. anchors.verticalCenter: extruderCountComboBox.verticalCenter
  219. }
  220. ComboBox
  221. {
  222. id: extruderCountComboBox
  223. model: ListModel
  224. {
  225. id: extruderCountModel
  226. Component.onCompleted:
  227. {
  228. for(var i = 0; i < manager.definedExtruderCount; i++)
  229. {
  230. extruderCountModel.append({text: String(i + 1), value: i});
  231. }
  232. }
  233. }
  234. Connections
  235. {
  236. target: manager
  237. onDefinedExtruderCountChanged:
  238. {
  239. extruderCountModel.clear();
  240. for(var i = 0; i < manager.definedExtruderCount; ++i)
  241. {
  242. extruderCountModel.append({text: String(i + 1), value: i});
  243. }
  244. }
  245. }
  246. currentIndex: machineExtruderCountProvider.properties.value - 1
  247. onActivated:
  248. {
  249. manager.setMachineExtruderCount(index + 1);
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. Row
  257. {
  258. spacing: UM.Theme.getSize("default_margin").width
  259. anchors.left: parent.left
  260. anchors.right: parent.right
  261. height: parent.height - y
  262. Column
  263. {
  264. height: parent.height
  265. width: settingsTabs.columnWidth
  266. Label
  267. {
  268. text: catalog.i18nc("@label", "Start Gcode")
  269. font.bold: true
  270. }
  271. Loader
  272. {
  273. id: machineStartGcodeField
  274. sourceComponent: gcodeTextArea
  275. property int areaWidth: parent.width
  276. property int areaHeight: parent.height - y
  277. property string settingKey: "machine_start_gcode"
  278. property string tooltip: catalog.i18nc("@tooltip", "Gcode commands to be executed at the very start.")
  279. }
  280. }
  281. Column {
  282. height: parent.height
  283. width: settingsTabs.columnWidth
  284. Label
  285. {
  286. text: catalog.i18nc("@label", "End Gcode")
  287. font.bold: true
  288. }
  289. Loader
  290. {
  291. id: machineEndGcodeField
  292. sourceComponent: gcodeTextArea
  293. property int areaWidth: parent.width
  294. property int areaHeight: parent.height - y
  295. property string settingKey: "machine_end_gcode"
  296. property string tooltip: catalog.i18nc("@tooltip", "Gcode commands to be executed at the very end.")
  297. }
  298. }
  299. }
  300. }
  301. }
  302. onCurrentIndexChanged:
  303. {
  304. if(currentIndex > 0)
  305. {
  306. contentItem.forceActiveFocus();
  307. }
  308. }
  309. Repeater
  310. {
  311. id: extruderTabsRepeater
  312. model: base.extruderTabsCount
  313. Tab
  314. {
  315. title: base.extrudersModel.getItem(index).name
  316. anchors.margins: UM.Theme.getSize("default_margin").width
  317. Column
  318. {
  319. spacing: UM.Theme.getSize("default_lining").width
  320. Label
  321. {
  322. text: catalog.i18nc("@label", "Nozzle Settings")
  323. font.bold: true
  324. }
  325. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  326. Loader
  327. {
  328. id: extruderNozzleSizeField
  329. visible: !Cura.MachineManager.hasVariants
  330. sourceComponent: numericTextFieldWithUnit
  331. property string settingKey: "machine_nozzle_size"
  332. property string label: catalog.i18nc("@label", "Nozzle size")
  333. property string unit: catalog.i18nc("@label", "mm")
  334. property bool isExtruderSetting: true
  335. }
  336. Loader
  337. {
  338. id: materialDiameterField
  339. visible: Cura.MachineManager.hasMaterials
  340. sourceComponent: numericTextFieldWithUnit
  341. property string settingKey: "material_diameter"
  342. property string label: catalog.i18nc("@label", "Material diameter")
  343. property string unit: catalog.i18nc("@label", "mm")
  344. 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.")
  345. property var afterOnEditingFinished:
  346. {
  347. if (settingsTabs.currentIndex > 0)
  348. {
  349. manager.updateMaterialForDiameter(settingsTabs.currentIndex - 1);
  350. }
  351. }
  352. property bool isExtruderSetting: true
  353. }
  354. Loader
  355. {
  356. id: extruderOffsetXField
  357. sourceComponent: numericTextFieldWithUnit
  358. property string settingKey: "machine_nozzle_offset_x"
  359. property string label: catalog.i18nc("@label", "Nozzle offset X")
  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. Loader
  366. {
  367. id: extruderOffsetYField
  368. sourceComponent: numericTextFieldWithUnit
  369. property string settingKey: "machine_nozzle_offset_y"
  370. property string label: catalog.i18nc("@label", "Nozzle offset Y")
  371. property string unit: catalog.i18nc("@label", "mm")
  372. property bool isExtruderSetting: true
  373. property bool forceUpdateOnChange: true
  374. property bool allowNegative: true
  375. }
  376. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  377. Row
  378. {
  379. spacing: UM.Theme.getSize("default_margin").width
  380. anchors.left: parent.left
  381. anchors.right: parent.right
  382. height: parent.height - y
  383. Column
  384. {
  385. height: parent.height
  386. width: settingsTabs.columnWidth
  387. Label
  388. {
  389. text: catalog.i18nc("@label", "Extruder Start Gcode")
  390. font.bold: true
  391. }
  392. Loader
  393. {
  394. id: extruderStartGcodeField
  395. sourceComponent: gcodeTextArea
  396. property int areaWidth: parent.width
  397. property int areaHeight: parent.height - y
  398. property string settingKey: "machine_extruder_start_code"
  399. property bool isExtruderSetting: true
  400. }
  401. }
  402. Column {
  403. height: parent.height
  404. width: settingsTabs.columnWidth
  405. Label
  406. {
  407. text: catalog.i18nc("@label", "Extruder End Gcode")
  408. font.bold: true
  409. }
  410. Loader
  411. {
  412. id: extruderEndGcodeField
  413. sourceComponent: gcodeTextArea
  414. property int areaWidth: parent.width
  415. property int areaHeight: parent.height - y
  416. property string settingKey: "machine_extruder_end_code"
  417. property bool isExtruderSetting: true
  418. }
  419. }
  420. }
  421. }
  422. }
  423. }
  424. }
  425. }
  426. Component
  427. {
  428. id: simpleCheckBox
  429. UM.TooltipArea
  430. {
  431. height: checkBox.height
  432. width: checkBox.width
  433. text: _tooltip
  434. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false: isExtruderSetting
  435. property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false: forceUpdateOnChange
  436. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  437. UM.SettingPropertyProvider
  438. {
  439. id: propertyProvider
  440. containerStackId: {
  441. if(_isExtruderSetting)
  442. {
  443. if(settingsTabs.currentIndex > 0)
  444. {
  445. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  446. }
  447. return "";
  448. }
  449. return Cura.MachineManager.activeMachineId;
  450. }
  451. key: settingKey
  452. watchedProperties: [ "value", "description" ]
  453. storeIndex: manager.containerIndex
  454. }
  455. CheckBox
  456. {
  457. id: checkBox
  458. text: label
  459. checked: String(propertyProvider.properties.value).toLowerCase() != 'false'
  460. onClicked:
  461. {
  462. propertyProvider.setPropertyValue("value", checked);
  463. if(_forceUpdateOnChange)
  464. {
  465. manager.forceUpdate();
  466. }
  467. }
  468. }
  469. }
  470. }
  471. Component
  472. {
  473. id: numericTextFieldWithUnit
  474. UM.TooltipArea
  475. {
  476. height: childrenRect.height
  477. width: childrenRect.width
  478. text: _tooltip
  479. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false: isExtruderSetting
  480. property bool _allowNegative: (typeof(allowNegative) === 'undefined') ? false : allowNegative
  481. property var _afterOnEditingFinished: (typeof(afterOnEditingFinished) === 'undefined') ? undefined : afterOnEditingFinished
  482. property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false : forceUpdateOnChange
  483. property string _label: (typeof(label) === 'undefined') ? "" : label
  484. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  485. UM.SettingPropertyProvider
  486. {
  487. id: propertyProvider
  488. containerStackId: {
  489. if(_isExtruderSetting)
  490. {
  491. if(settingsTabs.currentIndex > 0)
  492. {
  493. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  494. }
  495. return "";
  496. }
  497. return Cura.MachineManager.activeMachineId;
  498. }
  499. key: settingKey
  500. watchedProperties: [ "value", "description" ]
  501. storeIndex: manager.containerIndex
  502. }
  503. Row
  504. {
  505. spacing: UM.Theme.getSize("default_margin").width
  506. Label
  507. {
  508. text: _label
  509. visible: _label != ""
  510. elide: Text.ElideRight
  511. width: Math.max(0, settingsTabs.labelColumnWidth)
  512. anchors.verticalCenter: textFieldWithUnit.verticalCenter
  513. }
  514. Item
  515. {
  516. width: textField.width
  517. height: textField.height
  518. id: textFieldWithUnit
  519. TextField
  520. {
  521. id: textField
  522. text: {
  523. const value = propertyProvider.properties.value;
  524. return value ? value : "";
  525. }
  526. validator: RegExpValidator { regExp: _allowNegative ? /-?[0-9\.]{0,6}/ : /[0-9\.]{0,6}/ }
  527. onEditingFinished:
  528. {
  529. if (propertyProvider && text != propertyProvider.properties.value)
  530. {
  531. propertyProvider.setPropertyValue("value", text);
  532. if(_forceUpdateOnChange)
  533. {
  534. manager.forceUpdate();
  535. }
  536. if(_afterOnEditingFinished)
  537. {
  538. _afterOnEditingFinished();
  539. }
  540. }
  541. }
  542. }
  543. Label
  544. {
  545. text: unit
  546. anchors.right: textField.right
  547. anchors.rightMargin: y - textField.y
  548. anchors.verticalCenter: textField.verticalCenter
  549. }
  550. }
  551. }
  552. }
  553. }
  554. Component
  555. {
  556. id: comboBoxWithOptions
  557. UM.TooltipArea
  558. {
  559. height: childrenRect.height
  560. width: childrenRect.width
  561. text: _tooltip
  562. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false : isExtruderSetting
  563. property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false : forceUpdateOnChange
  564. property var _afterOnActivate: (typeof(afterOnActivate) === 'undefined') ? undefined : afterOnActivate
  565. property string _label: (typeof(label) === 'undefined') ? "" : label
  566. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  567. UM.SettingPropertyProvider
  568. {
  569. id: propertyProvider
  570. containerStackId: {
  571. if(_isExtruderSetting)
  572. {
  573. if(settingsTabs.currentIndex > 0)
  574. {
  575. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  576. }
  577. return "";
  578. }
  579. return Cura.MachineManager.activeMachineId;
  580. }
  581. key: settingKey
  582. watchedProperties: [ "value", "options", "description" ]
  583. storeIndex: manager.containerIndex
  584. }
  585. Row
  586. {
  587. spacing: UM.Theme.getSize("default_margin").width
  588. Label
  589. {
  590. text: _label
  591. visible: _label != ""
  592. elide: Text.ElideRight
  593. width: Math.max(0, settingsTabs.labelColumnWidth)
  594. anchors.verticalCenter: comboBox.verticalCenter
  595. }
  596. ComboBox
  597. {
  598. id: comboBox
  599. model: ListModel
  600. {
  601. id: optionsModel
  602. Component.onCompleted:
  603. {
  604. // Options come in as a string-representation of an OrderedDict
  605. var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/);
  606. if(options)
  607. {
  608. options = options[1].split("), (")
  609. for(var i = 0; i < options.length; i++)
  610. {
  611. var option = options[i].substring(1, options[i].length - 1).split("', '")
  612. optionsModel.append({text: option[1], value: option[0]});
  613. }
  614. }
  615. }
  616. }
  617. currentIndex:
  618. {
  619. var currentValue = propertyProvider.properties.value;
  620. var index = 0;
  621. for(var i = 0; i < optionsModel.count; i++)
  622. {
  623. if(optionsModel.get(i).value == currentValue) {
  624. index = i;
  625. break;
  626. }
  627. }
  628. return index
  629. }
  630. onActivated:
  631. {
  632. if(propertyProvider.properties.value != optionsModel.get(index).value)
  633. {
  634. propertyProvider.setPropertyValue("value", optionsModel.get(index).value);
  635. if(_forceUpdateOnChange)
  636. {
  637. manager.forceUpdate();
  638. }
  639. if(_afterOnActivate)
  640. {
  641. _afterOnActivate();
  642. }
  643. }
  644. }
  645. }
  646. }
  647. }
  648. }
  649. Component
  650. {
  651. id: gcodeTextArea
  652. UM.TooltipArea
  653. {
  654. height: gcodeArea.height
  655. width: gcodeArea.width
  656. text: _tooltip
  657. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false : isExtruderSetting
  658. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  659. UM.SettingPropertyProvider
  660. {
  661. id: propertyProvider
  662. containerStackId: {
  663. if(_isExtruderSetting)
  664. {
  665. if(settingsTabs.currentIndex > 0)
  666. {
  667. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  668. }
  669. return "";
  670. }
  671. return Cura.MachineManager.activeMachineId;
  672. }
  673. key: settingKey
  674. watchedProperties: [ "value", "description" ]
  675. storeIndex: manager.containerIndex
  676. }
  677. TextArea
  678. {
  679. id: gcodeArea
  680. width: areaWidth
  681. height: areaHeight
  682. font: UM.Theme.getFont("fixed")
  683. text: (propertyProvider.properties.value) ? propertyProvider.properties.value : ""
  684. onActiveFocusChanged:
  685. {
  686. if(!activeFocus)
  687. {
  688. propertyProvider.setPropertyValue("value", gcodeArea.text)
  689. }
  690. }
  691. Component.onCompleted:
  692. {
  693. wrapMode = TextEdit.NoWrap;
  694. }
  695. }
  696. }
  697. }
  698. Component
  699. {
  700. id: headPolygonTextField
  701. UM.TooltipArea
  702. {
  703. height: textField.height
  704. width: textField.width
  705. text: tooltip
  706. property string _label: (typeof(label) === 'undefined') ? "" : label
  707. Row
  708. {
  709. spacing: UM.Theme.getSize("default_margin").width
  710. Label
  711. {
  712. text: _label
  713. visible: _label != ""
  714. elide: Text.ElideRight
  715. width: Math.max(0, settingsTabs.labelColumnWidth)
  716. anchors.verticalCenter: textFieldWithUnit.verticalCenter
  717. }
  718. Item
  719. {
  720. id: textFieldWithUnit
  721. width: textField.width
  722. height: textField.height
  723. TextField
  724. {
  725. id: textField
  726. text:
  727. {
  728. var polygon = JSON.parse(machineHeadPolygonProvider.properties.value);
  729. var item = (axis == "x") ? 0 : 1
  730. var result = polygon[0][item];
  731. for(var i = 1; i < polygon.length; i++) {
  732. if (side == "min") {
  733. result = Math.min(result, polygon[i][item]);
  734. } else {
  735. result = Math.max(result, polygon[i][item]);
  736. }
  737. }
  738. result = Math.abs(result);
  739. printHeadPolygon[axis][side] = result;
  740. return result;
  741. }
  742. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  743. onEditingFinished:
  744. {
  745. printHeadPolygon[axis][side] = parseFloat(textField.text);
  746. var polygon = [];
  747. polygon.push([-printHeadPolygon["x"]["min"], printHeadPolygon["y"]["max"]]);
  748. polygon.push([-printHeadPolygon["x"]["min"],-printHeadPolygon["y"]["min"]]);
  749. polygon.push([ printHeadPolygon["x"]["max"], printHeadPolygon["y"]["max"]]);
  750. polygon.push([ printHeadPolygon["x"]["max"],-printHeadPolygon["y"]["min"]]);
  751. var polygon_string = JSON.stringify(polygon);
  752. if(polygon_string != machineHeadPolygonProvider.properties.value)
  753. {
  754. machineHeadPolygonProvider.setPropertyValue("value", polygon_string);
  755. manager.forceUpdate();
  756. }
  757. }
  758. }
  759. Label
  760. {
  761. text: catalog.i18nc("@label", "mm")
  762. anchors.right: textField.right
  763. anchors.rightMargin: y - textField.y
  764. anchors.verticalCenter: textField.verticalCenter
  765. }
  766. }
  767. }
  768. }
  769. }
  770. property var printHeadPolygon:
  771. {
  772. "x": {
  773. "min": 0,
  774. "max": 0,
  775. },
  776. "y": {
  777. "min": 0,
  778. "max": 0,
  779. },
  780. }
  781. UM.SettingPropertyProvider
  782. {
  783. id: machineExtruderCountProvider
  784. containerStackId: Cura.MachineManager.activeMachineId
  785. key: "machine_extruder_count"
  786. watchedProperties: [ "value", "description" ]
  787. storeIndex: manager.containerIndex
  788. }
  789. UM.SettingPropertyProvider
  790. {
  791. id: machineHeadPolygonProvider
  792. containerStackId: Cura.MachineManager.activeMachineId
  793. key: "machine_head_with_fans_polygon"
  794. watchedProperties: [ "value" ]
  795. storeIndex: manager.containerIndex
  796. }
  797. }