1 #include "StretchType.h"
10 #include <QPushButton>
12 #include <QTableWidget>
13 #include <QTextStream>
16 #include "Histogram.h"
17 #include "HistogramWidget.h"
18 #include "CubeStretch.h"
33 const QString &name,
const QColor &color) {
45 color.lighter(110), color.darker(110));
47 p_graph->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,
48 QSizePolicy::Minimum));
49 p_graph->setMinimumSize(QSize(100, 50));
55 connect(
this, SIGNAL(stretchChanged()),
this, SLOT(
updateGraph()));
56 connect(
this, SIGNAL(stretchChanged()),
this, SLOT(
updateTable()));
59 QPushButton *saveAsButton =
new QPushButton(
"Save Stretch Pairs to File...");
60 connect(saveAsButton, SIGNAL(clicked(
bool)),
this, SLOT(
savePairs()));
66 if (name.compare(
"Gray") == 0) {
67 QPushButton *saveToCubeButton =
new QPushButton(
"Save Stretch Pairs to Cube...");
68 connect(saveToCubeButton, SIGNAL(clicked(
bool)),
this, SIGNAL(
saveToCube()));
71 QPushButton *deleteFromCubeButton =
new QPushButton(
"Delete Stretch Pairs from Cube...");
72 connect(deleteFromCubeButton, SIGNAL(clicked(
bool)),
this, SIGNAL(deleteFromCube()));
75 QPushButton *loadStretchButton =
new QPushButton(
"Restore Saved Stretch from Cube...");
76 connect(loadStretchButton, SIGNAL(clicked(
bool)),
this, SIGNAL(loadStretch()));
79 QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
80 sizePolicy.setHeightForWidth(
true);
81 p_graph->setSizePolicy(sizePolicy);
122 QTableWidget *table =
new QTableWidget(0, 2);
125 labels <<
"Input" <<
"Output";
126 table->setHorizontalHeaderLabels(labels);
128 table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
129 table->setEditTriggers(QAbstractItemView::NoEditTriggers);
130 table->setSelectionMode(QAbstractItemView::NoSelection);
131 table->setMinimumSize(QSize(50, 20));
152 for(
int i = 0; i < stretch.
Pairs(); i++) {
153 QTableWidgetItem *inputItem =
new QTableWidgetItem(QString(
"%1").arg(
155 inputItem->setTextAlignment(Qt::AlignCenter);
156 QTableWidgetItem *outputItem =
new QTableWidgetItem(QString(
"%1").arg(
158 outputItem->setTextAlignment(Qt::AlignCenter);
160 p_table->setItem(i, 0, inputItem);
161 p_table->setItem(i, 1, outputItem);
171 QString filename = QFileDialog::getSaveFileName((
QWidget *)parent(),
172 "Choose filename to save under",
".",
"Text Files (*.txt)");
173 if(filename.isEmpty())
return;
175 QFile outfile(filename);
176 bool success = outfile.open(QIODevice::WriteOnly);
179 QMessageBox::critical((
QWidget *)parent(),
180 "Error",
"Cannot open file, please check permissions");
185 QTextStream stream(&outfile);
190 stream << stretch.
Text() << endl;