2 #include "ui_plotmakerdialog.h" 13 plot_viewer_ = plot_viewer;
15 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(data_keys.first());
16 if (dataset.isNull()){
17 QMessageBox::warning(
this,
"Dataset Does not Exist",
18 "An error has occurred: dataset does not exist with specified name");
22 if (!workspace_->GetMatrix(data_keys).n_elem){
23 QMessageBox::warning(
this,
"Matrix Does Not Exist",
24 "An error has occurred: matrix does not exist with specified keys");
29 if (workspace_->GetMatrix(data_keys).n_rows == dataset->abscissa_ref().n_rows)
30 ui->abscissaComboBox->addItem(
"Spectral Abscissa");
31 ui->abscissaComboBox->addItem(
"Column");
33 ui->xSpinBox->setMaximum(workspace_->GetMatrix(data_keys_).n_cols);
34 ui->ySpinBox->setMaximum(workspace_->GetMatrix(data_keys_).n_cols);
35 ui->xSpinBox->setMinimum(1);
36 ui->ySpinBox->setMinimum(1);
38 if (ui->abscissaComboBox->currentText() ==
"Spectral Abscissa")
39 ui->ySpinBox->setValue(1);
41 ui->ySpinBox->setValue(2);
49 void PlotMakerDialog::on_buttonBox_accepted()
52 QString abscissa_type = ui->abscissaComboBox->currentText();
53 QString dimension_type = ui->dimensionComboBox->currentText();
54 uword x_ind = ui->xSpinBox->value() - 1;
55 uword y_ind = ui->ySpinBox->value() - 1;
60 QString plot_title = data_keys_.last()
61 +
" " + QString::number(y_ind + 1);
62 if (abscissa_type ==
"Row" || abscissa_type ==
"Column"){
63 plot_title = plot_title
66 +
" " + QString::number(x_ind + 1);
69 if (dimension_type ==
"Column")
70 y = workspace_->GetMatrix(data_keys_).col(y_ind);
72 if (dimension_type ==
"Row")
73 y = workspace_->GetMatrix(data_keys_).row(y_ind).t();
75 if (abscissa_type ==
"Spectral Abscissa")
76 x = workspace_->GetDataset(data_keys_.first())->abscissa();
78 if (abscissa_type ==
"Column")
79 x = workspace_->GetMatrix(data_keys_).col(x_ind);
81 if (abscissa_type ==
"Row")
82 x = workspace_->GetMatrix(data_keys_).row(x_ind).t();
84 if (y.n_elem && (x.n_rows == y.n_rows)){
85 if (ui->typeComboBox->currentText() ==
"Scatter")
87 else plot_viewer_->
AddPlot(x, y, plot_title);
90 QMessageBox::warning(
this,
"Dimension Mismatch",
"Matrix dimensions do not match");
96 void PlotMakerDialog::on_dimensionComboBox_currentTextChanged(
const QString &arg1)
99 ui->abscissaComboBox->clear();
100 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(data_keys_.first());
101 if (workspace_->GetMatrix(data_keys_).n_cols == dataset->spectra_ref().n_rows)
102 ui->abscissaComboBox->addItem(
"Spectral Abscissa");
103 ui->abscissaComboBox->addItem(
"Row");
104 ui->xSpinBox->setMaximum(workspace_->GetMatrix(data_keys_).n_rows);
105 ui->ySpinBox->setMaximum(workspace_->GetMatrix(data_keys_).n_rows);
108 if (arg1 ==
"Column"){
109 ui->abscissaComboBox->clear();
110 QSharedPointer<VespucciDataset> dataset = workspace_->GetDataset(data_keys_.first());
111 if (workspace_->GetMatrix(data_keys_).n_rows == dataset->abscissa_ref().n_rows)
112 ui->abscissaComboBox->addItem(
"Spectral Abscissa");
113 ui->abscissaComboBox->addItem(
"Column");
114 ui->xSpinBox->setMaximum(workspace_->GetMatrix(data_keys_).n_cols);
115 ui->ySpinBox->setMaximum(workspace_->GetMatrix(data_keys_).n_cols);
PlotMakerDialog(MainWindow *parent, PlotViewer *plot_viewer, QSharedPointer< VespucciWorkspace > ws, QStringList data_keys)
void AddPlot(const mat &paired_data, const QString &tab_title)
void AddScatterPlot(const mat &paired_data, const QString &tab_title)
The MainWindow class The main window of the program, this is where the user performs most operations...