tychoBCGEN
0.5
Main Page
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
colormask.cpp
Go to the documentation of this file.
1
5
#include "
myscene.h
"
6
#include "
mainwindow.h
"
7
#include "
ui_mainwindow.h
"
8
#include "
colormask.h
"
9
#include "
ui_colormask.h
"
10
#include "
global.h
"
11
#include <QPixmap>
12
#include <QString>
13
#include <QGraphicsScene>
14
#include <QPainter>
15
#include <QColor>
16
#include <QRgb>
17
#include <QTimer>
18
19
int
red_low
;
20
int
red_up
;
21
int
green_low
;
22
int
green_up
;
23
int
blue_low
;
24
int
blue_up
;
25
int
value
;
26
27
colormask::colormask
(QWidget *parent) :
28
QDialog(parent),
29
ui(new Ui::
colormask
)
30
{
31
QTimer *timer =
new
QTimer(
this
);
32
ui
->
setupUi
(
this
);
33
34
connect(
ui
->
close
, SIGNAL(clicked()),
this
, SLOT(
close_color_mask_window
()));
35
connect(timer, SIGNAL(timeout()),
this
, SLOT(
make_color_mask_action
()));
36
timer->start(200);
37
38
//colormask sliders and spinboxes
39
connect(
ui
->
red_low
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_sliders
()));
40
connect(
ui
->
green_low
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_sliders
()));
41
connect(
ui
->
blue_low
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_sliders
()));
42
43
connect(
ui
->
red_low_2
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_spin_boxes
()));
44
connect(
ui
->
green_low_2
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_spin_boxes
()));
45
connect(
ui
->
blue_low_2
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_spin_boxes
()));
46
47
connect(
ui
->
red_up
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_sliders
()));
48
connect(
ui
->
green_up
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_sliders
()));
49
connect(
ui
->
blue_up
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_sliders
()));
50
51
connect(
ui
->
red_up_2
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_spin_boxes
()));
52
connect(
ui
->
green_up_2
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_spin_boxes
()));
53
connect(
ui
->
blue_up_2
, SIGNAL(valueChanged(
int
)),
this
, SLOT(
set_color_spin_boxes
()));
54
55
connect(
ui
->
red_checkbox
, SIGNAL(stateChanged(
int
)),
this
, SLOT(
enable_checkbox_red
()));
56
connect(
ui
->
green_checkbox
, SIGNAL(stateChanged(
int
)),
this
, SLOT(
enable_checkbox_green
()));
57
connect(
ui
->
blue_checkbox
, SIGNAL(stateChanged(
int
)),
this
, SLOT(
enable_checkbox_blue
()));
58
59
}
60
61
colormask::~colormask
()
62
{
63
delete
ui
;
64
}
65
66
void
colormask::make_color_mask_action
(){
67
68
ui
->
redvalue
->setText(QString::number(
pick_red
));
69
ui
->
greenvalue
->setText(QString::number(
pick_green
));
70
ui
->
bluevalue
->setText(QString::number(
pick_blue
));
71
72
ui
->
red_low
->setRange(0,
pick_red
);
73
ui
->
green_low
->setRange(0,
pick_green
);
74
ui
->
blue_low
->setRange(0,
pick_blue
);
75
76
ui
->
red_up
->setRange(0,255-
pick_red
);
77
ui
->
green_up
->setRange(0,255-
pick_green
);
78
ui
->
blue_up
->setRange(0,255-
pick_blue
);
79
80
}
81
82
void
colormask::update_color_mask_parameter
(){
83
84
red_low
=
ui
->
red_low
->value();
85
red_up
=
ui
->
red_up
->value();
86
green_low
=
ui
->
green_low
->value();
87
green_up
=
ui
->
green_up
->value();
88
blue_low
=
ui
->
blue_low
->value();
89
blue_up
=
ui
->
blue_up
->value();
90
value
=
red_low
+
red_up
+
green_low
+
green_up
+
blue_low
+
blue_up
;
91
92
colormask_counter
++;
93
}
94
95
void
colormask::set_color_sliders
(){
96
97
ui
->
red_low_2
->setValue(
ui
->
red_low
->value());
98
ui
->
green_low_2
->setValue(
ui
->
green_low
->value());
99
ui
->
blue_low_2
->setValue(
ui
->
blue_low
->value());
100
101
if
(
ui
->
red_checkbox
->isChecked()){
102
ui
->
red_up_2
->setValue(
ui
->
red_low
->value());
103
ui
->
red_up
->setDisabled(
true
);
104
}
105
else
{
106
ui
->
red_up_2
->setValue(
ui
->
red_up
->value());
107
ui
->
red_up
->setEnabled(
true
);
108
}
109
if
(
ui
->
green_checkbox
->isChecked()){
110
ui
->
green_up_2
->setValue(
ui
->
green_low
->value());
111
ui
->
green_up
->setDisabled(
true
);
112
}
113
else
{
114
ui
->
green_up_2
->setValue(
ui
->
green_up
->value());
115
ui
->
green_up
->setEnabled(
true
);
116
}
117
if
(
ui
->
blue_checkbox
->isChecked()){
118
ui
->
blue_up_2
->setValue(
ui
->
blue_low
->value());
119
ui
->
blue_up
->setDisabled(
true
);
120
}
121
else
{
122
ui
->
blue_up_2
->setValue(
ui
->
blue_up
->value());
123
ui
->
blue_up
->setEnabled(
true
);
124
}
125
126
update_color_mask_parameter
();
127
}
128
129
void
colormask::set_color_spin_boxes
(){
130
131
ui
->
red_low
->setValue(
ui
->
red_low_2
->value());
132
ui
->
green_low
->setValue(
ui
->
green_low_2
->value());
133
ui
->
blue_low
->setValue(
ui
->
blue_low_2
->value());
134
135
136
ui
->
red_up
->setValue(
ui
->
red_up_2
->value());
137
ui
->
green_up
->setValue(
ui
->
green_up_2
->value());
138
ui
->
blue_up
->setValue(
ui
->
blue_up_2
->value());
139
140
update_color_mask_parameter
();
141
}
142
143
void
colormask::enable_checkbox_red
(){
144
if
(
ui
->
red_checkbox
->isChecked()){
145
ui
->
red_up_2
->setValue(
ui
->
red_low
->value());
146
ui
->
red_up_2
->setDisabled(
true
);
147
ui
->
red_up
->setValue(
ui
->
red_low
->value());
148
ui
->
red_up
->setDisabled(
true
);
149
red_checked
=
true
;
150
}
151
else
{
152
ui
->
red_up_2
->setEnabled(
true
);
153
ui
->
red_up
->setEnabled(
true
);
154
red_checked
=
false
;
155
}
156
update_color_mask_parameter
();
157
}
158
159
void
colormask::enable_checkbox_green
(){
160
if
(
ui
->
green_checkbox
->isChecked()){
161
ui
->
green_up_2
->setValue(
ui
->
green_low
->value());
162
ui
->
green_up_2
->setDisabled(
true
);
163
ui
->
green_up
->setValue(
ui
->
green_low
->value());
164
ui
->
green_up
->setDisabled(
true
);
165
green_checked
=
true
;
166
}
167
else
{
168
ui
->
green_up_2
->setEnabled(
true
);
169
ui
->
green_up
->setEnabled(
true
);
170
green_checked
=
false
;
171
}
172
update_color_mask_parameter
();
173
}
174
175
void
colormask::enable_checkbox_blue
(){
176
if
(
ui
->
blue_checkbox
->isChecked()){
177
ui
->
blue_up_2
->setValue(
ui
->
blue_low
->value());
178
ui
->
blue_up_2
->setDisabled(
true
);
179
ui
->
blue_up
->setValue(
ui
->
blue_low
->value());
180
ui
->
blue_up
->setDisabled(
true
);
181
blue_checked
=
true
;
182
}
183
else
{
184
ui
->
blue_up_2
->setEnabled(
true
);
185
ui
->
blue_up
->setEnabled(
true
);
186
blue_checked
=
false
;
187
}
188
update_color_mask_parameter
();
189
}
190
191
void
colormask::close_color_mask_window
(){
192
this->close();
193
}
Generated on Wed Oct 9 2013 19:53:58 for tychoBCGEN by
1.8.1.1