-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.cpp
More file actions
61 lines (55 loc) · 1.54 KB
/
Copy pathMainWindow.cpp
File metadata and controls
61 lines (55 loc) · 1.54 KB
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
#include "MainWindow.h"
#include <qmessagebox.h>
#include <qfiledialog.h>
#include "XMLLoader.h"
#include <qpainter.h>
#include <qevent.h>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
connect(ui.markerArea, &MarkerWidget::scaleChanged, this, &MainWindow::updateScale);
}
MainWindow::~MainWindow()
{
}
void MainWindow::loadButtonClicked()
{
//file dialog
XMLLoader xml = XMLLoader();
std::string status;
QString fileName = QFileDialog::getOpenFileName(this, tr("Open XML"), QDir::currentPath(), tr("XML Files (*.xml)"));
if (!fileName.isEmpty())
{
std::string filePath = fileName.toStdString();
auto data = xml.readXML(filePath, &status);
if (!data.empty())
{
ui.statusBar->showMessage((std::string("File loaded, total points: ") + std::to_string(data.size())).c_str());
ui.markerArea->render(data);
}
else
{
status = "XML Error: " + status;
ui.statusBar->showMessage(status.c_str());
}
}
}
void MainWindow::aboutButtonClicked()
{
QMessageBox::aboutQt(this, "About application");
}
void MainWindow::updateScale()
{
ui.scaleLabel->setText(ui.markerArea->getScale().c_str());
}
void MainWindow::paintEvent(QPaintEvent* event)
{
QPainter painter(this);
painter.drawRect(ui.markerArea->x(), ui.markerArea->y(), ui.markerArea->width(), ui.markerArea->height());
}
void MainWindow::resizeEvent(QResizeEvent* event)
{
ui.markerArea->render();
event->accept();
}