MachineSettingsAction.qml 38 KB

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