MachineSettingsAction.qml 38 KB

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