OpenMS  2.7.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-2021.
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 LayerData;
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);
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 
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);
121  GLuint makeAxes_();
123  GLuint makeAxesTicks_();
127  GLuint makeGround_();
129  GLuint makeGridLines_();
132 
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 
154 
156  void normalizeAngle(int* angle);
157  // set translation vector to 0
159 
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:
241  };
242 }
Class that stores the data for one layer.
Definition: LayerData.h:96
Canvas for 3D-visualization of peak map data.
Definition: Plot3DCanvas.h:68
OpenGL Canvas for 3D-visualization of map data.
Definition: Plot3DOpenGLCanvas.h:62
double far_
member variable for the z- axis of the BB
Definition: Plot3DOpenGLCanvas.h:206
GLuint makeDataAsStick_()
Builds up a display list for the 3D view.
void qglClearColor_(QColor clearColor)
helper function to replicate old behaviour of QGLWidget
GLint project_(GLdouble objx, GLdouble objy, GLdouble objz, GLdouble *winx, GLdouble *winy)
helper function to project point to device space
void dataToZoomArray_(double x_1, double y_1, double x_2, double y_2)
calculates the zoom area , which is shown
void resizeGL(int w, int h) override
virtual function provided from QGLWidget
GLuint makeAxesTicks_()
Builds up a display list for axis ticks.
double near_
member variable for the z- axis of the BB
Definition: Plot3DOpenGLCanvas.h:204
Plot3DOpenGLCanvas(QWidget *parent, Plot3DCanvas &canvas_3d)
Constructor.
void setXLabel(const QString &l)
Definition: Plot3DOpenGLCanvas.h:101
void setZLabel(const QString &l)
Definition: Plot3DOpenGLCanvas.h:103
double x_2_
x2 coordinate of the zoomselection
Definition: Plot3DOpenGLCanvas.h:224
GLuint makeGridLines_()
Builds up a display list for grid lines.
int xrot_
member x-variables for the rotation
Definition: Plot3DOpenGLCanvas.h:178
void transformPoint_(GLdouble out[4], const GLdouble m[16], const GLdouble in[4])
helper function to transform point using matrix m (homogeneous coordinates)
void mousePressEvent(QMouseEvent *e) override
GLuint makeAxes_()
Builds up a display list for the axes.
GLuint ground_
Definition: Plot3DOpenGLCanvas.h:171
void mouseMoveEvent(QMouseEvent *e) override
int zrot_
member z-variables for the rotation
Definition: Plot3DOpenGLCanvas.h:182
void mouseReleaseEvent(QMouseEvent *e) override
void actionModeChange()
Slot that reacts on action mode changes.
double scaledRT_(double rt)
returns the BB-rt-coordinate : value –> BB-coordinates
int zrot_tmp_
member z-variable that stores the original angle during zoom mode
Definition: Plot3DOpenGLCanvas.h:189
int yrot_tmp_
member y-variable that stores the original angle during zoom mode
Definition: Plot3DOpenGLCanvas.h:187
AxisTickVector grid_mz_
member gridvectors which contains the data for the mz-axis-ticks
Definition: Plot3DOpenGLCanvas.h:216
void paintGL() override
virtual function provided from QGLWidget
double corner_
member variable for the x and y axis of the BB
Definition: Plot3DOpenGLCanvas.h:197
DRange< 3 > overall_values_
object which contains the min and max values of mz, rt and intensity
Definition: Plot3DOpenGLCanvas.h:212
double y_1_
y1 coordinate of the zoomselection
Definition: Plot3DOpenGLCanvas.h:226
double x_1_
x1 coordinate of the zoomselection
Definition: Plot3DOpenGLCanvas.h:222
GLuint makeDataAsTopView_()
Builds up a display list for the birds-eye view.
void renderText_(double x, double y, double z, const QString &text)
helper function to replicate old behaviour of QGLWidget
double zoom_tmp_
member variable that stores original zoom factor during zoom mode
Definition: Plot3DOpenGLCanvas.h:201
void focusOutEvent(QFocusEvent *e) override
double scaledInversRT_(double mz)
returns the rt-value : BB-coordinates –> value
int xrot_tmp_
member x-variable that stores the original angle during zoom mode
Definition: Plot3DOpenGLCanvas.h:185
void storeRotationAndZoom()
stores the original rotation and zoom factor (e.g. before changing into zoom mode)
double trans_y_
y_translation
Definition: Plot3DOpenGLCanvas.h:232
double scaledIntensity_(float intensity, Size layer_index)
returns the BB-intensity -coordinate : values –> BB-coordinates
GLuint axes_
Definition: Plot3DOpenGLCanvas.h:168
QPoint mouse_move_begin_
Definition: Plot3DOpenGLCanvas.h:194
void restoreRotationAndZoom()
restores the original rotation and zoom factor (e.g. before changing into zoom mode)
GLuint makeGround_()
Builds up a display list for the background.
GLuint axes_ticks_
Definition: Plot3DOpenGLCanvas.h:169
GLuint stickdata_
Definition: Plot3DOpenGLCanvas.h:167
AxisTickVector grid_rt_
member gridvectors which contains the data for the rt-axis-ticks
Definition: Plot3DOpenGLCanvas.h:218
double zoom_
member variable for the zoom mode
Definition: Plot3DOpenGLCanvas.h:199
void computeSelection_()
computes the dataset supposed to be drawn when a section has been selected in zoom mode
DRange< 1 > int_scale_
object which contains the values of the current min and max intensity
Definition: Plot3DOpenGLCanvas.h:214
void qglColor_(QColor color)
helper function to replicate old behaviour of QGLWidget
QString x_label_
Definition: Plot3DOpenGLCanvas.h:234
AxisTickVector grid_intensity_
member gridvectors which contains the data for the intensity-axis-ticks
Definition: Plot3DOpenGLCanvas.h:220
void updateIntensityScale()
updates the min and max values of the intensity
void recalculateDotGradient_(LayerData &layer)
recalculates the dot gradient interpolation values.
double scaledMZ_(double mz)
returns the BB-mz-coordinate : values –> BB-coordinates
float width_
the width of the viewport
Definition: Plot3DOpenGLCanvas.h:208
void normalizeAngle(int *angle)
normalize the angle by "angle % 360*16"
void calculateGridLines_()
calculate the ticks for the gridlines
GLuint gridlines_
Definition: Plot3DOpenGLCanvas.h:170
double y_2_
y2 coordinate of the zoomselection
Definition: Plot3DOpenGLCanvas.h:228
void initializeGL() override
virtual function provided from QGLWidget
Plot3DCanvas & canvas_3d_
reference to Plot3DCanvas
Definition: Plot3DOpenGLCanvas.h:175
virtual ~Plot3DOpenGLCanvas()
Destructor.
double trans_x_
x- translation
Definition: Plot3DOpenGLCanvas.h:230
double scaledInversMZ_(double mz)
returns the mz-value : BB-coordinates –> value
float height_
the height of the viewport
Definition: Plot3DOpenGLCanvas.h:210
QString z_label_
Definition: Plot3DOpenGLCanvas.h:236
void drawAxesLegend_()
Draws the axis texts.
int yrot_
member y-variables for the rotation
Definition: Plot3DOpenGLCanvas.h:180
QString y_label_
Definition: Plot3DOpenGLCanvas.h:235
void setYLabel(const QString &l)
Definition: Plot3DOpenGLCanvas.h:102
std::vector< std::vector< double > > AxisTickVector
Container for axis ticks.
Definition: Plot3DOpenGLCanvas.h:70
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
const double h
Definition: Constants.h:162
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47