PrintJobInformation.qml 6.8 KB

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