libpappsomspp
Library for mass spectrometry
basetraceplotwidget.h
Go to the documentation of this file.
1 /* This code comes right from the msXpertSuite software project.
2  *
3  * msXpertSuite - mass spectrometry software suite
4  * -----------------------------------------------
5  * Copyright(C) 2009,...,2018 Filippo Rusconi
6  *
7  * http://www.msxpertsuite.org
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  *
22  * END software license
23  */
24 
25 
26 #pragma once
27 
28 /////////////////////// StdLib includes
29 
30 
31 /////////////////////// Qt includes
32 #include <QObject>
33 #include <QString>
34 #include <QWidget>
35 #include <QBrush>
36 #include <QColor>
37 #include <QVector>
38 
39 
40 /////////////////////// QCustomPlot
41 #include <qcustomplot.h>
42 
43 
44 /////////////////////// Local includes
45 #include "../../exportinmportconfig.h"
46 #include "baseplotwidget.h"
47 #include "../../trace/trace.h"
48 
49 
50 namespace pappso
51 {
52 
53 
54 class BaseTracePlotWidget;
55 
56 typedef std::shared_ptr<BaseTracePlotWidget> BaseTracePlotWidgetSPtr;
57 typedef std::shared_ptr<const BaseTracePlotWidget> BaseTracePlotWidgetCstSPtr;
58 
60 {
61  Q_OBJECT
62 
63  public:
64  explicit BaseTracePlotWidget(QWidget *parent = 0);
65  explicit BaseTracePlotWidget(QWidget *parent,
66  const QString &x_axis_label,
67  const QString &y_axis_label);
68 
69  virtual ~BaseTracePlotWidget();
70 
71  virtual void setGraphData(int graph_index,
72  const std::vector<double> &keys,
73  const std::vector<double> &values);
74 
75  virtual void setGraphData(QCPGraph *graph_p,
76  const std::vector<double> &keys,
77  const std::vector<double> &values);
78 
79  virtual void clearGraphData(int graph_index);
80 
81  virtual void axisDoubleClickHandler(QCPAxis *axis,
82  QCPAxis::SelectablePart part,
83  QMouseEvent *event) override;
84 
85  // All these need to be overridden because of some special treatment in case
86  // of Trace plots (graphs, specifically, and not color maps, for example).
87  virtual void axisRescale() override;
88  virtual void axisReframe() override;
89  virtual void axisZoom() override;
90  virtual void axisPan() override;
91 
92  virtual QCPGraph *addTrace(const pappso::Trace &trace, const QColor &color);
93 
94  virtual bool
95  findIntegrationLowerRangeForKey(int index, double key, QCPRange &range);
96 
97  std::vector<double> getValuesX(int index) const;
98  std::vector<double> getValuesY(int index) const;
99 
100  QCPRange getValueRangeOnKeyRange(QCPAbstractPlottable *plottable_p, bool &ok);
101  QCPRange getValueRangeOnKeyRange(int index, bool &ok);
102 
103  double getYatX(double x, QCPGraph *graph_p);
104  // index is 0 by default, which means that if there is a single graph, then,
105  // that will be it.
106  double getYatX(double x, int index = 0);
107 
108  pappso::Trace toTrace(int index) const;
109  pappso::Trace toTrace(const QCPGraph *graph_p) const;
110  pappso::Trace toTrace(const QCPRange &x_axis_range, int index) const;
111  pappso::Trace toTrace(const QCPRange &x_axis_range,
112  const QCPGraph *graph_p) const;
113 };
114 
115 
116 } // namespace pappso
A simple container of DataPoint instances.
Definition: trace.h:148
#define PMSPP_LIB_DECL
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
Definition: aa.cpp:39
std::shared_ptr< BaseTracePlotWidget > BaseTracePlotWidgetSPtr
std::shared_ptr< const BaseTracePlotWidget > BaseTracePlotWidgetCstSPtr