source: nanovis/branches/1.1/nanovis.h @ 4923

Last change on this file since 4923 was 4904, checked in by ldelgass, 10 years ago

Merge serveral changes from trunk. Does not include threading, world space
changes, etc.

  • Property svn:eol-style set to native
File size: 5.4 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 <cstddef> // For size_t
20#include <string>
21#include <tr1/unordered_map>
22
23#include <tcl.h>
24
25#include <GL/glew.h>
26
27#include <vrmath/Vector3f.h>
28
29#include "config.h"
30#include "Camera.h"
31
32//defines for the image based flow visualization
33#define NMESH 256       //resolution of flow mesh
34#define NPIX  512       //display size
35
36namespace nv {
37namespace graphics {
38    class RenderContext;
39}
40namespace util {
41    class Fonts;
42}
43
44class Flow;
45class Grid;
46class HeightMap;
47class LIC;
48class PlaneRenderer;
49class Texture2D;
50class TransferFunction;
51class VelocityArrowsSlice;
52class Volume;
53class VolumeRenderer;
54
55class NanoVis
56{
57public:
58    typedef std::string TransferFunctionId;
59    typedef std::string VolumeId;
60    typedef std::string FlowId;
61    typedef std::string HeightMapId;
62    typedef std::tr1::unordered_map<TransferFunctionId, TransferFunction *> TransferFunctionHashmap;
63    typedef std::tr1::unordered_map<VolumeId, Volume *> VolumeHashmap;
64    typedef std::tr1::unordered_map<FlowId, Flow *> FlowHashmap;
65    typedef std::tr1::unordered_map<HeightMapId, HeightMap *> HeightMapHashmap;
66
67    static bool init(const char *path);
68    static bool initGL();
69    static bool initOffscreenBuffer();
70    static bool resizeOffscreenBuffer(int w, int h);
71    static void setBgColor(float color[3]);
72    static void render();
73    static void draw3dAxis();
74    static void update();
75    static void removeAllData();
76
77    static const Camera *getCamera()
78    {
79        return _camera;
80    }
81    static void panCamera(float dx, float dy);
82    static void zoomCamera(float z);
83    static void rotateCamera(float phi, float theta, float psi);
84    static void orientCamera(double *quat);
85    static void setCameraPosition(vrmath::Vector3f pos);
86    static void setCameraUpdir(Camera::AxisDirection dir);
87    static void resetCamera(bool resetOrientation = false);
88
89    static void eventuallyRedraw();
90
91    static void ppmWrite(const char *prefix);
92    static void bmpWrite(const char *prefix);
93    static void bmpWriteToFile(int frameNum, const char* dirName);
94 
95    static TransferFunction *getTransferFunction(const TransferFunctionId& id);
96    static TransferFunction *defineTransferFunction(const TransferFunctionId& id,
97                                                    size_t n, float *data);
98
99    static int renderLegend(TransferFunction *tf, double min, double max,
100                            int width, int height, const char *volArg);
101
102    static Volume *loadVolume(const char *tag, int width, int height, int depth,
103                              int numComponents, float *data, double vmin, double vmax,
104                              double nonZeroMin);
105
106    static void removeVolume(Volume *volume);
107
108    static void readScreen()
109    {
110        //glPixelStorei(GL_PACK_ALIGNMENT, 1);
111        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
112                     screenBuffer);
113    }
114    static void bindOffscreenBuffer()
115    {
116        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
117    }
118
119    static void setVolumeRanges();
120    static void setHeightmapRanges();
121    static bool setFlowRanges();
122
123    static Flow *getFlow(const char *name);
124    static Flow *createFlow(Tcl_Interp *interp, const char *name);
125    static void deleteFlows(Tcl_Interp *interp);
126    static void deleteFlow(const char *name);
127    static void getFlowBounds(vrmath::Vector3f& min,
128                              vrmath::Vector3f& max,
129                              bool onlyVisible = false);
130    static void renderFlows();
131    static void resetFlows();
132    static bool updateFlows();
133    static void advectFlows();
134
135    static Tcl_Interp *interp;
136
137    static bool redrawPending;
138    static bool debugFlag;
139    static bool axisOn;
140
141    static int winWidth;        ///< Width of the render window
142    static int winHeight;       ///< Height of the render window
143    static int renderWindow;    ///< GLUT handle for the render window
144    static unsigned char *screenBuffer;
145    static Texture2D *legendTexture;
146    static util::Fonts *fonts;
147    static graphics::RenderContext *renderContext;
148
149    static TransferFunctionHashmap tfTable; ///< maps transfunc name to TransferFunction object
150    static VolumeHashmap volumeTable;
151    static FlowHashmap flowTable;
152    static HeightMapHashmap heightMapTable;
153
154    static double magMin, magMax;
155    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
156    static vrmath::Vector3f sceneMin, sceneMax;
157
158    static VolumeRenderer *volRenderer;
159    static VelocityArrowsSlice *velocityArrowsSlice;
160    static LIC *licRenderer;
161    static PlaneRenderer *planeRenderer;
162    static Grid *grid;
163
164private:
165    static void collectBounds(bool onlyVisible = false);
166
167    static Camera *_camera;
168
169    //frame buffer for final rendering
170    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
171};
172
173}
174
175#endif
Note: See TracBrowser for help on using the repository browser.