-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathscaledialog.cpp
More file actions
130 lines (126 loc) · 3.87 KB
/
scaledialog.cpp
File metadata and controls
130 lines (126 loc) · 3.87 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
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
//
// CDpal
//
// This software is intended to be used for curve fitting of CD thermal
// denaturation data.
//
// Copyright (C) 2015 Markus Niklasson and Patrik Lundström
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//
// Programmers: Markus Niklasson and Patrik Lundström
//
// Adress correspondence to: patlu@ifm.liu.se
// Date: 18 August, 2017
// Version: 2.18
//
#include "scaledialog.h"
#include "ui_scaledialog.h"
#include <iostream>
scaleDialog::scaleDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::scaleDialog)
{
ui->setupUi(this);
QRect position = frameGeometry();
position.moveCenter(QDesktopWidget().availableGeometry().center());
move(position.topLeft());
setWindowFlags(Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_QuitOnClose, false);
ui->minEdit->setValidator( new QDoubleValidator(ui->minEdit) );
ui->minEdit_2->setValidator( new QDoubleValidator(ui->minEdit_2) );
ui->maxEdit->setValidator( new QDoubleValidator(ui->maxEdit) );
ui->maxEdit_2->setValidator( new QDoubleValidator(ui->maxEdit_2) );
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(acceptEvent()));
connect(ui->idxBox, SIGNAL(currentIndexChanged(int)), this, SLOT(enable()));
}
scaleDialog::~scaleDialog()
{
delete ui;
}
void scaleDialog::enable()
{
if(ui->idxBox->currentIndex()==1)
{
ui->minEdit->setEnabled(true);
ui->minEdit_2->setEnabled(true);
ui->maxEdit->setEnabled(true);
ui->maxEdit_2->setEnabled(true);
ui->label->setEnabled(true);
ui->label_2->setEnabled(true);
ui->label_3->setEnabled(true);
ui->label_4->setEnabled(true);
}
else
{
ui->minEdit->setDisabled(true);
ui->minEdit_2->setDisabled(true);
ui->maxEdit->setDisabled(true);
ui->maxEdit_2->setDisabled(true);
ui->label->setDisabled(true);
ui->label_2->setDisabled(true);
ui->label_3->setDisabled(true);
ui->label_4->setDisabled(true);
}
}
void scaleDialog::acceptEvent()
{
extern int scaleIdx;
bool ok =true;
if(ui->idxBox->currentIndex()==0)
scaleIdx=0;
else
{
scaleIdx=1;
extern double xmin;
extern double xmax;
extern double ymin;
extern double ymax;
QString x1,x2,y1,y2;
x1 = ui->minEdit->text();
x2 = ui->maxEdit->text();
y1 = ui->minEdit_2->text();
y2 = ui->maxEdit_2->text();
for(int i=0; i<x1.length(); i++)
if(x1[i]==',')
{
x1[i]='.';
break;
}
for(int i=0; i<x2.length(); i++)
if(x2[i]==',')
{
x2[i]='.';
break;
}
for(int i=0; i<y1.length(); i++)
if(y1[i]==',')
{
y1[i]='.';
break;
}
for(int i=0; i<y2.length(); i++)
if(y2[i]==',')
{
y2[i]='.';
break;
}
xmin=x1.toDouble();
ymin=y1.toDouble();
xmax=x2.toDouble();
ymax=y2.toDouble();
}
if(ok == true)
accept();
}