USGS

Isis 3.0 Object Programmers' Reference

Home

AdvancedStretch.cpp
1 #include "AdvancedStretch.h"
2 
3 #include <QStackedWidget>
4 #include <QVBoxLayout>
5 #include <QHBoxLayout>
6 #include <QLabel>
7 #include <QComboBox>
8 
9 #include "Stretch.h"
10 #include "IString.h"
11 #include "IException.h"
12 #include "StretchType.h"
13 #include "LinearStretchType.h"
14 #include "SawtoothStretchType.h"
15 #include "BinaryStretchType.h"
16 #include "ManualStretchType.h"
17 
18 namespace Isis {
28  const Stretch &curStretch,
29  const QString &name, const QColor &color) {
30  setLayout(new QVBoxLayout());
31 
32  setSizePolicy(QSizePolicy::MinimumExpanding,
33  QSizePolicy::MinimumExpanding);
34  QWidget *typeSelectionArea = new QWidget();
35  typeSelectionArea->setLayout(new QHBoxLayout());
36  typeSelectionArea->layout()->addWidget(new QLabel("Stretch Type"));
37 
38  QComboBox *stretchTypeSelection = new QComboBox();
39  stretchTypeSelection->addItem("Linear", 0);
40  stretchTypeSelection->addItem("Sawtooth", 1);
41  stretchTypeSelection->addItem("Binary", 2);
42  stretchTypeSelection->addItem("Manual", 3);
43 
44  typeSelectionArea->layout()->addWidget(stretchTypeSelection);
45  layout()->addWidget(typeSelectionArea);
46 
47  p_stretchTypeStack = new QStackedWidget();
48  LinearStretchType *linear = new LinearStretchType(hist, curStretch,
49  name, color);
50  connect(linear, SIGNAL(stretchChanged()), this, SIGNAL(stretchChanged()));
51  p_stretchTypeStack->addWidget(linear);
52 
53  SawtoothStretchType *sawtooth = new SawtoothStretchType(hist, curStretch,
54  name, color);
55  connect(sawtooth, SIGNAL(stretchChanged()), this, SIGNAL(stretchChanged()));
56  p_stretchTypeStack->addWidget(sawtooth);
57 
58  BinaryStretchType *binary = new BinaryStretchType(hist, curStretch,
59  name, color);
60  connect(binary, SIGNAL(stretchChanged()), this, SIGNAL(stretchChanged()));
61  p_stretchTypeStack->addWidget(binary);
62 
63  ManualStretchType *manual = new ManualStretchType(hist, curStretch,
64  name, color);
65  connect(manual, SIGNAL(stretchChanged()), this, SIGNAL(stretchChanged()));
66  p_stretchTypeStack->addWidget(manual);
67 
68  layout()->addWidget(p_stretchTypeStack);
69  connect(stretchTypeSelection, SIGNAL(currentIndexChanged(int)),
70  p_stretchTypeStack, SLOT(setCurrentIndex(int)));
71  connect(stretchTypeSelection, SIGNAL(currentIndexChanged(int)),
72  this, SIGNAL(stretchChanged()));
73  }
74 
75 
80  }
81 
82 
89  return ((StretchType *)p_stretchTypeStack->currentWidget())->getStretch();
90  }
91 
92 
102  StretchType *stretchType = (StretchType *)
103  p_stretchTypeStack->currentWidget();
104  stretchType->setStretch(newStretch);
105  }
106 
107 
117  for(int stretch = 0; stretch < p_stretchTypeStack->count(); stretch ++) {
118  StretchType *stretchType = (StretchType *)
119  p_stretchTypeStack->widget(stretch);
120  stretchType->setHistogram(newHist);
121  }
122  }
123 };