Skip to content
This repository has been archived by the owner on Feb 18, 2020. It is now read-only.

Commit

Permalink
major refactoring. We no longer will use findChild unless absolutely
Browse files Browse the repository at this point in the history
necessary. Within dialogs, we call members of ui directly.
  • Loading branch information
dpfoose committed Jul 7, 2016
1 parent f2f1a25 commit 1d0fdce
Show file tree
Hide file tree
Showing 81 changed files with 797 additions and 1,404 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -38,7 +38,7 @@ Names
* Setters are named in PascalCase like other functions, but are named after the variables they set (e.g. `SetName()` for the setter of the `name_` member).
* Getters are named after the member they return (e.g. the getter for `abscissa_` is named `abscissa()`). Getters that return pointers to members have `_ptr` appended to the end of their names. Where getters that return copies and getters that return references both exist, the getter that returns the reference is named with `_ref` appended.
* Every function belongs to a namespace, either the namespace of its parent class or a namespace like `Vespucci::Math` or `BinaryImport`.
* Widgets in Qt forms are named using Qt style inside .ui files, but use our style inside C++ classes (e.g. `nameLineEdit` becomes `name_line_edit_`). The type of the widget should be included in the name.
* Widgets in Qt forms are named using Qt camelCase style inside .ui files. The type of the widget should be included in the name because they have to be called something. Widgets should be accessed using the ui member of the form class.
* As mentioned above, an exception exists for a function whose sole purpose is to call the member of one of the class's members.

Types
Expand Down
6 changes: 6 additions & 0 deletions Test/Test.pro
Expand Up @@ -92,6 +92,12 @@ macx{
CONFIG += app_bundle c++11
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7

QMAKE_CXXFLAGS += --system-header-prefix=/usr \
--system-header-prefix=$$PWD/../armadillo \
--system-header-prefix=$$PWD/../mlpack \
--system-header-prefix=$$PWD/../yaml-cpp \
--system-header-prefix=$$PWD/../quazip

LIBS += -L/usr/lib -lc++

LIBS += -L$$OUT_PWD/../VespucciLibrary/ -lvespucci
Expand Down
78 changes: 34 additions & 44 deletions Vespucci/GUI/Analysis/bandratiodialog.cpp
Expand Up @@ -31,20 +31,10 @@ BandRatioDialog::BandRatioDialog(QWidget *parent,
workspace_ = ws;
dataset_ = workspace_->GetDataset(dataset_key);

spectrum_custom_plot_ = findChild<QCustomPlot *>("spectrumPlot");
first_min_line_edit_ = findChild<QLineEdit *>("firstMinLineEdit");
first_max_line_edit_ = findChild<QLineEdit *>("firstMaxLineEdit");
second_min_line_edit_ = findChild<QLineEdit *>("secondMinLineEdit");
second_max_line_edit_ = findChild<QLineEdit *>("secondMaxLineEdit");
name_line_edit_ = findChild<QLineEdit *>("nameLineEdit");
method_combo_box_ = findChild<QComboBox *>("peakComboBox");
range_label_ = findChild<QLabel *>("rangeLabel");
search_window_spin_box_ = findChild<QSpinBox*>("searchWindowSpinBox");

first_min_line_ = new QCPItemStraightLine(spectrum_custom_plot_);
first_max_line_ = new QCPItemStraightLine(spectrum_custom_plot_);
second_min_line_ = new QCPItemStraightLine(spectrum_custom_plot_);
second_max_line_ = new QCPItemStraightLine(spectrum_custom_plot_);
first_min_line_ = new QCPItemStraightLine(ui->spectrumCustomPlot);
first_max_line_ = new QCPItemStraightLine(ui->spectrumCustomPlot);
second_min_line_ = new QCPItemStraightLine(ui->spectrumCustomPlot);
second_max_line_ = new QCPItemStraightLine(ui->spectrumCustomPlot);

first_min_line_->point1->setCoords(0, 0);
first_min_line_->point2->setCoords(0, 1);
Expand All @@ -65,23 +55,23 @@ BandRatioDialog::BandRatioDialog(QWidget *parent,


QString label_text = QString::number(min) + "" + QString::number(max);
range_label_->setText(label_text);
ui->rangeLabel->setText(label_text);

uword origin = dataset_->FindOrigin();

QVector<double> plot_data = dataset_->PointSpectrum(origin);
QVector<double> wavelength = dataset_->WavelengthQVector();
if (plot_data.isEmpty()){plot_data = dataset_->PointSpectrum(0);}

first_min_line_edit_->setValidator(validator);
first_max_line_edit_->setValidator(validator);
second_min_line_edit_->setValidator(validator);
second_max_line_edit_->setValidator(validator);
spectrum_custom_plot_->addGraph();
spectrum_custom_plot_->graph(0)->addData(wavelength, plot_data);
spectrum_custom_plot_->rescaleAxes();
spectrum_custom_plot_->setInteraction(QCP::iRangeDrag, true);
spectrum_custom_plot_->setInteraction(QCP::iRangeZoom, true);
ui->firstMinLineEdit->setValidator(validator);
ui->firstMaxLineEdit->setValidator(validator);
ui->secondMinLineEdit->setValidator(validator);
ui->secondMaxLineEdit->setValidator(validator);
ui->spectrumCustomPlot->addGraph();
ui->spectrumCustomPlot->graph(0)->addData(wavelength, plot_data);
ui->spectrumCustomPlot->rescaleAxes();
ui->spectrumCustomPlot->setInteraction(QCP::iRangeDrag, true);
ui->spectrumCustomPlot->setInteraction(QCP::iRangeZoom, true);
}

BandRatioDialog::~BandRatioDialog()
Expand All @@ -95,16 +85,16 @@ BandRatioDialog::~BandRatioDialog()
/// instantiates the map data
void BandRatioDialog::on_buttonBox_accepted()
{
if (first_min_line_edit_->text().isEmpty() || first_max_line_edit_->text().isEmpty() || second_min_line_edit_->text().isEmpty() || second_max_line_edit_->text().isEmpty()){
if (ui->firstMinLineEdit->text().isEmpty() || ui->firstMaxLineEdit->text().isEmpty() || ui->secondMinLineEdit->text().isEmpty() || ui->secondMaxLineEdit->text().isEmpty()){
QMessageBox::warning(this, "Invalid Input!", "You must enter numbers for left and right bounds.");
return;
}


double first_entered_min = first_min_line_edit_->text().toDouble();
double second_entered_min = second_min_line_edit_->text().toDouble();
double first_entered_max = first_max_line_edit_->text().toDouble();
double second_entered_max = second_max_line_edit_->text().toDouble();
double first_entered_min = ui->firstMinLineEdit->text().toDouble();
double second_entered_min = ui->secondMinLineEdit->text().toDouble();
double first_entered_max = ui->firstMaxLineEdit->text().toDouble();
double second_entered_max = ui->secondMaxLineEdit->text().toDouble();

if (first_entered_min < dataset_->abscissa_ptr()->min() || second_entered_min < dataset_->abscissa_ptr()->min()){
QMessageBox::warning(this, "Invalid Input!", "You have entered a left bound that is smaller than the smallest number on the spectral abscissa");
Expand All @@ -115,13 +105,13 @@ void BandRatioDialog::on_buttonBox_accepted()
QMessageBox::warning(this, "Invalid Input!", "You have entered a right bound that is larger than the largest number on the spectral abscissa");
return;
}
uint bound_window = search_window_spin_box_->value();
uint bound_window = ui->searchWindowSpinBox->value();


QString name = name_line_edit_->text();
QString value_method = method_combo_box_->currentText();
QString name = ui->nameLineEdit->text();
QString value_method = ui->methodComboBox->currentText();

if (value_method == "Riemann Sum"){
if (value_method == "Empirical"){
try{
dataset_->BandRatio(name, first_entered_min, first_entered_max,
second_entered_min, second_entered_max,
Expand All @@ -138,7 +128,7 @@ void BandRatioDialog::on_buttonBox_accepted()
}
}
else{
QMessageBox::warning(this, "Error Occurred", "A non-fatal error occurred: invalid input from method_combo_box_");
QMessageBox::warning(this, "Error Occurred", "A non-fatal error occurred: invalid input from ui->methodComboBox");
}

close();
Expand All @@ -163,9 +153,9 @@ void BandRatioDialog::on_firstMinLineEdit_textChanged(const QString &arg1)
return;
first_min_line_->point1->setCoords(value, 0);
first_min_line_->point2->setCoords(value, 1);
if (!spectrum_custom_plot_->hasItem(first_min_line_))
spectrum_custom_plot_->addItem(first_min_line_);
spectrum_custom_plot_->repaint();
if (!ui->spectrumCustomPlot->hasItem(first_min_line_))
ui->spectrumCustomPlot->addItem(first_min_line_);
ui->spectrumCustomPlot->repaint();
}

void BandRatioDialog::on_firstMaxLineEdit_textChanged(const QString &arg1)
Expand All @@ -176,9 +166,9 @@ void BandRatioDialog::on_firstMaxLineEdit_textChanged(const QString &arg1)
return;
first_max_line_->point1->setCoords(value, 0);
first_max_line_->point2->setCoords(value, 1);
if (!spectrum_custom_plot_->hasItem(first_max_line_))
spectrum_custom_plot_->addItem(first_max_line_);
spectrum_custom_plot_->repaint();
if (!ui->spectrumCustomPlot->hasItem(first_max_line_))
ui->spectrumCustomPlot->addItem(first_max_line_);
ui->spectrumCustomPlot->repaint();
}

void BandRatioDialog::on_secondMinLineEdit_textChanged(const QString &arg1)
Expand All @@ -189,8 +179,8 @@ void BandRatioDialog::on_secondMinLineEdit_textChanged(const QString &arg1)
return;
second_min_line_->point1->setCoords(value, 0);
second_min_line_->point2->setCoords(value, 1);
if (!spectrum_custom_plot_->hasItem(second_min_line_))
spectrum_custom_plot_->addItem(second_min_line_);
if (!ui->spectrumCustomPlot->hasItem(second_min_line_))
ui->spectrumCustomPlot->addItem(second_min_line_);
}

void BandRatioDialog::on_secondMaxLineEdit_textChanged(const QString &arg1)
Expand All @@ -201,7 +191,7 @@ void BandRatioDialog::on_secondMaxLineEdit_textChanged(const QString &arg1)
return;
second_max_line_->point1->setCoords(value, 0);
second_max_line_->point2->setCoords(value, 1);
if (!spectrum_custom_plot_->hasItem(second_max_line_))
spectrum_custom_plot_->addItem(second_max_line_);
if (!ui->spectrumCustomPlot->hasItem(second_max_line_))
ui->spectrumCustomPlot->addItem(second_max_line_);
}

52 changes: 2 additions & 50 deletions Vespucci/GUI/Analysis/bandratiodialog.h
Expand Up @@ -54,62 +54,14 @@ private slots:

private:
Ui::BandRatioDialog *ui;

///
/// \brief workspace
/// Pointer to the workspace (which contains dataset list)
QSharedPointer<VespucciWorkspace> workspace_;

///
/// \brief spectrum_custom_plot_
/// Pointer to the plot inside this window that displays a preview of the data
QCustomPlot *spectrum_custom_plot_;

///
/// \brief first_min_line_edit_
/// User enteres first minimum here
QLineEdit *first_min_line_edit_;

///
/// \brief first_max_line_edit_
/// User enters first maximum here
QLineEdit *first_max_line_edit_;

///
/// \brief second_min_line_edit_
/// User enters second minimum here
QLineEdit *second_min_line_edit_;

///
/// \brief second_max_line_edit_
/// User enteres second maximum here
QLineEdit *second_max_line_edit_;


///
/// \brief integration_method_selector_combo_box_
/// User selects the integration method here
QComboBox *method_combo_box_;

///
/// \brief name_line_edit_
/// User enters map name here
QLineEdit *name_line_edit_;

QSpinBox *search_window_spin_box_;
///
/// \brief data_index_
/// Index of the VespucciDataset object in the various lists
int data_index_;

///
/// \brief range_label_
/// Displays the valid range
QLabel *range_label_;

///
/// \brief first_min_line_
///
///
QCPItemStraightLine *first_min_line_;
///
/// \brief first_max_line_
Expand All @@ -128,8 +80,8 @@ private slots:
/// \brief dataset_
/// Points to the dataset we're working with.
QSharedPointer<VespucciDataset> dataset_;
QSharedPointer<VespucciWorkspace> workspace_;

QCheckBox *map_check_box_;
};

#endif // BANDRATIODIALOG_H
46 changes: 19 additions & 27 deletions Vespucci/GUI/Analysis/bandratiodialog.ui
Expand Up @@ -74,7 +74,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCustomPlot" name="spectrumPlot" native="true">
<widget class="QCustomPlot" name="spectrumCustomPlot" native="true">
<property name="minimumSize">
<size>
<width>600</width>
Expand Down Expand Up @@ -161,28 +161,14 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Peak Determination</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="peakComboBox">
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string/>
<string>Search window for inflection points.</string>
</property>
<property name="text">
<string>Search Window Size</string>
</property>
<item>
<property name="text">
<string>Riemann Sum</string>
</property>
</item>
<item>
<property name="text">
<string>Gaussian Fit</string>
</property>
</item>
</widget>
</item>
<item row="4" column="1">
Expand All @@ -201,16 +187,22 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>Search window for inflection points.</string>
</property>
<item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Search Window Size</string>
<string>Quantification</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="methodComboBox">
<item>
<property name="text">
<string>Empirical</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
8 changes: 3 additions & 5 deletions Vespucci/GUI/Analysis/classicalleastsquaresdialog.cpp
Expand Up @@ -6,13 +6,11 @@ ClassicalLeastSquaresDialog::ClassicalLeastSquaresDialog(QWidget *parent, QShare
ui(new Ui::ClassicalLeastSquaresDialog)
{
ui->setupUi(this);
reference_combo_box_ = findChild<QComboBox *>("datasetComboBox");
name_line_edit_= findChild<QLineEdit *>("nameLineEdit");

workspace_ = ws;
dataset_ = workspace_->GetDataset(dataset_key);
QStringList matrix_keys = dataset_->AuxiliaryMatrixKeys();
reference_combo_box_->addItems(matrix_keys);
ui->referenceComboBox->addItems(matrix_keys);

}

Expand All @@ -25,9 +23,9 @@ ClassicalLeastSquaresDialog::~ClassicalLeastSquaresDialog()

void ClassicalLeastSquaresDialog::on_buttonBox_accepted()
{
QString name = name_line_edit_->text();
QString name = ui->nameLineEdit->text();
try{
dataset_->ClassicalLeastSquares(name, reference_combo_box_->currentText());
dataset_->ClassicalLeastSquares(name, ui->referenceComboBox->currentText());
}catch(exception e){
workspace_->main_window()->DisplayExceptionWarning(e);
}
Expand Down
2 changes: 0 additions & 2 deletions Vespucci/GUI/Analysis/classicalleastsquaresdialog.h
Expand Up @@ -21,8 +21,6 @@ private slots:

private:
Ui::ClassicalLeastSquaresDialog *ui;
QComboBox *reference_combo_box_;
QLineEdit *name_line_edit_;
QSharedPointer<VespucciWorkspace> workspace_;
QSharedPointer<VespucciDataset> dataset_;
};
Expand Down
16 changes: 6 additions & 10 deletions Vespucci/GUI/Analysis/kmeansdialog.cpp
Expand Up @@ -31,13 +31,9 @@ KMeansDialog::KMeansDialog(QWidget *parent, QSharedPointer<VespucciWorkspace> ws
ui(new Ui::KMeansDialog)
{
ui->setupUi(this);
name_line_edit_ = findChild<QLineEdit *>("nameLineEdit");
cluster_spin_box_ = findChild<QSpinBox *>("clustersSpinBox");
prediction_check_box_ = findChild<QCheckBox *>("predictionCheckBox");
metric_combo_box_ = findChild<QComboBox *>("metricComboBox");
workspace_ = ws;
dataset_ = workspace_->GetDataset(dataset_key);
name_line_edit_->setEnabled(false);
ui->nameLineEdit->setEnabled(false);
}

KMeansDialog::~KMeansDialog()
Expand All @@ -51,13 +47,13 @@ KMeansDialog::~KMeansDialog()
void KMeansDialog::on_buttonBox_accepted()
{

QString metric_text = metric_combo_box_->currentText();
QString metric_text = ui->metricComboBox->currentText();
int clusters;
QString name = name_line_edit_->text();
if (prediction_check_box_->isChecked())
QString name = ui->nameLineEdit->text();
if (ui->predictionCheckBox->isChecked())
clusters = 0;
else
clusters = cluster_spin_box_->value();
clusters = ui->clustersSpinBox->value();
try{
dataset_->KMeans(clusters, metric_text, name);
}catch(exception e){
Expand All @@ -79,5 +75,5 @@ void KMeansDialog::on_buttonBox_rejected()

void KMeansDialog::on_predictionCheckBox_clicked(bool checked)
{
cluster_spin_box_->setEnabled(!checked);
ui->clustersSpinBox->setEnabled(!checked);
}

0 comments on commit 1d0fdce

Please sign in to comment.