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
./gui/mainwindow.cpp
./gui/masschroq_gui.cpp
./gui/xicSelectionWidget.cpp
./gui/plotStyle.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
SET(GUI_MOC_HDRS
./gui/plotStyle.h
./gui/gui_types.h
./gui/mainwindow.h
./gui/xicSelectionWidget.h
./gui/xicProfile.h
./gui/xicPlot.h
./gui/plot.h
)
set(CMAKE_MODULE_PATH ${masschroq_SOURCE_DIR}/modules)
......
......@@ -17,35 +17,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* \file gui_utilities.h
* \date November 22, 2011
* \file gui_types.h
* \date November 23, 2011
* \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 {
QPen pen;
QwtPlotCurve::CurveStyle style; // setStyle(QwtPlotCurve::Lines)
QwtPlotCurve::RenderHint render; // setRenderHint(QwtPlotItem::RenderAntialiased)
QwtPlotCurve::LegendAttribute legend; // setLegendAttribute(QwtPlotCurve::LegendShowLine, on)
#ifndef _GUI_TYPES_H_
#define _GUI_TYPES_H_ 1
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)
{
}
#include "plotStyle.h"
} PlotStyle;
/*********** Global variables definitions*********************************/
const PlotStyle OriginalXicStyle(QPen(Qt::black));
......@@ -53,22 +40,4 @@ const PlotStyle FilterBackgroundStyle(QPen(Qt::green));
const PlotStyle FilterSpikeStyle(QPen(Qt::blue));
/**
\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_ */
#endif /* _GUI_TYPES_H_ */
......@@ -5,6 +5,9 @@
#include "mainwindow.h"
#include "xicSelectionWidget.h"
#include "xicProfile.h"
#include "xicPlot.h"
MainWindow::MainWindow(QWidget *parent)
......@@ -16,8 +19,8 @@ MainWindow::MainWindow(QWidget *parent)
// Central Widget
QWidget * widget = new QWidget();
setCentralWidget(widget);
_plot_area = new Plot(this);
setCentralWidget(_plot_area);
//_plot = new XicPlot(this);
//const int margin = 4;
......@@ -104,9 +107,18 @@ MainWindow::extractXicWidget() {
}
void
MainWindow::extractXic(XicSelectionWidget * xic) {
XicProfile * original_xic = _masschroq_gui->extractXicProfile(_current_msrun_file, xic);
_xic_profiles->push_back[original_xic];
MainWindow::extractXic(XicSelectionWidget * xic_widget) {
XicProfile * xic_profile = new XicProfile();
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
......
......@@ -4,6 +4,7 @@
#include <QAction>
#include "masschroq_gui.h"
#include "plot.h"
class MainWindow : public QMainWindow
{
......@@ -18,6 +19,7 @@ private slots:
void loadMsrun();
void extractXicWidget();
void extractXic(XicSelectionWidget * xic);
void plotXic(XicProfile * xic_profile);
void filterXic();
void about();
......@@ -35,13 +37,14 @@ private:
//createStatusBar();
//createDockWindows();
//Plot * _plot;
//QListWidget * filtersList;
//QListWidget * quantiItemsList;
MasschroqGui * _masschroq_gui;
Plot * _plot_area;
QMenu * _fileMenu;
QMenu * _toolsMenu;
QMenu * _helpMenu;
......
......@@ -91,46 +91,39 @@ MasschroqGui::getMsRun(const QString & filename) const {
}
}
XicProfile *
MasschroqGui::extractXicProfile(const QString & msrun_filename, XicSelectionWidget * xic) {
qDebug() << "Yo 1" << endl;
void
MasschroqGui::extractXicProfile(XicProfile * xic_profile,
const QString & msrun_filename,
XicSelectionWidget * xic) {
Msrun * msrun = getMsRun(msrun_filename);
if (msrun == NULL) {
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();
qDebug() << "Yo 3" << endl;
mcq_xic_type xic_type = xic->getXicType();
mcq_double mz_value = xic->getMzToExtract();
mcq_double rt_value = xic->getRtToExtract();
qDebug() << "Yo 3" << endl;
extraction_method->setMz(mz_value);
qDebug() << "Yo 4" << endl;
QuantiItemBase * quanti_item;
if (rt_value != 0) {
quanti_item = new QuantiItemMzRt(*extraction_method, rt_value);
} else {
quanti_item = new QuantiItemBase(*extraction_method);
}
// extract XIC
qDebug() << "Yo 3" << endl;
msrun->prepareSpectraForQuantification(extraction_method);
xicBase * current_xic = msrun->extractXic(xic_type, quanti_item);
qDebug() << "Yo 4" << endl;
if (current_xic == 0) {
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 {
/// creates and sets an msrun
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 :
......
/**
* \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"
XicPlot::XicPlot(QWidget * parent, XicProfile * xic_profile) :
QwtPlot(parent),
XicPlot::XicPlot(const QString & title, XicProfile * xic_profile) :
QwtPlotCurve(title),
_xic_profile(xic_profile)
{
setAutoReplot(false);
connect(_xic_profile, SIGNAL(changed()), this, SLOT(plotXic()));
setPlotStyle(_xic_profile->getStyle());
setPlotData();
}
XicPlot::~XicPlot() {
}
void
XicPlot::setStyle(const PlotStyle * style) {
XicPlot::setPlotStyle(PlotStyle * 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
XicPlot::plotXic() {
this->setStyle(_xic_profile->getStyle());
_curve = new QwtPlotCurve(_plot_style->legend);
// setSamples()
// attach/add à main_window
XicPlot::setPlotData() {
unsigned int plotsize(_xic_profile->size());
mcq_double x1[plotsize], y1[plotsize];
_xic_profile->fill_data_array(x1, y1, plotsize);
this->setData(x1, y1, plotsize);
}
......@@ -20,32 +20,30 @@
/**
* \file xicPlot.h
* \date November 08, 2011
* \date November 22, 2011
* \author Edlira Nano
*/
#ifndef _XICPLOT_H_
#define _XICPLOT_H_ 1
#include <QwtPlot>
#include <qwt_plot_curve.h>
#include "xicProfile.h"
//#include "plotStyle.h"
class QwtPlotCurve;
class XicPlot : public QwtPlot {
Q_OBJECT
class XicPlot : public QwtPlotCurve {
public:
public:
XicPlot(QWidget * parent = NULL, XicProfile * xic_profile);
XicPlot(const QString & title, XicProfile * xic_profile);
virtual ~XicPlot();
private slots :
void plotXic();
private:
void setStyle(const PlotStyle * style);
void setPlotData();
void setPlotStyle(PlotStyle * style);
XicProfile * _xic_profile;
PlotStyle * _plot_style;
......
......@@ -5,14 +5,21 @@
*/
#include "xicProfile.h"
#include "gui_types.h"
#include <iostream>
XicProfile::XicProfile() {
XicProfile::XicProfile(QObject * parent)
: QObject(parent)
{
_rt_vector = new std::vector<mcq_double>;
_intensity_vector = new std::vector<mcq_double>;
_plot_style = new PlotStyle(QPen(Qt::black));
}
XicProfile::~XicProfile() {
delete _plot_style;
if (_rt_vector != 0) {
delete _rt_vector;
_rt_vector = 0;
......@@ -23,8 +30,20 @@ XicProfile::~XicProfile() {
}
}
void
XicProfile::setOriginalXic(const std::vector<mcq_double> & rt_v,
const std::vector<mcq_double> & intensity_v) {
setRtVector(rt_v);
setIntensityVector(intensity_v);
setStyle(OriginalXicStyle);
Q_EMIT created(this);
}
void
XicProfile::setRtVector(const std::vector<mcq_double> & rt_v) {
_rt_vector->clear();
std::vector<mcq_double>::const_iterator it_rt;
for (it_rt = rt_v.begin();
it_rt != rt_v.end();
......@@ -36,6 +55,8 @@ XicProfile::setRtVector(const std::vector<mcq_double> & rt_v) {
void
XicProfile::setIntensityVector(const std::vector<mcq_double> & intensity_v) {
_intensity_vector->clear();
std::vector<mcq_double>::const_iterator it_int;
for (it_int = intensity_v.begin();
it_int != intensity_v.end();
......@@ -43,5 +64,48 @@ XicProfile::setIntensityVector(const std::vector<mcq_double> & intensity_v) {
_intensity_vector->push_back(*it_int);
std::cout << "int : " << *it_int << std::endl;
}
Q_EMIT created(this);
}
const std::vector<mcq_double> *
XicProfile::getRtVector() const {
return _rt_vector;
}
const std::vector<mcq_double> *
XicProfile::getIntensityVector() const {
return _intensity_vector;
}
void
XicProfile::setStyle(const PlotStyle & plot_style) {
*_plot_style = plot_style;
}
PlotStyle *
XicProfile::getStyle() const {
return _plot_style;
}
void
XicProfile::fill_data_array(mcq_double * xdata,
mcq_double * ydata,
unsigned int plotsize) const {
std::vector<mcq_double>::const_iterator itrt;
std::vector<mcq_double>::const_iterator itint;
unsigned int i;
/// _p_v_rt and _p_v_intensity have the same size
for (itrt = _rt_vector->begin(), itint = _intensity_vector->begin(), i = 0;
itrt != _rt_vector->end() || itint != _intensity_vector->end();
++itrt, ++itint, ++i)
{
xdata[i] = *itrt;
ydata[i] = *itint;
}
}
unsigned int
XicProfile::size() const {
return _rt_vector->size();
}
......@@ -28,7 +28,9 @@
#define XIC_PROFILE_H_ 1
#include <vector>
#include "../mcq_types.h"
#include "plotStyle.h"
//class xicBase;
......@@ -41,32 +43,50 @@
* an original unaltered XIC or a filtered XIC.
*/
class XicProfile {
class XicProfile : public QObject {
Q_OBJECT
public :
XicProfile();
XicProfile(QObject * parent = 0);
virtual ~XicProfile();
void setRtVector(const std::vector<mcq_double> & rt_v);
void setOriginalXic(const std::vector<mcq_double