MachineSettingsAction.qml 38 KB

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