/
main.qml
executable file
·360 lines (320 loc) · 12.5 KB
/
main.qml
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
import QtQuick 2.12
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.4
import QtQuick.Layouts 1.11
import QtQuick.Dialogs 1.0
ApplicationWindow {
id: applicationWindow
title: qsTr("HistopathApp")
visible: true
width: 1024
height: 576
menuBar: MenuBar {
Menu {
title: qsTr("File")
Action {
text: qsTr("Open")
onTriggered: fileDialog.open()
}
Action { text: qsTr("Save") }
Action { text: qsTr("Save as...")}
}
Menu {
title: qsTr("Processing")
enabled: viewer.selected_file
Action {
text: worker_manager.running ? qsTr("Stop processing") : qsTr("Start processing")
onTriggered: {
worker_manager.running ? worker_manager.stop_worker() : worker_manager.start_worker(viewer.selected_file)
}
}
}
Menu {
title: qsTr("Configuration")
Menu {
title: qsTr("Language")
Action {
text: qsTr("English")
onTriggered: {
translator.set_language("en")
}
}
Action {
text: qsTr("Spanish")
onTriggered: {
translator.set_language("es")
}
}
Action {
text: qsTr("French")
onTriggered: {
translator.set_language("fr")
}
}
}
}
Menu {
title: qsTr("Help")
Action { text: qsTr("Open help")}
}
}
SplitView {
id: splitView
anchors.fill: parent
orientation: Qt.Horizontal
Rectangle {
id: leftPanel
SplitView.preferredWidth: (viewer.selected_file.toString() === "") ? 0 : parent.width * 0.2
// SplitView.preferredWidth: parent.width * 0.2
// SplitView.minimumWidth: parent.width * 0.15
SplitView.maximumWidth: parent.width * 0.5
color: Material.color(Material.Grey, Material.Shade50)
ScrollView {
anchors.fill: parent
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff // disable the horizontal scroll bar
ListView {
id: listView
model: viewer.selected_file_siblings
width: parent.width
height: parent.height
anchors.fill: parent
spacing: 10
// The delegate presents the information stored in the model
delegate: Rectangle {
border.color: Material.color(Material.Grey, (display === viewer.selected_file) ? Material.Shade700 : Material.Shade300)
border.width: (display === viewer.selected_file) ? 3 : 1
width: parent.width
height: parent.width * 0.60
Image {
asynchronous: true
fillMode: Image.PreserveAspectCrop
source: display
width: parent.width - 20
height: parent.width * 0.56
sourceSize.width: 512
sourceSize.height: 512
anchors.centerIn: parent
BusyIndicator {
running: parent.status === Image.Loading
anchors.centerIn: parent
}
}
// Label {
// text: display
// anchors.centerIn: parent.Center
// }
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
viewer.mask_file = ''
viewer.selected_file = display
}
}
}
}
}
// Button {
// text: qsTr("Select WSI")
//// Material.background: Material.Indigo
//// anchors.centerIn: parent
// onClicked: {
// fileDialog.open()
// }
// }
// Button {
// text: qsTr("Stop worker")
//// Material.background: Material.Indigo
//// anchors.centerIn: parent
// visible: worker_manager.running
// onClicked: {
// worker_manager.stop_worker()
// }
// }
}
Rectangle {
id: visor
Layout.fillWidth: true
color: "white"
Rectangle {
anchors.fill: parent
z: dragArea.z+1
visible: (viewer.selected_file.toString() === "")
Label {
text: qsTr("Drag and drop an image here to open it")
color: Material.color(Material.Grey, Material.Shade400)
anchors.centerIn: parent
}
}
BusyIndicator {
running: mapImage.status === Image.Loading
anchors.centerIn: parent
z: dragArea.z + 4
}
Flickable {
id: flick
anchors.fill: parent
clip: true
Rectangle {
id: rect
width: Math.max(mapImage.sourceSize.width, flick.width)
height: Math.max(mapImage.sourceSize.height, flick.height)
transform: Scale {
id: scaler
origin.x: pinchArea.m_x2
origin.y: pinchArea.m_y2
xScale: pinchArea.m_zoom2
yScale: pinchArea.m_zoom2
}
Image
{
asynchronous: true
id: mapImage
z: dragArea.z+1
source: viewer.selected_file
//anchors.centerIn: parent
//fillMode: Image.PreserveAspectFit
anchors.fill: parent
}
Image {
asynchronous: true
id: maskImage
z:dragArea.z + 2
source: viewer.mask_file
anchors.fill: parent
}
PinchArea {
id: pinchArea
anchors.fill: parent
property real m_x1: 0
property real m_y1: 0
property real m_y2: 0
property real m_x2: 0
property real m_zoom1: 0.5
property real m_zoom2: 0.5
property real m_max: 2
property real m_min: 0.2
onPinchStarted: {
m_x1 = scaler.origin.x
m_y1 = scaler.origin.y
m_x2 = pinch.startCenter.x
m_y2 = pinch.startCenter.y
rect.x = rect.x + (pinchArea.m_x1-pinchArea.m_x2)*(1-pinchArea.m_zoom1)
rect.y = rect.y + (pinchArea.m_y1-pinchArea.m_y2)*(1-pinchArea.m_zoom1)
}
onPinchUpdated: {
m_zoom1 = scaler.xScale
var dz = pinch.scale-pinch.previousScale
var newZoom = m_zoom1+dz
if (newZoom <= m_max && newZoom >= m_min) {
m_zoom2 = newZoom
}
}
MouseArea {
id: dragArea
hoverEnabled: true
anchors.fill: parent
drag.target: rect
drag.filterChildren: true
onWheel: {
pinchArea.m_x1 = scaler.origin.x
pinchArea.m_y1 = scaler.origin.y
pinchArea.m_zoom1 = scaler.xScale
pinchArea.m_x2 = mouseX
pinchArea.m_y2 = mouseY
var newZoom
if (wheel.angleDelta.y > 0) {
newZoom = pinchArea.m_zoom1+0.1
if (newZoom <= pinchArea.m_max) {
pinchArea.m_zoom2 = newZoom
} else {
pinchArea.m_zoom2 = pinchArea.m_max
}
} else {
newZoom = pinchArea.m_zoom1-0.1
if (newZoom >= pinchArea.m_min) {
pinchArea.m_zoom2 = newZoom
} else {
pinchArea.m_zoom2 = pinchArea.m_min
}
}
rect.x = rect.x + (pinchArea.m_x1-pinchArea.m_x2)*(1-pinchArea.m_zoom1)
rect.y = rect.y + (pinchArea.m_y1-pinchArea.m_y2)*(1-pinchArea.m_zoom1)
console.debug(rect.width+" -- "+rect.height+"--"+rect.scale)
}
}
}
}
}
Rectangle {
anchors.bottom: parent.bottom
// anchors.left: parent.left
anchors.right: parent.right
height: 35
width: 200
z: dragArea.z + 6
color: "transparent"
visible: !(viewer.mask_file.toString() === "")
RowLayout {
Slider {
id: maskOpacitySlider
from: 0.0
to: 1.0
value: 1
stepSize: 0.1
onValueChanged: {
maskImage.opacity = maskOpacitySlider.value
}
}
}
}
// Image {
// id:background_image
// z: 10
// fillMode: Image.PreserveAspectFit
// source: "/media/abraham/Datos/University/Tesis/Code/app/assets/background.png"
// height: parent.height
// width: parent.width
// }
ProgressBar {
id: progressBar
width: parent.width
anchors.bottom: parent.bottom
from: 0
to: 100
visible: worker_manager.running
value: worker_manager.progress
Behavior on value { NumberAnimation {} }
}
}
}
Rectangle {
anchors.bottom: parent.bottom
anchors.left: parent.left
height: labelStatus.height
width: labelStatus.width
border.color: Material.color(Material.Grey, Material.Shade200)
color: Material.color(Material.Grey, Material.Shade100)
visible: labelStatus.text.length > 0
z: 30
Label {
id:labelStatus
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
padding: 5
elide: Text.ElideRight
text: worker_manager.status
}
}
FileDialog {
id: fileDialog
title: qsTr("Select an image")
// folder: shortcuts.home
nameFilters: [ qsTr("Image files ") + " (*.jpg *.png *.bmp)" ]
onAccepted: {
// mapImage.source = fileDialog.fileUrl
// background_image.z = -1
viewer.selected_file = fileDialog.fileUrl
}
}
}