source: nanovis/branches/1.2/nanovis.h @ 5523

Last change on this file since 5523 was 5523, checked in by ldelgass, 4 years ago

Remove old axis from nanovis

  • 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 <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
33//defines for the image based flow visualization
34#define NMESH 256       //resolution of flow mesh
35#define NPIX  512       //display size
36
37namespace nv {
38namespace graphics {
39    class RenderContext;
40}
41namespace util {
42    class Fonts;
43}
44
45class Flow;
46class Grid;
47class HeightMap;
48class LIC;
49class OrientationIndicator;
50class PlaneRenderer;
51class Texture2D;
52class TransferFunction;
53class VelocityArrowsSlice;
54class Volume;
55class VolumeRenderer;
56
57class NanoVis
58{
59public:
60    typedef std::string TransferFunctionId;
61    typedef std::string VolumeId;
62    typedef std::string FlowId;
63    typedef std::string HeightMapId;
64    typedef std::tr1::unordered_map<TransferFunctionId, TransferFunction *> TransferFunctionHashmap;
65    typedef std::tr1::unordered_map<VolumeId, Volume *> VolumeHashmap;
66    typedef std::tr1::unordered_map<FlowId, Flow *> FlowHashmap;
67    typedef std::tr1::unordered_map<HeightMapId, HeightMap *> HeightMapHashmap;
68
69    static bool init(const char *path);
70    static bool initGL();
71    static bool initOffscreenBuffer();
72    static bool resizeOffscreenBuffer(int w, int h);
73    static void setBgColor(float color[3]);
74    static void render();
75    static void update();
76    static void removeAllData();
77
78    static const Camera *getCamera()
79    {
80        return _camera;
81    }
82    static void panCamera(float dx, float dy);
83    static void zoomCamera(float z);
84    static void rotateCamera(float phi, float theta, float psi);
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    static void renderFlows();
125    static void resetFlows();
126    static bool updateFlows();
127    static void advectFlows();
128
129    static Tcl_Interp *interp;
130
131    static bool redrawPending;
132    static bool debugFlag;
133    static bool axisOn;
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 float xMin, xMax, yMin, yMax, zMin, zMax;
149    static vrmath::BBox sceneBounds;
150
151    static VolumeRenderer *volRenderer;
152    static VelocityArrowsSlice *velocityArrowsSlice;
153    static LIC *licRenderer;
154    static PlaneRenderer *planeRenderer;
155    static OrientationIndicator *orientationIndicator;
156    static Grid *grid;
157
158private:
159    static void collectBounds(bool onlyVisible = false);
160
161    static Camera *_camera;
162
163    //frame buffer for final rendering
164    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
165};
166
167}
168
169#endif
Note: See TracBrowser for help on using the repository browser.