Commit 782d1442 authored by Edlira Nano's avatar Edlira Nano
Browse files

plots available

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2247 e4b6dbb4-9209-464b-83f7-6257456c460c
parent 44fd25a9
...@@ -131,14 +131,22 @@ SET(GUI_SRCS ...@@ -131,14 +131,22 @@ SET(GUI_SRCS
./gui/mainwindow.cpp ./gui/mainwindow.cpp
./gui/masschroq_gui.cpp ./gui/masschroq_gui.cpp
./gui/xicSelectionWidget.cpp ./gui/xicSelectionWidget.cpp
./gui/plotStyle.cpp
./gui/xicProfile.cpp ./gui/xicProfile.cpp
./gui/xicPlot.cpp
./gui/plot.cpp
) )
# another list, this time it includes all header files that should be treated with moc # another list, this time it includes all header files that should be treated with moc
SET(GUI_MOC_HDRS SET(GUI_MOC_HDRS
./gui/plotStyle.h
./gui/gui_types.h
./gui/mainwindow.h ./gui/mainwindow.h
./gui/xicSelectionWidget.h ./gui/xicSelectionWidget.h
./gui/xicProfile.h ./gui/xicProfile.h
./gui/xicPlot.h
./gui/plot.h
) )
set(CMAKE_MODULE_PATH ${masschroq_SOURCE_DIR}/modules) set(CMAKE_MODULE_PATH ${masschroq_SOURCE_DIR}/modules)
......
...@@ -17,35 +17,22 @@ ...@@ -17,35 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
/** /**
* \file gui_utilities.h * \file gui_types.h
* \date November 22, 2011 * \date November 23, 2011
* \author Edlira Nano * \author Edlira Nano
* \brief This header contains all the type re-definitions and all
* the global variables definitions used in MassChroQ GUI.
*/ */
#ifndef GUI_UTILITIES_H_
#define GUI_UTILITIES_H_ 1
typedef struct { #ifndef _GUI_TYPES_H_
QPen pen; #define _GUI_TYPES_H_ 1
QwtPlotCurve::CurveStyle style; // setStyle(QwtPlotCurve::Lines)
QwtPlotCurve::RenderHint render; // setRenderHint(QwtPlotItem::RenderAntialiased) #include "plotStyle.h"
QwtPlotCurve::LegendAttribute legend; // setLegendAttribute(QwtPlotCurve::LegendShowLine, on)
PlotStyle(QPen p,
QwtPlotCurve::CurveStyle s = QwtPlotCurve::Lines,
QwtPlotCurve::RenderHint r = QwtPlotItem::RenderAntialiased,
QwtPlotCurve::LegendAttribute l = QwtPlotCurve::LegendShowLine)
: pen(p),
style(s),
render(r),
legend(l)
{
}
} PlotStyle;
/*********** Global variables definitions*********************************/
const PlotStyle OriginalXicStyle(QPen(Qt::black)); const PlotStyle OriginalXicStyle(QPen(Qt::black));
...@@ -53,22 +40,4 @@ const PlotStyle FilterBackgroundStyle(QPen(Qt::green)); ...@@ -53,22 +40,4 @@ const PlotStyle FilterBackgroundStyle(QPen(Qt::green));
const PlotStyle FilterSpikeStyle(QPen(Qt::blue)); const PlotStyle FilterSpikeStyle(QPen(Qt::blue));
#endif /* _GUI_TYPES_H_ */
/**
\class GuiUtilities
\brief This class implements some calculation algorithms needed by
the MassChroQ Gui
*/
class GuiUtilities {
private :
GuiUtilities();
virtual ~GuiUtilities();
public :
};
#endif /* GUI_UTILITIES_H_ */
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "xicSelectionWidget.h" #include "xicSelectionWidget.h"
#include "xicProfile.h"
#include "xicPlot.h"
MainWindow::MainWindow(QWidget *parent) MainWindow::MainWindow(QWidget *parent)
...@@ -16,8 +19,8 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -16,8 +19,8 @@ MainWindow::MainWindow(QWidget *parent)
// Central Widget // Central Widget
QWidget * widget = new QWidget(); _plot_area = new Plot(this);
setCentralWidget(widget); setCentralWidget(_plot_area);
//_plot = new XicPlot(this); //_plot = new XicPlot(this);
//const int margin = 4; //const int margin = 4;
...@@ -104,9 +107,18 @@ MainWindow::extractXicWidget() { ...@@ -104,9 +107,18 @@ MainWindow::extractXicWidget() {
} }
void void
MainWindow::extractXic(XicSelectionWidget * xic) { MainWindow::extractXic(XicSelectionWidget * xic_widget) {
XicProfile * original_xic = _masschroq_gui->extractXicProfile(_current_msrun_file, xic); XicProfile * xic_profile = new XicProfile();
_xic_profiles->push_back[original_xic]; connect(xic_profile, SIGNAL(created(XicProfile *)), this, SLOT(plotXic(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);
} }
void void
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <QAction> #include <QAction>
#include "masschroq_gui.h" #include "masschroq_gui.h"
#include "plot.h"
class MainWindow : public QMainWindow class MainWindow : public QMainWindow
{ {
...@@ -18,6 +19,7 @@ private slots: ...@@ -18,6 +19,7 @@ private slots:
void loadMsrun(); void loadMsrun();
void extractXicWidget(); void extractXicWidget();
void extractXic(XicSelectionWidget * xic); void extractXic(XicSelectionWidget * xic);
void plotXic(XicProfile * xic_profile);
void filterXic(); void filterXic();
void about(); void about();
...@@ -28,20 +30,21 @@ protected: ...@@ -28,20 +30,21 @@ protected:
private: private:
void createActions(); void createActions();
void createMenus(); void createMenus();
//createToolbars(); //createToolbars();
//createStatusBar(); //createStatusBar();
//createDockWindows(); //createDockWindows();
//Plot * _plot;
//QListWidget * filtersList; //QListWidget * filtersList;
//QListWidget * quantiItemsList; //QListWidget * quantiItemsList;
MasschroqGui * _masschroq_gui; MasschroqGui * _masschroq_gui;
Plot * _plot_area;
QMenu * _fileMenu; QMenu * _fileMenu;
QMenu * _toolsMenu; QMenu * _toolsMenu;
QMenu * _helpMenu; QMenu * _helpMenu;
......
...@@ -91,46 +91,39 @@ MasschroqGui::getMsRun(const QString & filename) const { ...@@ -91,46 +91,39 @@ MasschroqGui::getMsRun(const QString & filename) const {
} }
} }
XicProfile * void
MasschroqGui::extractXicProfile(const QString & msrun_filename, XicSelectionWidget * xic) { MasschroqGui::extractXicProfile(XicProfile * xic_profile,
qDebug() << "Yo 1" << endl; const QString & msrun_filename,
XicSelectionWidget * xic) {
Msrun * msrun = getMsRun(msrun_filename); Msrun * msrun = getMsRun(msrun_filename);
if (msrun == NULL) { if (msrun == NULL) {
throw mcqError(QObject::tr("The msrun with filename %1, does not exist").arg(msrun_filename)); throw mcqError(QObject::tr("The msrun with filename %1, does not exist").arg(msrun_filename));
} }
qDebug() << "Yo 2" << endl;
if (xic == NULL)
qDebug() << "Null" << endl;
XicExtractionMethodBase * extraction_method = xic->getXicExtractionMethod(); XicExtractionMethodBase * extraction_method = xic->getXicExtractionMethod();
qDebug() << "Yo 3" << endl;
mcq_xic_type xic_type = xic->getXicType(); mcq_xic_type xic_type = xic->getXicType();
mcq_double mz_value = xic->getMzToExtract(); mcq_double mz_value = xic->getMzToExtract();
mcq_double rt_value = xic->getRtToExtract(); mcq_double rt_value = xic->getRtToExtract();
qDebug() << "Yo 3" << endl;
extraction_method->setMz(mz_value); extraction_method->setMz(mz_value);
qDebug() << "Yo 4" << endl;
QuantiItemBase * quanti_item; QuantiItemBase * quanti_item;
if (rt_value != 0) { if (rt_value != 0) {
quanti_item = new QuantiItemMzRt(*extraction_method, rt_value); quanti_item = new QuantiItemMzRt(*extraction_method, rt_value);
} else { } else {
quanti_item = new QuantiItemBase(*extraction_method); quanti_item = new QuantiItemBase(*extraction_method);
} }
// extract XIC // extract XIC
qDebug() << "Yo 3" << endl;
msrun->prepareSpectraForQuantification(extraction_method); msrun->prepareSpectraForQuantification(extraction_method);
xicBase * current_xic = msrun->extractXic(xic_type, quanti_item); xicBase * current_xic = msrun->extractXic(xic_type, quanti_item);
qDebug() << "Yo 4" << endl;
if (current_xic == 0) { if (current_xic == 0) {
qDebug() << "MsrunSelectionXic null xic "; qDebug() << "MsrunSelectionXic null xic ";
} }
qDebug() << "Yo 5" << endl;
XicProfile * xic_profile = new XicProfile();
xic_profile->setRtVector(*(current_xic->getRetentionTimes()));
xic_profile->setIntensityVector(*(current_xic->getIntensities()));
qDebug() << "Yo 6" << endl;
delete (current_xic);
msrun->doneWithSpectra();
return xic_profile; xic_profile->setOriginalXic( *(current_xic->getRetentionTimes()),
*(current_xic->getIntensities()) );
delete (current_xic);
msrun->doneWithSpectra();
} }
...@@ -56,7 +56,9 @@ class MasschroqGui { ...@@ -56,7 +56,9 @@ class MasschroqGui {
/// creates and sets an msrun /// creates and sets an msrun
void setMsRun(const QString & filename); void setMsRun(const QString & filename);
XicProfile * extractXicProfile(const QString & msrun_filename, XicSelectionWidget * xic); void extractXicProfile(XicProfile * xic_profile,
const QString & msrun_filename,
XicSelectionWidget * xic);
private : private :
......
/**
* \file plot.cpp
* \date November 23, 2011
* \author Edlira Nano
*/
#include "plot.h"
#include "xicPlot.h"
#include <qwt_legend.h>
Plot::Plot(QWidget *parent) :
QwtPlot(parent) {
setAutoReplot(false);
setTitle("Xic Plots");
// legend
QwtLegend * legend = new QwtLegend;
insertLegend(legend, QwtPlot::BottomLegend);
setAxisTitle(QwtPlot::xBottom, "Retention time (s)");
setAxisTitle(QwtPlot::yLeft, "Intensity");
}
void
Plot::addPlot(XicPlot * plot) {
plot->attach(this);
this->replot();
}
/*
*
* 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 plot.h
* \date November 23, 2011
* \author Edlira Nano
*/
#ifndef _PLOT_H_
#define _PLOT_H_ 1
#include <qwt_plot.h>
class XicPlot;
class Plot : public QwtPlot {
Q_OBJECT
public:
Plot(QWidget * parent);
void addPlot(XicPlot * plot);
// public Q_SLOTS:
// private:
};
#endif // _PLOT_H_
/**
* \file plotStyle.cpp
* \date November 22, 2011
* \author Edlira Nano
*/
#include "plotStyle.h"
PlotStyle::PlotStyle(QPen pen, bool lines, bool render)
:
_pen(pen),
_lines(lines),
_render_antialiased(render)
{
}
PlotStyle::~PlotStyle() {
}
/*
*
* 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 plotStyle.h
* \date November 22, 2011
* \author Edlira Nano
*/
#ifndef _PLOT_STYLE_H_
#define _PLOT_STYLE_H_ 1
#include <QPen>
/**
\class PlotStyle
\brief
*/
class PlotStyle {
public :
PlotStyle(QPen pen, bool lines = true, bool render = true);
virtual ~PlotStyle();
QPen _pen;
bool _lines; // setStyle(QwtPlotCurve::Lines)
bool _render_antialiased; // setRenderHint(QwtPlotItem::RenderAntialiased)
};
#endif /* _PLOT_STYLE_H_ */
/**
* \file xicPlot.cpp
* \date November 22, 2011
* \author Edlira Nano
*/
#include "xicPlot.h" #include "xicPlot.h"
XicPlot::XicPlot(QWidget * parent, XicProfile * xic_profile) : XicPlot::XicPlot(const QString & title, XicProfile * xic_profile) :
QwtPlot(parent), QwtPlotCurve(title),
_xic_profile(xic_profile) _xic_profile(xic_profile)
{ {
setAutoReplot(false); setPlotStyle(_xic_profile->getStyle());
connect(_xic_profile, SIGNAL(changed()), this, SLOT(plotXic())); setPlotData();
} }
XicPlot::~XicPlot() { XicPlot::~XicPlot() {
} }
void void
XicPlot::setStyle(const PlotStyle * style) { XicPlot::setPlotStyle(PlotStyle * style) {
_plot_style = style; _plot_style = style;
this->setPen(_plot_style->_pen);
if (_plot_style->_lines) {
this->setStyle(QwtPlotCurve::Lines);
}
if (_plot_style->_render_antialiased) {
this->setRenderHint(QwtPlotItem::RenderAntialiased);
}
} }
void void
XicPlot::plotXic() { XicPlot::setPlotData() {
this->setStyle(_xic_profile->getStyle()); unsigned int plotsize(_xic_profile->size());
_curve = new QwtPlotCurve(_plot_style->legend); mcq_double x1[plotsize], y1[plotsize];
// setSamples() _xic_profile->fill_data_array(x1, y1, plotsize);
// attach/add à main_window this->setData(x1, y1, plotsize);
} }
...@@ -20,32 +20,30 @@ ...@@ -20,32 +20,30 @@
/** /**
* \file xicPlot.h * \file xicPlot.h
* \date November 08, 2011 * \date November 22, 2011
* \author Edlira Nano * \author Edlira Nano
*/ */
#ifndef _XICPLOT_H_ #ifndef _XICPLOT_H_
#define _XICPLOT_H_ 1 #define _XICPLOT_H_ 1
#include <QwtPlot> #include <qwt_plot_curve.h>
#include "xicProfile.h"
//#include "plotStyle.h"
class QwtPlotCurve;
class XicPlot : public QwtPlot { class XicPlot : public QwtPlotCurve {
Q_OBJECT
public:
public:
XicPlot(QWidget * parent = NULL, XicProfile * xic_profile);
virtual ~XicPlot();
private slots : XicPlot(const QString & title, XicProfile * xic_profile);
virtual ~XicPlot();
void plotXic();
private: private:
void setStyle(const PlotStyle * style); void setPlotData();
void setPlotStyle(PlotStyle * style);
XicProfile * _xic_profile; XicProfile * _xic_profile;
PlotStyle * _plot_style; PlotStyle * _plot_style;
......
...@@ -5,14 +5,21 @@ ...@@ -5,14 +5,21 @@
*/ */
#include "xicProfile.h" #include "xicProfile.h"
#include "gui_types.h"
#include <iostream> #include <iostream>
XicProfile::XicProfile() {