10 #include <QPushButton> 11 #include <QSizePolicy> 12 #include <QStackedWidget> 14 #include <QToolButton> 17 #include "AdvancedStretchDialog.h" 23 #include "MainWindow.h" 25 #include "RubberBandTool.h" 30 #include "ViewportMainWindow.h" 55 QPushButton *hiddenButton =
new QPushButton();
56 hiddenButton->setVisible(
false);
57 hiddenButton->setDefault(
true);
72 if (parentMainWindow) {
73 connect(
this, SIGNAL(
warningSignal(std::string &,
const std::string)),
74 parentMainWindow, SLOT(displayWarning(std::string &,
const std::string &)));
101 action->setIcon(QPixmap(
toolIconDir() +
"/stretch_global.png"));
102 action->setToolTip(
"Stretch (S)");
103 action->setShortcut(Qt::Key_S);
105 "<b>Function:</b> Change the stretch range of the cube.\ 106 <p><b>Shortcut:</b> S</p> ";
107 action->setWhatsThis(text);
136 QToolButton *butt =
new QToolButton(hbox);
137 butt->setAutoRaise(
true);
138 butt->setIconSize(QSize(22, 22));
139 butt->setIcon(QPixmap(
toolIconDir() +
"/regional_stretch-2.png"));
140 butt->setToolTip(
"Stretch");
142 "<b>Function:</b> Automatically compute min/max stretch using viewed \ 143 pixels in the band(s) of the active viewport. That is, only pixels \ 144 that are visible in the viewport are used. \ 145 If the viewport is in RGB color all three bands will be stretched. \ 146 <p><b>Shortcut:</b> Ctrl+R</p> \ 147 <p><b>Mouse:</b> Left click \ 148 <p><b>Hint:</b> Left click and drag for a local stretch. Uses only \ 149 pixels in the red marquee</p>";
150 butt->setWhatsThis(text);
162 "<b>Function:</b> Selecting the color will allow the appropriate \ 163 min/max to be seen and/or edited in text fields to the right.";
174 QDoubleValidator *dval =
new QDoubleValidator(hbox);
179 "<b>Function:</b> Shows the current minimum pixel value. Pixel values \ 180 below minimum are shown as black. Pixel values above the maximum \ 181 are shown as white or the highest intensity of red/green/blue \ 182 if in color. Pixel values between the minimum and maximum are stretched \ 183 linearly between black and white (or color component). \ 184 <p><b>Hint:</b> You can manually edit the minimum but it must be \ 185 less than the maximum.";
195 "<b>Function:</b> Shows the current maximum pixel value. Pixel values \ 196 below minimum are shown as black. Pixel values above the maximum \ 197 are shown as white or the highest intensity of red/green/blue \ 198 if in color. Pixel values between the minimum and maximum are stretched \ 199 linearly between black and white (or color component). \ 200 <p><b>Hint:</b> You can manually edit the maximum but it must be \ 201 greater than the minimum";
215 copyAll->setIcon(QPixmap(
toolIconDir() +
"/copy_stretch.png"));
216 copyAll->setText(
"to All Viewports");
219 copyMenu->addAction(copyAll);
226 m_copyButton->setPopupMode(QToolButton::MenuButtonPopup);
231 "<b>Function:</b> Copy the current stretch to all the \ 232 active viewports. Or use the drop down menu to copy the current stretch \ 233 to all the bands in the active viewport. \ 234 <p><b>Hint:</b> Can reset the stretch to an automaticaly computed \ 235 stretch by using the 'Reset' stretch button option. </p>";
239 currentView->setText(
"Active Viewport");
240 currentView->setIcon(QPixmap(
toolIconDir() +
"/global_stretch.png"));
241 globalMenu->addAction(currentView);
242 connect(currentView, SIGNAL(triggered(
bool)),
this, SLOT(
stretchGlobal()));
245 globalAll->setText(
"All Viewports");
246 globalMenu->addAction(globalAll);
250 globalBands->setText(
"All Bands");
251 globalMenu->addAction(globalBands);
262 "<b>Function:</b> Reset the stretch to be automatically computed " 263 "using the statisics from the entire image. Use the drop down menu " 264 "to reset the stretch for all the bands in the active viewport or " 265 "to reset the stretch for all the viewports.";
268 QPushButton *advancedButton =
new QPushButton(
"Advanced");
273 "<b>Function:</b> While this button is pressed down, the visible stretch " 274 "will be the automatically computed stretch using the statisics from the " 275 "entire image. The original stretch is restored once you let up on this " 281 QHBoxLayout *layout =
new QHBoxLayout(hbox);
282 layout->setMargin(0);
289 layout->addWidget(advancedButton);
291 layout->addStretch();
292 hbox->setLayout(layout);
368 bluStretch, bluHist);
408 bluStretch, bluHist);
440 if(cvp && cvp->
isGray()) {
481 QRect rect(0, 0, cvp->viewport()->width(), cvp->viewport()->height());
483 if(bandId == (
int)
Gray) {
496 if(bandId == (
int)
Red || bandId == (
int)
All) {
507 if(bandId == (
int)
Green || bandId == (
int)
All) {
518 if(bandId == (
int)
Blue || bandId == (
int)
All) {
541 if(cvp == NULL)
return;
569 double min = 0, max = 0;
574 min = stretch.
Input(0);
586 min = rstretch.
Input(0);
590 min = gstretch.
Input(0);
594 min = bstretch.
Input(0);
625 if(cvp == NULL)
return;
665 if(cvp == NULL)
return;
699 redStretch.
AddPair(max, 255.0);
703 greenStretch.
AddPair(min, 0.0);
704 greenStretch.
AddPair(max, 255.0);
709 blueStretch.
AddPair(max, 255.0);
743 if(cvp == NULL)
return;
754 if(cvp == NULL)
return;
790 if(cvp == NULL)
return;
801 QRect rect(0, 0, cvp->viewport()->width(), cvp->viewport()->height());
806 QString message =
"Cannot stretch while the cube is still loading";
807 QMessageBox::warning((
QWidget *)parent(),
"Warning", message);
821 if(cvp == NULL)
return;
822 if(!rubberBandTool()->isValid())
return;
824 QRect rubberBandRect = rubberBandTool()->
rectangle();
826 if(rubberBandRect.width() == 0 || rubberBandRect.height() == 0)
return;
872 "Unknown stretch band",
890 if(cvp == NULL)
return;
896 if(s == Qt::RightButton) {
913 rubberBandTool()->
enable(RubberBandTool::RectangleMode);
925 if(cvp == NULL)
return;
977 if(thisViewport == NULL)
return;
1033 if(stretch.
Pairs() == 0) {
1034 stretch.
AddPair(-DBL_MAX, 0.0);
1035 stretch.
AddPair(DBL_MAX, 255.0);
1056 else if(band ==
Green) {
1060 else if(band ==
Blue) {
1070 if(fabs(hist.Percent(0.5) - hist.Percent(99.5)) > DBL_EPSILON) {
1071 stretch.
AddPair(hist.Percent(0.5), 0.0);
1072 stretch.
AddPair(hist.Percent(99.5), 255.0);
1075 stretch.
AddPair(-DBL_MAX, 0.0);
1076 stretch.
AddPair(DBL_MAX, 255.0);
1095 for(
int line = 0; line < cube->
lineCount(); line++) {
1118 "Cannot stretch while the cube is still loading",
1122 QRect dataArea = QRect(buffer->
bufferXYRect().intersected(rect));
1125 for(
int y = dataArea.top();
1126 !dataArea.isNull() && y <= dataArea.bottom();
1130 for(
int x = dataArea.left(); x < dataArea.right(); x++) {
1131 stats.AddData(line[x - buffer->
bufferXYRect().left()]);
1150 double min,
double max) {
1154 for(
int line = 0; line < cube->
lineCount(); line++) {
1191 QRect rect,
double min,
double max) {
1192 QRect dataArea = QRect(buffer->
bufferXYRect().intersected(rect));
1197 for(
int y = dataArea.top(); !dataArea.isNull() && y <= dataArea.bottom(); y++) {
1199 hist.
AddData(&line.front() + (dataArea.left() - buffer->
bufferXYRect().left()), dataArea.width());
1208 std::string msg =
"Insufficient data Min [" + sMin +
"], Max [" + sMax +
"]";
1209 msg +=
" in the stretch area.";
void setAllBandStretches(Stretch stretch)
Sets a stretch for all bands.
Cube display widget for certain Isis MDI applications.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the histogram counters.
Stretch redStretch() const
Return the red band stretch.
ViewportBuffer * grayBuffer()
Returns the gray viewport buffer (Will be NULL if in RGB mode.)
Reads and stores visible DN values.
ViewportBuffer * redBuffer()
Returns the red viewport buffer (Will be NULL if in Gray mode.)
void stretchBlue(const QString &string)
Apply stretch pairs to blue bands.
Stretch greenStretch() const
Return the green band stretch.
double Input(const int index) const
Returns the value of the input side of the stretch pair at the specified index.
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
void forgetStretches()
Resets all remembered stretches.
void stretchRed(const QString &string)
Apply stretch pairs to red bands.
Stretch getGrayStretch()
This returns the advanced stretch's stretch for gray.
double BestMaximum(const double percent=99.5) const
This method returns the better of the absolute maximum or the Chebyshev maximum.
const std::vector< double > & getLine(int line)
Retrieves a line from the buffer.
Buffer for containing a three dimensional section of an image.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Namespace for the standard library.
void SetBasePosition(const int start_sample, const int start_line, const int start_band)
This method is used to set the base position of the shape buffer.
Stretch getRedStretch()
This returns the advanced stretch's stretch for red.
Widget to display Isis cubes for qt apps.
BigInt ValidPixels() const
Returns the total number of valid pixels processed.
This error is for when a programmer made an API call that was illegal.
QRect bufferXYRect()
Returns a rect, in screen pixels, of the area this buffer covers.
int Pairs() const
Returns the number of stretch pairs.
Stretch grayStretch() const
Return the gray band stretch.
This was called the Qisis MainWindow.
bool isRgbMode() const
Returns true if the dialog is displaying the RGB advanced stretches.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
This class is used to accumulate statistics on double arrays.
void AddPair(const double input, const double output)
Adds a stretch pair to the list of pairs.
double BestMinimum(const double percent=99.5) const
This method returns the better of the absolute minimum or the Chebyshev minimum.
void stretchKnownGlobal()
List<Tool *> p This stretches to the global stretch.
void CopyPairs(const Stretch &other)
Copies the stretch pairs from another Stretch object, but maintains special pixel values...
bool enabled()
Returns true if the advanced stretch is enabled.
Container of a cube histogram.
#define _FILEINFO_
Macro for the filename and line number.
void enableRgbMode(Stretch &redStretch, Histogram &redHist, Stretch &grnStretch, Histogram &grnHist, Stretch &bluStretch, Histogram &bluHist)
This displays RGB advanced stretches.
A type of error that could only have occurred due to a mistake on the user's part (e...
void enableGrayMode(Stretch &grayStretch, Histogram &grayHist)
This displays a gray advanced stretch.
A type of error that cannot be classified as any of the other error types.
double Percent(const double percent) const
Computes and returns the value at X percent of the histogram.
Stretch getBluStretch()
This returns the advanced stretch's stretch for blue.
void read(Blob &blob) const
This method will read data from the specified Blob object.
bool working()
This tests if queued actions exist in the viewport buffer.
PixelType pixelType() const
ViewportBuffer * blueBuffer()
Returns the blue viewport buffer (Will be NULL if in Gray mode.)
void ClearPairs()
Clears the stretch pairs.
Stretch getGrnStretch()
This returns the advanced stretch's stretch for green.
void stretchGreen(const QString &string)
Apply stretch pairs to green bands.
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.
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 hasEntireCube()
Method to see if the entire cube is in the buffer.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
void stretchGray(const QString &string)
Apply stretch pairs to gray band.
ViewportBuffer * greenBuffer()
Returns the green viewport buffer (Will be NULL if in Gray mode.)
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.
IO Handler for Isis Cubes.
void enable(bool enable)
Sets the enabled state to enable.