Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PrintJobInformation.qml « ActionPanel « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9cdbf0714f17daade89cdd1cebac37a40b2608be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// Copyright (c) 2019 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.7
import QtQuick.Controls 2.1

import UM 1.1 as UM
import Cura 1.0 as Cura

Column
{
    id: base
    spacing: UM.Theme.getSize("default_margin").width

    UM.I18nCatalog
    {
        id: catalog
        name: "cura"
    }

    Column
    {
        id: timeSpecification
        width: parent.width
        topPadding: UM.Theme.getSize("default_margin").height
        leftPadding: UM.Theme.getSize("default_margin").width
        rightPadding: UM.Theme.getSize("default_margin").width

        Label
        {
            text: catalog.i18nc("@label", "Time estimation").toUpperCase()
            color: UM.Theme.getColor("primary")
            font: UM.Theme.getFont("default_bold")
            renderType: Text.NativeRendering
        }

        Label
        {
            id: byLineType

            property var printDuration: PrintInformation.currentPrintTime
            property var columnWidthMultipliers: [ 0.45, 0.3, 0.25 ]
            property var columnHorizontalAligns: [ Text.AlignLeft, Text.AlignHCenter, Text.AlignRight ]

            function getMaterialTable()
            {
                var result = []

                // All the time information for the different features is achieved
                var printTime = PrintInformation.getFeaturePrintTimes()
                var totalSeconds = parseInt(printDuration.getDisplayString(UM.DurationFormat.Seconds))

                // A message is created and displayed when the user hover the time label
                for(var feature in printTime)
                {
                    if(!printTime[feature].isTotalDurationZero)
                    {
                        var row = []
                        row.push(feature + ": ")
                        row.push("%1".arg(printTime[feature].getDisplayString(UM.DurationFormat.ISO8601).slice(0,-3)))
                        row.push("%1%".arg(Math.round(100 * parseInt(printTime[feature].getDisplayString(UM.DurationFormat.Seconds)) / totalSeconds)))
                        result.push(row)
                    }
                }

                return result
            }

            Column
            {
                Repeater
                {
                    model: byLineType.getMaterialTable()
                    Row
                    {
                        Repeater
                        {
                            model: modelData
                            Label
                            {
                                width: Math.round(byLineType.width * byLineType.columnWidthMultipliers[index])
                                height: contentHeight
                                horizontalAlignment: byLineType.columnHorizontalAligns[index]
                                color: UM.Theme.getColor("text")
                                font: UM.Theme.getFont("default")
                                wrapMode: Text.WrapAnywhere
                                text: modelData
                                renderType: Text.NativeRendering
                            }
                        }
                    }
                }
            }

            width: parent.width - 2 * UM.Theme.getSize("default_margin").width
            height: childrenRect.height
            color: UM.Theme.getColor("text")
            font: UM.Theme.getFont("default")
            renderType: Text.NativeRendering
            textFormat: Text.RichText
        }
    }

    Column
    {
        id: materialSpecification
        width: parent.width
        bottomPadding: UM.Theme.getSize("default_margin").height
        leftPadding: UM.Theme.getSize("default_margin").width
        rightPadding: UM.Theme.getSize("default_margin").width

        Label
        {
            text: catalog.i18nc("@label", "Material estimation").toUpperCase()
            color: UM.Theme.getColor("primary")
            font: UM.Theme.getFont("default_bold")
            renderType: Text.NativeRendering
        }
        
        Label
        {
            id: byMaterialType

            property var printMaterialLengths: PrintInformation.materialLengths
            property var printMaterialWeights: PrintInformation.materialWeights
            property var printMaterialCosts: PrintInformation.materialCosts
            property var printMaterialNames: PrintInformation.materialNames
            property var columnWidthMultipliers: [ 0.46, 0.18, 0.18, 0.18 ]
            property var columnHorizontalAligns: [ Text.AlignLeft, Text.AlignHCenter, Text.AlignHCenter, Text.AlignRight ]

            function getMaterialTable()
            {
                var result = []

                var lengths = []
                var weights = []
                var costs = []
                var names = []
                if(printMaterialLengths)
                {
                    for(var index = 0; index < printMaterialLengths.length; index++)
                    {
                        if(printMaterialLengths[index] > 0)
                        {
                            names.push(printMaterialNames[index])
                            lengths.push(printMaterialLengths[index].toFixed(2))
                            weights.push(String(printMaterialWeights[index].toFixed(1)))
                            var cost = printMaterialCosts[index] == undefined ? 0 : printMaterialCosts[index].toFixed(2)
                            costs.push(cost)
                        }
                    }
                }
                if(lengths.length == 0)
                {
                    lengths = ["0.00"]
                    weights = ["0.0"]
                    costs = ["0.00"]
                }

                for(var index = 0; index < lengths.length; index++)
                {
                    var row = []
                    row.push("%1".arg(names[index]))
                    row.push(catalog.i18nc("@label m for meter", "%1m").arg(lengths[index]))
                    row.push(catalog.i18nc("@label g for grams", "%1g").arg(weights[index]))
                    row.push("%1 %2".arg(UM.Preferences.getValue("cura/currency")).arg(costs[index]))
                    result.push(row)
                }

                return result
            }

            Column
            {
                Repeater
                {
                    model: byMaterialType.getMaterialTable()
                    Row
                    {
                        Repeater
                        {
                            model: modelData
                            Label
                            {
                                width: Math.round(byMaterialType.width * byMaterialType.columnWidthMultipliers[index])
                                height: contentHeight
                                horizontalAlignment: byMaterialType.columnHorizontalAligns[index]
                                color: UM.Theme.getColor("text")
                                font: UM.Theme.getFont("default")
                                wrapMode: Text.WrapAnywhere
                                text: modelData
                                renderType: Text.NativeRendering
                            }
                        }
                    }
                }
            }

            width: parent.width - 2 * UM.Theme.getSize("default_margin").width
            height: childrenRect.height
            color: UM.Theme.getColor("text")
            font: UM.Theme.getFont("default")
            renderType: Text.NativeRendering
            textFormat: Text.RichText
        }
    }
}