source: nanovis/trunk/nanovis.h @ 4827

Last change on this file since 4827 was 4822, checked in by ldelgass, 10 years ago

Move md5 include

  • Property svn:eol-style set to native
File size: 5.1 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/BBox.h>
34#include <vrmath/Vector3f.h>
35
36#include "config.h"
37#include "Camera.h"
38#include "FlowTypes.h"
39
40//defines for the image based flow visualization
41#define NMESH 256       //resolution of flow mesh
42#define NPIX  512       //display size
43
44namespace nv {
45namespace graphics {
46    class RenderContext;
47}
48namespace util {
49    class Fonts;
50}
51
52class Flow;
53class Grid;
54class HeightMap;
55class LIC;
56class OrientationIndicator;
57class PlaneRenderer;
58class Texture2D;
59class TransferFunction;
60class VelocityArrowsSlice;
61class Volume;
62class VolumeRenderer;
63
64class NanoVis
65{
66public:
67    typedef std::string TransferFunctionId;
68    typedef std::string VolumeId;
69    typedef std::string FlowId;
70    typedef std::string HeightMapId;
71    typedef std::tr1::unordered_map<TransferFunctionId, TransferFunction *> TransferFunctionHashmap;
72    typedef std::tr1::unordered_map<VolumeId, Volume *> VolumeHashmap;
73    typedef std::tr1::unordered_map<FlowId, Flow *> FlowHashmap;
74    typedef std::tr1::unordered_map<HeightMapId, HeightMap *> HeightMapHashmap;
75
76    static bool init(const char *path);
77    static bool initGL();
78    static bool initOffscreenBuffer();
79    static bool resizeOffscreenBuffer(int w, int h);
80    static void setBgColor(float color[3]);
81    static void render();
82    static void update();
83    static void removeAllData();
84
85    static const Camera *getCamera()
86    {
87        return _camera;
88    }
89    static void panCamera(float dx, float dy);
90    static void zoomCamera(float z);
91    static void orientCamera(double *quat);
92    static void setCameraPosition(vrmath::Vector3f pos);
93    static void setCameraUpdir(Camera::AxisDirection dir);
94    static void resetCamera(bool resetOrientation = false);
95
96    static void eventuallyRedraw();
97 
98    static TransferFunction *getTransferFunction(const TransferFunctionId& id);
99    static TransferFunction *defineTransferFunction(const TransferFunctionId& id,
100                                                    size_t n, float *data);
101
102    static int renderLegend(TransferFunction *tf, double min, double max,
103                            int width, int height, const char *volArg);
104
105    static Volume *loadVolume(const char *tag, int width, int height, int depth,
106                              int numComponents, float *data, double vmin, double vmax,
107                              double nonZeroMin);
108
109    static void removeVolume(Volume *volume);
110
111    static void readScreen()
112    {
113        glPixelStorei(GL_PACK_ALIGNMENT, 1);
114        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
115                     screenBuffer);
116    }
117    static void bindOffscreenBuffer()
118    {
119        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
120    }
121
122    static void setVolumeRanges();
123    static void setHeightmapRanges();
124    static bool setFlowRanges();
125
126    static Flow *getFlow(const char *name);
127    static Flow *createFlow(Tcl_Interp *interp, const char *name);
128    static void deleteFlows(Tcl_Interp *interp);
129    static void deleteFlow(const char *name);
130
131    static void renderFlows();
132    static void resetFlows();
133    static bool updateFlows();
134    static void advectFlows();
135
136    static Tcl_Interp *interp;
137
138    static bool redrawPending;
139    static bool debugFlag;
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 vrmath::BBox sceneBounds;
155
156    static VolumeRenderer *volRenderer;
157    static VelocityArrowsSlice *velocityArrowsSlice;
158    static LIC *licRenderer;
159    static PlaneRenderer *planeRenderer;
160    static OrientationIndicator *orientationIndicator;
161    static Grid *grid;
162
163private:
164    static void collectBounds(bool onlyVisible = false);
165
166    static Camera *_camera;
167
168    //frame buffer for final rendering
169    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
170};
171
172}
173
174#endif
Note: See TracBrowser for help on using the repository browser.