Bedleveling.qml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. // Copyright (c) 2015 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.1 as UM
  8. import Cura 1.0 as Cura
  9. import ".."
  10. Item
  11. {
  12. id: wizardPage
  13. property int leveling_state: 0
  14. property bool three_point_leveling: true
  15. property int platform_width: UM.MachineManager.getSettingValue("machine_width")
  16. property int platform_height: UM.MachineManager.getSettingValue("machine_depth")
  17. anchors.fill: parent;
  18. property variant printer_connection: Cura.USBPrinterManager.connectedPrinterList.getItem(0).printer
  19. Component.onCompleted:
  20. {
  21. printer_connection.homeBed()
  22. printer_connection.moveHead(0, 0, 3)
  23. printer_connection.homeHead()
  24. }
  25. UM.I18nCatalog { id: catalog; name:"cura"}
  26. property variant wizard: null;
  27. Connections
  28. {
  29. target: wizardPage.wizard
  30. onNextClicked: //You can add functions here that get triggered when the final button is clicked in the wizard-element
  31. {
  32. if(wizardPage.wizard.lastPage == true){
  33. wizardPage.wizard.visible = false
  34. }
  35. }
  36. }
  37. Label
  38. {
  39. id: pageTitle
  40. width: parent.width
  41. text: catalog.i18nc("@title", "Bed Leveling")
  42. wrapMode: Text.WordWrap
  43. font.pointSize: 18;
  44. }
  45. Label
  46. {
  47. id: pageDescription
  48. anchors.top: pageTitle.bottom
  49. anchors.topMargin: UM.Theme.getSize("default_margin").height
  50. width: parent.width
  51. wrapMode: Text.WordWrap
  52. text: catalog.i18nc("@label","To make sure your prints will come out great, you can now adjust your buildplate. When you click 'Move to Next Position' the nozzle will move to the different positions that can be adjusted.")
  53. }
  54. Label
  55. {
  56. id: bedlevelingText
  57. anchors.top: pageDescription.bottom
  58. anchors.topMargin: UM.Theme.getSize("default_margin").height
  59. width: parent.width
  60. wrapMode: Text.WordWrap
  61. text: catalog.i18nc("@label", "For every postition; insert a piece of paper under the nozzle and adjust the print bed height. The print bed height is right when the paper is slightly gripped by the tip of the nozzle.")
  62. }
  63. Item{
  64. id: bedlevelingWrapper
  65. anchors.top: bedlevelingText.bottom
  66. anchors.topMargin: UM.Theme.getSize("default_margin").height
  67. anchors.horizontalCenter: parent.horizontalCenter
  68. height: skipBedlevelingButton.height
  69. width: bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height < wizardPage.width ? bedlevelingButton.width + skipBedlevelingButton.width + UM.Theme.getSize("default_margin").height : wizardPage.width
  70. Button
  71. {
  72. id: bedlevelingButton
  73. anchors.top: parent.top
  74. anchors.left: parent.left
  75. text: catalog.i18nc("@action:button","Move to Next Position");
  76. onClicked:
  77. {
  78. if(wizardPage.leveling_state == 0)
  79. {
  80. printer_connection.moveHead(0, 0, 3)
  81. printer_connection.homeHead()
  82. printer_connection.moveHead(0, 0, 3)
  83. printer_connection.moveHead(platform_width - 10, 0, 0)
  84. printer_connection.moveHead(0, 0, -3)
  85. }
  86. if(wizardPage.leveling_state == 1)
  87. {
  88. printer_connection.moveHead(0, 0, 3)
  89. printer_connection.moveHead(-platform_width/2, platform_height - 10, 0)
  90. printer_connection.moveHead(0, 0, -3)
  91. }
  92. if(wizardPage.leveling_state == 2)
  93. {
  94. printer_connection.moveHead(0, 0, 3)
  95. printer_connection.moveHead(-platform_width/2 + 10, -(platform_height + 10), 0)
  96. printer_connection.moveHead(0, 0, -3)
  97. }
  98. wizardPage.leveling_state++
  99. if (wizardPage.leveling_state >= 3){
  100. resultText.visible = true
  101. skipBedlevelingButton.enabled = false
  102. bedlevelingButton.enabled = false
  103. wizardPage.leveling_state = 0
  104. }
  105. }
  106. }
  107. Button
  108. {
  109. id: skipBedlevelingButton
  110. anchors.top: parent.width < wizardPage.width ? parent.top : bedlevelingButton.bottom
  111. anchors.topMargin: parent.width < wizardPage.width ? 0 : UM.Theme.getSize("default_margin").height/2
  112. anchors.left: parent.width < wizardPage.width ? bedlevelingButton.right : parent.left
  113. anchors.leftMargin: parent.width < wizardPage.width ? UM.Theme.getSize("default_margin").width : 0
  114. text: catalog.i18nc("@action:button","Skip Bedleveling");
  115. onClicked: {
  116. if(wizardPage.wizard.lastPage == true){
  117. var old_page_count = wizardPage.wizard.getPageCount()
  118. // Delete old pages (if any)
  119. for (var i = old_page_count - 1; i > 0; i--)
  120. {
  121. wizardPage.wizard.removePage(i)
  122. }
  123. wizardPage.wizard.currentPage = 0
  124. wizardPage.wizard.visible = false
  125. }
  126. }
  127. }
  128. }
  129. Label
  130. {
  131. id: resultText
  132. visible: false
  133. anchors.top: bedlevelingWrapper.bottom
  134. anchors.topMargin: UM.Theme.getSize("default_margin").height
  135. anchors.left: parent.left
  136. width: parent.width
  137. wrapMode: Text.WordWrap
  138. text: catalog.i18nc("@label", "Everything is in order! You're done with bedleveling.")
  139. }
  140. function threePointLeveling(width, height)
  141. {
  142. }
  143. }