1 #include "StretchType.h"    10 #include <QPushButton>    12 #include <QTableWidget>    13 #include <QTextStream>    17 #include "HistogramWidget.h"    32                            const QString &name, 
const QColor &color) {
    44                                   color.lighter(110), color.darker(110));
    46     p_graph->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,
    47                                        QSizePolicy::Minimum));
    48     p_graph->setMinimumSize(QSize(100, 50));
    58     QPushButton *saveAsButton = 
new QPushButton(
"Save Stretch Pairs...");
    59     connect(saveAsButton, SIGNAL(clicked(
bool)), 
this, SLOT(
savePairs()));
    62     QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    63     sizePolicy.setHeightForWidth(
true);
    64     p_graph->setSizePolicy(sizePolicy);
   104     QTableWidget *table = 
new QTableWidget(0, 2);
   107     labels << 
"Input" << 
"Output";
   108     table->setHorizontalHeaderLabels(labels);
   110     table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
   111     table->setEditTriggers(QAbstractItemView::NoEditTriggers);
   112     table->setSelectionMode(QAbstractItemView::NoSelection);
   113     table->setMinimumSize(QSize(50, 20));
   134     for(
int i = 0; i < stretch.
Pairs(); i++) {
   135       QTableWidgetItem *inputItem = 
new QTableWidgetItem(QString(
"%1").arg(
   137       inputItem->setTextAlignment(Qt::AlignCenter);
   138       QTableWidgetItem *outputItem = 
new QTableWidgetItem(QString(
"%1").arg(
   140       outputItem->setTextAlignment(Qt::AlignCenter);
   142       p_table->setItem(i, 0, inputItem);
   143       p_table->setItem(i, 1, outputItem);
   153     QString filename = QFileDialog::getSaveFileName((
QWidget *)parent(),
   154                        "Choose filename to save under", 
".", 
"Text Files (*.txt)");
   155     if(filename.isEmpty()) 
return;
   157     QFile outfile(filename);
   158     bool success = outfile.open(QIODevice::WriteOnly);
   161       QMessageBox::critical((
QWidget *)parent(),
   162                             "Error", 
"Cannot open file, please check permissions");
   167     QTextStream stream(&outfile);
   172     stream << stretch.
Text() << endl;
 void savePairs()
This asks the user for a file and saves the current stretch pairs to that file. 
 
virtual Stretch getStretch()
Returns the current stretch object. 
 
QTableWidget * createStretchTable()
This creates the stretch pairs table. 
 
double Input(const int index) const
Returns the value of the input side of the stretch pair at the specified index. 
 
void stretchChanged()
Emitted when a new Stretch object is available. 
 
Stretch * p_stretch
Current stretch pairs stored here. 
 
QTableWidget * p_table
Pairs table. 
 
int Pairs() const
Returns the number of stretch pairs. 
 
Container of a cube histogram. 
 
double Output(const int index) const
Returns the value of the output side of the stretch pair at the specified index. 
 
QString Text() const
Converts stretch pair to a string. 
 
virtual void setHistogram(const Histogram &)
This should be called when the visible area changes. 
 
virtual void setStretch(Stretch)=0
Children must re-implement this to update their stretch pairs and GUI elements appropriately. 
 
StretchType(const Histogram &hist, const Stretch &stretch, const QString &name, const QColor &color)
This constructs a stretch type. 
 
void updateGraph()
This updates the graph with the current stretch object. 
 
HistogramWidget * p_graph
Histogram graph. 
 
Namespace for ISIS/Bullet specific routines. 
 
void updateTable()
This updates the table with the current stretch pairs. 
 
virtual ~StretchType()
Destructor. 
 
Histogram * p_cubeHist
Visible area histogram. 
 
QGridLayout * p_mainLayout
Main layout.