VAPOR3 3.9.4
AnnotationRenderer.h
Go to the documentation of this file.
1//-- AnnotationRenderer.h ----------------------------------------------------------
2//
3// Copyright (C) 2011
4// University Corporation for Atmospheric Research
5// All Rights Reserved
6//
7//----------------------------------------------------------------------------
8//
9// File: AnnotationRenderer.h
10//
11// Author: Alan Norton
12//
13//
14// Description: Definition of AnnotationRenderer class
15//
16//
17//
18//----------------------------------------------------------------------------
19
20#ifndef ANNOTATIONRENDERER_H
21#define ANNOTATIONRENDERER_H
22
23#include <vapor/Grid.h>
24#include <vapor/Renderer.h>
25#include <vapor/Transform.h>
26#include <vapor/DataMgrUtils.h>
27#include <vapor/GLManager.h>
28
29namespace VAPoR {
30
31class DataStatus;
32struct GLManager;
33
39
41private:
42 struct billboard;
43
44public:
46 AnnotationRenderer(const ParamsMgr *pm, const DataStatus *dataStatus, string winName);
47
49 void InitializeGL(GLManager *glManager);
50
53
55 void InScenePaint(size_t ts);
56
58 void OverlayPaint(size_t ts);
59
60 void AddText(string text, int x, int y, int size, float color[3], int type = 0);
61 void AddTextNormalizedCoords(string text, float x, float y, int size, float color[3], int type = 0);
62
63 void DrawText();
64
65 void DrawText(vector<billboard> billboards);
66
67 void ClearText(int type = -1);
68
71
72#ifdef VAPOR3_0_0_ALPHA
74 void invalidateCache();
75#endif
76
77protected:
78private:
79 struct billboard {
80 string text;
81 double x;
82 double y;
83 float xn;
84 float yn;
85 int size;
86 float color[3];
87 };
88 vector<billboard> _billboards;
89 vector<billboard> _timeAnnot;
90 vector<billboard> _axisAnnot;
91 vector<billboard> _miscAnnot;
92
93 const ParamsMgr * m_paramsMgr;
94 const DataStatus *m_dataStatus;
95 string m_winName;
96 GLManager * _glManager;
97 int _currentTimestep;
98 string _fontFile;
99 string _fontName;
100
101 void _drawAxes(std::vector<double> min, std::vector<double> max, std::vector<double> origin, std::vector<double> color, double width);
102 void _drawTic(double startPosn[], double endPosn[], double width, std::vector<double> color);
103 void _drawTimeAnnotation();
104
105 void _makeTransformMatrix(const Transform *transform, glm::mat4 &transformMatrix) const;
106
107 void _applyDataMgrCornerToDomain(std::vector<double> &domainExtents, const glm::vec4 &dataMgrCorner, const glm::mat4 &transformMatrix) const;
108
109 void _getDataMgrCorner(const int cornerNumber, glm::vec4 &dataMgrCorner, const CoordType &minDataMgrExtents, const CoordType &maxDataMgrExtents) const;
110
111 void _applyDataMgrToDomainExtents(std::vector<double> &domainExtents, const CoordType &dataMgrMinExts, const CoordType &dataMgrMaxExts, const Transform *transform) const;
112
113 void _calculateDomainExtents(std::vector<double> &domainExtents) const;
114
115 void drawDomainFrame(const std::vector<double> corners) const;
116
117 std::vector<double> getDomainExtents() const;
118 AxisAnnotation * getCurrentAxisAnnotation();
119 string getCurrentDataMgrName() const;
120 void scaleNormalizedCoordinatesToWorld(std::vector<double> &coords, string dataMgrName);
121
127 void _configureMatrixForArrows(MatrixManager *matrixManager);
128
129#ifdef VAPOR3_0_0_ALPHA
131 void drawRegionBounds(size_t ts) const;
132#endif
133
134 // Draw the axis lines, while building text labels.
135 //
136 void drawAxisTics(AxisAnnotation *aa = NULL);
137 void drawAxisTics(AxisAnnotation *aa, std::vector<double> minTic, std::vector<double> maxTic);
138
139 void applyTransform(Transform *t);
140 void renderText(double text, double coords[], AxisAnnotation *aa = NULL);
141 Transform *getTransform(string dataMgr = "");
142 void convertPointToLonLat(double &xCoord, double &yCoord);
143
144#ifdef VAPOR3_0_0_ALPHA
157 static void ConvertAxes(bool toLatLon, const vector<long> ticDirs, const vector<double> fromMinTic, const vector<double> fromMaxTic, const vector<double> fromOrigin,
158 const vector<double> fromTicLength, double toMinTic[3], double toMaxTic[3], double toOrigin[3], double toTicLength[3]);
159
160 // This method converts lon lat to user coords, assuming a "flat" earth so axes will not wrap.
161 static void flatConvertFromLonLat(double x[2], double minLon, double maxLon, double minX, double maxX);
162
163#endif
164};
165
166}; // namespace VAPoR
167
168#endif // ANNOTATIONRENDERER_H
Class that draws various geometry as specified by AnnotationParams.
void DrawAxisArrows()
Draw Axis arrows.
void InScenePaint(size_t ts)
Render the in-scene features.
void AddText(string text, int x, int y, int size, float color[3], int type=0)
void DrawText(vector< billboard > billboards)
void AddTextNormalizedCoords(string text, float x, float y, int size, float color[3], int type=0)
AnnotationRenderer(const ParamsMgr *pm, const DataStatus *dataStatus, string winName)
Constructor, must invoke Renderer constructor.
virtual ~AnnotationRenderer()
Destructor.
void ClearText(int type=-1)
void InitializeGL(GLManager *glManager)
Method to initialize GL rendering. Must be called from a GL context.
void OverlayPaint(size_t ts)
Render the overlay features.
class that indicates location and direction of view
A class for describing the currently loaded dataset.
Definition: DataStatus.h:50
Replaces the OpenGL matrix stack.
Definition: MatrixManager.h:27
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53
class that indicates location and direction of view
Definition: Transform.h:22
Wasp base class.
Definition: MyBase.h:67
#define RENDER_API
Definition: common.h:78
std::array< double, 3 > CoordType
Type for specifying floating point coordinates.
Definition: Grid.h:23
Contains references to context scope OpenGL data.
Definition: GLManager.h:18