MachineSettingsAction.qml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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: ListModel
  132. {
  133. id: flavorModel
  134. Component.onCompleted:
  135. {
  136. // Options come in as a string-representation of an OrderedDict
  137. var options = machineGCodeFlavorProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/);
  138. if(options)
  139. {
  140. options = options[1].split("), (")
  141. for(var i = 0; i < options.length; i++)
  142. {
  143. var option = options[i].substring(1, options[i].length - 1).split("', '")
  144. flavorModel.append({text: option[1], value: option[0]});
  145. }
  146. }
  147. }
  148. }
  149. currentIndex:
  150. {
  151. var currentValue = machineGCodeFlavorProvider.properties.value;
  152. var index = 0;
  153. for(var i = 0; i < flavorModel.count; i++)
  154. {
  155. if(flavorModel.get(i).value == currentValue) {
  156. index = i;
  157. break;
  158. }
  159. }
  160. return index
  161. }
  162. onActivated:
  163. {
  164. machineGCodeFlavorProvider.setPropertyValue("value", flavorModel.get(index).value);
  165. manager.updateHasMaterialsMetadata();
  166. }
  167. }
  168. }
  169. }
  170. Column
  171. {
  172. width: parent.width / 2
  173. spacing: UM.Theme.getSize("default_margin").height
  174. Label
  175. {
  176. text: catalog.i18nc("@label", "Printhead Settings")
  177. font.bold: true
  178. }
  179. Grid
  180. {
  181. columns: 3
  182. columnSpacing: UM.Theme.getSize("default_margin").width
  183. Label
  184. {
  185. text: catalog.i18nc("@label", "X min")
  186. }
  187. TextField
  188. {
  189. id: printheadXMinField
  190. text: getHeadPolygonCoord("x", "min")
  191. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  192. onEditingFinished: setHeadPolygon()
  193. }
  194. Label
  195. {
  196. text: catalog.i18nc("@label", "mm")
  197. }
  198. Label
  199. {
  200. text: catalog.i18nc("@label", "Y min")
  201. }
  202. TextField
  203. {
  204. id: printheadYMinField
  205. text: getHeadPolygonCoord("y", "min")
  206. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  207. onEditingFinished: setHeadPolygon()
  208. }
  209. Label
  210. {
  211. text: catalog.i18nc("@label", "mm")
  212. }
  213. Label
  214. {
  215. text: catalog.i18nc("@label", "X max")
  216. }
  217. TextField
  218. {
  219. id: printheadXMaxField
  220. text: getHeadPolygonCoord("x", "max")
  221. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  222. onEditingFinished: setHeadPolygon()
  223. }
  224. Label
  225. {
  226. text: catalog.i18nc("@label", "mm")
  227. }
  228. Label
  229. {
  230. text: catalog.i18nc("@label", "Y max")
  231. }
  232. TextField
  233. {
  234. id: printheadYMaxField
  235. text: getHeadPolygonCoord("y", "max")
  236. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  237. onEditingFinished: setHeadPolygon()
  238. }
  239. Label
  240. {
  241. text: catalog.i18nc("@label", "mm")
  242. }
  243. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  244. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  245. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  246. Label
  247. {
  248. text: catalog.i18nc("@label", "Gantry height")
  249. }
  250. TextField
  251. {
  252. id: gantryHeightField
  253. text: gantryHeightProvider.properties.value
  254. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  255. onEditingFinished: { gantryHeightProvider.setPropertyValue("value", text) }
  256. }
  257. Label
  258. {
  259. text: catalog.i18nc("@label", "mm")
  260. }
  261. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  262. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  263. Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
  264. Label
  265. {
  266. text: catalog.i18nc("@label", "Nozzle size")
  267. visible: !Cura.MachineManager.hasVariants
  268. }
  269. TextField
  270. {
  271. id: nozzleSizeField
  272. text: machineNozzleSizeProvider.properties.value
  273. visible: !Cura.MachineManager.hasVariants
  274. validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
  275. onEditingFinished: { machineNozzleSizeProvider.setPropertyValue("value", text) }
  276. }
  277. Label
  278. {
  279. text: catalog.i18nc("@label", "mm")
  280. visible: !Cura.MachineManager.hasVariants
  281. }
  282. }
  283. }
  284. }
  285. Row
  286. {
  287. spacing: UM.Theme.getSize("default_margin").width
  288. anchors.left: parent.left
  289. anchors.right: parent.right
  290. height: parent.height - y
  291. Column
  292. {
  293. height: parent.height
  294. width: parent.width / 2
  295. Label
  296. {
  297. text: catalog.i18nc("@label", "Start Gcode")
  298. }
  299. TextArea
  300. {
  301. id: machineStartGcodeField
  302. width: parent.width
  303. height: parent.height - y
  304. font: UM.Theme.getFont("fixed")
  305. wrapMode: TextEdit.NoWrap
  306. text: machineStartGcodeProvider.properties.value
  307. onActiveFocusChanged:
  308. {
  309. if(!activeFocus)
  310. {
  311. machineStartGcodeProvider.setPropertyValue("value", machineStartGcodeField.text)
  312. }
  313. }
  314. }
  315. }
  316. Column {
  317. height: parent.height
  318. width: parent.width / 2
  319. Label
  320. {
  321. text: catalog.i18nc("@label", "End Gcode")
  322. }
  323. TextArea
  324. {
  325. id: machineEndGcodeField
  326. width: parent.width
  327. height: parent.height - y
  328. font: UM.Theme.getFont("fixed")
  329. wrapMode: TextEdit.NoWrap
  330. text: machineEndGcodeProvider.properties.value
  331. onActiveFocusChanged:
  332. {
  333. if(!activeFocus)
  334. {
  335. machineEndGcodeProvider.setPropertyValue("value", machineEndGcodeField.text)
  336. }
  337. }
  338. }
  339. }
  340. }
  341. }
  342. }
  343. function getHeadPolygonCoord(axis, minMax)
  344. {
  345. var polygon = JSON.parse(machineHeadPolygonProvider.properties.value);
  346. var item = (axis == "x") ? 0 : 1
  347. var result = polygon[0][item];
  348. for(var i = 1; i < polygon.length; i++) {
  349. if (minMax == "min") {
  350. result = Math.min(result, polygon[i][item]);
  351. } else {
  352. result = Math.max(result, polygon[i][item]);
  353. }
  354. }
  355. return Math.abs(result);
  356. }
  357. function setHeadPolygon()
  358. {
  359. var polygon = [];
  360. polygon.push([-parseFloat(printheadXMinField.text), parseFloat(printheadYMaxField.text)]);
  361. polygon.push([-parseFloat(printheadXMinField.text),-parseFloat(printheadYMinField.text)]);
  362. polygon.push([ parseFloat(printheadXMaxField.text), parseFloat(printheadYMaxField.text)]);
  363. polygon.push([ parseFloat(printheadXMaxField.text),-parseFloat(printheadYMinField.text)]);
  364. machineHeadPolygonProvider.setPropertyValue("value", JSON.stringify(polygon));
  365. manager.forceUpdate();
  366. }
  367. UM.SettingPropertyProvider
  368. {
  369. id: machineWidthProvider
  370. containerStackId: Cura.MachineManager.activeMachineId
  371. key: "machine_width"
  372. watchedProperties: [ "value" ]
  373. storeIndex: manager.containerIndex
  374. }
  375. UM.SettingPropertyProvider
  376. {
  377. id: machineDepthProvider
  378. containerStackId: Cura.MachineManager.activeMachineId
  379. key: "machine_depth"
  380. watchedProperties: [ "value" ]
  381. storeIndex: manager.containerIndex
  382. }
  383. UM.SettingPropertyProvider
  384. {
  385. id: machineHeightProvider
  386. containerStackId: Cura.MachineManager.activeMachineId
  387. key: "machine_height"
  388. watchedProperties: [ "value" ]
  389. storeIndex: manager.containerIndex
  390. }
  391. UM.SettingPropertyProvider
  392. {
  393. id: machineHeatedBedProvider
  394. containerStackId: Cura.MachineManager.activeMachineId
  395. key: "machine_heated_bed"
  396. watchedProperties: [ "value" ]
  397. storeIndex: manager.containerIndex
  398. }
  399. UM.SettingPropertyProvider
  400. {
  401. id: machineCenterIsZeroProvider
  402. containerStackId: Cura.MachineManager.activeMachineId
  403. key: "machine_center_is_zero"
  404. watchedProperties: [ "value" ]
  405. storeIndex: manager.containerIndex
  406. }
  407. UM.SettingPropertyProvider
  408. {
  409. id: machineGCodeFlavorProvider
  410. containerStackId: Cura.MachineManager.activeMachineId
  411. key: "machine_gcode_flavor"
  412. watchedProperties: [ "value", "options" ]
  413. storeIndex: manager.containerIndex
  414. }
  415. UM.SettingPropertyProvider
  416. {
  417. id: machineNozzleSizeProvider
  418. containerStackId: Cura.MachineManager.activeMachineId
  419. key: "machine_nozzle_size"
  420. watchedProperties: [ "value" ]
  421. storeIndex: manager.containerIndex
  422. }
  423. UM.SettingPropertyProvider
  424. {
  425. id: gantryHeightProvider
  426. containerStackId: Cura.MachineManager.activeMachineId
  427. key: "gantry_height"
  428. watchedProperties: [ "value" ]
  429. storeIndex: manager.containerIndex
  430. }
  431. UM.SettingPropertyProvider
  432. {
  433. id: machineHeadPolygonProvider
  434. containerStackId: Cura.MachineManager.activeMachineId
  435. key: "machine_head_with_fans_polygon"
  436. watchedProperties: [ "value" ]
  437. storeIndex: manager.containerIndex
  438. }
  439. UM.SettingPropertyProvider
  440. {
  441. id: machineStartGcodeProvider
  442. containerStackId: Cura.MachineManager.activeMachineId
  443. key: "machine_start_gcode"
  444. watchedProperties: [ "value" ]
  445. storeIndex: manager.containerIndex
  446. }
  447. UM.SettingPropertyProvider
  448. {
  449. id: machineEndGcodeProvider
  450. containerStackId: Cura.MachineManager.activeMachineId
  451. key: "machine_end_gcode"
  452. watchedProperties: [ "value" ]
  453. storeIndex: manager.containerIndex
  454. }
  455. }