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

Last change on this file since 3464 was 3463, checked in by ldelgass, 7 years ago

Begin process of renaming R2 library

  • Property svn:eol-style set to native
File size: 5.6 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-2012  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 NANOVIS_H
17#define NANOVIS_H
18
19#include <tcl.h>
20#include <md5.h>
21#include <GL/glew.h>
22
23#include <math.h>
24#include <stddef.h> // For size_t
25#include <stdio.h>
26
27#include <vector>
28#include <iostream>
29
30#include <rappture.h>
31
32#include "config.h"
33
34#define NANOVIS_VERSION         "1.1"
35
36//defines for the image based flow visualization
37#define NMESH 256       //resolution of flow mesh
38#define NPIX  512       //display size
39
40namespace nv {
41namespace graphics {
42    class RenderContext;
43}
44namespace util {
45    class Fonts;
46}
47}
48
49class VolumeRenderer;
50class PointSetRenderer;
51class NvParticleRenderer;
52class NvFlowVisRenderer;
53class PlaneRenderer;
54class VelocityArrowsSlice;
55class NvLIC;
56class PointSet;
57class Texture2D;
58class NvColorTableRenderer;
59class HeightMap;
60class NvVectorField;
61class Grid;
62class NvCamera;
63class TransferFunction;
64class Volume;
65class FlowCmd;
66class FlowIterator;
67
68class NanoVis
69{
70public:
71    enum NanoVisFlags { 
72        REDRAW_PENDING = (1 << 0), 
73        MAP_FLOWS = (1 << 1),
74        MAP_VOLUMES = (1 << 2),
75        MAP_HEIGHTMAPS = (1 << 3),
76    };
77
78    static void processCommands();
79    static void init(const char *path);
80    static void initGL();
81    static void initOffscreenBuffer();
82    static void resizeOffscreenBuffer(int w, int h);
83    static void display();
84    static void draw3dAxis();
85    static void idle();
86    static void update();
87    static void removeAllData();
88
89    static const NvCamera *getCamera()
90    {
91        return cam;
92    }
93    static void pan(float dx, float dy);
94    static void zoom(float z);
95
96    static void eventuallyRedraw(unsigned int flag = 0);
97
98    static void setVolumeRanges();
99    static void setHeightmapRanges();
100
101#ifdef KEEPSTATS
102    static int getStatsFile(Tcl_Obj *objPtr);
103    static int writeToStatsFile(int f, const char *s, size_t length);
104#endif
105    static void ppmWrite(const char *prefix);
106    static void sendDataToClient(const char *command, const char *data,
107                                 size_t dlen);
108    static void bmpWrite(const char *prefix);
109    static void bmpWriteToFile(int frame_number, const char* directory_name);
110 
111    static TransferFunction *getTransfunc(const char *name);
112    static TransferFunction *defineTransferFunction(const char *name, 
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 n, float* data, double vmin, double vmax, 
120                              double nonZeroMin);
121
122    static void removeVolume(Volume *volPtr);
123
124    static void readScreen()
125    {
126        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, 
127                     screenBuffer);
128    }
129    static void bindOffscreenBuffer()
130    {
131        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
132    }
133
134    static FlowCmd *FirstFlow(FlowIterator *iterPtr);
135    static FlowCmd *NextFlow(FlowIterator *iterPtr);
136    static void InitFlows();
137    static int GetFlow(Tcl_Interp *interp, Tcl_Obj *objPtr,
138                       FlowCmd **flowPtrPtr);
139    static int CreateFlow(Tcl_Interp *interp, Tcl_Obj *objPtr);
140    static void DeleteFlows(Tcl_Interp *interp);
141    static bool MapFlows();
142    static void RenderFlows();
143    static void ResetFlows();
144    static bool UpdateFlows();
145    static void AdvectFlows();
146
147    static FILE *stdin, *logfile, *recfile;
148    static int statsFile;
149    static unsigned int flags;
150    static bool debugFlag;
151    static bool axisOn;
152    static int winWidth;        //size of the render window
153    static int winHeight;       //size of the render window
154    static int renderWindow;
155    static unsigned char *screenBuffer;
156    static Texture2D *legendTexture;
157    static Grid *grid;
158    static nv::util::Fonts *fonts;
159    static int updir;
160    static NvCamera *cam;
161    static nv::graphics::RenderContext *renderContext;
162
163    static Tcl_HashTable tfTable;
164    static Tcl_HashTable volumeTable;
165    static Tcl_HashTable flowTable;
166    static Tcl_HashTable heightmapTable;
167
168    static double magMin, magMax;
169    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
170
171    static NvColorTableRenderer *colorTableRenderer;
172    static VolumeRenderer *volRenderer;
173#ifdef notdef
174    static NvFlowVisRenderer *flowVisRenderer;
175#endif
176    static VelocityArrowsSlice *velocityArrowsSlice;
177    static NvLIC *licRenderer;
178    static PlaneRenderer *planeRenderer;
179#if PLANE_CMD
180    static int numPlanes;
181    static Texture2D *plane[]; ///< Pointers to 2D planes
182#endif
183#ifdef USE_POINTSET_RENDERER
184    static PointSetRenderer *pointSetRenderer;
185    static std::vector<PointSet *> pointSet;
186#endif
187
188    static Tcl_Interp *interp;
189    static struct timeval startTime;           /* Start of elapsed time. */
190private:
191    static float _licSlice;  ///< Slice position [0,1]
192    static int _licAxis;     ///< Slice axis: 0:x, 1:y, 2:z
193
194    //frame buffer for final rendering
195    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
196};
197
198#endif
Note: See TracBrowser for help on using the repository browser.