-
Notifications
You must be signed in to change notification settings - Fork 2
/
mainwindow.cpp
executable file
·148 lines (107 loc) · 3.81 KB
/
mainwindow.cpp
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
#include "ui_mainwindow.h"
#include "mainwindow.h"
#include "ProbeCalibrationWidget.h"
#include <QVBoxLayout>
#include <vtkEventQtSlotConnect.h>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setAttribute(Qt::WA_DeleteOnClose);
this->displayWidget = new QVTKImageWidget();
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->QLayout::addWidget(displayWidget);
ui->imageWidget->setLayout(layout);
// hide the slider andonly show if an image stack is load
ui->imageSlider->hide();
// create the connections
Connections = vtkSmartPointer<vtkEventQtSlotConnect>::New();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::addImages()
{
this->imagesFilenames = QFileDialog::getOpenFileNames(this, tr("Open Images"), QDir::currentPath());
if (!imagesFilenames.isEmpty())
{
if (imagesFilenames.size() == 1)
{
ui->imageSlider->hide();
addLogText("Loading: <b>" + imagesFilenames.first() + "</b>");
displayWidget->setAndDisplayImage(imagesFilenames.first());
addLogText("Image Type: <b>" + displayWidget->getImageType() + "</b>");
addLogText("Pixel Type: <b>" + displayWidget->getPixelType() + "</b>");
addLogText("Num of Dimensions: <b>" + displayWidget->getNumOfDimesions() + "</b>");
}
else
{
// if selected multiple files
ui->imageSlider->show();
ui->imageSlider->setTickInterval(1);
ui->imageSlider->setRange(0, imagesFilenames.size() - 1);
this->displayWidget->setAndDisplayMultipleImages(imagesFilenames);
for (int i = 0; i < imagesFilenames.size(); i++)
{
addLogText("Loading: <b>" + imagesFilenames.at(i) + "</b>");
}
}
// get left mouse pressed with high priority
// Connections->Connect(displayWidget->getQVTKWidget()->GetRenderWindow()->GetInteractor(),
// vtkCommand::LeftButtonPressEvent, this,
// SLOT(print()));
}
else
{
return;
}
}
void MainWindow::probeCalibration()
{
if (!displayWidget->getImageStack().empty())
{
ProbeCalibrationWidget* probeCalibration = new ProbeCalibrationWidget();
if (displayWidget->isImageStackLoaded)
probeCalibration->setImageStack(displayWidget->getImageStack());
else
probeCalibration->setImage(displayWidget->getImageViewer()->GetInput());
// get left mouse pressed with high priority
Connections->Connect(displayWidget->getQVTKWidget()->GetRenderWindow()->GetInteractor(),
vtkCommand::LeftButtonPressEvent,
probeCalibration,
SLOT(getCoordinates()));
probeCalibration->setMainWindow(this);
probeCalibration->show();
}
else
{
QErrorMessage errorMessage;
errorMessage.showMessage("No images loaded, </ br> please load an images before calibrate the probe");
errorMessage.exec();
}
// ProbeCalibrationWidget* probeCalibration = new ProbeCalibrationWidget();
// probeCalibration->setMainWindow(this);
// probeCalibration->show();
}
void MainWindow::displaySelectedImage(int idx)
{
this->displayWidget->displaySelectedImage(idx);
}
QVTKImageWidget* MainWindow::getDisplayWidget()
{
return this->displayWidget;
}
void MainWindow::addLogText(QString str)
{
ui->textEdit->append(str);
// move the cursor to the end of the last line
QTextCursor cursor = ui->textEdit->textCursor();
cursor.movePosition(QTextCursor::End);
ui->textEdit->setTextCursor(cursor);
}
void MainWindow::print()
{
this->addLogText("estoy cachando el evento");
}