OpenMS  3.0.0
Plot3DOpenGLCanvas.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2022.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Timo Sachsenberg $
32 // $Authors: Cornelia Friedle $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
37 // OpenMS_GUI config
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
40 #include <QOpenGLWidget>
41 #include <QOpenGLFunctions_2_0>
42 
43 // OpenMS
45 
46 namespace OpenMS
47 {
48  class Plot3DCanvas;
49  class LayerDataBase;
50 
59  class OPENMS_GUI_DLLAPI Plot3DOpenGLCanvas :
60  public QOpenGLWidget,
61  protected QOpenGLFunctions_2_0
62  {
63  Q_OBJECT
64 
65  friend class Plot3DCanvas;
66 
67 public:
68 
70  typedef std::vector<std::vector<double> > AxisTickVector;
71 
78  Plot3DOpenGLCanvas(QWidget * parent, Plot3DCanvas & canvas_3d);
84  ~Plot3DOpenGLCanvas() override;
85 
87  void initializeGL() override;
89  void resizeGL(int w, int h) override;
91  void paintGL() override;
92 
95  void mouseMoveEvent(QMouseEvent * e) override;
96  void mouseReleaseEvent(QMouseEvent * e) override;
97  void mousePressEvent(QMouseEvent * e) override;
98  void focusOutEvent(QFocusEvent * e) override;
100 
101  void setXLabel(const QString& l) { x_label_ = l; }
102  void setYLabel(const QString& l) { y_label_ = l; }
103  void setZLabel(const QString& l) { z_label_ = l; }
104 
106  void updateIntensityScale();
107 protected:
109  GLint project_(GLdouble objx, GLdouble objy, GLdouble objz, GLdouble * winx, GLdouble * winy);
111  void transformPoint_(GLdouble out[4], const GLdouble m[16], const GLdouble in[4]);
113  void renderText_(double x, double y, double z, const QString & text);
115  void qglColor_(QColor color);
117  void qglClearColor_(QColor clearColor);
119  GLuint makeDataAsStick_();
121  GLuint makeAxes_();
123  GLuint makeAxesTicks_();
125  GLuint makeDataAsTopView_();
127  GLuint makeGround_();
129  GLuint makeGridLines_();
131  void drawAxesLegend_();
132 
134  void computeSelection_();
135 
137  void dataToZoomArray_(double x_1, double y_1, double x_2, double y_2);
138 
140  double scaledRT_(double rt);
142  double scaledInversRT_(double mz);
144  double scaledMZ_(double mz);
146  double scaledInversMZ_(double mz);
148  double scaledIntensity_(float intensity, Size layer_index);
149 
151  void recalculateDotGradient_(LayerDataBase& layer);
153  void calculateGridLines_();
154 
156  void normalizeAngle(int* angle);
157  // set translation vector to 0
158  void resetTranslation();
159 
161  void storeRotationAndZoom();
163  void restoreRotationAndZoom();
164 
167  GLuint stickdata_;
168  GLuint axes_;
169  GLuint axes_ticks_;
170  GLuint gridlines_;
171  GLuint ground_;
173 
176 
178  int xrot_;
180  int yrot_;
182  int zrot_;
183 
190 
191  QPainter* painter_ = nullptr;
192 
194  QPoint mouse_move_end_, mouse_move_begin_;
195 
197  double corner_;
199  double zoom_;
201  double zoom_tmp_;
202 
204  double near_;
206  double far_;
208  float width_;
210  float height_;
222  double x_1_;
224  double x_2_;
226  double y_1_;
228  double y_2_;
230  double trans_x_;
232  double trans_y_;
233 
234  QString x_label_;
235  QString y_label_;
236  QString z_label_;
237 
238 protected slots:
240  void actionModeChange();
241  };
242 }
OpenMS::Plot3DOpenGLCanvas::far_
double far_
member variable for the z- axis of the BB
Definition: Plot3DOpenGLCanvas.h:206
DRange.h
OpenMS::Plot3DOpenGLCanvas::x_2_
double x_2_
x2 coordinate of the zoomselection
Definition: Plot3DOpenGLCanvas.h:224
OpenMS::Plot3DOpenGLCanvas::xrot_tmp_
int xrot_tmp_
member x-variable that stores the original angle during zoom mode
Definition: Plot3DOpenGLCanvas.h:185
OpenMS::Plot3DOpenGLCanvas::setYLabel
void setYLabel(const QString &l)
Definition: Plot3DOpenGLCanvas.h:102
OpenMS::Plot3DCanvas
Canvas for 3D-visualization of peak map data.
Definition: Plot3DCanvas.h:66
OpenMS::DRange< 3 >
OpenMS::Plot3DOpenGLCanvas::setZLabel
void setZLabel(const QString &l)
Definition: Plot3DOpenGLCanvas.h:103
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::Plot3DOpenGLCanvas::y_label_
QString y_label_
Definition: Plot3DOpenGLCanvas.h:235
OpenMS::Plot3DOpenGLCanvas::y_1_
double y_1_
y1 coordinate of the zoomselection
Definition: Plot3DOpenGLCanvas.h:226
OpenMS::Plot3DOpenGLCanvas::setXLabel
void setXLabel(const QString &l)
Definition: Plot3DOpenGLCanvas.h:101
QWidget
OpenMS::Plot3DOpenGLCanvas::ground_
GLuint ground_
Definition: Plot3DOpenGLCanvas.h:171
OpenMS::Plot3DOpenGLCanvas::mouse_move_end_
QPoint mouse_move_end_
member variables for the zoom-mode
Definition: Plot3DOpenGLCanvas.h:194
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
OpenMS::Plot3DOpenGLCanvas::near_
double near_
member variable for the z- axis of the BB
Definition: Plot3DOpenGLCanvas.h:204
OpenMS::Plot3DOpenGLCanvas::grid_mz_
AxisTickVector grid_mz_
member gridvectors which contains the data for the mz-axis-ticks
Definition: Plot3DOpenGLCanvas.h:216
OpenMS::Plot3DOpenGLCanvas::grid_rt_
AxisTickVector grid_rt_
member gridvectors which contains the data for the rt-axis-ticks
Definition: Plot3DOpenGLCanvas.h:218
OpenMS::Plot3DOpenGLCanvas::zoom_
double zoom_
member variable for the zoom mode
Definition: Plot3DOpenGLCanvas.h:199
OpenMS::Plot3DOpenGLCanvas::int_scale_
DRange< 1 > int_scale_
object which contains the values of the current min and max intensity
Definition: Plot3DOpenGLCanvas.h:214
OpenMS::Plot3DOpenGLCanvas::width_
float width_
the width of the viewport
Definition: Plot3DOpenGLCanvas.h:208
OpenMS::Plot3DOpenGLCanvas::overall_values_
DRange< 3 > overall_values_
object which contains the min and max values of mz, rt and intensity
Definition: Plot3DOpenGLCanvas.h:212
OpenMS::Plot3DOpenGLCanvas::z_label_
QString z_label_
Definition: Plot3DOpenGLCanvas.h:236
OpenMS::Plot3DOpenGLCanvas::AxisTickVector
std::vector< std::vector< double > > AxisTickVector
Container for axis ticks.
Definition: Plot3DOpenGLCanvas.h:70
QOpenGLFunctions_2_0
OpenMS::Plot3DOpenGLCanvas::stickdata_
GLuint stickdata_
Definition: Plot3DOpenGLCanvas.h:167
OpenMS::Plot3DOpenGLCanvas::yrot_tmp_
int yrot_tmp_
member y-variable that stores the original angle during zoom mode
Definition: Plot3DOpenGLCanvas.h:187
OpenMS::Plot3DOpenGLCanvas::xrot_
int xrot_
member x-variables for the rotation
Definition: Plot3DOpenGLCanvas.h:178
OpenMS::Plot3DOpenGLCanvas::y_2_
double y_2_
y2 coordinate of the zoomselection
Definition: Plot3DOpenGLCanvas.h:228
OpenMS::Constants::h
const double h
Definition: Constants.h:162
OpenMS::Plot3DOpenGLCanvas::axes_ticks_
GLuint axes_ticks_
Definition: Plot3DOpenGLCanvas.h:169
OpenMS::Plot3DOpenGLCanvas::zrot_
int zrot_
member z-variables for the rotation
Definition: Plot3DOpenGLCanvas.h:182
OpenMS::Plot3DOpenGLCanvas::yrot_
int yrot_
member y-variables for the rotation
Definition: Plot3DOpenGLCanvas.h:180
OpenMS::Plot3DOpenGLCanvas::height_
float height_
the height of the viewport
Definition: Plot3DOpenGLCanvas.h:210
OpenMS::Plot3DOpenGLCanvas::axes_
GLuint axes_
Definition: Plot3DOpenGLCanvas.h:168
OpenMS::Plot3DOpenGLCanvas::corner_
double corner_
member variable for the x and y axis of the BB
Definition: Plot3DOpenGLCanvas.h:197
OpenMS::Plot3DOpenGLCanvas::zoom_tmp_
double zoom_tmp_
member variable that stores original zoom factor during zoom mode
Definition: Plot3DOpenGLCanvas.h:201
OpenMS::LayerDataBase
Class that stores the data for one layer.
Definition: LayerDataBase.h:97
QOpenGLWidget
OpenMS::Plot3DOpenGLCanvas::trans_y_
double trans_y_
y_translation
Definition: Plot3DOpenGLCanvas.h:232
OpenMS::Plot3DOpenGLCanvas
OpenGL Canvas for 3D-visualization of map data.
Definition: Plot3DOpenGLCanvas.h:59
OpenMS::Plot3DOpenGLCanvas::zrot_tmp_
int zrot_tmp_
member z-variable that stores the original angle during zoom mode
Definition: Plot3DOpenGLCanvas.h:189
OpenMS::Plot3DOpenGLCanvas::x_label_
QString x_label_
Definition: Plot3DOpenGLCanvas.h:234
OpenMS::Plot3DOpenGLCanvas::canvas_3d_
Plot3DCanvas & canvas_3d_
reference to Plot3DCanvas
Definition: Plot3DOpenGLCanvas.h:175
OpenMS::Plot3DOpenGLCanvas::gridlines_
GLuint gridlines_
Definition: Plot3DOpenGLCanvas.h:170
OpenMS::Plot3DOpenGLCanvas::x_1_
double x_1_
x1 coordinate of the zoomselection
Definition: Plot3DOpenGLCanvas.h:222
OpenMS::Plot3DOpenGLCanvas::grid_intensity_
AxisTickVector grid_intensity_
member gridvectors which contains the data for the intensity-axis-ticks
Definition: Plot3DOpenGLCanvas.h:220
OpenMS::Plot3DOpenGLCanvas::trans_x_
double trans_x_
x- translation
Definition: Plot3DOpenGLCanvas.h:230