Isis 3 Programmer Reference
AdvancedStretchDialog.cpp
1 #include "AdvancedStretchDialog.h"
2 
3 #include <QHBoxLayout>
4 #include <QString>
5 
6 #include "CubeViewport.h"
7 #include "Stretch.h"
8 #include "AdvancedStretch.h"
9 
10 namespace Isis {
17  QDialog(parent) {
18  p_grayStretch = NULL;
19  p_redStretch = NULL;
20  p_grnStretch = NULL;
21  p_bluStretch = NULL;
22  p_enabled = false;
23 
24  QHBoxLayout *layout = new QHBoxLayout();
25  setLayout(layout);
26  }
27 
28 
34  }
35 
36 
48  Histogram &redHist,
49  Stretch &grnStretch, Histogram &grnHist,
50  Stretch &bluStretch, Histogram &bluHist) {
52 
53  p_redStretch = new AdvancedStretch(redHist, redStretch,
54  "Red", QColor(Qt::red));
55  layout()->addWidget(p_redStretch);
56 
57  p_grnStretch = new AdvancedStretch(grnHist, grnStretch,
58  "Green", QColor(Qt::green));
59  layout()->addWidget(p_grnStretch);
60 
61  p_bluStretch = new AdvancedStretch(bluHist, bluStretch,
62  "Blue", QColor(Qt::blue));
63  layout()->addWidget(p_bluStretch);
64  updateGeometry();
65 
66  connect(p_redStretch, SIGNAL(stretchChanged()),
67  this, SIGNAL(stretchChanged()));
68  connect(p_grnStretch, SIGNAL(stretchChanged()),
69  this, SIGNAL(stretchChanged()));
70  connect(p_bluStretch, SIGNAL(stretchChanged()),
71  this, SIGNAL(stretchChanged()));
72  }
73 
88  Histogram &redHist,
89  Stretch &grnStretch, Histogram &grnHist,
90  Stretch &bluStretch, Histogram &bluHist)
91  {
92  if(p_redStretch) {
93  p_redStretch->setStretch(redStretch);
94  p_redStretch->setHistogram(redHist);
95  }
96 
97  if(p_grnStretch) {
98  p_grnStretch->setStretch(grnStretch);
99  p_grnStretch->setHistogram(grnHist);
100  }
101 
102  if(p_bluStretch) {
103  p_bluStretch->setStretch(bluStretch);
104  p_bluStretch->setHistogram(bluHist);
105  }
106  }
107 
108 
109 
117  Histogram &grayHist) {
119 
120  p_grayStretch = new AdvancedStretch(grayHist, grayStretch,
121  "Gray", QColor(Qt::gray));
122  layout()->addWidget(p_grayStretch);
123  updateGeometry();
124 
125  connect(p_grayStretch, SIGNAL(stretchChanged()),
126  this, SIGNAL(stretchChanged()));
127  }
128 
129 
135  if(p_redStretch) {
136  layout()->removeWidget(p_redStretch);
137  disconnect(p_redStretch, SIGNAL(stretchChanged()),
138  this, SIGNAL(stretchChanged()));
139  delete p_redStretch;
140  p_redStretch = NULL;
141  }
142 
143  if(p_grnStretch) {
144  layout()->removeWidget(p_grnStretch);
145  disconnect(p_grnStretch, SIGNAL(stretchChanged()),
146  this, SIGNAL(stretchChanged()));
147  delete p_grnStretch;
148  p_grnStretch = NULL;
149  }
150 
151  if(p_bluStretch) {
152  layout()->removeWidget(p_bluStretch);
153  disconnect(p_bluStretch, SIGNAL(stretchChanged()),
154  this, SIGNAL(stretchChanged()));
155  delete p_bluStretch;
156  p_bluStretch = NULL;
157  }
158 
159  if(p_grayStretch) {
160  layout()->removeWidget(p_grayStretch);
161  disconnect(p_grayStretch, SIGNAL(stretchChanged()),
162  this, SIGNAL(stretchChanged()));
163  delete p_grayStretch;
164  p_grayStretch = NULL;
165  }
166  }
167 
168 
176  if(p_grayStretch){
178  }
179  if(p_redStretch) {
181  }
182  if(p_grnStretch){
184  }
185  if(p_bluStretch){
187  }
188  }
189 
190 
200  const Histogram &grnHist,
201  const Histogram &bluHist) {
202 
203  if(p_redStretch){
204  p_redStretch->setHistogram(redHist);
205  }
206  if(p_grnStretch){
207  p_grnStretch->setHistogram(grnHist);
208  }
209  if(p_bluStretch){
210  p_bluStretch->setHistogram(bluHist);
211  }
212  }
213 
214 
222  if(p_grayStretch)
223  p_grayStretch->setHistogram(grayHist);
224  }
225 
226 
232  void AdvancedStretchDialog::showEvent(QShowEvent *event) {
233  QDialog::showEvent(event);
234  emit visibilityChanged();
235  }
236 
237 
243  void AdvancedStretchDialog::hideEvent(QHideEvent *event) {
244  QDialog::hideEvent(event);
245  emit visibilityChanged();
246  }
247 
248 
256  return (p_redStretch && p_grnStretch && p_bluStretch);
257  }
258 
259 
266  if(p_grayStretch) {
267  return p_grayStretch->getStretch();
268  }
269  else {
270  QString msg = "Gray mode not enabled, cannot get gray stretch";
272  }
273  }
274 
275 
282  if(p_redStretch) {
283  return p_redStretch->getStretch();
284  }
285  else {
286  QString msg = "RGB mode not enabled, cannot get red stretch";
288  }
289  }
290 
291 
298  if(p_grnStretch) {
299  return p_grnStretch->getStretch();
300  }
301  else {
302  QString msg = "RGB mode not enabled, cannot get green stretch";
304  }
305  }
306 
307 
314  if(p_bluStretch) {
315  return p_bluStretch->getStretch();
316  }
317  else {
318  QString msg = "RGB mode not enabled, cannot get blue stretch";
320  }
321  }
322 }
Stretch redStretch() const
Return the red band stretch.
Stretch greenStretch() const
Return the green band stretch.
Stretch getGrayStretch()
This returns the advanced stretch&#39;s stretch for gray.
Stretch getRedStretch()
This returns the advanced stretch&#39;s stretch for red.
Widget to display Isis cubes for qt apps.
Definition: CubeViewport.h:132
AdvancedStretchDialog(QWidget *parent)
This constructs an advanced stretch.
void setHistogram(const Histogram &newHist)
This is called when the visible area changes, so that the histogram can be updated.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
void destroyCurrentStretches()
This cleans up memory from currently displayed advanced stretches.
AdvancedStretch * p_redStretch
Red stretch pane.
Stretch grayStretch() const
Return the gray band stretch.
bool isRgbMode() const
Returns true if the dialog is displaying the RGB advanced stretches.
void showEvent(QShowEvent *)
This is implemented to send a signal when visibility changes.
~AdvancedStretchDialog()
This destroys the advanced stretch dialog.
AdvancedStretch * p_bluStretch
Blue stretch pane.
Container of a cube histogram.
Definition: Histogram.h:86
Pixel value mapper.
Definition: Stretch.h:72
Advanced Stretch Dialog.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
void enableRgbMode(Stretch &redStretch, Histogram &redHist, Stretch &grnStretch, Histogram &grnHist, Stretch &bluStretch, Histogram &bluHist)
This displays RGB advanced stretches.
AdvancedStretch * p_grayStretch
Gray stretch pane.
void enableGrayMode(Stretch &grayStretch, Histogram &grayHist)
This displays a gray advanced stretch.
Stretch getBluStretch()
This returns the advanced stretch&#39;s stretch for blue.
AdvancedStretch * p_grnStretch
Green stretch pane.
void setStretch(Stretch newStretch)
This is called when the user creates a stretch outside of the advanced stretch.
void hideEvent(QHideEvent *)
This is implemented to send a signal when visibility changes.
Stretch getGrnStretch()
This returns the advanced stretch&#39;s stretch for green.
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void updateHistogram(const Histogram &grayHist)
This calls setHistogram on the gray advanced stretche.
void updateHistograms(const Histogram &redHist, const Histogram &grnHist, const Histogram &bluHist)
This calls setHistogram on all of the advanced stretches.
bool p_enabled
True if advanced stretch should be used.
void visibilityChanged()
Emitted when this dialog is shown or hidden.
Stretch getStretch()
This returns the current stretch type&#39;s stretch.
void updateForRGBMode(Stretch &redStretch, Histogram &redHist, Stretch &grnStretch, Histogram &grnHist, Stretch &bluStretch, Histogram &bluHist)
Update the stretch and histogram for all the bands for All BandId option.
Stretch blueStretch() const
Return the blue band stretch.
void updateStretch(CubeViewport *)
This calls setStretch on all applicable advanced stretches.
void stretchChanged()
Emitted when an advanced stretch has changed.