1 #include "ManualStretchType.h" 7 #include <QTableWidget> 11 #include "HistogramWidget.h" 26 const QString &name,
const QColor &color)
28 p_errorMessage = NULL;
31 QHBoxLayout *buttonLayout =
new QHBoxLayout();
32 p_errorMessage =
new QLabel;
34 QPushButton *addButton =
new QPushButton(
"Add Row");
35 connect(addButton, SIGNAL(clicked(
bool)),
37 buttonLayout->addWidget(addButton);
39 QPushButton *deleteButton =
new QPushButton(
"Delete Row");
40 connect(deleteButton, SIGNAL(clicked(
bool)),
42 buttonLayout->addWidget(deleteButton);
44 buttonContainer->setLayout(buttonLayout);
49 p_table->setSelectionMode(QAbstractItemView::SingleSelection);
50 p_table->setSelectionBehavior(QAbstractItemView::SelectRows);
51 p_table->setEditTriggers(QAbstractItemView::DoubleClicked |
52 QAbstractItemView::SelectedClicked |
53 QAbstractItemView::AnyKeyPressed);
54 connect(
p_table, SIGNAL(cellChanged(
int,
int)),
55 this, SLOT(readTable()));
111 if (selectedRanges.empty()) {
112 IString msg =
"You must select a row to delete";
116 int row = selectedRanges.first().topRow();
120 void ManualStretchType::readTable() {
126 Stretch ManualStretchType::convertTableToStretch() {
128 stretch.ClearPairs();
130 p_errorMessage->setText(
"");
132 if (
p_table->columnCount() == 2) {
133 for (
int i = 0; i <
p_table->rowCount(); i++) {
136 !
p_table->item(i, 0)->data(Qt::DisplayRole).isNull() &&
137 !
p_table->item(i, 1)->data(Qt::DisplayRole).isNull()) {
139 p_table->item(i, 0)->data(Qt::DisplayRole).toString().toDouble(),
140 p_table->item(i, 1)->data(Qt::DisplayRole).toString().toDouble());
145 catch (IException &e) {
146 p_errorMessage->setText(
147 "<font color='red'>" + e.toString() +
"</font>");
virtual void setStretch(Stretch)
Given an arbitrary stretch, this will re-interpret it, as best as possible, into a manual stretch...
void stretchChanged()
Emitted when a new Stretch object is available.
ManualStretchType(const Histogram &, const Stretch &, const QString &name, const QColor &color)
This constructs a manual stretch type.
Stretch * p_stretch
Current stretch pairs stored here.
QTableWidget * p_table
Pairs table.
~ManualStretchType()
Destructor.
void CopyPairs(const Stretch &other)
Copies the stretch pairs from another Stretch object, but maintains special pixel values...
Container of a cube histogram.
#define _FILEINFO_
Macro for the filename and line number.
void deleteButtonPressed(bool)
This is called when a user clicks "Delete" and is responsible for removing the pair with the given in...
A type of error that could only have occurred due to a mistake on the user's part (e...
QString Text() const
Converts stretch pair to a string.
Adds specific functionality to C++ strings.
Namespace for ISIS/Bullet specific routines.
This is the base class for advanced stretches.
void updateTable()
This updates the table with the current stretch pairs.
void addButtonPressed(bool)
This is called when a user clicks "Add / Edit" and is responsible for adding the pair into the correc...
QGridLayout * p_mainLayout
Main layout.