Commit 79eb1427 authored by Edlira Nano's avatar Edlira Nano
Browse files

gui continued

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2248 e4b6dbb4-9209-464b-83f7-6257456c460c
parent 782d1442
/**
* \file filterBackgroundWidget.cpp
* \date November 24, 2011
* \author Edlira Nano
*/
#include "filterBackgroundWidget.h"
#include <QtGui>
FilterBackgroundWidget::FilterBackgroundWidget(QWidget * parent) : QWidget(parent) {
create_parameters();
QPushButton * filterButton = new QPushButton(tr("&Filter"));
extractButton->setDefault(true);
_button_box = new QDialogButtonBox(Qt::Vertical);
_button_box->addButton(filterButton, QDialogButtonBox::AcceptRole);
_button_box->addButton(QDialogButtonBox::Cancel);
connect(_button_box, SIGNAL(accepted()), this, SLOT(filterXic()));
connect(_button_box, SIGNAL(rejected()), this, SLOT(cancel()));
QVBoxLayout * mainLayout = new QVBoxLayout;
setWindowTitle(tr("Filter background XIC noise"));
}
FilterBackgroundWidget::~FilterBackgroundWidget() {
}
void
FilterBackgroundWidget::create_parameters() {
QGridLayout *layout = new QGridLayout;
QLabel * median_label = new QLabel("Median filtering half window");
QSpinBox * median_box = new QSpinBox;
median_box->setMaximum(20);
median_box->setWrapping(true);
median_box->setSingleStep(1);
connect(median_box, SIGNAL(valueChanged(unsigned int)),
this, SLOT(setMedianHalfWindow(unsigned int)));
median_box->setValue(5);
// setMedianHalfWindow(5);
layout->addWidget(median_label, 0, 0);
layout->addWidget(median_box, 0, 1);
QLabel * minmax_label = new QLabel("MinMax filtering half window");
QSpinBox * minmax_box = new QSpinBox;
minmax_box->setMaximum(20);
minmax_box->setWrapping(true);
minmax_box->setSingleStep(1);
connect(minmax_box, SIGNAL(valueChanged(unsigned int)),
this, SLOT(setMinMaxHalfWindow(unsigned int)));
median_box->setValue(5);
// setMinMaxHalfWindow(5);
layout->addWidget(median_label, 1, 0);
layout->addWidget(median_box, 1, 1);
}
void
FilterBackgroundWidget:setMedianHalfWindow(unsigned int i) {
_median_half_window = i;
}
void
FilterBackgroundWidget:setMinMaxHalfWindow(unsigned int i) {
_min_max_half_window = i;
}
void
FilterBackgroundWidget::filterXic() {
}
void
FilterBackgroundWidget::cancel() {
this->close();
this->deleteLater();
}
/*
*
* MassChroQ: Mass Chromatogram Quantification software.
* Copyright (C) 2010 Olivier Langella, Edlira Nano, Benoit Valot, Michel Zivy.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file filterBackgroundWidget.h
* \date November 24, 2011
* \author Edlira Nano
*/
#ifndef FILTER_BACKGROUND_WIDGET_H_
#define FILTER_BACKGROUND_WIDGET_H_ 1
//#include "../mcq_types.h"
class QButtonGroup;
class QGroupBox;
class QDialogButtonBox;
class QAbstractButton;
class XicExtractionMethodBase;
/**
* \class FilterBackgroundWidget
* \brief Xic Filter Background Widget
*
*
*/
class FilterBackgroundWidget : public QWidget {
Q_OBJECT
public :
FilterBackgroundWidget(QWidget * parent = 0);
virtual ~FilterBackgroundWidget();
XicExtractionMethodBase * getXicExtractionMethod() const;
const mcq_xic_type getXicType() const;
const mcq_double getMzToExtract() const;
const mcq_double getRtToExtract() const;
private slots :
void setMedianHalfWindow(const unsigned int i);
void setMinMaxHalfWindow(const unsigned int i);
void filterXic();
void cancel();
signals :
// void extract(XicSelectionWidget *);
protected :
unsigned int _median_half_window;
unsigned int _min_max_half_window;
private :
// void create_xic_type_group();
// void create_xic_range_group();
// void create_mz_group();
// QGroupBox * _xic_type_group;
// QGroupBox * _xic_range_group;
// QGroupBox * _mz_group;
QDialogButtonBox * _button_box;
};
#endif /* FILTER_BACKGROUND_WIDGET_H_ */
......@@ -87,13 +87,14 @@ MainWindow::createActions() {
void
MainWindow::loadMsrun() {
QString filename = QFileDialog::getOpenFileName(this, tr("Open Msrun File"),
QString::null,
tr("mzXML or mzML files (*.mzXML *.mzML)"));
QString::null,
tr("mzXML or mzML files (*.mzXML *.mzML)"));
if (!filename.isEmpty()) {
_current_msrun_file = filename;
_masschroq_gui->setMsRun(filename);
}
cout << "end loading" << endl;
}
......@@ -109,16 +110,16 @@ MainWindow::extractXicWidget() {
void
MainWindow::extractXic(XicSelectionWidget * xic_widget) {
XicProfile * xic_profile = new XicProfile();
connect(xic_profile, SIGNAL(created(XicProfile *)), this, SLOT(plotXic(XicProfile *)));
connect(xic_profile, SIGNAL(created(XicProfile *)), this, SLOT(plotNewXic(XicProfile *)));
_xic_profiles.push_back(xic_profile);
_masschroq_gui->extractXicProfile(xic_profile, _current_msrun_file, xic_widget);
}
void
MainWindow::plotXic(XicProfile * xic_profile) {
XicPlot * plot = new XicPlot("Original Xic", xic_profile);
_plot_area->addPlot(plot);
MainWindow::plotNewXic(XicProfile * xic_profile) {
_plot_area->clear();
_plot_area->addPlot(xic_profile);
}
void
......
......@@ -19,7 +19,7 @@ private slots:
void loadMsrun();
void extractXicWidget();
void extractXic(XicSelectionWidget * xic);
void plotXic(XicProfile * xic_profile);
void plotNewXic(XicProfile * xic_profile);
void filterXic();
void about();
......
......@@ -14,6 +14,7 @@
#include "../lib/xicExtractionMethods/xicExtractionMethodBase.h"
#include "../lib/quanti_items/quantiItemMzRt.h"
#include "../lib/xic/xic_base.h"
#include <QMessageBox>
#include <math.h>
......@@ -30,9 +31,17 @@ MasschroqGui::setMsRun(const QString & filename) {
QFileInfo filenameInfo(filename);
if (! filenameInfo.exists()) {
throw mcqError(QObject::tr("The chosen MSrun file %1, does not exist").arg(filename));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(QObject::tr("The chosen MS run file '%1', does not exist.\nPlease, choose an existing file.").arg(filename));
msgBox.exec();
return;
} else if (! filenameInfo.isReadable()) {
throw mcqError(QObject::tr("The chosen MSrun file %1, is not readable").arg(filename));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(QObject::tr("The chosen MS run file '%1', is not readable.\nPlease, change the read permissions on this file or load another one. ").arg(filename));
msgBox.exec();
return;
}
QString suffix = filenameInfo.suffix();
......@@ -42,7 +51,11 @@ MasschroqGui::setMsRun(const QString & filename) {
} else if (suffix == "mzML") {
format = MZML;
} else {
throw mcqError(QObject::tr("The chosen MSrun file format %1, is not mzXML or mzML format").arg(suffix));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(QObject::tr("You have chosen a file in '.%1' format.\nMS run files must be in '.mzXML' or '.mzML' formats.\nPlease, choose an MS run file in one of these formats.").arg(suffix));
msgBox.exec();
return;
}
mcq_double size_in_bytes = filenameInfo.size();
......@@ -54,8 +67,13 @@ MasschroqGui::setMsRun(const QString & filename) {
<< "' : parsing begin" << endl;
msrun->set_from_xml(filename, format);
this->addMsRun(filename, msrun);
_current_loaded_msrun = msrun;
} catch (mcqError error) {
throw mcqError(QObject::tr("problem creating msrun %1:\n%2").arg(filename, error.what()));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QObject::tr("Problem loading MS run '%1':\n%2").arg(filename, error.what()));
msgBox.exec();
return;
}
} else {
mcq_double nb_of_slices_double = ceil(size_in_bytes/MAX_SLICE_SIZE);
......@@ -69,8 +87,13 @@ MasschroqGui::setMsRun(const QString & filename) {
msrun->set_from_xml(filename, format);
this->addMsRun(filename, msrun);
_current_loaded_msrun = msrun;
} catch (mcqError error) {
throw mcqError(QObject::tr("problem creating msrun %1:\n%2").arg(filename, error.what()));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QObject::tr("Problem loading MS run '%1':\n%2").arg(filename, error.what()));
msgBox.exec();
return;
}
}
}
......@@ -96,10 +119,22 @@ MasschroqGui::extractXicProfile(XicProfile * xic_profile,
const QString & msrun_filename,
XicSelectionWidget * xic) {
Msrun * msrun = getMsRun(msrun_filename);
Msrun * msrun = getMsRun(msrun_filename);
if (msrun == NULL) {
throw mcqError(QObject::tr("The msrun with filename %1, does not exist").arg(msrun_filename));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QObject::tr("The MS run '%1', has not been loaded.\nPlease load an MS run file first.").arg(msrun_filename));
msgBox.exec();
return;
}
if (_current_loaded_msrun != msrun) {
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QObject::tr("The MS run '%1', is not the current working MS run.").arg(msrun_filename));
msgBox.exec();
return;
}
XicExtractionMethodBase * extraction_method = xic->getXicExtractionMethod();
......
......@@ -67,6 +67,8 @@ class MasschroqGui {
std::map<QString, Msrun *> _msrun_map;
Msrun * _current_loaded_msrun;
};
......
......@@ -22,11 +22,41 @@ Plot::Plot(QWidget *parent) :
setAxisTitle(QwtPlot::xBottom, "Retention time (s)");
setAxisTitle(QwtPlot::yLeft, "Intensity");
}
Plot::~Plot() {
std::vector<XicPlot *>::iterator it;
for (it = _xic_plots.begin();
it != _xic_plots.end();
++it) {
if (*it != 0) {
delete (*it);
*it = 0;
}
}
_xic_plots.clear();
}
void
Plot::addPlot(XicPlot * plot) {
Plot::addPlot(XicProfile * xic_profile) {
XicPlot * plot = new XicPlot("", xic_profile);
plot->attach(this);
_xic_plots.push_back(plot);
this->replot();
}
void
Plot::clear() {
std::vector<XicPlot *>::iterator it;
for (it = _xic_plots.begin();
it != _xic_plots.end();
++it) {
if (*it != 0) {
delete (*it);
*it = 0;
}
}
_xic_plots.clear();
replot();
}
......@@ -29,6 +29,7 @@
#include <qwt_plot.h>
class XicProfile;
class XicPlot;
class Plot : public QwtPlot {
......@@ -37,14 +38,20 @@ class Plot : public QwtPlot {
public:
Plot(QWidget * parent);
virtual ~Plot();
void addPlot(XicProfile * plot);
void addPlot(XicPlot * plot);
void clear();
// public Q_SLOTS:
// private:
private:
std::vector<XicPlot *> _xic_plots;
};
......
......@@ -4,9 +4,10 @@
* \author Edlira Nano
*/
#include "xicSelectionWidget.h"
#include <QtGui>
#include "../lib/mcq_error.h"
#include "xicSelectionWidget.h"
#include "../lib/xicExtractionMethods/xicExtractionMethodMzRange.h"
#include "../lib/xicExtractionMethods/xicExtractionMethodPpmRange.h"
......
......@@ -27,7 +27,6 @@
#ifndef XIC_SELECTION_WIDGET_H_
#define XIC_SELECTION_WIDGET_H_ 1
#include <QDialog>
#include "../mcq_types.h"
class QButtonGroup;
......
......@@ -132,10 +132,8 @@ xicPlot::plotXic(const xicBase& the_data, QColor color, QString title) {
// DYE 1
//dye_name = the_data.get_dye_name(channel_number).c_str();
channel_number = 1;
cout << "Yo 1" << endl;
unsigned int plotsize1(the_data.size());
QwtPlotCurve * curve1 = new QwtPlotCurve("c1");
cout << "Yo 2" << endl;
/*
QwtPlotCurve *curve1 = new QwtPlotCurve(dye_name);
*/
......@@ -145,13 +143,13 @@ xicPlot::plotXic(const xicBase& the_data, QColor color, QString title) {
//cout << endl << "wavelength" << the_data.get_wavelength(channel_number) << endl;
//couleur.setRgb (255,0, 0 );
pinceau.setColor(color);
curve1->setPen(pinceau);
double x1[plotsize1], y1[plotsize1];
cout << "Yo 3" << endl;
the_data.fill_data_array(x1, y1, plotsize1);
cout << "Yo 4" << endl;
curve1->setData(x1, y1, plotsize1);
curve1->attach(this);
curve1->setPen(pinceau);
double x1[plotsize1], y1[plotsize1];
cout << "Yo 3" << endl;
the_data.fill_data_array(x1, y1, plotsize1);
cout << "Yo 4" << endl;
curve1->setData(x1, y1, plotsize1);
curve1->attach(this);
// finally, refresh the plot
//this->replot();
......@@ -168,19 +166,19 @@ xicPlot::plotXic(const xicBase& the_data, QColor color, QString title) {
*/
// finally, refresh the plot
setAxisAutoScale ( yLeft);
setAxisAutoScale ( yRight);
setAxisAutoScale ( xBottom);
setAxisAutoScale ( xTop);
cout << "Yo 5" << endl;
this->replot();
setAxisAutoScale ( yLeft);
setAxisAutoScale ( yRight);
setAxisAutoScale ( xBottom);
setAxisAutoScale ( xTop);
cout << "Yo 5" << endl;
this->replot();
cout << "Yo 6" << endl;
delete _zoomer;
_zoomer = new Zoomer(canvas());
_zoomer->setRubberBandPen(QPen(Qt::red, 2, Qt::DotLine));
_zoomer->setTrackerPen(QPen(Qt::red));
_zoomer->rescale();
cout << "Yo 6" << endl;
delete _zoomer;
_zoomer = new Zoomer(canvas());
_zoomer->setRubberBandPen(QPen(Qt::red, 2, Qt::DotLine));
_zoomer->setTrackerPen(QPen(Qt::red));
}
_zoomer->rescale();
}
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