MachineSettingsAction.qml 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  1. // Copyright (c) 2016 Ultimaker B.V.
  2. // Cura is released under the terms of the AGPLv3 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. anchors.fill: parent;
  12. Item
  13. {
  14. id: bedLevelMachineAction
  15. anchors.fill: parent;
  16. UM.I18nCatalog { id: catalog; name: "cura"; }
  17. Label
  18. {
  19. id: pageTitle
  20. width: parent.width
  21. text: catalog.i18nc("@title", "Machine Settings")
  22. wrapMode: Text.WordWrap
  23. font.pointSize: 18;
  24. }
  25. Label
  26. {
  27. id: pageDescription
  28. anchors.top: pageTitle.bottom
  29. anchors.topMargin: UM.Theme.getSize("default_margin").height
  30. width: parent.width
  31. wrapMode: Text.WordWrap
  32. text: catalog.i18nc("@label", "Please enter the correct settings for your printer below:")
  33. }
  34. Column
  35. {
  36. height: parent.height - y
  37. width: parent.width - UM.Theme.getSize("default_margin").width
  38. spacing: UM.Theme.getSize("default_margin").height
  39. anchors.left: parent.left
  40. anchors.top: pageDescription.bottom
  41. anchors.topMargin: UM.Theme.getSize("default_margin").height
  42. Row
  43. {
  44. width: parent.width
  45. spacing: UM.Theme.getSize("default_margin").height
  46. Column
  47. {
  48. width: parent.width / 2
  49. spacing: UM.Theme.getSize("default_margin").height
  50. Label
  51. {
  52. text: catalog.i18nc("@label", "Printer Settings")
  53. font.bold: true
  54. }
  55. Grid
  56. {
  57. columns: 3
  58. columnSpacing: UM.Theme.getSize("default_margin").width
  59. Label
  60. {
  61. text: catalog.i18nc("@label", "X (Width)")
  62. }
  63. TextField
  64. {
  65. id: buildAreaWidthField
  66. text: machineWidthProvider.properties.value
  67. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  68. onEditingFinished: { machineWidthProvider.setPropertyValue("value", text); manager.forceUpdate() }
  69. }
  70. Label
  71. {
  72. text: catalog.i18nc("@label", "mm")
  73. }
  74. Label
  75. {
  76. text: catalog.i18nc("@label", "Y (Depth)")
  77. }
  78. TextField
  79. {
  80. id: buildAreaDepthField
  81. text: machineDepthProvider.properties.value
  82. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  83. onEditingFinished: { machineDepthProvider.setPropertyValue("value", text); manager.forceUpdate() }
  84. }
  85. Label
  86. {
  87. text: catalog.i18nc("@label", "mm")
  88. }
  89. Label
  90. {
  91. text: catalog.i18nc("@label", "Z (Height)")
  92. }
  93. TextField
  94. {
  95. id: buildAreaHeightField
  96. text: machineHeightProvider.properties.value
  97. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  98. onEditingFinished: { machineHeightProvider.setPropertyValue("value", text); manager.forceUpdate() }
  99. }
  100. Label
  101. {
  102. text: catalog.i18nc("@label", "mm")
  103. }
  104. }
  105. Column
  106. {
  107. Row
  108. {
  109. spacing: UM.Theme.getSize("default_margin").width
  110. Label
  111. {
  112. text: catalog.i18nc("@label", "Build Plate Shape")
  113. }
  114. ComboBox
  115. {
  116. id: shapeComboBox
  117. model: ListModel
  118. {
  119. id: shapesModel
  120. Component.onCompleted:
  121. {
  122. // Options come in as a string-representation of an OrderedDict
  123. var options = machineShapeProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/);
  124. if(options)
  125. {
  126. options = options[1].split("), (")
  127. for(var i = 0; i < options.length; i++)
  128. {
  129. var option = options[i].substring(1, options[i].length - 1).split("', '")
  130. shapesModel.append({text: option[1], value: option[0]});
  131. }
  132. }
  133. }
  134. }
  135. currentIndex:
  136. {
  137. var currentValue = machineShapeProvider.properties.value;
  138. var index = 0;
  139. for(var i = 0; i < shapesModel.count; i++)
  140. {
  141. if(shapesModel.get(i).value == currentValue) {
  142. index = i;
  143. break;
  144. }
  145. }
  146. return index
  147. }
  148. onActivated:
  149. {
  150. machineShapeProvider.setPropertyValue("value", shapesModel.get(index).value);
  151. manager.forceUpdate();
  152. }
  153. }
  154. }
  155. CheckBox
  156. {
  157. id: centerIsZeroCheckBox
  158. text: catalog.i18nc("@option:check", "Machine Center is Zero")
  159. checked: String(machineCenterIsZeroProvider.properties.value).toLowerCase() != 'false'
  160. onClicked:
  161. {
  162. machineCenterIsZeroProvider.setPropertyValue("value", checked);
  163. manager.forceUpdate();
  164. }
  165. }
  166. CheckBox
  167. {
  168. id: heatedBedCheckBox
  169. text: catalog.i18nc("@option:check", "Heated Bed")
  170. checked: String(machineHeatedBedProvider.properties.value).toLowerCase() != 'false'
  171. onClicked: machineHeatedBedProvider.setPropertyValue("value", checked)
  172. }
  173. }
  174. Row
  175. {
  176. spacing: UM.Theme.getSize("default_margin").width
  177. Label
  178. {
  179. text: catalog.i18nc("@label", "GCode Flavor")
  180. }
  181. ComboBox
  182. {
  183. model: ListModel
  184. {
  185. id: flavorModel
  186. Component.onCompleted:
  187. {
  188. // Options come in as a string-representation of an OrderedDict
  189. var options = machineGCodeFlavorProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/);
  190. if(options)
  191. {
  192. options = options[1].split("), (")
  193. for(var i = 0; i < options.length; i++)
  194. {
  195. var option = options[i].substring(1, options[i].length - 1).split("', '")
  196. flavorModel.append({text: option[1], value: option[0]});
  197. }
  198. }
  199. }
  200. }
  201. currentIndex:
  202. {
  203. var currentValue = machineGCodeFlavorProvider.properties.value;
  204. var index = 0;
  205. for(var i = 0; i < flavorModel.count; i++)
  206. {
  207. if(flavorModel.get(i).value == currentValue) {
  208. index = i;
  209. break;
  210. }
  211. }
  212. return index
  213. }
  214. onActivated:
  215. {
  216. machineGCodeFlavorProvider.setPropertyValue("value", flavorModel.get(index).value);
  217. manager.updateHasMaterialsMetadata();
  218. }
  219. }
  220. }
  221. }
  222. Column
  223. {
  224. width: parent.width / 2
  225. spacing: UM.Theme.getSize("default_margin").height
  226. Label
  227. {
  228. text: catalog.i18nc("@label", "Printhead Settings")
  229. font.bold: true
  230. }
  231. Grid
  232. {
  233. columns: 3
  234. columnSpacing: UM.Theme.getSize("default_margin").width
  235. Label
  236. {
  237. text: catalog.i18nc("@label", "X min")
  238. }
  239. TextField
  240. {
  241. id: printheadXMinField
  242. text: getHeadPolygonCoord("x", "min")
  243. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  244. onEditingFinished: setHeadPolygon()
  245. }
  246. Label
  247. {
  248. text: catalog.i18nc("@label", "mm")
  249. }
  250. Label
  251. {
  252. text: catalog.i18nc("@label", "Y min")
  253. }
  254. TextField
  255. {
  256. id: printheadYMinField
  257. text: getHeadPolygonCoord("y", "min")
  258. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  259. onEditingFinished: setHeadPolygon()
  260. }
  261. Label
  262. {
  263. text: catalog.i18nc("@label", "mm")
  264. }
  265. Label
  266. {
  267. text: catalog.i18nc("@label", "X max")
  268. }
  269. TextField
  270. {
  271. id: printheadXMaxField
  272. text: getHeadPolygonCoord("x", "max")
  273. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  274. onEditingFinished: setHeadPolygon()
  275. }
  276. Label
  277. {
  278. text: catalog.i18nc("@label", "mm")
  279. }
  280. Label
  281. {
  282. text: catalog.i18nc("@label", "Y max")
  283. }
  284. TextField
  285. {
  286. id: printheadYMaxField
  287. text: getHeadPolygonCoord("y", "max")
  288. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  289. onEditingFinished: setHeadPolygon()
  290. }
  291. Label
  292. {
  293. text: catalog.i18nc("@label", "mm")
  294. }
  295. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  296. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  297. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  298. Label
  299. {
  300. text: catalog.i18nc("@label", "Gantry height")
  301. }
  302. TextField
  303. {
  304. id: gantryHeightField
  305. text: gantryHeightProvider.properties.value
  306. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  307. onEditingFinished: { gantryHeightProvider.setPropertyValue("value", text) }
  308. }
  309. Label
  310. {
  311. text: catalog.i18nc("@label", "mm")
  312. }
  313. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  314. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  315. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  316. Label
  317. {
  318. text: catalog.i18nc("@label", "Nozzle size")
  319. visible: !Cura.MachineManager.hasVariants
  320. }
  321. TextField
  322. {
  323. id: nozzleSizeField
  324. text: machineNozzleSizeProvider.properties.value
  325. visible: !Cura.MachineManager.hasVariants
  326. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  327. onEditingFinished: { machineNozzleSizeProvider.setPropertyValue("value", text) }
  328. }
  329. Label
  330. {
  331. text: catalog.i18nc("@label", "mm")
  332. visible: !Cura.MachineManager.hasVariants
  333. }
  334. }
  335. }
  336. }
  337. Row
  338. {
  339. spacing: UM.Theme.getSize("default_margin").width
  340. anchors.left: parent.left
  341. anchors.right: parent.right
  342. height: parent.height - y
  343. Column
  344. {
  345. height: parent.height
  346. width: parent.width / 2
  347. Label
  348. {
  349. text: catalog.i18nc("@label", "Start Gcode")
  350. }
  351. TextArea
  352. {
  353. id: machineStartGcodeField
  354. width: parent.width
  355. height: parent.height - y
  356. font: UM.Theme.getFont("fixed")
  357. wrapMode: TextEdit.NoWrap
  358. text: machineStartGcodeProvider.properties.value
  359. onActiveFocusChanged:
  360. {
  361. if(!activeFocus)
  362. {
  363. machineStartGcodeProvider.setPropertyValue("value", machineStartGcodeField.text)
  364. }
  365. }
  366. }
  367. }
  368. Column {
  369. height: parent.height
  370. width: parent.width / 2
  371. Label
  372. {
  373. text: catalog.i18nc("@label", "End Gcode")
  374. }
  375. TextArea
  376. {
  377. id: machineEndGcodeField
  378. width: parent.width
  379. height: parent.height - y
  380. font: UM.Theme.getFont("fixed")
  381. wrapMode: TextEdit.NoWrap
  382. text: machineEndGcodeProvider.properties.value
  383. onActiveFocusChanged:
  384. {
  385. if(!activeFocus)
  386. {
  387. machineEndGcodeProvider.setPropertyValue("value", machineEndGcodeField.text)
  388. }
  389. }
  390. }
  391. }
  392. }
  393. }
  394. }
  395. function getHeadPolygonCoord(axis, minMax)
  396. {
  397. var polygon = JSON.parse(machineHeadPolygonProvider.properties.value);
  398. var item = (axis == "x") ? 0 : 1
  399. var result = polygon[0][item];
  400. for(var i = 1; i < polygon.length; i++) {
  401. if (minMax == "min") {
  402. result = Math.min(result, polygon[i][item]);
  403. } else {
  404. result = Math.max(result, polygon[i][item]);
  405. }
  406. }
  407. return Math.abs(result);
  408. }
  409. function setHeadPolygon()
  410. {
  411. var polygon = [];
  412. polygon.push([-parseFloat(printheadXMinField.text), parseFloat(printheadYMaxField.text)]);
  413. polygon.push([-parseFloat(printheadXMinField.text),-parseFloat(printheadYMinField.text)]);
  414. polygon.push([ parseFloat(printheadXMaxField.text), parseFloat(printheadYMaxField.text)]);
  415. polygon.push([ parseFloat(printheadXMaxField.text),-parseFloat(printheadYMinField.text)]);
  416. machineHeadPolygonProvider.setPropertyValue("value", JSON.stringify(polygon));
  417. manager.forceUpdate();
  418. }
  419. UM.SettingPropertyProvider
  420. {
  421. id: machineWidthProvider
  422. containerStackId: Cura.MachineManager.activeMachineId
  423. key: "machine_width"
  424. watchedProperties: [ "value" ]
  425. storeIndex: manager.containerIndex
  426. }
  427. UM.SettingPropertyProvider
  428. {
  429. id: machineDepthProvider
  430. containerStackId: Cura.MachineManager.activeMachineId
  431. key: "machine_depth"
  432. watchedProperties: [ "value" ]
  433. storeIndex: manager.containerIndex
  434. }
  435. UM.SettingPropertyProvider
  436. {
  437. id: machineHeightProvider
  438. containerStackId: Cura.MachineManager.activeMachineId
  439. key: "machine_height"
  440. watchedProperties: [ "value" ]
  441. storeIndex: manager.containerIndex
  442. }
  443. UM.SettingPropertyProvider
  444. {
  445. id: machineShapeProvider
  446. containerStackId: Cura.MachineManager.activeMachineId
  447. key: "machine_shape"
  448. watchedProperties: [ "value", "options" ]
  449. storeIndex: manager.containerIndex
  450. }
  451. UM.SettingPropertyProvider
  452. {
  453. id: machineHeatedBedProvider
  454. containerStackId: Cura.MachineManager.activeMachineId
  455. key: "machine_heated_bed"
  456. watchedProperties: [ "value" ]
  457. storeIndex: manager.containerIndex
  458. }
  459. UM.SettingPropertyProvider
  460. {
  461. id: machineCenterIsZeroProvider
  462. containerStackId: Cura.MachineManager.activeMachineId
  463. key: "machine_center_is_zero"
  464. watchedProperties: [ "value" ]
  465. storeIndex: manager.containerIndex
  466. }
  467. UM.SettingPropertyProvider
  468. {
  469. id: machineGCodeFlavorProvider
  470. containerStackId: Cura.MachineManager.activeMachineId
  471. key: "machine_gcode_flavor"
  472. watchedProperties: [ "value", "options" ]
  473. storeIndex: manager.containerIndex
  474. }
  475. UM.SettingPropertyProvider
  476. {
  477. id: machineNozzleSizeProvider
  478. containerStackId: Cura.MachineManager.activeMachineId
  479. key: "machine_nozzle_size"
  480. watchedProperties: [ "value" ]
  481. storeIndex: manager.containerIndex
  482. }
  483. UM.SettingPropertyProvider
  484. {
  485. id: gantryHeightProvider
  486. containerStackId: Cura.MachineManager.activeMachineId
  487. key: "gantry_height"
  488. watchedProperties: [ "value" ]
  489. storeIndex: manager.containerIndex
  490. }
  491. UM.SettingPropertyProvider
  492. {
  493. id: machineHeadPolygonProvider
  494. containerStackId: Cura.MachineManager.activeMachineId
  495. key: "machine_head_with_fans_polygon"
  496. watchedProperties: [ "value" ]
  497. storeIndex: manager.containerIndex
  498. }
  499. UM.SettingPropertyProvider
  500. {
  501. id: machineStartGcodeProvider
  502. containerStackId: Cura.MachineManager.activeMachineId
  503. key: "machine_start_gcode"
  504. watchedProperties: [ "value" ]
  505. storeIndex: manager.containerIndex
  506. }
  507. UM.SettingPropertyProvider
  508. {
  509. id: machineEndGcodeProvider
  510. containerStackId: Cura.MachineManager.activeMachineId
  511. key: "machine_end_gcode"
  512. watchedProperties: [ "value" ]
  513. storeIndex: manager.containerIndex
  514. }
  515. }