From 5c527b1f50319d1404edd07e3395b88c18b30083 Mon Sep 17 00:00:00 2001
From: Olivier Langella <olivier.langella@u-psud.fr>
Date: Fri, 22 Dec 2017 09:22:43 +0100
Subject: [PATCH] using QCPbars

---
 src/gui/project_view/projectwindow.cpp | 25 ++++++++++++-------------
 src/gui/project_view/projectwindow.h   |  2 ++
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp
index 939827d94..dbd44dac0 100644
--- a/src/gui/project_view/projectwindow.cpp
+++ b/src/gui/project_view/projectwindow.cpp
@@ -36,7 +36,6 @@
 #include "../workerthread.h"
 #include "../../core/labeling/labelingmethod.h"
 #include "../../../utils/utils.h"
-#include <qcustomplot.h>
 
 
 
@@ -78,14 +77,7 @@ ProjectWindow::ProjectWindow(MainWindow *parent):
 //setLocale(QLocale(QLocale::English, QLocale::UnitedKingdom));
     setFocusPolicy(Qt::ClickFocus);
 
-    QCPGraph * p_graph = ui->mass_histogram_widget->addGraph();
-    //p_graph->setName("raw xic");
-    //QPen pen;
-    //pen.setColor(getNewColors());
-    //graph()->setPen(pen);
-    //graph()->setName(lineNames.at(i-QCPGraph::lsNone));
-    p_graph->setLineStyle(QCPGraph::LineStyle::lsStepCenter);
-    //p_graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 2.0));
+    _p_bars = new QCPBars(ui->mass_histogram_widget->xAxis, ui->mass_histogram_widget->yAxis);
 
 
 #if QT_VERSION >= 0x050000
@@ -310,10 +302,17 @@ void ProjectWindow::computeMassPrecision() {
             y.push_back(mass_pair.second);
         }
 
-        QCPGraph * p_graph = ui->mass_histogram_widget->graph();
-        p_graph->setData(x,y);
-        p_graph->rescaleAxes(true);
-        ui->mass_histogram_widget->rescaleAxes();
+        //delete _p_bars;
+        //_p_bars = new QCPBars(ui->mass_histogram_widget->xAxis, ui->mass_histogram_widget->yAxis);
+        _p_bars->clearData();
+        _p_bars->setWidth((x[0] - x[x.size()-1])/x.size());
+        _p_bars->setData(x, y);
+        _p_bars->rescaleAxes(true);
+        ui->mass_histogram_widget->yAxis->setRange(0, *std::max(y.begin(), y.end()));
+        ui->mass_histogram_widget->xAxis->setRange(x[0], x[x.size()-1]);
+        //QCPGraph * p_graph = ui->mass_histogram_widget->graph();
+        //p_graph->setData(x,y);
+        //ui->mass_histogram_widget->rescaleAxes();
         ui->mass_histogram_widget->replot();
     }
     catch (pappso::PappsoException exception_pappso) {
diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h
index 713be30e4..6ec84b58a 100644
--- a/src/gui/project_view/projectwindow.h
+++ b/src/gui/project_view/projectwindow.h
@@ -37,6 +37,7 @@
 #include "../peptide_detail_view/peptidewindow.h"
 #include "gui/project_view/automatic_filter_widget/automaticfilterwidget.h"
 #include "../waiting_message_dialog/waitingmessagedialog.h"
+#include <qcustomplot.h>
 
 class MainWindow;
 
@@ -131,6 +132,7 @@ private:
     QStandardItemModel * _p_fasta_str_li;
     std::vector<FastaFileSp> _fastafile_list;
     WaitingMessageDialog * _p_waiting_message_dialog;
+    QCPBars *_p_bars;
 
 
 };
-- 
GitLab