1#include "ManualStretchType.h"
10#include "CubeViewport.h"
11#include "HistogramWidget.h"
12#include "Statistics.h"
14#include "CubeStretch.h"
27 const QString &name,
const QColor &color)
29 p_errorMessage = NULL;
32 QHBoxLayout *buttonLayout =
new QHBoxLayout();
33 p_errorMessage =
new QLabel;
35 QPushButton *addButton =
new QPushButton(
"Add Row");
36 connect(addButton, SIGNAL(clicked(
bool)),
38 buttonLayout->addWidget(addButton);
40 QPushButton *deleteButton =
new QPushButton(
"Delete Row");
41 connect(deleteButton, SIGNAL(clicked(
bool)),
43 buttonLayout->addWidget(deleteButton);
45 buttonContainer->setLayout(buttonLayout);
50 p_table->setSelectionMode(QAbstractItemView::SingleSelection);
51 p_table->setSelectionBehavior(QAbstractItemView::SelectRows);
52 p_table->setEditTriggers(QAbstractItemView::DoubleClicked |
53 QAbstractItemView::SelectedClicked |
54 QAbstractItemView::AnyKeyPressed);
55 connect(
p_table, SIGNAL(cellChanged(
int,
int)),
56 this, SLOT(readTable()));
57 disconnect(
this, SIGNAL(stretchChanged()),
this, SLOT(
updateTable()));
89 emit stretchChanged();
109 QList<QTableWidgetSelectionRange> selectedRanges =
112 if (selectedRanges.empty()) {
113 IString msg =
"You must select a row to delete";
117 int row = selectedRanges.first().topRow();
121 void ManualStretchType::readTable() {
123 emit stretchChanged();
127 Stretch ManualStretchType::convertTableToStretch() {
129 stretch.ClearPairs();
131 p_errorMessage->setText(
"");
133 if (
p_table->columnCount() == 2) {
134 for (
int i = 0; i <
p_table->rowCount(); i++) {
137 !
p_table->item(i, 0)->data(Qt::DisplayRole).isNull() &&
138 !
p_table->item(i, 1)->data(Qt::DisplayRole).isNull()) {
140 p_table->item(i, 0)->data(Qt::DisplayRole).toString().toDouble(),
141 p_table->item(i, 1)->data(Qt::DisplayRole).toString().toDouble());
146 catch (IException &e) {
147 p_errorMessage->setText(
148 "<font color='red'>" + e.toString() +
"</font>");
Stores stretch information for a cube.
Container of a cube histogram.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Adds specific functionality to C++ strings.
~ManualStretchType()
Destructor.
void addButtonPressed(bool)
This is called when a user clicks "Add / Edit" and is responsible for adding the pair into the correc...
virtual void setStretch(Stretch)
Given an arbitrary stretch, this will re-interpret it, as best as possible, into a manual stretch.
void deleteButtonPressed(bool)
This is called when a user clicks "Delete" and is responsible for removing the pair with the given in...
virtual CubeStretch getStretch()
Gets the current CubeStretch for this ManualStretch.
ManualStretchType(const Histogram &, const Stretch &, const QString &name, const QColor &color)
This constructs a manual stretch type.
void CopyPairs(const Stretch &other)
Copies the stretch pairs from another Stretch object, but maintains special pixel values.
QString Text() const
Converts stretch pair to a string.
This is the base class for advanced stretches.
QTableWidget * p_table
Pairs table.
Stretch * p_stretch
Current stretch pairs stored here.
QGridLayout * p_mainLayout
Main layout.
void updateTable()
This updates the table with the current stretch pairs.
This is free and unencumbered software released into the public domain.