-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
97 lines (93 loc) · 4.13 KB
/
mainwindow.cpp
File metadata and controls
97 lines (93 loc) · 4.13 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
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFileDialog>
#include "geditem.h"
#include "events.cpp"
#include <QFile>
#include <QImage>
MainWindowClass::MainWindowClass(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindowClass)
{
ui->setupUi(this);
ui->picLabel->installEventFilter(this); //installs the eventhandler do get the mousclicks on the pic
this->outputDir="none";
}
MainWindowClass::~MainWindowClass()
{
delete ui;
}
void MainWindowClass::setValuesByMethod(QString method) {
GEDItem *link = dynamic_cast <GEDItem*>(ui->listWidget->currentItem());
// x1, y1 are the center coords, x2, y2 are the coords for the angle point
float x1 = link->getXNULL().toFloat();
float y1 = link->getYNULL().toFloat();
float x2 = link->getxRMAXT().toFloat();
float y2 = link->getyRMAXT().toFloat();
if (method == "Whole area" ) {
ui->XSCATlineEdit->setReadOnly(true);
ui->YSCATlineEdit->setReadOnly(true);
link->setMode(method);
if (link->getXSCAT().toFloat() == 0.0) {
ui->XSCATlineEdit->setText(QString::number(link->distance(x1, x2, y1, y2)*2.0));
} else {
ui->XSCATlineEdit->setText(link->getXSCAT());
}
if (link->getYSCAT().toFloat() == 0.0) {
ui->YSCATlineEdit->setText(QString::number(link->distance(x1, x2, y1, y2)*2.0));
} else {
ui->YSCATlineEdit->setText(link->getYSCAT());
}
ui->ANGLElineEdit->setText(QString::number(0.0));
ui->ANGLElineEdit->setReadOnly(true);
} else if (method == "Right-Left" || method == "Left" || method == "Right") {
ui->XSCATlineEdit->setText("0.0");
ui->XSCATlineEdit->setReadOnly(true);
ui->YSCATlineEdit->setReadOnly(false);
ui->ANGLElineEdit->setReadOnly(false);
if (link->getYSCAT().toFloat() == 0.0) {
ui->YSCATlineEdit->setText(QString::number(link->distance(x1, x2, y1, y2)*2.0));
} else {
ui->YSCATlineEdit->setText(link->getYSCAT());
}
link->setMode(method);
float x3 = 0.0; // stupid
// lets test it the user clicked left or right from the center for the angle point
if (x1>x2) { // user clicked left
x3 = x1-link->distance(x1, x2, y1, y2);
} else { // right side
x3 = x1+link->distance(x1, x2, y1, y2);
}
float y3 = y1;
float angle = link->calcAngle(x1, y1, x2, y2, x3, y3);
ui->ANGLElineEdit->setText(QString::number(angle));
} else if (method == "Top-Down"|| method == "Top" || method == "Down") {
ui->XSCATlineEdit->setReadOnly(false);
if (link->getXSCAT().toFloat() == 0.0) {
ui->XSCATlineEdit->setText(QString::number(link->distance(x1, x2, y1, y2)*2.0));
} else {
ui->XSCATlineEdit->setText(link->getXSCAT());
}
ui->YSCATlineEdit->setText("0.0");
ui->YSCATlineEdit->setReadOnly(true);
ui->ANGLElineEdit->setReadOnly(false);
link->setMode(method);
float y3 = 0.0; // stupid
//lets test if the user clicked under or above the center
if (y1>y2) { // clicked above the center
y3 = y1-link->distance(x1, x2, y1, y2);
} else {
y3 = y1 + link->distance(x1, x2, y1, y2);
}
float x3 = x1;
float angle = link->calcAngle(x1, y1, x2, y2, x3, y3);
ui->ANGLElineEdit->setText(QString::number(angle));
} /*else if ( method == "Selected area" || method == "Set points first" || method == "Choose method") {
ui->XSCATlineEdit->setReadOnly(false);
ui->YSCATlineEdit->setReadOnly(false);
ui->XSCATlineEdit->setText(ui->RMAXTlineEdit->text());
ui->YSCATlineEdit->setText(ui->RMAXTlineEdit->text());
link->setMode(method);
float angle = link->calcAngle(link->getXNULL().toFloat(), link->getYNULL().toFloat(), link->getxRMAXT().toFloat(), link->getyRMAXT().toFloat(), link->getxAngle().toFloat(), link->getyAngle().toFloat());
ui->ANGLElineEdit->setText(QString::number(angle));
} */
}