PrintJobInformation.qml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // Copyright (c) 2019 Ultimaker B.V.
  2. // Cura is released under the terms of the LGPLv3 or higher.
  3. import QtQuick 2.7
  4. import QtQuick.Controls 2.1
  5. import UM 1.1 as UM
  6. import Cura 1.0 as Cura
  7. Column
  8. {
  9. id: base
  10. spacing: UM.Theme.getSize("default_margin").width
  11. UM.I18nCatalog
  12. {
  13. id: catalog
  14. name: "cura"
  15. }
  16. Column
  17. {
  18. id: timeSpecification
  19. width: parent.width
  20. topPadding: UM.Theme.getSize("default_margin").height
  21. leftPadding: UM.Theme.getSize("default_margin").width
  22. rightPadding: UM.Theme.getSize("default_margin").width
  23. Label
  24. {
  25. text: catalog.i18nc("@label", "Time estimation").toUpperCase()
  26. color: UM.Theme.getColor("primary")
  27. font: UM.Theme.getFont("default_bold")
  28. renderType: Text.NativeRendering
  29. }
  30. Label
  31. {
  32. id: byLineType
  33. property var printDuration: PrintInformation.currentPrintTime
  34. property var columnWidthMultipliers: [ 0.45, 0.3, 0.25 ]
  35. property var columnHorizontalAligns: [ Text.AlignLeft, Text.AlignHCenter, Text.AlignRight ]
  36. function getMaterialTable()
  37. {
  38. var result = []
  39. // All the time information for the different features is achieved
  40. var printTime = PrintInformation.getFeaturePrintTimes()
  41. var totalSeconds = parseInt(printDuration.getDisplayString(UM.DurationFormat.Seconds))
  42. // A message is created and displayed when the user hover the time label
  43. for(var feature in printTime)
  44. {
  45. if(!printTime[feature].isTotalDurationZero)
  46. {
  47. var row = []
  48. row.push(feature + ": ")
  49. row.push("%1".arg(printTime[feature].getDisplayString(UM.DurationFormat.ISO8601).slice(0,-3)))
  50. row.push("%1%".arg(Math.round(100 * parseInt(printTime[feature].getDisplayString(UM.DurationFormat.Seconds)) / totalSeconds)))
  51. result.push(row)
  52. }
  53. }
  54. return result
  55. }
  56. Column
  57. {
  58. Repeater
  59. {
  60. model: byLineType.getMaterialTable()
  61. Row
  62. {
  63. Repeater
  64. {
  65. model: modelData
  66. Label
  67. {
  68. width: Math.round(byLineType.width * byLineType.columnWidthMultipliers[index])
  69. height: contentHeight
  70. horizontalAlignment: byLineType.columnHorizontalAligns[index]
  71. color: UM.Theme.getColor("text")
  72. font: UM.Theme.getFont("default")
  73. wrapMode: Text.WrapAnywhere
  74. text: modelData
  75. renderType: Text.NativeRendering
  76. }
  77. }
  78. }
  79. }
  80. }
  81. width: parent.width - 2 * UM.Theme.getSize("default_margin").width
  82. height: childrenRect.height
  83. color: UM.Theme.getColor("text")
  84. font: UM.Theme.getFont("default")
  85. renderType: Text.NativeRendering
  86. textFormat: Text.RichText
  87. }
  88. }
  89. Column
  90. {
  91. id: materialSpecification
  92. width: parent.width
  93. bottomPadding: UM.Theme.getSize("default_margin").height
  94. leftPadding: UM.Theme.getSize("default_margin").width
  95. rightPadding: UM.Theme.getSize("default_margin").width
  96. Label
  97. {
  98. text: catalog.i18nc("@label", "Material estimation").toUpperCase()
  99. color: UM.Theme.getColor("primary")
  100. font: UM.Theme.getFont("default_bold")
  101. renderType: Text.NativeRendering
  102. }
  103. Label
  104. {
  105. id: byMaterialType
  106. property var printMaterialLengths: PrintInformation.materialLengths
  107. property var printMaterialWeights: PrintInformation.materialWeights
  108. property var printMaterialCosts: PrintInformation.materialCosts
  109. property var printMaterialNames: PrintInformation.materialNames
  110. property var columnWidthMultipliers: [ 0.46, 0.18, 0.18, 0.18 ]
  111. property var columnHorizontalAligns: [ Text.AlignLeft, Text.AlignHCenter, Text.AlignHCenter, Text.AlignRight ]
  112. function getMaterialTable()
  113. {
  114. var result = []
  115. var lengths = []
  116. var weights = []
  117. var costs = []
  118. var names = []
  119. if(printMaterialLengths)
  120. {
  121. for(var index = 0; index < printMaterialLengths.length; index++)
  122. {
  123. if(printMaterialLengths[index] > 0)
  124. {
  125. names.push(printMaterialNames[index])
  126. lengths.push(printMaterialLengths[index].toFixed(2))
  127. weights.push(String(printMaterialWeights[index].toFixed(1)))
  128. var cost = printMaterialCosts[index] == undefined ? 0 : printMaterialCosts[index].toFixed(2)
  129. costs.push(cost)
  130. }
  131. }
  132. }
  133. if(lengths.length == 0)
  134. {
  135. lengths = ["0.00"]
  136. weights = ["0.0"]
  137. costs = ["0.00"]
  138. }
  139. for(var index = 0; index < lengths.length; index++)
  140. {
  141. var row = []
  142. row.push("%1".arg(names[index]))
  143. row.push(catalog.i18nc("@label m for meter", "%1m").arg(lengths[index]))
  144. row.push(catalog.i18nc("@label g for grams", "%1g").arg(weights[index]))
  145. row.push("%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]))
  146. result.push(row)
  147. }
  148. return result
  149. }
  150. Column
  151. {
  152. Repeater
  153. {
  154. model: byMaterialType.getMaterialTable()
  155. Row
  156. {
  157. Repeater
  158. {
  159. model: modelData
  160. Label
  161. {
  162. width: Math.round(byMaterialType.width * byMaterialType.columnWidthMultipliers[index])
  163. height: contentHeight
  164. horizontalAlignment: byMaterialType.columnHorizontalAligns[index]
  165. color: UM.Theme.getColor("text")
  166. font: UM.Theme.getFont("default")
  167. wrapMode: Text.WrapAnywhere
  168. text: modelData
  169. renderType: Text.NativeRendering
  170. }
  171. }
  172. }
  173. }
  174. }
  175. width: parent.width - 2 * UM.Theme.getSize("default_margin").width
  176. height: childrenRect.height
  177. color: UM.Theme.getColor("text")
  178. font: UM.Theme.getFont("default")
  179. renderType: Text.NativeRendering
  180. textFormat: Text.RichText
  181. }
  182. }
  183. }