VAPOR3 3.9.4
Visualizer.h
Go to the documentation of this file.
1//************************************************************************
2// *
3// Copyright (C) 2004 *
4// University Corporation for Atmospheric Research *
5// All Rights Reserved *
6// *
7//************************************************************************/
8//
9// File: Visualizer.h
10//
11// Author: Alan Norton
12// National Center for Atmospheric Research
13// PO 3000, Boulder, Colorado
14//
15// Date: September 2013
16//
17// Description: Definition of Visualizer class:
18// A Visualizer object is associated with each visualization window. It contains
19// information required for rendering, performs
20// navigation and resize, and defers drawing to the viz window's list of
21// registered renderers.
22
23#pragma once
24
25#include <map>
26#include <vapor/DataStatus.h>
27#include <vapor/ParamsMgr.h>
28#include <vapor/Renderer.h>
30#include <vapor/Framebuffer.h>
31
32namespace VAPoR {
33
45
47public:
48 Visualizer(const ParamsMgr *pm, const DataStatus *dataStatus, string winName);
50
54
58
62
65 int InitializeGL(GLManager *glManager);
66
71 int paintEvent(bool fast);
72
76 int resizeGL(int w, int h);
77
80 string GetWindowName() const { return _winName; }
81
84 int GetNumRenderers() const { return _renderers.size(); }
85
88 //
89 int CreateRenderer(string dataSetName, string renderType, string renderName);
90
97 //
98 void DestroyRenderer(string renderType, string renderName, bool hasOpenGLContext);
99
106 //
107 void DestroyAllRenderers(bool hasOpenGLContext);
108
109 bool HasRenderer(string renderType, string renderName) const;
110
113 void MoveRendererToFront(string renderType, string renderName);
114 void MoveRenderersOfTypeToFront(const std::string &type);
115
118 double getPixelSize() const;
119
122 int SetImageCaptureEnabled(bool onOff, string filename)
123 {
124 if (_animationCaptureEnabled) {
125 SetErrMsg("Image capture concurrent with Animation Capture\n");
126 return -1;
127 }
128 _imageCaptureEnabled = onOff;
129 if (onOff)
130 _captureImageFile = filename;
131 else
132 _captureImageFile = "";
133 return 0;
134 }
135
138 int SetAnimationCaptureEnabled(bool onOff, string filename)
139 {
140 if (_imageCaptureEnabled) {
141 SetErrMsg("Image capture concurrent with Animation Capture\n");
142 return -1;
143 }
144 if (_animationCaptureEnabled == onOff) {
145 SetErrMsg("Animation capture in incorrect state\n");
146 return -1;
147 }
148 _animationCaptureEnabled = onOff;
149 if (onOff)
150 _captureImageFile = filename;
151 else
152 _captureImageFile = "";
153 return 0;
154 }
155
157 //
158 void DrawText(string text, int x, int y, int size, float color[3], int type = 0) { _vizFeatures->AddText(text, x, y, size, color, type); }
159
160 void DrawTextNormalizedCoords(string text, float x, float y, int size, float color[3], int type = 0) { _vizFeatures->AddTextNormalizedCoords(text, x, y, size, color, type); }
161
162 void ClearText() { _vizFeatures->ClearText(); }
163
167 //
169
170 void ClearRenderCache(const string &inst);
171
172private:
174 void _renderColorbars(int timeStep);
175
181 int _captureImage(std::string path);
182
183 void _loadMatricesFromViewpointParams();
184
186 enum GLVendorType { UNKNOWN = 0, MESA, NVIDIA, ATI, INTEL };
187
190 static GLVendorType GetVendor();
191
193 int _configureLighting();
194
198 bool _getPixelData(unsigned char *data) const;
199
200 void _deleteFlaggedRenderers();
201 int _initializeNewRenderers();
202 void _clearActiveFramebuffer(float r, float g, float b) const;
203 void _applyDatasetTransformsForRenderer(Renderer *r);
204
205 int _getCurrentTimestep() const;
206
207 static void _incrementPath(string &s);
208
209 Renderer *_getRenderer(string type, string instance) const;
210
211 const ParamsMgr * _paramsMgr;
212 const DataStatus * _dataStatus;
213 string _winName;
214 GLManager * _glManager;
215 AnnotationRenderer *_vizFeatures;
216
217 bool _insideGLContext; // This is only to make sure we don't call certain functions when they are not supposed to be called. In some situations this variable will be set to true incorrectly. In
218 // those cases there is already some other error so it doesn't matter.
219 bool _imageCaptureEnabled;
220 bool _animationCaptureEnabled;
221 string _captureImageFile;
222
223 vector<Renderer *> _renderers;
224 vector<Renderer *> _renderersToDestroy;
225
226 Framebuffer _framebuffer;
227 unsigned int _screenQuadVAO = 0;
228 unsigned int _screenQuadVBO = 0;
229};
230
231}; // namespace VAPoR
A class for describing visual features displayed in the visualizer.
Class that draws various geometry as specified by AnnotationParams.
A class for describing the currently loaded dataset.
Definition: DataStatus.h:50
Wrapper class for an OpenGL Framebuffer.
Definition: Framebuffer.h:23
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53
A class for describing a 3D axis-aligned region in user space.
Definition: regionparams.h:44
A class that performs rendering in a Visualizer.
Definition: Renderer.h:121
A class for describing the viewpoint and lights in a 3D VAPOR scene.
A class for performing OpenGL rendering in VAPOR GUI Window.
Definition: Visualizer.h:46
string GetWindowName() const
Definition: Visualizer.h:80
int InitializeGL(GLManager *glManager)
void DrawTextNormalizedCoords(string text, float x, float y, int size, float color[3], int type=0)
Definition: Visualizer.h:160
double getPixelSize() const
bool HasRenderer(string renderType, string renderName) const
int GetNumRenderers() const
Definition: Visualizer.h:84
RegionParams * getActiveRegionParams() const
void ClearRenderCache(const string &inst)
Visualizer(const ParamsMgr *pm, const DataStatus *dataStatus, string winName)
ViewpointParams * getActiveViewpointParams() const
int resizeGL(int w, int h)
void MoveRendererToFront(string renderType, string renderName)
void DestroyRenderer(string renderType, string renderName, bool hasOpenGLContext)
void DestroyAllRenderers(bool hasOpenGLContext)
int SetImageCaptureEnabled(bool onOff, string filename)
Definition: Visualizer.h:122
AnnotationParams * getActiveAnnotationParams() const
void DrawText(string text, int x, int y, int size, float color[3], int type=0)
Draw a text banner at x, y coordinates.
Definition: Visualizer.h:158
void MoveRenderersOfTypeToFront(const std::string &type)
int CreateRenderer(string dataSetName, string renderType, string renderName)
int SetAnimationCaptureEnabled(bool onOff, string filename)
Definition: Visualizer.h:138
int paintEvent(bool fast)
Wasp base class.
Definition: MyBase.h:67
#define RENDER_API
Definition: common.h:78
Contains references to context scope OpenGL data.
Definition: GLManager.h:18