-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
139 lines (111 loc) · 5.03 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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "polygondrawer.h"
#include "linedrawer.h"
#include "mousefollower.h"
#include "hintboxdrawer.h"
#include <QColorDialog>
// ==================================================================================================
// PUBLIC MEMBERS
// ==================================================================================================
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
color(255, 255, 255) {
ui->setupUi(this);
setWindowTitle(tr("Scan Line Algorithm Tester"));
openGlCanvas = ui->centralWidget->findChild<CanvasOpenGL*>();
onReset();
}
// ==================================================================================================
MainWindow::~MainWindow() {
delete ui;
delete openGlCanvas;
}
// ==================================================================================================
CanvasOpenGL* MainWindow::Canvas() const {
return openGlCanvas;
}
// ==================================================================================================
// PRIVATE MEMBERS
// ==================================================================================================
void MainWindow::keyReleaseEvent(QKeyEvent* e) {
emit keyReleased(e->key());
}
// ==================================================================================================
// PRIVATE MEMBERS (SLOTS)
// ==================================================================================================
void MainWindow::on_ClearButton_clicked() {
// OBS: Qt defines on_<Button>_<Signal> as default callbacks for any UI element in the same object
// To automatically create one, right click in the button/object and select "Go to slot"
// and select the desired event. It will create the corresponding fct.
emit clearPressed();
}
// ==================================================================================================
void MainWindow::on_changeColor_released() {
//QColorDialogTester color_test;
//color_test.onColor();
QColor color = QColorDialog::getColor(this->color, this );
if( color.isValid() )
{
this->color = color;
openGlCanvas->SetPointsColor(color);
}
}
// ==================================================================================================
void MainWindow::on_obsXValue_valueChanged(double x) {
emit cameraRotationChanged(static_cast<int>(x),
static_cast<int>(this->ui->obsYValue->value()),
static_cast<int>(this->ui->obsZValue->value()));
}
void MainWindow::on_obsYValue_valueChanged(double y) {
emit cameraRotationChanged(static_cast<int>(this->ui->obsXValue->value()),
static_cast<int>(y),
static_cast<int>(this->ui->obsZValue->value()));
}
void MainWindow::on_obsZValue_valueChanged(double z) {
emit cameraRotationChanged(static_cast<int>(this->ui->obsXValue->value()),
static_cast<int>(this->ui->obsYValue->value()),
static_cast<int>(z));
}
// ==================================================================================================
void MainWindow::on_lightValueX_valueChanged(double x) {
emit lightingValueChanged(static_cast<int>(x),
static_cast<int>(this->ui->lightValueY->value()),
static_cast<int>(this->ui->lightValueZ->value()));
}
void MainWindow::on_lightValueY_valueChanged(double y) {
emit lightingValueChanged(static_cast<int>(this->ui->lightValueX->value()),
static_cast<int>(y),
static_cast<int>(this->ui->lightValueZ->value()));
}
void MainWindow::on_lightValueZ_valueChanged(double z) {
emit lightingValueChanged(static_cast<int>(this->ui->lightValueX->value()),
static_cast<int>(this->ui->lightValueY->value()),
static_cast<int>(z));
}
// ==================================================================================================
void MainWindow::on_toningValue_currentTextChanged(const QString &shading) {
emit shadingChanged(shading);
}
// ==================================================================================================
void MainWindow::on_ResetButton_released() {
onReset();
}
void MainWindow::onReset() {
// Observer
this->ui->obsXValue->setValue(0.0);
this->ui->obsYValue->setValue(0.0);
this->ui->obsZValue->setValue(0.0);
emit cameraRotationChanged(0, 0, 0);
// Lighting
this->ui->lightValueX->setValue(openGlCanvas->width()/2);
this->ui->lightValueY->setValue(openGlCanvas->height()/2);
this->ui->lightValueZ->setValue(-100);
emit lightingValueChanged(openGlCanvas->width()/2, openGlCanvas->height()/2, -100);
this->ui->toningValue->setCurrentIndex(0);
emit shadingChanged("Flat");
}
void MainWindow::on_editButton_released() {
emit editPressed();
}