source: nanovis/trunk/nanovis.h @ 4894

Last change on this file since 4894 was 4887, checked in by ldelgass, 9 years ago

cleanup includes

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