MachineSettingsAction.qml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911
  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. Loader
  384. {
  385. id: extruderCoolingFanNumberField
  386. sourceComponent: numericTextFieldWithUnit
  387. property string settingKey: "machine_extruder_cooling_fan_number"
  388. property string label: catalog.i18nc("@label", "Cooling Fan Number")
  389. property string unit: catalog.i18nc("@label", "")
  390. property bool isExtruderSetting: true
  391. property bool forceUpdateOnChange: true
  392. property bool allowNegative: false
  393. }
  394. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  395. Row
  396. {
  397. spacing: UM.Theme.getSize("default_margin").width
  398. anchors.left: parent.left
  399. anchors.right: parent.right
  400. height: parent.height - y
  401. Column
  402. {
  403. height: parent.height
  404. width: settingsTabs.columnWidth
  405. Label
  406. {
  407. text: catalog.i18nc("@label", "Extruder Start G-code")
  408. font.bold: true
  409. }
  410. Loader
  411. {
  412. id: extruderStartGcodeField
  413. sourceComponent: gcodeTextArea
  414. property int areaWidth: parent.width
  415. property int areaHeight: parent.height - y
  416. property string settingKey: "machine_extruder_start_code"
  417. property bool isExtruderSetting: true
  418. }
  419. }
  420. Column {
  421. height: parent.height
  422. width: settingsTabs.columnWidth
  423. Label
  424. {
  425. text: catalog.i18nc("@label", "Extruder End G-code")
  426. font.bold: true
  427. }
  428. Loader
  429. {
  430. id: extruderEndGcodeField
  431. sourceComponent: gcodeTextArea
  432. property int areaWidth: parent.width
  433. property int areaHeight: parent.height - y
  434. property string settingKey: "machine_extruder_end_code"
  435. property bool isExtruderSetting: true
  436. }
  437. }
  438. }
  439. }
  440. }
  441. }
  442. }
  443. }
  444. Component
  445. {
  446. id: simpleCheckBox
  447. UM.TooltipArea
  448. {
  449. height: checkBox.height
  450. width: checkBox.width
  451. text: _tooltip
  452. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false: isExtruderSetting
  453. property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false: forceUpdateOnChange
  454. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  455. UM.SettingPropertyProvider
  456. {
  457. id: propertyProvider
  458. containerStackId: {
  459. if(_isExtruderSetting)
  460. {
  461. if(settingsTabs.currentIndex > 0)
  462. {
  463. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  464. }
  465. return "";
  466. }
  467. return base.activeMachineId
  468. }
  469. key: settingKey
  470. watchedProperties: [ "value", "description" ]
  471. storeIndex: manager.containerIndex
  472. }
  473. CheckBox
  474. {
  475. id: checkBox
  476. text: label
  477. checked: String(propertyProvider.properties.value).toLowerCase() != 'false'
  478. onClicked:
  479. {
  480. propertyProvider.setPropertyValue("value", checked);
  481. if(_forceUpdateOnChange)
  482. {
  483. manager.forceUpdate();
  484. }
  485. }
  486. }
  487. }
  488. }
  489. Component
  490. {
  491. id: numericTextFieldWithUnit
  492. UM.TooltipArea
  493. {
  494. height: childrenRect.height
  495. width: childrenRect.width
  496. text: _tooltip
  497. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false: isExtruderSetting
  498. property bool _allowNegative: (typeof(allowNegative) === 'undefined') ? false : allowNegative
  499. property var _afterOnEditingFinished: (typeof(afterOnEditingFinished) === 'undefined') ? undefined : afterOnEditingFinished
  500. property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false : forceUpdateOnChange
  501. property string _label: (typeof(label) === 'undefined') ? "" : label
  502. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  503. UM.SettingPropertyProvider
  504. {
  505. id: propertyProvider
  506. containerStackId: {
  507. if(_isExtruderSetting)
  508. {
  509. if(settingsTabs.currentIndex > 0)
  510. {
  511. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  512. }
  513. return "";
  514. }
  515. return base.activeMachineId
  516. }
  517. key: settingKey
  518. watchedProperties: [ "value", "description" ]
  519. storeIndex: manager.containerIndex
  520. }
  521. Row
  522. {
  523. spacing: UM.Theme.getSize("default_margin").width
  524. Label
  525. {
  526. text: _label
  527. visible: _label != ""
  528. elide: Text.ElideRight
  529. width: Math.max(0, settingsTabs.labelColumnWidth)
  530. anchors.verticalCenter: textFieldWithUnit.verticalCenter
  531. }
  532. Item
  533. {
  534. width: textField.width
  535. height: textField.height
  536. id: textFieldWithUnit
  537. TextField
  538. {
  539. id: textField
  540. text: {
  541. const value = propertyProvider.properties.value;
  542. return value ? value : "";
  543. }
  544. validator: RegExpValidator { regExp: _allowNegative ? /-?[0-9\.,]{0,6}/ : /[0-9\.,]{0,6}/ }
  545. onEditingFinished:
  546. {
  547. if (propertyProvider && text != propertyProvider.properties.value)
  548. {
  549. propertyProvider.setPropertyValue("value", text);
  550. if(_forceUpdateOnChange)
  551. {
  552. manager.forceUpdate();
  553. }
  554. if(_afterOnEditingFinished)
  555. {
  556. _afterOnEditingFinished();
  557. }
  558. }
  559. }
  560. }
  561. Label
  562. {
  563. text: unit
  564. anchors.right: textField.right
  565. anchors.rightMargin: y - textField.y
  566. anchors.verticalCenter: textField.verticalCenter
  567. }
  568. }
  569. }
  570. }
  571. }
  572. Component
  573. {
  574. id: comboBoxWithOptions
  575. UM.TooltipArea
  576. {
  577. height: childrenRect.height
  578. width: childrenRect.width
  579. text: _tooltip
  580. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false : isExtruderSetting
  581. property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false : forceUpdateOnChange
  582. property var _afterOnActivate: (typeof(afterOnActivate) === 'undefined') ? undefined : afterOnActivate
  583. property string _label: (typeof(label) === 'undefined') ? "" : label
  584. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  585. UM.SettingPropertyProvider
  586. {
  587. id: propertyProvider
  588. containerStackId: {
  589. if(_isExtruderSetting)
  590. {
  591. if(settingsTabs.currentIndex > 0)
  592. {
  593. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  594. }
  595. return "";
  596. }
  597. return base.activeMachineId
  598. }
  599. key: settingKey
  600. watchedProperties: [ "value", "options", "description" ]
  601. storeIndex: manager.containerIndex
  602. }
  603. Row
  604. {
  605. spacing: UM.Theme.getSize("default_margin").width
  606. Label
  607. {
  608. text: _label
  609. visible: _label != ""
  610. elide: Text.ElideRight
  611. width: Math.max(0, settingsTabs.labelColumnWidth)
  612. anchors.verticalCenter: comboBox.verticalCenter
  613. }
  614. ComboBox
  615. {
  616. id: comboBox
  617. model: ListModel
  618. {
  619. id: optionsModel
  620. Component.onCompleted:
  621. {
  622. // Options come in as a string-representation of an OrderedDict
  623. var options = propertyProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/);
  624. if(options)
  625. {
  626. options = options[1].split("), (")
  627. for(var i = 0; i < options.length; i++)
  628. {
  629. var option = options[i].substring(1, options[i].length - 1).split("', '")
  630. optionsModel.append({text: option[1], value: option[0]});
  631. }
  632. }
  633. }
  634. }
  635. currentIndex:
  636. {
  637. var currentValue = propertyProvider.properties.value;
  638. var index = 0;
  639. for(var i = 0; i < optionsModel.count; i++)
  640. {
  641. if(optionsModel.get(i).value == currentValue) {
  642. index = i;
  643. break;
  644. }
  645. }
  646. return index
  647. }
  648. onActivated:
  649. {
  650. if(propertyProvider.properties.value != optionsModel.get(index).value)
  651. {
  652. propertyProvider.setPropertyValue("value", optionsModel.get(index).value);
  653. if(_forceUpdateOnChange)
  654. {
  655. manager.forceUpdate();
  656. }
  657. if(_afterOnActivate)
  658. {
  659. _afterOnActivate();
  660. }
  661. }
  662. }
  663. }
  664. }
  665. }
  666. }
  667. Component
  668. {
  669. id: gcodeTextArea
  670. UM.TooltipArea
  671. {
  672. height: gcodeArea.height
  673. width: gcodeArea.width
  674. text: _tooltip
  675. property bool _isExtruderSetting: (typeof(isExtruderSetting) === 'undefined') ? false : isExtruderSetting
  676. property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
  677. UM.SettingPropertyProvider
  678. {
  679. id: propertyProvider
  680. containerStackId: {
  681. if(_isExtruderSetting)
  682. {
  683. if(settingsTabs.currentIndex > 0)
  684. {
  685. return Cura.ExtruderManager.extruderIds[String(settingsTabs.currentIndex - 1)];
  686. }
  687. return "";
  688. }
  689. return base.activeMachineId
  690. }
  691. key: settingKey
  692. watchedProperties: [ "value", "description" ]
  693. storeIndex: manager.containerIndex
  694. }
  695. TextArea
  696. {
  697. id: gcodeArea
  698. width: areaWidth
  699. height: areaHeight
  700. font: UM.Theme.getFont("fixed")
  701. text: (propertyProvider.properties.value) ? propertyProvider.properties.value : ""
  702. onActiveFocusChanged:
  703. {
  704. if(!activeFocus)
  705. {
  706. propertyProvider.setPropertyValue("value", gcodeArea.text)
  707. }
  708. }
  709. Component.onCompleted:
  710. {
  711. wrapMode = TextEdit.NoWrap;
  712. }
  713. }
  714. }
  715. }
  716. Component
  717. {
  718. id: headPolygonTextField
  719. UM.TooltipArea
  720. {
  721. height: textField.height
  722. width: textField.width
  723. text: tooltip
  724. property string _label: (typeof(label) === 'undefined') ? "" : label
  725. Row
  726. {
  727. spacing: UM.Theme.getSize("default_margin").width
  728. Label
  729. {
  730. text: _label
  731. visible: _label != ""
  732. elide: Text.ElideRight
  733. width: Math.max(0, settingsTabs.labelColumnWidth)
  734. anchors.verticalCenter: textFieldWithUnit.verticalCenter
  735. }
  736. Item
  737. {
  738. id: textFieldWithUnit
  739. width: textField.width
  740. height: textField.height
  741. TextField
  742. {
  743. id: textField
  744. text:
  745. {
  746. var polygon = JSON.parse(machineHeadPolygonProvider.properties.value);
  747. var item = (axis == "x") ? 0 : 1
  748. var result = polygon[0][item];
  749. for(var i = 1; i < polygon.length; i++) {
  750. if (side == "min") {
  751. result = Math.min(result, polygon[i][item]);
  752. } else {
  753. result = Math.max(result, polygon[i][item]);
  754. }
  755. }
  756. result = Math.abs(result);
  757. printHeadPolygon[axis][side] = result;
  758. return result;
  759. }
  760. validator: RegExpValidator { regExp: /[0-9\.,]{0,6}/ }
  761. onEditingFinished:
  762. {
  763. printHeadPolygon[axis][side] = parseFloat(textField.text.replace(',','.'));
  764. var polygon = [];
  765. polygon.push([-printHeadPolygon["x"]["min"], printHeadPolygon["y"]["max"]]);
  766. polygon.push([-printHeadPolygon["x"]["min"],-printHeadPolygon["y"]["min"]]);
  767. polygon.push([ printHeadPolygon["x"]["max"], printHeadPolygon["y"]["max"]]);
  768. polygon.push([ printHeadPolygon["x"]["max"],-printHeadPolygon["y"]["min"]]);
  769. var polygon_string = JSON.stringify(polygon);
  770. if(polygon_string != machineHeadPolygonProvider.properties.value)
  771. {
  772. machineHeadPolygonProvider.setPropertyValue("value", polygon_string);
  773. manager.forceUpdate();
  774. }
  775. }
  776. }
  777. Label
  778. {
  779. text: catalog.i18nc("@label", "mm")
  780. anchors.right: textField.right
  781. anchors.rightMargin: y - textField.y
  782. anchors.verticalCenter: textField.verticalCenter
  783. }
  784. }
  785. }
  786. }
  787. }
  788. property var printHeadPolygon:
  789. {
  790. "x": {
  791. "min": 0,
  792. "max": 0,
  793. },
  794. "y": {
  795. "min": 0,
  796. "max": 0,
  797. },
  798. }
  799. UM.SettingPropertyProvider
  800. {
  801. id: machineExtruderCountProvider
  802. containerStackId: base.activeMachineId
  803. key: "machine_extruder_count"
  804. watchedProperties: [ "value", "description" ]
  805. storeIndex: manager.containerIndex
  806. }
  807. UM.SettingPropertyProvider
  808. {
  809. id: machineHeadPolygonProvider
  810. containerStackId: base.activeMachineId
  811. key: "machine_head_with_fans_polygon"
  812. watchedProperties: [ "value" ]
  813. storeIndex: manager.containerIndex
  814. }
  815. }