Commit 51ada734 authored by Edlira Nano's avatar Edlira Nano
Browse files

xicSelectionWidget continue

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2243 e4b6dbb4-9209-464b-83f7-6257456c460c
parent eefd4eae
......@@ -4,7 +4,6 @@
#include <QDockWidget>
#include "mainwindow.h"
#include "masschroq_gui.h"
#include "xicSelectionWidget.h"
......@@ -13,7 +12,8 @@ MainWindow::MainWindow(QWidget *parent)
QMainWindow(parent)
{
_masschroq_gui = new MasschroqGui();
// Central Widget
QWidget * widget = new QWidget();
......@@ -86,11 +86,10 @@ MainWindow::loadMsrun() {
QString filename = QFileDialog::getOpenFileName(this, tr("Open Msrun File"),
QString::null,
tr("mzXML or mzML files (*.mzXML *.mzML)"));
MasschroqGui masschroq_gui;
if (!filename.isEmpty()) {
_current_msrun_file = filename;
masschroq_gui.setMsRun(filename);
_masschroq_gui->setMsRun(filename);
}
cout << "end loading" << endl;
}
......@@ -101,7 +100,13 @@ MainWindow::extractXicWidget() {
XicSelectionWidget * xic = new XicSelectionWidget(dock);
dock->setWidget(xic);
addDockWidget(Qt::LeftDockWidgetArea, dock);
connect(xic, SIGNAL(extract()), this, SLOT(extractXic(xic)));
}
void
MainWindow::extractXic(XicSelectionWidget * xic) {
_masschroq_gui->extractXic(xic);
}
void
......@@ -111,6 +116,8 @@ MainWindow::filterXic() {
void MainWindow::about() {
QMessageBox::about(this, tr("About MassChroQ"),
tr("This is <b>MassChroQ GUI</b> version beta."));
......
......@@ -3,6 +3,8 @@
#include <QToolBar>
#include <QAction>
#include "masschroq_gui.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
......@@ -11,13 +13,15 @@ public:
MainWindow(QWidget * parent = 0);
private Q_SLOTS:
private slots:
void loadMsrun();
void extractXicWidget();
void extractXic(XicSelectionWidget *);
void filterXic();
void about();
protected:
//void closeEvent(QCloseEvent *event);
......@@ -36,6 +40,8 @@ private:
//QListWidget * filtersList;
//QListWidget * quantiItemsList;
MasschroqGui * _masschroq_gui;
QMenu * _fileMenu;
QMenu * _toolsMenu;
QMenu * _helpMenu;
......
......@@ -48,7 +48,7 @@ MasschroqGui::setMsRun(const QString & filename) {
<< filename.toStdString()
<< "' : parsing begin" << endl;
msrun->set_from_xml(filename, format);
//this->addMsRun(msrun);
this->addMsRun(filename, msrun);
} catch (mcqError error) {
throw mcqError(QObject::tr("problem creating msrun %1:\n%2").arg(filename, error.what()));
}
......@@ -63,10 +63,52 @@ MasschroqGui::setMsRun(const QString & filename) {
<<", : parsing begin" << endl;
msrun->set_from_xml(filename, format);
//this->addMsRun(msrun);
this->addMsRun(filename, msrun);
} catch (mcqError error) {
throw mcqError(QObject::tr("problem creating msrun %1:\n%2").arg(filename, error.what()));
}
}
}
void
MasschroqGui::addMsRun(const QString & filename, const Msrun * msrun) {
_msrun_map[filename] = msrun;
}
Msrun *
MassChroq::getMsRun(const QString & filename) const {
std::map<QString, Msrun *>::const_iterator it;
it = _msrun_map.find(filename);
if (it == end()) {
return (NULL);
} else {
return (it->second);
}
}
XicProfile *
MassChroq::extractXicProfile(XicSelectionWidget * xic) {
XicExtractionMethodBase * extraction_method = xic->getXicExtractionMethod();
mcq_xic_type xic_type = xic->getXicType();
mcq_double mz_value = xic->getMzToExtract();
mcq_double rt_value = xic->getRtToExtract();
// extract XIC
_msrun->prepareSpectraForQuantification(extraction_method);
xicBase * current_xic = _msrun->extractXic(xic_type, quanti_item);
if (current_xic == 0) {
qDebug() << "MsrunSelectionXic null xic ";
}
XicProfile * xic_profile = new XicProfile();
xic_profile->setRtVector(*(current_xic->getRetentionTimes()));
xic_profile->setIntensityVector(*(current_xic->getIntensities()));
delete (current_xic);
_msrun.doneWithSpectra();
return xic_profile;
}
......@@ -51,15 +51,16 @@ class MasschroqGui {
virtual ~MasschroqGui();
/// creates and sets an msrun
void setMsRun(const QString & idname, const QFileInfo & fielInfo, const QString & format);
void addMsRun(Msrun * p_msrun);
void setMsRun(const QString & filename);
Msrun * findMsRun(const QString & msrun_id) const;
XicProfile * extractXicProfile(XicSelectionWidget xic);
public:
private :
void setMsRun(const QString & filename);
void addMsRun(const QString & filename, const Msrun * msrun);
Msrun * getMsRun(const QString & filename) const;
std::map<QString, Msrun *> _msrun_map;
};
......
......@@ -7,7 +7,7 @@
#include <QtGui>
#include "xicSelectionWidget.h"
XicSelectionWidget::XicSelectionWidget(QWidget * parent) : QDialog(parent) {
XicSelectionWidget::XicSelectionWidget(QWidget * parent) : QWidget(parent) {
create_xic_type_group();
create_xic_range_group();
......@@ -19,8 +19,8 @@ XicSelectionWidget::XicSelectionWidget(QWidget * parent) : QDialog(parent) {
_button_box->addButton(extractButton, QDialogButtonBox::AcceptRole);
_button_box->addButton(QDialogButtonBox::Cancel);
connect(_button_box, SIGNAL(accepted()), this, SLOT(accept()));
connect(_button_box, SIGNAL(rejected()), this, SLOT(reject()));
connect(_button_box, SIGNAL(accepted()), this, SLOT(extractXic()));
connect(_button_box, SIGNAL(rejected()), this, SLOT(cancel()));
QVBoxLayout * mainLayout = new QVBoxLayout;
mainLayout->addWidget(_xic_type_group);
......@@ -28,8 +28,8 @@ XicSelectionWidget::XicSelectionWidget(QWidget * parent) : QDialog(parent) {
mainLayout->addWidget(_mz_group);
mainLayout->addWidget(_button_box);
setLayout(mainLayout);
setWindowTitle(tr("XIC extraction"));
}
XicSelectionWidget::~XicSelectionWidget() {
......@@ -41,9 +41,10 @@ XicSelectionWidget::create_xic_type_group() {
_xic_type_group = new QGroupBox(tr("XIC type"));
QVBoxLayout *layout = new QVBoxLayout;
QCheckBox * xic_type_max = new QCheckBox(tr("max xic type"));
QCheckBox * xic_type_max = new QCheckBox(tr("max xic"));
xic_type_max->setChecked(true);
QCheckBox * xic_type_sum = new QCheckBox(tr("sum xic type"));
setXicType(MAX_XIC_TYPE);
QCheckBox * xic_type_sum = new QCheckBox(tr("sum xic"));
QButtonGroup * xic_type_buttons = new QButtonGroup();
xic_type_buttons->setExclusive(true);
......@@ -54,6 +55,9 @@ XicSelectionWidget::create_xic_type_group() {
layout->addWidget(xic_type_sum);
_xic_type_group->setLayout(layout);
connect(xic_type_buttons, SIGNAL(buttonClicked(QAbstractButton * )),
this, SLOT(setXicType(QAbstractButton *)));
}
void
......@@ -61,9 +65,11 @@ XicSelectionWidget::create_xic_range_group() {
_xic_range_group = new QGroupBox(tr("XIC extraction range"));
QGridLayout *layout = new QGridLayout;
QCheckBox * ppm_range = new QCheckBox(tr("ppm_range"));
QCheckBox * ppm_range = new QCheckBox(tr("ppm range"));
ppm_range->setChecked(true);
QCheckBox * mz_range = new QCheckBox(tr("mz_range"));
XicExtractionMethodPpmRange extraction_method = new XicExtractionMethodPpmRange();
setXicExtractionMethod(extraction_method);
QCheckBox * mz_range = new QCheckBox(tr("mz range"));
QButtonGroup * xic_range_buttons = new QButtonGroup();
xic_range_buttons->setExclusive(true);
......@@ -80,6 +86,7 @@ XicSelectionWidget::create_xic_range_group() {
min_box->setSingleStep(0.1);
layout->addWidget(min_label, 1, 0);
layout->addWidget(min_box, 1, 1);
setMinRange(0);
QLabel * max_label = new QLabel("maximum range");
QDoubleSpinBox * max_box = new QDoubleSpinBox;
......@@ -88,8 +95,17 @@ XicSelectionWidget::create_xic_range_group() {
max_box->setSingleStep(0.1);
layout->addWidget(max_label, 2, 0);
layout->addWidget(max_box, 2, 1);
setMaxRange(0);
_xic_range_group->setLayout(layout);
connect(xic_range_buttons, SIGNAL(buttonClicked(QAbstractButton * )),
this, SLOT(setXicExtractionMethod(QAbstractButton *)));
connect(min_box, SIGNAL(valueChanged(double)), this, SLOT(setMinRange(double)));
connect(max_box, SIGNAL(valueChanged(double)), this, SLOT(setMaxRange(double)));
}
......@@ -100,11 +116,124 @@ XicSelectionWidget::create_mz_group() {
QDoubleSpinBox * mz_value = new QDoubleSpinBox;
mz_value->setMaximum(5000.0000);
mz_value->setSingleStep(10.0000);
setMzToExtract(0);
QDoubleSpinBox * rt_value = new QDoubleSpinBox;
rt_value->setMaximum(5000.0000);
rt_value->setSingleStep(10.0000);
setRtToExtract(0);
layout->addRow(tr("mz value to extract"), mz_value);
layout->addRow(tr("rt value to extract"), rt_value);
_mz_group->setLayout(layout);
connect(mz_value, SIGNAL(valueChanged(double)), this, SLOT(setMzToExtract(double)));
connect(rt_value, SIGNAL(valueChanged(double)), this, SLOT(setRtToExtract(double)));
}
void
XicSelectionWidget::setXicType(mcq_xic_type & type) {
if ( (type != MAX_XIC_TYPE) || (type != SUM_XIC_TYPE) ) {
throw mcqError(QObject::tr("XicSelectionWidget::setXicType(mcq_xic_type) : invalid xic type"));
}
_xic_type = type;
}
void
XicSelectionWidget::setXicType(QAbstractButton * button) {
QString button_text = button->text();
mcq_xic_type xic_type;
if (button_text == "max xic") {
xic_type = MAX_XIC_TYPE;
} else if (button_text == "sum xic") {
xic_type = SUM_XIC_TYPE;
} else {
throw mcqError(QObject::tr("XicSelectionWidget::setXicType(QAbstractButton *) : Invalid xic type button"));
}
setXicType(xic_type);
}
void
XicSelectionWidget::setXicExtractionMethod(XicExtractionMethodBase * extraction_method) {
if (extraction_method == 0) {
throw mcqError(QObject::tr("XicSelectionWidget::setXicExtractionMethod(XicExtractionMethodBase *) : Null extraction method"));
}
if (_xic_extraction_method != 0) {
delete _xic_extraction_method;
_xic_extraction_method = 0;
}
_xic_extraction_method = extraction_method;
}
void
XicSelectionWidget::setXicExtractionMethod(QAbstractButton * button) {
QString button_text = button->text();
XicExtractionMethodBase * extraction_method;
if (button_text == "ppm range") {
extraction_method = new XicExtractionMethodPpmRange();
} else if (button_text == "mz range") {
extraction_method = new XicExtractionMethodMzRange();
} else {
throw mcqError(QObject::tr("XicSelectionWidget::setXicExtractionMethod(QAbstractButton *) : Invalid range extraction type"));
}
setXicExtractionMethod(extraction_method);
}
void
XicSelectionWidget::setMinRange(mcq_double min) {
_min_range = min;
_xic_extraction_method->set_low_mz_range(_min_range);
}
void
XicSelectionWidget::setMaxRange(mcq_double max) {
_max_range = max;
_xic_extraction_method->set_high_mz_range(_max_range);
}
void
XicSelectionWidget::setMzToExtract(mcq_double mz) {
_mz_to_extract = mz;
}
void
XicSelectionWidget::setRtToExtract(mcq_double rt) {
_rt_to_extract = rt;
}
void
XicSelectionWidget::extractXic() {
emit extract();
}
void
XicSelectionWidget::cancel() {
this->close();
this->deleteLater();
}
const XicExtractionMethodBase *
XicSelectionWidget::getXicExtractionMethod() const {
return _xic_extraction_method;
}
const mcq_xic_type
XicSelectionWidget::getXicType() const {
return _xic_type;
}
const mcq_double
XicSelectionWidget::getMzToExtract() const {
return _mz_to_extract;
}
const mcq_double
XicSelectionWidget::getRtToExtract() const {
return _rt_to_extract;
}
......@@ -41,7 +41,7 @@ class QDialogButtonBox;
*
*/
class XicSelectionWidget : public QDialog {
class XicSelectionWidget : public QWidget {
Q_OBJECT
......@@ -51,8 +51,42 @@ class XicSelectionWidget : public QDialog {
virtual ~XicSelectionWidget();
const XicExtractionMethodBase * getXicExtractionMethod() const;
const mcq_xic_type getXicType() const;
const mcq_double getMzToExtract() const;
const mcq_double getRtToExtract() const;
private slots :
void setXicType(QAbstractButton *);
void setXicExtractionMethod(QAbstractButton *);
void setMinRange(mcq_double min);
void setMaxRange(mcq_double max);
void setMzToExtract(mcq_double mz);
void setRtToExtract(mcq_double rt);
void extractXic();
void cancel();
signals :
void extract();
protected :
mcq_xic_type _xic_type;
XicExtractionMethodBase * _xic_extraction_method;
mcq_double _min_range;
mcq_double _max_range;
mcq_double _mz_to_extract;
mcq_double _rt_to_extract;
void setXicType(mcq_xic_type & type);
void setXicExtractionMethod(XicExtractionMethodBase * extraction_method);
private :
void create_xic_type_group();
......@@ -60,11 +94,8 @@ class XicSelectionWidget : public QDialog {
void create_mz_group();
QGroupBox * _xic_type_group;
QGroupBox * _xic_range_group;
QGroupBox * _mz_group;
QDialogButtonBox * _button_box;
};
......
......@@ -38,8 +38,8 @@ chooseMzPrecisionWidget::chooseMzPrecisionWidget(): QWidget()
text.setNum(_xic_mz, 'f', 2);
_mass_choose_label = new QLineEdit();//new QLabel(text, this);
_mass_choose_label->setAlignment(Qt::AlignRight);
_mass_choose_label->setFixedWidth(_mass_choose_label->fontMetrics().width("10000.09"));
_mass_choose_label->setAlignment(Qt::AlignRight);
_mass_choose_label->setFixedWidth(_mass_choose_label->fontMetrics().width("10000.09"));
_mass_choose_label->setText(text);
_bkg_median_window_size_edit = new QLineEdit();
......@@ -52,7 +52,7 @@ chooseMzPrecisionWidget::chooseMzPrecisionWidget(): QWidget()
text.setNum(_bkg_min_max_window_size);
_bkg_min_max_window_size_edit->setText(text);
QVBoxLayout * slider_layout;
QVBoxLayout * slider_layout;
slider_layout = new QVBoxLayout(this);
slider_layout->addWidget(_slider);
......@@ -72,13 +72,13 @@ chooseMzPrecisionWidget::chooseMzPrecisionWidget(): QWidget()
QWidget * bkg_min_max_window = new QWidget();
bkg_min_max_window->setLayout(bkg_min_max_window_layout);
slider_layout->addWidget(_mass_choose_label);
slider_layout->addWidget(_mass_choose_label);
slider_layout->addWidget(bkg_median_window);
slider_layout->addWidget(bkg_min_max_window);
QWidget * precision_window = new QWidget();
slider_layout->addWidget(bkg_min_max_window);
QWidget * precision_window = new QWidget();
precision_window->setLayout(choose_precision_layout);
slider_layout->addWidget(precision_window);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment