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

Last change on this file since 3377 was 3377, checked in by gah, 10 years ago

rework of stats log file.

  • Property svn:eol-style set to native
File size: 5.9 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 graphics {
41    class RenderContext;
42}
43
44class VolumeRenderer;
45class PointSetRenderer;
46class NvParticleRenderer;
47class NvFlowVisRenderer;
48class PlaneRenderer;
49class VelocityArrowsSlice;
50class NvLIC;
51class PointSet;
52class Texture2D;
53class NvColorTableRenderer;
54class HeightMap;
55class NvVectorField;
56class Grid;
57class R2Fonts;
58class NvCamera;
59class TransferFunction;
60class Volume;
61class FlowCmd;
62class FlowIterator;
63
64class NanoVis
65{
66public:
67    enum NanoVisFlags {
68        REDRAW_PENDING = (1 << 0),
69        MAP_FLOWS = (1 << 1),
70        MAP_VOLUMES = (1 << 2),
71        MAP_HEIGHTMAPS = (1 << 3),
72    };
73
74    static void xinetdListen();
75    static void init(const char *path);
76    static void initGL();
77    static void initOffscreenBuffer();
78    static void resizeOffscreenBuffer(int w, int h);
79    static void displayOffscreenBuffer();
80    static void display();
81    static void draw3dAxis();
82    static void idle();
83    static void update();
84    static void removeAllData();
85
86    static const NvCamera *getCamera()
87    {
88        return cam;
89    }
90    static void pan(float dx, float dy);
91    static void zoom(float z);
92
93    static void eventuallyRedraw(unsigned int flag = 0);
94
95    static void setVolumeRanges();
96    static void setHeightmapRanges();
97
98#ifdef KEEPSTATS
99    static int getStatsFile(Tcl_Obj *objPtr);
100    static int writeToStatsFile(int f, const char *s, size_t length);
101#endif
102    static void ppmWrite(const char *prefix);
103    static void sendDataToClient(const char *command, const char *data,
104                                 size_t dlen);
105    static void bmpWrite(const char *prefix);
106    static void bmpWriteToFile(int frame_number, const char* directory_name);
107 
108    static TransferFunction *getTransfunc(const char *name);
109    static TransferFunction *defineTransferFunction(const char *name,
110                                                    size_t n, float *data);
111
112    static int renderLegend(TransferFunction *tf, double min, double max,
113                            int width, int height, const char *volArg);
114
115    static Volume *loadVolume(const char *tag, int width, int height, int depth,
116                              int n, float* data, double vmin, double vmax,
117                              double nonZeroMin);
118
119    static void removeVolume(Volume *volPtr);
120
121#ifndef XINETD
122    static void keyboard(unsigned char key, int x, int y);
123    static void mouse(int button, int state, int x, int y);
124    static void motion(int x, int y);
125    static void updateRot(int delta_x, int delta_y);
126    static void updateTrans(int delta_x, int delta_y, int delta_z);
127    static void resize(int w, int h);
128    static void render();
129#endif
130
131    static void readScreen()
132    {
133        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
134                     screenBuffer);
135    }
136    static void bindOffscreenBuffer()
137    {
138        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
139    }
140
141    static FlowCmd *FirstFlow(FlowIterator *iterPtr);
142    static FlowCmd *NextFlow(FlowIterator *iterPtr);
143    static void InitFlows();
144    static int GetFlow(Tcl_Interp *interp, Tcl_Obj *objPtr,
145                       FlowCmd **flowPtrPtr);
146    static int CreateFlow(Tcl_Interp *interp, Tcl_Obj *objPtr);
147    static void DeleteFlows(Tcl_Interp *interp);
148    static bool MapFlows();
149    static void RenderFlows();
150    static void ResetFlows();
151    static bool UpdateFlows();
152    static void AdvectFlows();
153
154    static FILE *stdin, *logfile, *recfile;
155    static int statsFile;
156    static unsigned int flags;
157    static bool debugFlag;
158    static bool axisOn;
159    static int winWidth;        //size of the render window
160    static int winHeight;       //size of the render window
161    static int renderWindow;
162    static unsigned char *screenBuffer;
163    static Texture2D *legendTexture;
164    static Grid *grid;
165    static R2Fonts *fonts;
166    static int updir;
167    static NvCamera *cam;
168    static graphics::RenderContext *renderContext;
169
170    static Tcl_HashTable tfTable;
171    static Tcl_HashTable volumeTable;
172    static Tcl_HashTable flowTable;
173    static Tcl_HashTable heightmapTable;
174
175    static double magMin, magMax;
176    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
177
178    static NvColorTableRenderer *colorTableRenderer;
179    static VolumeRenderer *volRenderer;
180#ifdef notdef
181    static NvFlowVisRenderer *flowVisRenderer;
182#endif
183    static VelocityArrowsSlice *velocityArrowsSlice;
184    static NvLIC *licRenderer;
185    static PlaneRenderer *planeRenderer;
186#if PLANE_CMD
187    static int numPlanes;
188    static Texture2D *plane[]; ///< Pointers to 2D planes
189#endif
190#ifdef USE_POINTSET_RENDERER
191    static PointSetRenderer *pointSetRenderer;
192    static std::vector<PointSet *> pointSet;
193#endif
194
195    static Tcl_Interp *interp;
196    static struct timeval startTime;           /* Start of elapsed time. */
197private:
198    static float _licSlice;  ///< Slice position [0,1]
199    static int _licAxis;     ///< Slice axis: 0:x, 1:y, 2:z
200
201    //frame buffer for final rendering
202    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
203};
204
205#endif
Note: See TracBrowser for help on using the repository browser.