Commit df4cf3fd authored by Langella Olivier's avatar Langella Olivier
Browse files

introducing qcustomplot in masschroq studio

parent e2303bab
......@@ -9,11 +9,13 @@ if (MINGW32)
INCLUDE_DIRECTORIES( ${Qwt6_INCLUDE_DIR} )
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Xml XmlPatterns Widgets Concurrent REQUIRED )
ELSE (MINGW32)
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Xml XmlPatterns Widgets Concurrent REQUIRED )
FIND_PACKAGE( Qt5 COMPONENTS Core Gui Xml XmlPatterns Widgets Concurrent PrintSupport REQUIRED )
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
FIND_PACKAGE( Qwt6 REQUIRED )
endif (MINGW32)
FIND_PACKAGE( QCustomPlot REQUIRED )
if (NOT ODSSTREAM_INCLUDE_DIR)
FIND_PACKAGE( Odsstream REQUIRED )
endif (NOT ODSSTREAM_INCLUDE_DIR)
......@@ -285,7 +287,7 @@ ELSE (MINGW32)
ADD_LIBRARY(${MASSCHROQ_LIB_NAME} SHARED ${MASSCHROQ_LIB_SRCS} ${MASSCHROQ_LIB_MOC_SRCS}
${SAXLIB_SRCS} ${OBIWARP_SRCS} ${MASSCHROQ_RCC_SRCS_QT5})
TARGET_LINK_LIBRARIES(${MASSCHROQ_LIB_NAME} Qt5::Core Qt5::Gui Qt5::Xml Qt5::XmlPatterns Qt5::Concurrent ${PAPPSOMSPP_QT5_LIBRARY} ${ODSSTREAM_QT5_LIBRARY})
TARGET_LINK_LIBRARIES(${MASSCHROQ_LIB_NAME} Qt5::Core Qt5::Gui Qt5::Xml Qt5::XmlPatterns Qt5::Concurrent ${PAPPSOMSPP_QT5_LIBRARY} ${ODSSTREAM_QT5_LIBRARY} )
target_include_directories (${MASSCHROQ_LIB_NAME} PUBLIC ${Qt5Core_INCLUDES} ${Qt5Concurrent_INCLUDES} ${Qt5Gui_INCLUDES} ${Qt5Xml_INCLUDES} ${Qt5XmlPatterns_INCLUDES})
SET_TARGET_PROPERTIES(${MASSCHROQ_LIB_NAME} PROPERTIES
VERSION ${MASSCHROQ_LIB_VERSION}
......@@ -313,7 +315,7 @@ ELSE (MINGW32)
ELSE (NOQWT)
MESSAGE("Qwt6_Qt5_LIBRARY:${Qwt6_Qt5_LIBRARY}")
ADD_EXECUTABLE(masschroq_studio gui/parameterGui.cpp ${STUDIO_SRCS} ${STUDIO_MOC_SRCS})
TARGET_LINK_LIBRARIES(masschroq_studio ${MASSCHROQ_LIB_NAME} Qt5::Core Qt5::Gui Qt5::Widgets ${Qwt6_Qt5_LIBRARY} ${PAPPSOMSPP_QT5_LIBRARY} ${ODSSTREAM_QT5_LIBRARY})
TARGET_LINK_LIBRARIES(masschroq_studio ${MASSCHROQ_LIB_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::PrintSupport ${Qwt6_Qt5_LIBRARY} ${PAPPSOMSPP_QT5_LIBRARY} ${ODSSTREAM_QT5_LIBRARY} ${QCustomPlot_LIBRARIES})
target_include_directories (masschroq_studio PUBLIC ${Qt5Core_INCLUDES} ${Qt5Concurrent_INCLUDES} ${Qt5Gui_INCLUDES} ${Qt5Xml_INCLUDES} ${Qt5XmlPatterns_INCLUDES} ${Qwt6_INCLUDE_DIR})
ENDIF (NOQWT)
......
......@@ -5,181 +5,163 @@
*/
#include "plot_aligned.h"
#include <qwt_legend.h>
#include <qwt_symbol.h>
PlotAligned::PlotAligned(QWidget *parent) :
QwtPlot(parent) {
QCustomPlot(parent) {
setAutoReplot(false);
setTitle("");
// legend
QwtLegend * legend = new QwtLegend;
insertLegend(legend, QwtPlot::BottomLegend);
setAxisTitle(QwtPlot::xBottom, "Retention time (s)");
setAxisTitle(QwtPlot::yLeft, "Delta RT (s)");
// enable zooming
_zoomer = nullptr;
_p_curve_deltart = new QwtPlotCurve("Aligned RT");
_p_curve_ms2 = new QwtPlotCurve("Common identification");
xAxis->setLabel("Retention time (s)");
yAxis->setLabel("Delta RT (s)");
}
PlotAligned::~PlotAligned() {
this->clear();
if (_zoomer != nullptr) {
delete _zoomer;
_zoomer = nullptr;
}
this->clear();
}
void PlotAligned::viewAlignedMsRun(const Msrun * msrun) {
qDebug() << "PlotAligned::viewAlignedMsRun begin";
const std::vector<mcq_double> originalRt =
msrun->getOriginalRetentionTimes();
const std::vector<mcq_double> alignedRt = msrun->getAlignedRetentionTimes();
if (originalRt.size() == alignedRt.size()) {
std::vector<mcq_double>::const_iterator itOriginal = originalRt.begin();
std::vector<mcq_double>::const_iterator itAligned = alignedRt.begin();
//QwtPlotCurve * curve = new QwtPlotCurve("Aligned RT");
_p_curve_deltart->setStyle(QwtPlotCurve::Lines);
_p_curve_deltart->setRenderHint(QwtPlotItem::RenderAntialiased);
_p_curve_deltart->setPen(QColor(Qt::blue));
//_alignedPlots.push_back(curve);
unsigned int plotsize(alignedRt.size());
mcq_double x1[plotsize], y1[plotsize];
int i = 0;
for (; itOriginal != originalRt.end(); ++itOriginal, ++itAligned) {
y1[i] = (*itOriginal) - (*itAligned);
x1[i] = (*itOriginal);
i++;
}
_p_curve_deltart->setSamples(x1, y1, plotsize);
_p_curve_deltart->attach(this);
this->setTitle(
tr("Alignment of '%1'").arg(
msrun->getXmlFileInfo().fileName()));
this->replot();
initZoomer();
}
qDebug() << "PlotAligned::viewAlignedMsRun end";
qDebug() << "PlotAligned::viewAlignedMsRun begin";
const std::vector<mcq_double> originalRt =
msrun->getOriginalRetentionTimes();
const std::vector<mcq_double> alignedRt = msrun->getAlignedRetentionTimes();
if (originalRt.size() == alignedRt.size()) {
std::vector<mcq_double>::const_iterator itOriginal = originalRt.begin();
std::vector<mcq_double>::const_iterator itAligned = alignedRt.begin();
unsigned int plotsize(alignedRt.size());
int i = 0;
addGraph();
QPen pen;
pen.setColor(QColor(Qt::blue));
graph()->setPen(pen);
//graph()->setName(lineNames.at(i-QCPGraph::lsNone));
//graph()->setLineStyle((QCPGraph::LineStyle)i);
graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 5));
// generate data:
QVector<double> x(plotsize), y(plotsize);
for (; itOriginal != originalRt.end(); ++itOriginal, ++itAligned)
{
x[i] = (*itOriginal) - (*itAligned);
y[i] = (*itOriginal);
i++;
}
graph()->setData(x, y);
graph()->rescaleAxes(true);
}
qDebug() << "PlotAligned::viewAlignedMsRun end";
}
void PlotAligned::viewAlignedMS2Peaks(const MonitorAlignmentPlot * monitorAlignment) {
qDebug() << "PlotAligned::viewAlignedMS2Peaks begin";
if(monitorAlignment==0)
return;
if(monitorAlignment==0)
return;
qDebug() << "View Ms2 point";
qDebug() << "View Ms2 point";
/*
_p_curve_ms2->detach();
delete (_p_curve_ms2);
_p_curve_ms2 = nullptr;
this->QwtPlot::replot();
initZoomer();
initZoomer();
//delete _p_curve_ms2;
_p_curve_ms2 = new QwtPlotCurve("Common identification");
_p_curve_ms2 = new QwtPlotCurve("Common identification");
_p_curve_ms2->attach(this);
//QwtPlotCurve * curve = new QwtPlotCurve("Common identification");
_p_curve_ms2->setStyle(QwtPlotCurve::Dots);
_p_curve_ms2->setRenderHint(QwtPlotItem::RenderAntialiased);
_p_curve_ms2->setSymbol(new QwtSymbol(QwtSymbol::Star2, QColor(Qt::black), QColor(Qt::black),
QSize(9, 9)));
//_alignedPlots.push_back(curve);
const std::map<mcq_double,mcq_double>& mapDeltaPeaks = monitorAlignment->getMs2CommonPeak();
// QVector<QPointF> *data = static_cast<QVector<QPointF> *>(_p_curve_ms2->data());
//QwtPlotCurve * curve = new QwtPlotCurve("Common identification");
_p_curve_ms2->setStyle(QwtPlotCurve::Dots);
_p_curve_ms2->setRenderHint(QwtPlotItem::RenderAntialiased);
_p_curve_ms2->setSymbol(new QwtSymbol(QwtSymbol::Star2, QColor(Qt::black), QColor(Qt::black),
QSize(9, 9)));
//_alignedPlots.push_back(curve);
const std::map<mcq_double,mcq_double>& mapDeltaPeaks = monitorAlignment->getMs2CommonPeak();
// QVector<QPointF> *data = static_cast<QVector<QPointF> *>(_p_curve_ms2->data());
//_p_msms_data->clear();
//_msms_data.clear();
//_msms_data.clear();
//_p_curve_ms2->detach();
QVector< double > x;
QVector< double > y;
//unsigned int plotsize(mapDeltaPeaks.size());
//mcq_double x1[plotsize], y1[plotsize];
std::map<mcq_double,mcq_double>::const_iterator it;
//int i = 0;
for (it = mapDeltaPeaks.begin(); it != mapDeltaPeaks.end(); ++it) {
QPointF one_point;
//unsigned int plotsize(mapDeltaPeaks.size());
//mcq_double x1[plotsize], y1[plotsize];
std::map<mcq_double,mcq_double>::const_iterator it;
//int i = 0;
for (it = mapDeltaPeaks.begin(); it != mapDeltaPeaks.end(); ++it) {
QPointF one_point;
x.push_back(it->first);
y.push_back(it->second);
//one_point.setX(it->first);
//one_point.setY(it->second);
//_msms_data.push_back(one_point);
//y1[i] = it->second;
//x1[i] = it->first;
//i++;
}
_p_msms_data = new QwtPointArrayData(x,y);
_p_curve_ms2->setData(_p_msms_data);
this->replot();
initZoomer();
*/
addGraph();
QPen pen;
pen.setColor(QColor(Qt::blue));
graph()->setPen(pen);
//graph()->setName(lineNames.at(i-QCPGraph::lsNone));
//graph()->setLineStyle((QCPGraph::LineStyle)i);
graph()->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 5));
// generate data:
QVector<double> x, y;
std::map<mcq_double,mcq_double>::const_iterator it;
const std::map<mcq_double,mcq_double>& mapDeltaPeaks = monitorAlignment->getMs2CommonPeak();
for (it = mapDeltaPeaks.begin(); it != mapDeltaPeaks.end(); ++it)
{
x.push_back(it->first);
y.push_back(it->second);
//one_point.setX(it->first);
//one_point.setY(it->second);
//_msms_data.push_back(one_point);
//y1[i] = it->second;
//x1[i] = it->first;
//i++;
}
_p_msms_data = new QwtPointArrayData(x,y);
_p_curve_ms2->setData(_p_msms_data);
this->replot();
initZoomer();
}
graph()->setData(x, y);
graph()->rescaleAxes(true);
qDebug() << "PlotAligned::viewAlignedMS2Peaks end";
}
void PlotAligned::clear() {
qDebug() << "PlotAligned::clear() begin";
/*
if (_msms_data.size() > 0) {
const QwtSymbol symbol(QwtSymbol::Star1, QColor(Qt::white), QColor(Qt::white),
QSize(9, 9));
_p_curve_ms2->setSymbol(symbol);
//QwtData data(_p_curve_ms2->data());
//QwtData * p_data = _p_curve_ms2->data().copy();
_p_curve_ms2->setData(_msms_data);
replot();
}*/
//_p_curve_ms2->setSamples(QVector<QPointF>());
_p_curve_deltart->setSamples(QVector<QPointF>());
_p_curve_ms2->detach();
_p_curve_deltart->detach();
setAxisAutoScale(QwtPlot::xBottom);
setAxisAutoScale(QwtPlot::yLeft);
this->setTitle("");
//_msms_data.clear();
replot();
initZoomer();
qDebug() << "PlotAligned::clear() end";
qDebug() << "PlotAligned::clear() begin";
/*
if (_msms_data.size() > 0) {
const QwtSymbol symbol(QwtSymbol::Star1, QColor(Qt::white), QColor(Qt::white),
QSize(9, 9));
_p_curve_ms2->setSymbol(symbol);
//QwtData data(_p_curve_ms2->data());
//QwtData * p_data = _p_curve_ms2->data().copy();
_p_curve_ms2->setData(_msms_data);
replot();
}*/
//_p_curve_ms2->setSamples(QVector<QPointF>());
qDebug() << "PlotAligned::clear() end";
}
void PlotAligned::clearPlot() {
this->clear();
this->clear();
}
void PlotAligned::initZoomer() {
// LeftButton for the zooming
// MidButton for the panning
// RightButton: zoom out by 1
// Ctrl+RighButton: zoom out to full size
if (_zoomer != nullptr)
delete _zoomer;
_zoomer = new QwtPlotZoomer(canvas());
_zoomer->setResizeMode(QwtPicker::KeepSize);
_zoomer->setTrackerMode(QwtPicker::AlwaysOn);
_zoomer->setMousePattern(QwtEventPattern::MouseSelect2, Qt::RightButton,
Qt::ControlModifier);
_zoomer->setMousePattern(QwtEventPattern::MouseSelect3, Qt::RightButton);
const QColor c(Qt::darkBlue);
_zoomer->setRubberBandPen(c);
_zoomer->setTrackerPen(c);
// LeftButton for the zooming
// MidButton for the panning
// RightButton: zoom out by 1
// Ctrl+RighButton: zoom out to full size
}
......@@ -23,7 +23,7 @@
* \brief widget to plot alignements
* \date November 23, 2011
* \author Edlira Nano
*
*
* it receives alignment signals from alignment workers (connected by AlignmentWidget)
* clear display and draw new alignments
*/
......@@ -32,46 +32,37 @@
#define _PLOT_ALIGNED_H_ 1
//#include <qwt_compat.h>
#include <qwt_plot.h>
#include <qwt_plot_zoomer.h>
#include <qwt_plot_curve.h>
#include <qwt_point_data.h>
#include "../treatment/treatment_box_xic_extract.h"
#include "../treatment/treatment_box_xic_detect.h"
#include "../treatment/treatment_box_xic_filter.h"
#include "../treatment/treatment_box.h"
#include <vector>
#include "../../lib/alignments/monitors/monitor_alignment_plot.h"
#include <qcustomplot.h>
class PlotAligned : public QwtPlot {
Q_OBJECT
class PlotAligned : public QCustomPlot {
Q_OBJECT
public:
PlotAligned(QWidget * parent);
virtual ~PlotAligned();
void clear();
PlotAligned(QWidget * parent);
void initZoomer();
virtual ~PlotAligned();
void clear();
void initZoomer();
public slots :
void viewAlignedMsRun(const Msrun *);
void viewAlignedMS2Peaks(const MonitorAlignmentPlot *);
void clearPlot();
void viewAlignedMsRun(const Msrun *);
void viewAlignedMS2Peaks(const MonitorAlignmentPlot *);
void clearPlot();
private:
//std::vector<QwtPlotCurve *> _alignedPlots;
QwtPlotZoomer * _zoomer;
QwtPlotCurve * _p_curve_deltart;
QwtPlotCurve * _p_curve_ms2;
QwtPointArrayData * _p_msms_data;
//std::vector<QwtPlotCurve *> _alignedPlots;
};
......
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