source: trunk/packages/vizservers/nanovis/nanovis.h @ 3628

Last change on this file since 3628 was 3626, checked in by ldelgass, 11 years ago

Remove unused method from nanovis.h

  • Property svn:eol-style set to native
File size: 5.5 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * ----------------------------------------------------------------------
4 *  nanovis.h: package header
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
10 *  Copyright (c) 2004-2013  HUBzero Foundation, LLC
11 *
12 *  See the file "license.terms" for information on usage and
13 *  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 * ======================================================================
15 */
16#ifndef NV_NANOVIS_H
17#define NV_NANOVIS_H
18
19#include <math.h>
20#include <stddef.h> // For size_t
21#include <stdio.h>
22#include <sys/time.h>
23#include <sys/types.h> // For pid_t
24
25#include <tcl.h>
26
27#include <GL/glew.h>
28
29#include <vector>
30#include <iostream>
31#include <tr1/unordered_map>
32
33#include <vrmath/Vector3f.h>
34
35#include "config.h"
36#include "md5.h"
37
38//defines for the image based flow visualization
39#define NMESH 256       //resolution of flow mesh
40#define NPIX  512       //display size
41
42namespace nv {
43namespace graphics {
44    class RenderContext;
45}
46namespace util {
47    class Fonts;
48}
49
50class Camera;
51class Flow;
52class Grid;
53class HeightMap;
54class LIC;
55class OrientationIndicator;
56class PlaneRenderer;
57class Texture2D;
58class TransferFunction;
59class VelocityArrowsSlice;
60class Volume;
61class VolumeRenderer;
62
63class NanoVis
64{
65public:
66    enum AxisDirections {
67        X_POS = 1,
68        Y_POS = 2,
69        Z_POS = 3,
70        X_NEG = -1,
71        Y_NEG = -2,
72        Z_NEG = -3
73    };
74
75    enum NanoVisFlags {
76        REDRAW_PENDING = (1 << 0),
77        MAP_FLOWS = (1 << 1)
78    };
79
80    typedef std::string TransferFunctionId;
81    typedef std::string VolumeId;
82    typedef std::string FlowId;
83    typedef std::string HeightMapId;
84    typedef std::tr1::unordered_map<TransferFunctionId, TransferFunction *> TransferFunctionHashmap;
85    typedef std::tr1::unordered_map<VolumeId, Volume *> VolumeHashmap;
86    typedef std::tr1::unordered_map<FlowId, Flow *> FlowHashmap;
87    typedef std::tr1::unordered_map<HeightMapId, HeightMap *> HeightMapHashmap;
88
89    static bool init(const char *path);
90    static bool initGL();
91    static bool initOffscreenBuffer();
92    static bool resizeOffscreenBuffer(int w, int h);
93    static void setBgColor(float color[3]);
94    static void render();
95    static void update();
96    static void removeAllData();
97
98    static const Camera *getCamera()
99    {
100        return cam;
101    }
102    static void pan(float dx, float dy);
103    static void zoom(float z);
104    static void resetCamera(bool resetOrientation = false);
105
106    static void eventuallyRedraw(unsigned int flag = 0);
107
108    static void setVolumeRanges();
109    static void setHeightmapRanges();
110 
111    static TransferFunction *getTransferFunction(const TransferFunctionId& id);
112    static TransferFunction *defineTransferFunction(const TransferFunctionId& id,
113                                                    size_t n, float *data);
114
115    static int renderLegend(TransferFunction *tf, double min, double max,
116                            int width, int height, const char *volArg);
117
118    static Volume *loadVolume(const char *tag, int width, int height, int depth,
119                              int numComponents, float *data, double vmin, double vmax,
120                              double nonZeroMin);
121
122    static void removeVolume(Volume *volume);
123
124    static void readScreen()
125    {
126        glPixelStorei(GL_PACK_ALIGNMENT, 1);
127        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
128                     screenBuffer);
129    }
130    static void bindOffscreenBuffer()
131    {
132        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
133    }
134
135    static Flow *getFlow(const char *name);
136    static Flow *createFlow(Tcl_Interp *interp, const char *name);
137    static void deleteFlows(Tcl_Interp *interp);
138    static void deleteFlow(const char *name);
139    static bool mapFlows();
140    static void getFlowBounds(vrmath::Vector3f& min,
141                              vrmath::Vector3f& max,
142                              bool onlyVisible = false);
143    static void renderFlows();
144    static void resetFlows();
145    static bool updateFlows();
146    static void advectFlows();
147
148    static Tcl_Interp *interp;
149
150    static unsigned int flags;
151    static bool debugFlag;
152
153    static int winWidth;        ///< Width of the render window
154    static int winHeight;       ///< Height of the render window
155    static int renderWindow;    //< GLUT handle for the render window
156    static unsigned char *screenBuffer;
157    static Texture2D *legendTexture;
158    static util::Fonts *fonts;
159    static int updir;
160    static Camera *cam;
161    static graphics::RenderContext *renderContext;
162
163    static TransferFunctionHashmap tfTable; ///< maps transfunc name to TransferFunction object
164    static VolumeHashmap volumeTable;
165    static FlowHashmap flowTable;
166    static HeightMapHashmap heightMapTable;
167
168    static double magMin, magMax;
169    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
170    static vrmath::Vector3f sceneMin, sceneMax;
171
172    static VolumeRenderer *volRenderer;
173    static VelocityArrowsSlice *velocityArrowsSlice;
174    static LIC *licRenderer;
175    static PlaneRenderer *planeRenderer;
176    static OrientationIndicator *orientationIndicator;
177    static Grid *grid;
178
179private:
180    static void collectBounds(bool onlyVisible = false);
181
182    static float _licSlice;  ///< Slice position [0,1]
183    static int _licAxis;     ///< Slice axis: 0:x, 1:y, 2:z
184
185    //frame buffer for final rendering
186    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
187};
188
189}
190
191#endif
Note: See TracBrowser for help on using the repository browser.