Commit 44fd25a9 authored by Edlira Nano's avatar Edlira Nano
Browse files

xicPlot continued

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2246 e4b6dbb4-9209-464b-83f7-6257456c460c
parent e23ee756
shlibs:Depends=libc6 (>= 2.1.3), libgcc1 (>= 1:4.1.1), libqt4-network (>= 4:4.5.3), libqt4-xml (>= 4:4.5.3), libqt4-xmlpatterns (>= 4:4.5.3), libqtcore4 (>= 4:4.5.3), libqtgui4 (>= 4:4.5.3), libstdc++6 (>= 4.4.0)
shlibs:Depends=libc6 (>= 2.4), libgcc1 (>= 1:4.1.1), libqt4-network (>= 4:4.5.3), libqt4-xml (>= 4:4.5.3), libqt4-xmlpatterns (>= 4:4.5.3), libqtcore4 (>= 4:4.5.3), libqtgui4 (>= 4:4.5.3), libstdc++6 (>= 4.4.0), masschroq
misc:Depends=
/*
*
* 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 gui_utilities.h
* \date November 22, 2011
* \author Edlira Nano
*/
#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)
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;
const PlotStyle OriginalXicStyle(QPen(Qt::black));
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_ */
......@@ -105,7 +105,8 @@ MainWindow::extractXicWidget() {
void
MainWindow::extractXic(XicSelectionWidget * xic) {
_masschroq_gui->extractXicProfile(_current_msrun_file, xic);
XicProfile * original_xic = _masschroq_gui->extractXicProfile(_current_msrun_file, xic);
_xic_profiles->push_back[original_xic];
}
void
......
......@@ -57,4 +57,6 @@ private:
QString _current_msrun_file;
std::vector<XicProfile *> _xic_profiles;
};
#include "xicPlot.h"
XicPlot::XicPlot(QWidget * parent, XicProfile * xic_profile) :
QwtPlot(parent),
_xic_profile(xic_profile)
{
setAutoReplot(false);
connect(_xic_profile, SIGNAL(changed()), this, SLOT(plotXic()));
}
XicPlot::~XicPlot() {
}
void
XicPlot::setStyle(const PlotStyle * style) {
_plot_style = style;
}
void
XicPlot::plotXic() {
this->setStyle(_xic_profile->getStyle());
_curve = new QwtPlotCurve(_plot_style->legend);
// setSamples()
// attach/add à main_window
}
......@@ -19,62 +19,37 @@
*/
/**
* \file xicPlots.h
* \file xicPlot.h
* \date November 08, 2011
* \author Edlira Nano
*/
#ifndef _XICPLOTS_H_
#define _XICPLOTS_H_ 1
#ifndef _XICPLOT_H_
#define _XICPLOT_H_ 1
#include <QwtPlot>
class QwtPlotCurve;
class CurveData {
// A container class for growing data
public:
CurveData();
void append(double * x, double * y, int count);
// int count() const;
int size() const;
const double *x() const;
const double *y() const;
class XicPlot : public QwtPlot {
Q_OBJECT
private:
int d_count;
QwtArray<double> d_x;
QwtArray<double> d_y;
};
public:
XicPlot(QWidget * parent = NULL, XicProfile * xic_profile);
virtual ~XicPlot();
private slots :
class XicPlots: public QwtPlot {
Q_OBJECT
void plotXic();
public:
XicPlots(QWidget * parent = NULL);
virtual ~XicPlots();
void setXic(Msrun & ms_run,
const XicExtractionMethodBase * p_mz_extraction,
//const msRunHashGroup & group,
unsigned int median_window_length,
unsigned int min_max_window_length);
void appendData(double x, double y);
void appendData(double * x, double * y, int size);
void removeData();
private:
void plotXic(const xicBase& the_data, QColor color, QString title);
CurveData * d_data;
QwtPlotCurve * d_curve;
void setStyle(const PlotStyle * style);
XicProfile * _xic_profile;
PlotStyle * _plot_style;
};
#endif // _XICPLOTS_H_
#endif // _XICPLOT_H_
#include "xicplot.h"
CurveData::CurveData() {
}
void CurveData::append(double * x, double * y, int count) {
int newSize = ((d_count + count) / 1000 + 1) * 1000;
if (newSize > size()) {
d_x.resize(newSize);
d_y.resize(newSize);
}
for (register int i = 0; i < count; i++) {
d_x[d_count + i] = x[i];
d_y[d_count + i] = y[i];
}
d_count += count;
}
int CurveData::size() const {
return d_x.size();
}
const double * CurveData::x() const {
return d_x.data();
}
const double * CurveData::y() const {
return d_y.data();
}
XicPlot::XicPlot(QWidget * parent) :
QwtPlot(parent), d_data(NULL), d_curve(NULL) {
setAutoReplot(false);
// enable zooming
_zoomer = new Zoomer(canvas());
_zoomer->setRubberBandPen(QPen(Qt::red, 2, Qt::DotLine));
_zoomer->setTrackerPen(QPen(Qt::red));
}
XicPlot::~XicPlot() {
delete d_data;
}
void xicPlot::appendData(double x, double y) {
appendData(&x, &y, 1);
}
void xicPlot::appendData(double * x, double * y, int size) {
if (d_data == NULL)
d_data = new CurveData;
if (d_curve == NULL) {
d_curve = new QwtPlotCurve("Test Curve");
d_curve->setStyle(QwtPlotCurve::NoCurve);
d_curve->setPaintAttribute(QwtPlotCurve::PaintFiltered);
const QColor &c = Qt::white;
d_curve->setSymbol(QwtSymbol(QwtSymbol::XCross, QBrush(c), QPen(c),
QSize(5, 5)));
d_curve->attach(this);
}
d_data->append(x, y, size);
d_curve->setRawData(d_data->x(), d_data->y(), d_data->size());
#ifdef __GNUC__
#endif
const bool cacheMode = canvas()->testPaintAttribute(
QwtPlotCanvas::PaintCached);
canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
d_curve->draw(d_curve->dataSize() - size, d_curve->dataSize() - 1);
canvas()->setPaintAttribute(QwtPlotCanvas::PaintCached, cacheMode);
}
void xicPlot::removeData() {
clear();
delete d_curve;
d_curve = NULL;
delete d_data;
d_data = NULL;
replot();
}
void xicPlot::setXic(Msrun & ms_run,
const XicExtractionMethodBase * p_mz_extraction,
//const msRunHashGroup & group,
unsigned int median_window_length,
unsigned int min_max_window_length) {
ms_run.prepareSpectraForQuantification(p_mz_extraction);
QuantiItemBase mz_select(*p_mz_extraction);
xicBase * the_xic =
ms_run.extractXic(MAX_XIC_TYPE, &mz_select);
// xicMax the_xic(&ms_run, &mz_select);
QColor couleur;
couleur.setRgb(255, 0, 0);
plotXic(*the_xic, couleur, "xic");
couleur.setRgb(0, 255, 0, 100);
the_xic->applyFilterBackground(median_window_length, min_max_window_length);
plotXic(*the_xic, couleur, "filtered");
ms_run.doneWithSpectra();
//delete the_xic;
}
void
xicPlot::plotXic(const xicBase& the_data, QColor color, QString title) {
cout << "begin xicPlot::plotXic(const xic& the_data, QColor color, Qstring title)"
<< endl;
//_zoomer->rescale();
//dye1
unsigned int channel_number;
//QString dye_name;
//clear();
// 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);
*/
QPen pinceau;
//QColor couleur;
//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);
// finally, refresh the plot
//this->replot();
/**
QwtPlotCurve * curve2 = new QwtPlotCurve("filter");
the_data.filterBackground(1, 30, 60);
couleur.setRgb (0,255, 0 );
pinceau.setColor(couleur);
curve2->setPen(pinceau);
//double x1[plotsize1], y1[plotsize1];
the_data.fill_data_array(x1, y1, plotsize1);
curve2->setData(x1, y1, plotsize1);
curve2->attach(this);
*/
// finally, refresh the plot
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();
}
......@@ -43,4 +43,5 @@ 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);
}
......@@ -42,8 +42,10 @@
*/
class XicProfile {
public :
Q_OBJECT
public :
XicProfile();
......@@ -53,6 +55,10 @@ class XicProfile {
void setIntensityVector(const std::vector<mcq_double> & intensity_v);
Q_SIGNALS :
void changed();
private :
/// XicProfile's retention times (x-axis)
......@@ -62,7 +68,7 @@ class XicProfile {
std::vector<mcq_double> * _intensity_vector;
/// The XIC this profile corresponds to
//xicBase * _xic;
/// xicBase * _xic;
};
......
/**
* \file utilities.cpp
* \date 29 November, 2010
* \date November 29, 2010
* \author Edlira Nano
*/
......
......@@ -49,7 +49,7 @@ mcq_double get_median(constvdoubleit beginit, constvdoubleit endit);
mcq_double get_spike_to_zero(constvdoubleit beginit, constvdoubleit endit);
/**
\class AlgoPlus
\class Utilities
\brief This class implements some calculation algorithms needed by
MassChroQ
*/
......
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