| OpenMS 2.5.0

Spectrum3DOpenGLCanvas.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-2020.
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
44 #include <OpenMS/DATASTRUCTURES/DRange.h>
45
46 namespace OpenMS
47 {
48 class Spectrum3DCanvas;
49
58 class OPENMS_GUI_DLLAPI Spectrum3DOpenGLCanvas :
59 public QOpenGLWidget,
60 protected QOpenGLFunctions_2_0
61 {
62 Q_OBJECT
63
64 friend class Spectrum3DCanvas;
65
66 public:
67
69 typedef std::vector<std::vector<double> > AxisTickVector;
70
77 Spectrum3DOpenGLCanvas(QWidget * parent, Spectrum3DCanvas & canvas_3d);
83 virtual ~Spectrum3DOpenGLCanvas();
84
86 void initializeGL() override;
88 void resizeGL(int w, int h) override;
90 void paintGL() override;
91
94 void mouseMoveEvent(QMouseEvent * e) override;
95 void mouseReleaseEvent(QMouseEvent * e) override;
96 void mousePressEvent(QMouseEvent * e) override;
97 void focusOutEvent(QFocusEvent * e) override;
99
100 void setXLabel(const QString& l) { x_label_ = l; }
101 void setYLabel(const QString& l) { y_label_ = l; }
102 void setZLabel(const QString& l) { z_label_ = l; }
103
105 void updateIntensityScale();
106 protected:
108 GLint project_(GLdouble objx, GLdouble objy, GLdouble objz, GLdouble * winx, GLdouble * winy);
110 void transformPoint_(GLdouble out[4], const GLdouble m[16], const GLdouble in[4]);
112 void renderText_(double x, double y, double z, const QString & text);
114 void qglColor_(QColor color);
116 void qglClearColor_(QColor clearColor);
118 GLuint makeDataAsStick_();
120 GLuint makeAxes_();
122 GLuint makeAxesTicks_();
124 GLuint makeDataAsTopView_();
126 GLuint makeGround_();
128 GLuint makeGridLines_();
130 void drawAxesLegend_();
131
133 void computeSelection_();
134
136 void dataToZoomArray_(double x_1, double y_1, double x_2, double y_2);
137
139 double scaledRT_(double rt);
141 double scaledInversRT_(double mz);
143 double scaledMZ_(double mz);
145 double scaledInversMZ_(double mz);
147 double scaledIntensity_(float intensity, Size layer_index);
148
150 void recalculateDotGradient_(Size layer);
152 void calculateGridLines_();
153
155 void normalizeAngle(int * angle);
156 // set translation vector to 0
157 void resetTranslation();
158 //document me
159 void timeMessure();
160
162 void storeRotationAndZoom();
164 void restoreRotationAndZoom();
165
168 GLuint stickdata_;
169 GLuint axes_;
170 GLuint axes_ticks_;
171 GLuint gridlines_;
172 GLuint ground_;
174
176 Spectrum3DCanvas & canvas_3d_;
177
179 int xrot_;
181 int yrot_;
183 int zrot_;
184
186 int xrot_tmp_;
188 int yrot_tmp_;
190 int zrot_tmp_;
191
192 QPainter* painter_ = nullptr;
193
195 QPoint mouse_move_end_, mouse_move_begin_;
196
198 double corner_;
200 double zoom_;
202 double zoom_tmp_;
203
205 double near_;
207 double far_;
209 float width_;
211 float height_;
213 DRange<3> overall_values_;
215 DRange<1> int_scale_;
217 AxisTickVector grid_mz_;
219 AxisTickVector grid_rt_;
221 AxisTickVector grid_intensity_;
223 double x_1_;
225 double x_2_;
227 double y_1_;
229 double y_2_;
231 double trans_x_;
233 double trans_y_;
234
235 QString x_label_;
236 QString y_label_;
237 QString z_label_;
238
239 protected slots:
241 void actionModeChange();
242 };
243 }
OpenMS::Spectrum3DOpenGLCanvas::y_2_
double y_2_
y2 coordinate of the zoomselection
Definition: Spectrum3DOpenGLCanvas.h:229
OpenMS::Spectrum3DOpenGLCanvas::trans_x_
double trans_x_
x- translation
Definition: Spectrum3DOpenGLCanvas.h:231
OpenMS::Spectrum3DOpenGLCanvas::overall_values_
DRange< 3 > overall_values_
object which contains the min and max values of mz, rt and intensity
Definition: Spectrum3DOpenGLCanvas.h:213
OpenMS::Spectrum3DOpenGLCanvas::y_label_
QString y_label_
Definition: Spectrum3DOpenGLCanvas.h:236
QWidget
OpenMS::Spectrum3DOpenGLCanvas::x_2_
double x_2_
x2 coordinate of the zoomselection
Definition: Spectrum3DOpenGLCanvas.h:225
OpenMS::Spectrum3DOpenGLCanvas::height_
float height_
the height of the viewport
Definition: Spectrum3DOpenGLCanvas.h:211
OpenMS::Spectrum3DOpenGLCanvas::z_label_
QString z_label_
Definition: Spectrum3DOpenGLCanvas.h:237
DRange.h
OpenMS::Spectrum3DOpenGLCanvas::zrot_
int zrot_
member z-variables for the rotation
Definition: Spectrum3DOpenGLCanvas.h:183
OpenMS::Spectrum3DOpenGLCanvas::gridlines_
GLuint gridlines_
Definition: Spectrum3DOpenGLCanvas.h:171
OpenMS::Spectrum3DOpenGLCanvas::zoom_tmp_
double zoom_tmp_
member variable that stores original zoom factor during zoom mode
Definition: Spectrum3DOpenGLCanvas.h:202
OpenMS::Spectrum3DOpenGLCanvas::y_1_
double y_1_
y1 coordinate of the zoomselection
Definition: Spectrum3DOpenGLCanvas.h:227
OpenMS::Spectrum3DOpenGLCanvas::near_
double near_
member variable for the z- axis of the BB
Definition: Spectrum3DOpenGLCanvas.h:205
OpenMS::Spectrum3DOpenGLCanvas::x_label_
QString x_label_
Definition: Spectrum3DOpenGLCanvas.h:235
OpenMS::Spectrum3DOpenGLCanvas
OpenGL Canvas for 3D-visualization of map data.
Definition: Spectrum3DOpenGLCanvas.h:58
OpenMS::Spectrum3DOpenGLCanvas::grid_intensity_
AxisTickVector grid_intensity_
member gridvectors which contains the data for the intensity-axis-ticks
Definition: Spectrum3DOpenGLCanvas.h:221
OpenMS::Spectrum3DOpenGLCanvas::axes_ticks_
GLuint axes_ticks_
Definition: Spectrum3DOpenGLCanvas.h:170
OpenMS::Spectrum3DCanvas
Canvas for 3D-visualization of peak map data.
Definition: Spectrum3DCanvas.h:66
OpenMS::Spectrum3DOpenGLCanvas::int_scale_
DRange< 1 > int_scale_
object which contains the values of the current min and max intensity
Definition: Spectrum3DOpenGLCanvas.h:215
OpenMS::Spectrum3DOpenGLCanvas::mouse_move_end_
QPoint mouse_move_end_
member variables for the zoom-mode
Definition: Spectrum3DOpenGLCanvas.h:195
OpenMS::Spectrum3DOpenGLCanvas::xrot_
int xrot_
member x-variables for the rotation
Definition: Spectrum3DOpenGLCanvas.h:179
OpenMS::Spectrum3DOpenGLCanvas::AxisTickVector
std::vector< std::vector< double > > AxisTickVector
Container for axis ticks.
Definition: Spectrum3DOpenGLCanvas.h:69
OpenMS::Spectrum3DOpenGLCanvas::yrot_
int yrot_
member y-variables for the rotation
Definition: Spectrum3DOpenGLCanvas.h:181
OpenMS::Spectrum3DOpenGLCanvas::setZLabel
void setZLabel(const QString &l)
Definition: Spectrum3DOpenGLCanvas.h:102
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Spectrum3DOpenGLCanvas::width_
float width_
the width of the viewport
Definition: Spectrum3DOpenGLCanvas.h:209
OpenMS::DRange< 3 >
OpenMS::Spectrum3DOpenGLCanvas::axes_
GLuint axes_
Definition: Spectrum3DOpenGLCanvas.h:169
OpenMS::Spectrum3DOpenGLCanvas::zoom_
double zoom_
member variable for the zoom mode
Definition: Spectrum3DOpenGLCanvas.h:200
QOpenGLWidget
OpenMS::Spectrum3DOpenGLCanvas::stickdata_
GLuint stickdata_
Definition: Spectrum3DOpenGLCanvas.h:168
OpenMS::Spectrum3DOpenGLCanvas::setYLabel
void setYLabel(const QString &l)
Definition: Spectrum3DOpenGLCanvas.h:101
OpenMS::Spectrum3DOpenGLCanvas::grid_mz_
AxisTickVector grid_mz_
member gridvectors which contains the data for the mz-axis-ticks
Definition: Spectrum3DOpenGLCanvas.h:217
OpenMS::Spectrum3DOpenGLCanvas::grid_rt_
AxisTickVector grid_rt_
member gridvectors which contains the data for the rt-axis-ticks
Definition: Spectrum3DOpenGLCanvas.h:219
OpenMS::Spectrum3DOpenGLCanvas::yrot_tmp_
int yrot_tmp_
member y-variable that stores the original angle during zoom mode
Definition: Spectrum3DOpenGLCanvas.h:188
OpenMS::Spectrum3DOpenGLCanvas::trans_y_
double trans_y_
y_translation
Definition: Spectrum3DOpenGLCanvas.h:233
OpenMS::Spectrum3DOpenGLCanvas::far_
double far_
member variable for the z- axis of the BB
Definition: Spectrum3DOpenGLCanvas.h:207
OpenMS::Spectrum3DOpenGLCanvas::x_1_
double x_1_
x1 coordinate of the zoomselection
Definition: Spectrum3DOpenGLCanvas.h:223
OpenMS::Spectrum3DOpenGLCanvas::corner_
double corner_
member variable for the x and y axis of the BB
Definition: Spectrum3DOpenGLCanvas.h:198
OpenMS::Spectrum3DOpenGLCanvas::ground_
GLuint ground_
Definition: Spectrum3DOpenGLCanvas.h:172
OpenMS::Spectrum3DOpenGLCanvas::setXLabel
void setXLabel(const QString &l)
Definition: Spectrum3DOpenGLCanvas.h:100
OpenMS::Spectrum3DOpenGLCanvas::canvas_3d_
Spectrum3DCanvas & canvas_3d_
reference to Spectrum3DCanvas
Definition: Spectrum3DOpenGLCanvas.h:176
OpenMS::Spectrum3DOpenGLCanvas::xrot_tmp_
int xrot_tmp_
member x-variable that stores the original angle during zoom mode
Definition: Spectrum3DOpenGLCanvas.h:186
OpenMS::Size
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
OpenMS::Spectrum3DOpenGLCanvas::zrot_tmp_
int zrot_tmp_
member z-variable that stores the original angle during zoom mode
Definition: Spectrum3DOpenGLCanvas.h:190
OpenMS::Constants::h
const double h
QOpenGLFunctions_2_0