MachineSettingsAction.qml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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. CheckBox
  108. {
  109. id: heatedBedCheckBox
  110. text: catalog.i18nc("@option:check", "Heated Bed")
  111. checked: String(machineHeatedBedProvider.properties.value).toLowerCase() != 'false'
  112. onClicked: machineHeatedBedProvider.setPropertyValue("value", checked)
  113. }
  114. CheckBox
  115. {
  116. id: centerIsZeroCheckBox
  117. text: catalog.i18nc("@option:check", "Machine Center is Zero")
  118. checked: String(machineCenterIsZeroProvider.properties.value).toLowerCase() != 'false'
  119. onClicked: machineCenterIsZeroProvider.setPropertyValue("value", checked)
  120. }
  121. }
  122. Row
  123. {
  124. spacing: UM.Theme.getSize("default_margin").width
  125. Label
  126. {
  127. text: catalog.i18nc("@label", "GCode Flavor")
  128. }
  129. ComboBox
  130. {
  131. model: ["RepRap (Marlin/Sprinter)", "UltiGCode", "Repetier"]
  132. currentIndex:
  133. {
  134. var index = model.indexOf(machineGCodeFlavorProvider.properties.value);
  135. if(index == -1)
  136. {
  137. index = 0;
  138. }
  139. return index
  140. }
  141. onActivated:
  142. {
  143. machineGCodeFlavorProvider.setPropertyValue("value", model[index]);
  144. manager.updateHasMaterialsMetadata();
  145. }
  146. }
  147. }
  148. }
  149. Column
  150. {
  151. width: parent.width / 2
  152. spacing: UM.Theme.getSize("default_margin").height
  153. Label
  154. {
  155. text: catalog.i18nc("@label", "Printhead Settings")
  156. font.bold: true
  157. }
  158. Grid
  159. {
  160. columns: 3
  161. columnSpacing: UM.Theme.getSize("default_margin").width
  162. Label
  163. {
  164. text: catalog.i18nc("@label", "X min")
  165. }
  166. TextField
  167. {
  168. id: printheadXMinField
  169. text: getHeadPolygonCoord("x", "min")
  170. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  171. onEditingFinished: setHeadPolygon()
  172. }
  173. Label
  174. {
  175. text: catalog.i18nc("@label", "mm")
  176. }
  177. Label
  178. {
  179. text: catalog.i18nc("@label", "Y min")
  180. }
  181. TextField
  182. {
  183. id: printheadYMinField
  184. text: getHeadPolygonCoord("y", "min")
  185. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  186. onEditingFinished: setHeadPolygon()
  187. }
  188. Label
  189. {
  190. text: catalog.i18nc("@label", "mm")
  191. }
  192. Label
  193. {
  194. text: catalog.i18nc("@label", "X max")
  195. }
  196. TextField
  197. {
  198. id: printheadXMaxField
  199. text: getHeadPolygonCoord("x", "max")
  200. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  201. onEditingFinished: setHeadPolygon()
  202. }
  203. Label
  204. {
  205. text: catalog.i18nc("@label", "mm")
  206. }
  207. Label
  208. {
  209. text: catalog.i18nc("@label", "Y max")
  210. }
  211. TextField
  212. {
  213. id: printheadYMaxField
  214. text: getHeadPolygonCoord("y", "max")
  215. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  216. onEditingFinished: setHeadPolygon()
  217. }
  218. Label
  219. {
  220. text: catalog.i18nc("@label", "mm")
  221. }
  222. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  223. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  224. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  225. Label
  226. {
  227. text: catalog.i18nc("@label", "Gantry height")
  228. }
  229. TextField
  230. {
  231. id: gantryHeightField
  232. text: gantryHeightProvider.properties.value
  233. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  234. onEditingFinished: { gantryHeightProvider.setPropertyValue("value", text) }
  235. }
  236. Label
  237. {
  238. text: catalog.i18nc("@label", "mm")
  239. }
  240. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  241. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  242. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  243. Label
  244. {
  245. text: catalog.i18nc("@label", "Nozzle size")
  246. }
  247. TextField
  248. {
  249. id: nozzleSizeField
  250. text: machineNozzleSizeProvider.properties.value
  251. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  252. onEditingFinished: { machineNozzleSizeProvider.setPropertyValue("value", text) }
  253. }
  254. Label
  255. {
  256. text: catalog.i18nc("@label", "mm")
  257. }
  258. }
  259. }
  260. }
  261. Row
  262. {
  263. spacing: UM.Theme.getSize("default_margin").width
  264. anchors.left: parent.left
  265. anchors.right: parent.right
  266. height: parent.height - y
  267. Column
  268. {
  269. height: parent.height
  270. width: parent.width / 2
  271. Label
  272. {
  273. text: catalog.i18nc("@label", "Start Gcode")
  274. }
  275. TextArea
  276. {
  277. id: machineStartGcodeField
  278. width: parent.width
  279. height: parent.height - y
  280. text: machineStartGcodeProvider.properties.value
  281. onActiveFocusChanged:
  282. {
  283. if(!activeFocus)
  284. {
  285. machineStartGcodeProvider.setPropertyValue("value", machineStartGcodeField.text)
  286. }
  287. }
  288. }
  289. }
  290. Column {
  291. height: parent.height
  292. width: parent.width / 2
  293. Label
  294. {
  295. text: catalog.i18nc("@label", "End Gcode")
  296. }
  297. TextArea
  298. {
  299. id: machineEndGcodeField
  300. width: parent.width
  301. height: parent.height - y
  302. text: machineEndGcodeProvider.properties.value
  303. onActiveFocusChanged:
  304. {
  305. if(!activeFocus)
  306. {
  307. machineEndGcodeProvider.setPropertyValue("value", machineEndGcodeField.text)
  308. }
  309. }
  310. }
  311. }
  312. }
  313. }
  314. }
  315. function getHeadPolygonCoord(axis, minMax)
  316. {
  317. var polygon = JSON.parse(machineHeadPolygonProvider.properties.value);
  318. var item = (axis == "x") ? 0 : 1
  319. var result = polygon[0][item];
  320. for(var i = 1; i < polygon.length; i++) {
  321. if (minMax == "min") {
  322. result = Math.min(result, polygon[i][item]);
  323. } else {
  324. result = Math.max(result, polygon[i][item]);
  325. }
  326. }
  327. return Math.abs(result);
  328. }
  329. function setHeadPolygon()
  330. {
  331. var polygon = [];
  332. polygon.push([-parseFloat(printheadXMinField.text), parseFloat(printheadYMaxField.text)]);
  333. polygon.push([-parseFloat(printheadXMinField.text),-parseFloat(printheadYMinField.text)]);
  334. polygon.push([ parseFloat(printheadXMaxField.text), parseFloat(printheadYMaxField.text)]);
  335. polygon.push([ parseFloat(printheadXMaxField.text),-parseFloat(printheadYMinField.text)]);
  336. machineHeadPolygonProvider.setPropertyValue("value", JSON.stringify(polygon));
  337. manager.forceUpdate();
  338. }
  339. UM.SettingPropertyProvider
  340. {
  341. id: machineWidthProvider
  342. containerStackId: Cura.MachineManager.activeMachineId
  343. key: "machine_width"
  344. watchedProperties: [ "value" ]
  345. storeIndex: 4
  346. }
  347. UM.SettingPropertyProvider
  348. {
  349. id: machineDepthProvider
  350. containerStackId: Cura.MachineManager.activeMachineId
  351. key: "machine_depth"
  352. watchedProperties: [ "value" ]
  353. storeIndex: 4
  354. }
  355. UM.SettingPropertyProvider
  356. {
  357. id: machineHeightProvider
  358. containerStackId: Cura.MachineManager.activeMachineId
  359. key: "machine_height"
  360. watchedProperties: [ "value" ]
  361. storeIndex: 4
  362. }
  363. UM.SettingPropertyProvider
  364. {
  365. id: machineHeatedBedProvider
  366. containerStackId: Cura.MachineManager.activeMachineId
  367. key: "machine_heated_bed"
  368. watchedProperties: [ "value" ]
  369. storeIndex: 4
  370. }
  371. UM.SettingPropertyProvider
  372. {
  373. id: machineCenterIsZeroProvider
  374. containerStackId: Cura.MachineManager.activeMachineId
  375. key: "machine_center_is_zero"
  376. watchedProperties: [ "value" ]
  377. storeIndex: 4
  378. }
  379. UM.SettingPropertyProvider
  380. {
  381. id: machineGCodeFlavorProvider
  382. containerStackId: Cura.MachineManager.activeMachineId
  383. key: "machine_gcode_flavor"
  384. watchedProperties: [ "value" ]
  385. storeIndex: 4
  386. }
  387. UM.SettingPropertyProvider
  388. {
  389. id: machineNozzleSizeProvider
  390. containerStackId: Cura.MachineManager.activeMachineId
  391. key: "machine_nozzle_size"
  392. watchedProperties: [ "value" ]
  393. storeIndex: 4
  394. }
  395. UM.SettingPropertyProvider
  396. {
  397. id: gantryHeightProvider
  398. containerStackId: Cura.MachineManager.activeMachineId
  399. key: "gantry_height"
  400. watchedProperties: [ "value" ]
  401. storeIndex: 4
  402. }
  403. UM.SettingPropertyProvider
  404. {
  405. id: machineHeadPolygonProvider
  406. containerStackId: Cura.MachineManager.activeMachineId
  407. key: "machine_head_with_fans_polygon"
  408. watchedProperties: [ "value" ]
  409. storeIndex: 4
  410. }
  411. UM.SettingPropertyProvider
  412. {
  413. id: machineStartGcodeProvider
  414. containerStackId: Cura.MachineManager.activeMachineId
  415. key: "machine_start_gcode"
  416. watchedProperties: [ "value" ]
  417. storeIndex: 4
  418. }
  419. UM.SettingPropertyProvider
  420. {
  421. id: machineEndGcodeProvider
  422. containerStackId: Cura.MachineManager.activeMachineId
  423. key: "machine_end_gcode"
  424. watchedProperties: [ "value" ]
  425. storeIndex: 4
  426. }
  427. }