RecommendedSupportSelector.qml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. // Copyright (c) 2018 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Controls.Styles 1.4
  6. import UM 1.2 as UM
  7. import Cura 1.0 as Cura
  8. //
  9. // Enable support
  10. //
  11. Item
  12. {
  13. id: enableSupportRow
  14. height: childrenRect.height
  15. property real labelColumnWidth: Math.round(width / 3)
  16. Cura.IconWithText
  17. {
  18. id: enableSupportRowTitle
  19. anchors.top: parent.top
  20. anchors.left: parent.left
  21. visible: enableSupportCheckBox.visible
  22. source: UM.Theme.getIcon("category_support")
  23. text: catalog.i18nc("@label", "Support")
  24. width: labelColumnWidth
  25. }
  26. Item
  27. {
  28. id: enableSupportContainer
  29. height: enableSupportCheckBox.height
  30. anchors
  31. {
  32. left: enableSupportRowTitle.right
  33. right: parent.right
  34. verticalCenter: enableSupportRowTitle.verticalCenter
  35. }
  36. CheckBox
  37. {
  38. id: enableSupportCheckBox
  39. anchors.verticalCenter: parent.verticalCenter
  40. property alias _hovered: enableSupportMouseArea.containsMouse
  41. style: UM.Theme.styles.checkbox
  42. enabled: recommendedPrintSettup.settingsEnabled
  43. visible: supportEnabled.properties.enabled == "True"
  44. checked: supportEnabled.properties.value == "True"
  45. MouseArea
  46. {
  47. id: enableSupportMouseArea
  48. anchors.fill: parent
  49. hoverEnabled: true
  50. onClicked: supportEnabled.setPropertyValue("value", supportEnabled.properties.value != "True")
  51. onEntered:
  52. {
  53. base.showTooltip(enableSupportCheckBox, Qt.point(-enableSupportContainer.x - UM.Theme.getSize("thick_margin").width, 0),
  54. catalog.i18nc("@label", "Generate structures to support parts of the model which have overhangs. Without these structures, such parts would collapse during printing."))
  55. }
  56. onExited: base.hideTooltip()
  57. }
  58. }
  59. ComboBox
  60. {
  61. id: supportExtruderCombobox
  62. height: UM.Theme.getSize("print_setup_big_dropdown").height
  63. anchors
  64. {
  65. left: enableSupportCheckBox.right
  66. right: parent.right
  67. leftMargin: UM.Theme.getSize("thick_margin").width
  68. rightMargin: UM.Theme.getSize("thick_margin").width
  69. verticalCenter: parent.verticalCenter
  70. }
  71. style: UM.Theme.styles.combobox_color
  72. enabled: recommendedPrintSettup.settingsEnabled
  73. visible: enableSupportCheckBox.visible && (supportEnabled.properties.value == "True") && (extrudersEnabledCount.properties.value > 1)
  74. textRole: "text" // this solves that the combobox isn't populated in the first time Cura is started
  75. model: extruderModel
  76. property alias _hovered: supportExtruderMouseArea.containsMouse
  77. property string color_override: "" // for manually setting values
  78. property string color: // is evaluated automatically, but the first time is before extruderModel being filled
  79. {
  80. var current_extruder = extruderModel.get(currentIndex);
  81. color_override = "";
  82. if (current_extruder === undefined) return ""
  83. return (current_extruder.color) ? current_extruder.color : "";
  84. }
  85. currentIndex:
  86. {
  87. if (supportExtruderNr.properties == null)
  88. {
  89. return Cura.MachineManager.defaultExtruderPosition
  90. }
  91. else
  92. {
  93. var extruder = parseInt(supportExtruderNr.properties.value)
  94. if ( extruder === -1)
  95. {
  96. return Cura.MachineManager.defaultExtruderPosition
  97. }
  98. return extruder;
  99. }
  100. }
  101. onActivated: supportExtruderNr.setPropertyValue("value", String(index))
  102. MouseArea
  103. {
  104. id: supportExtruderMouseArea
  105. anchors.fill: parent
  106. hoverEnabled: true
  107. enabled: recommendedPrintSettup.settingsEnabled
  108. acceptedButtons: Qt.NoButton
  109. onEntered:
  110. {
  111. base.showTooltip(supportExtruderCombobox, Qt.point(-enableSupportContainer.x - supportExtruderCombobox.x - UM.Theme.getSize("thick_margin").width, 0),
  112. catalog.i18nc("@label", "Select which extruder to use for support. This will build up supporting structures below the model to prevent the model from sagging or printing in mid air."));
  113. }
  114. onExited: base.hideTooltip()
  115. }
  116. function updateCurrentColor()
  117. {
  118. var current_extruder = extruderModel.get(currentIndex)
  119. if (current_extruder !== undefined)
  120. {
  121. supportExtruderCombobox.color_override = current_extruder.color
  122. }
  123. }
  124. }
  125. }
  126. ListModel
  127. {
  128. id: extruderModel
  129. Component.onCompleted: populateExtruderModel()
  130. }
  131. //: Model used to populate the extrudelModel
  132. Cura.ExtrudersModel
  133. {
  134. id: extruders
  135. onModelChanged: populateExtruderModel()
  136. }
  137. UM.SettingPropertyProvider
  138. {
  139. id: supportEnabled
  140. containerStack: Cura.MachineManager.activeMachine
  141. key: "support_enable"
  142. watchedProperties: [ "value", "enabled", "description" ]
  143. storeIndex: 0
  144. }
  145. UM.SettingPropertyProvider
  146. {
  147. id: extrudersEnabledCount
  148. containerStack: Cura.MachineManager.activeMachine
  149. key: "extruders_enabled_count"
  150. watchedProperties: [ "value" ]
  151. storeIndex: 0
  152. }
  153. UM.SettingPropertyProvider
  154. {
  155. id: supportExtruderNr
  156. containerStack: Cura.MachineManager.activeMachine
  157. key: "support_extruder_nr"
  158. watchedProperties: [ "value" ]
  159. storeIndex: 0
  160. }
  161. UM.SettingPropertyProvider
  162. {
  163. id: machineExtruderCount
  164. containerStack: Cura.MachineManager.activeMachine
  165. key: "machine_extruder_count"
  166. watchedProperties: ["value"]
  167. storeIndex: 0
  168. }
  169. function populateExtruderModel()
  170. {
  171. extruderModel.clear()
  172. for (var extruderNumber = 0; extruderNumber < extruders.rowCount(); extruderNumber++)
  173. {
  174. extruderModel.append({
  175. text: extruders.getItem(extruderNumber).name,
  176. color: extruders.getItem(extruderNumber).color
  177. })
  178. }
  179. supportExtruderCombobox.updateCurrentColor()
  180. }
  181. }