Isis 3.0 Object Programmers' Reference
Home
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
AdvancedStretchDialog.cpp
1
#include "AdvancedStretchDialog.h"
2
3
#include <QHBoxLayout>
4
5
#include "
CubeViewport.h
"
6
#include "
Stretch.h
"
7
#include "AdvancedStretch.h"
8
9
namespace
Isis {
15
AdvancedStretchDialog::AdvancedStretchDialog
(
QWidget
*parent) :
16
QDialog
(parent) {
17
p_grayStretch
= NULL;
18
p_redStretch
= NULL;
19
p_grnStretch
= NULL;
20
p_bluStretch
= NULL;
21
p_enabled
=
false
;
22
23
QHBoxLayout *layout =
new
QHBoxLayout();
24
setLayout(layout);
25
}
26
27
31
AdvancedStretchDialog::~AdvancedStretchDialog
() {
32
destroyCurrentStretches
();
33
}
34
35
46
void
AdvancedStretchDialog::enableRgbMode
(
Stretch
&redStretch,
47
Histogram
&redHist,
48
Stretch
&grnStretch,
Histogram
&grnHist,
49
Stretch
&bluStretch,
Histogram
&bluHist) {
50
destroyCurrentStretches
();
51
52
p_redStretch
=
new
AdvancedStretch
(redHist, redStretch,
53
"Red"
, QColor(Qt::red));
54
layout()->addWidget(
p_redStretch
);
55
56
p_grnStretch
=
new
AdvancedStretch
(grnHist, grnStretch,
57
"Green"
, QColor(Qt::green));
58
layout()->addWidget(
p_grnStretch
);
59
60
p_bluStretch
=
new
AdvancedStretch
(bluHist, bluStretch,
61
"Blue"
, QColor(Qt::blue));
62
layout()->addWidget(
p_bluStretch
);
63
updateGeometry();
64
65
connect(
p_redStretch
, SIGNAL(
stretchChanged
()),
66
this
, SIGNAL(
stretchChanged
()));
67
connect(
p_grnStretch
, SIGNAL(
stretchChanged
()),
68
this
, SIGNAL(
stretchChanged
()));
69
connect(
p_bluStretch
, SIGNAL(
stretchChanged
()),
70
this
, SIGNAL(
stretchChanged
()));
71
}
72
86
void
AdvancedStretchDialog::updateForRGBMode
(
Stretch
&redStretch,
87
Histogram
&redHist,
88
Stretch
&grnStretch,
Histogram
&grnHist,
89
Stretch
&bluStretch,
Histogram
&bluHist)
90
{
91
if
(
p_redStretch
) {
92
p_redStretch
->
setStretch
(redStretch);
93
p_redStretch
->
setHistogram
(redHist);
94
}
95
96
if
(
p_grnStretch
) {
97
p_grnStretch
->
setStretch
(grnStretch);
98
p_grnStretch
->
setHistogram
(grnHist);
99
}
100
101
if
(
p_bluStretch
) {
102
p_bluStretch
->
setStretch
(bluStretch);
103
p_bluStretch
->
setHistogram
(bluHist);
104
}
105
}
106
107
108
115
void
AdvancedStretchDialog::enableGrayMode
(
Stretch
&grayStretch,
116
Histogram
&grayHist) {
117
destroyCurrentStretches
();
118
119
p_grayStretch
=
new
AdvancedStretch
(grayHist, grayStretch,
120
"Gray"
, QColor(Qt::gray));
121
layout()->addWidget(
p_grayStretch
);
122
updateGeometry();
123
124
connect(
p_grayStretch
, SIGNAL(
stretchChanged
()),
125
this
, SIGNAL(
stretchChanged
()));
126
}
127
128
133
void
AdvancedStretchDialog::destroyCurrentStretches
() {
134
if
(
p_redStretch
) {
135
layout()->removeWidget(
p_redStretch
);
136
disconnect(
p_redStretch
, SIGNAL(
stretchChanged
()),
137
this
, SIGNAL(
stretchChanged
()));
138
delete
p_redStretch
;
139
p_redStretch
= NULL;
140
}
141
142
if
(
p_grnStretch
) {
143
layout()->removeWidget(
p_grnStretch
);
144
disconnect(
p_grnStretch
, SIGNAL(
stretchChanged
()),
145
this
, SIGNAL(
stretchChanged
()));
146
delete
p_grnStretch
;
147
p_grnStretch
= NULL;
148
}
149
150
if
(
p_bluStretch
) {
151
layout()->removeWidget(
p_bluStretch
);
152
disconnect(
p_bluStretch
, SIGNAL(
stretchChanged
()),
153
this
, SIGNAL(
stretchChanged
()));
154
delete
p_bluStretch
;
155
p_bluStretch
= NULL;
156
}
157
158
if
(
p_grayStretch
) {
159
layout()->removeWidget(
p_grayStretch
);
160
disconnect(
p_grayStretch
, SIGNAL(
stretchChanged
()),
161
this
, SIGNAL(
stretchChanged
()));
162
delete
p_grayStretch
;
163
p_grayStretch
= NULL;
164
}
165
}
166
167
174
void
AdvancedStretchDialog::updateStretch
(
CubeViewport
*cvp) {
175
if
(
p_grayStretch
){
176
p_grayStretch
->
setStretch
(cvp->
grayStretch
());
177
}
178
if
(
p_redStretch
) {
179
p_redStretch
->
setStretch
(cvp->
redStretch
());
180
}
181
if
(
p_grnStretch
){
182
p_grnStretch
->
setStretch
(cvp->
greenStretch
());
183
}
184
if
(
p_bluStretch
){
185
p_bluStretch
->
setStretch
(cvp->
blueStretch
());
186
}
187
}
188
189
198
void
AdvancedStretchDialog::updateHistograms
(
const
Histogram
&redHist,
199
const
Histogram
&grnHist,
200
const
Histogram
&bluHist) {
201
202
if
(
p_redStretch
){
203
p_redStretch
->
setHistogram
(redHist);
204
}
205
if
(
p_grnStretch
){
206
p_grnStretch
->
setHistogram
(grnHist);
207
}
208
if
(
p_bluStretch
){
209
p_bluStretch
->
setHistogram
(bluHist);
210
}
211
}
212
213
220
void
AdvancedStretchDialog::updateHistogram
(
const
Histogram
&grayHist) {
221
if
(
p_grayStretch
)
222
p_grayStretch
->
setHistogram
(grayHist);
223
}
224
225
231
void
AdvancedStretchDialog::showEvent
(QShowEvent *event) {
232
QDialog::showEvent
(event);
233
emit
visibilityChanged
();
234
}
235
236
242
void
AdvancedStretchDialog::hideEvent
(QHideEvent *event) {
243
QDialog::hideEvent
(event);
244
emit
visibilityChanged
();
245
}
246
247
254
bool
AdvancedStretchDialog::isRgbMode
()
const
{
255
return
(
p_redStretch
&&
p_grnStretch
&&
p_bluStretch
);
256
}
257
258
264
Stretch
AdvancedStretchDialog::getGrayStretch
() {
265
if
(
p_grayStretch
) {
266
return
p_grayStretch
->
getStretch
();
267
}
268
else
{
269
IString
msg =
"Gray mode not enabled, cannot get gray stretch"
;
270
throw
IException
(
IException::Programmer
, msg,
_FILEINFO_
);
271
}
272
}
273
274
280
Stretch
AdvancedStretchDialog::getRedStretch
() {
281
if
(
p_redStretch
) {
282
return
p_redStretch
->
getStretch
();
283
}
284
else
{
285
IString
msg =
"RGB mode not enabled, cannot get red stretch"
;
286
throw
IException
(
IException::Programmer
, msg,
_FILEINFO_
);
287
}
288
}
289
290
296
Stretch
AdvancedStretchDialog::getGrnStretch
() {
297
if
(
p_grnStretch
) {
298
return
p_grnStretch
->
getStretch
();
299
}
300
else
{
301
IString
msg =
"RGB mode not enabled, cannot get green stretch"
;
302
throw
IException
(
IException::Programmer
, msg,
_FILEINFO_
);
303
}
304
}
305
306
312
Stretch
AdvancedStretchDialog::getBluStretch
() {
313
if
(
p_bluStretch
) {
314
return
p_bluStretch
->
getStretch
();
315
}
316
else
{
317
IString
msg =
"RGB mode not enabled, cannot get blue stretch"
;
318
throw
IException
(
IException::Programmer
, msg,
_FILEINFO_
);
319
}
320
}
321
}