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

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

Remove XINETD define from nanovis. We only support server mode now, no glut
interaction loop with mouse/keyboard handlers. Fixes for trace logging to make
output closer to vtkvis: inlcude function name for trace messages, remove
newlines from format strings in macros since newlines get added by syslog.

  • Property svn:eol-style set to native
File size: 5.5 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 processCommands();
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 display();
80    static void draw3dAxis();
81    static void idle();
82    static void update();
83    static void removeAllData();
84
85    static const NvCamera *getCamera()
86    {
87        return cam;
88    }
89    static void pan(float dx, float dy);
90    static void zoom(float z);
91
92    static void eventuallyRedraw(unsigned int flag = 0);
93
94    static void setVolumeRanges();
95    static void setHeightmapRanges();
96
97#ifdef KEEPSTATS
98    static int getStatsFile(Tcl_Obj *objPtr);
99    static int writeToStatsFile(int f, const char *s, size_t length);
100#endif
101    static void ppmWrite(const char *prefix);
102    static void sendDataToClient(const char *command, const char *data,
103                                 size_t dlen);
104    static void bmpWrite(const char *prefix);
105    static void bmpWriteToFile(int frame_number, const char* directory_name);
106 
107    static TransferFunction *getTransfunc(const char *name);
108    static TransferFunction *defineTransferFunction(const char *name, 
109                                                    size_t n, float *data);
110
111    static int renderLegend(TransferFunction *tf, double min, double max, 
112                            int width, int height, const char *volArg);
113
114    static Volume *loadVolume(const char *tag, int width, int height, int depth,
115                              int n, float* data, double vmin, double vmax, 
116                              double nonZeroMin);
117
118    static void removeVolume(Volume *volPtr);
119
120    static void readScreen()
121    {
122        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, 
123                     screenBuffer);
124    }
125    static void bindOffscreenBuffer()
126    {
127        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
128    }
129
130    static FlowCmd *FirstFlow(FlowIterator *iterPtr);
131    static FlowCmd *NextFlow(FlowIterator *iterPtr);
132    static void InitFlows();
133    static int GetFlow(Tcl_Interp *interp, Tcl_Obj *objPtr,
134                       FlowCmd **flowPtrPtr);
135    static int CreateFlow(Tcl_Interp *interp, Tcl_Obj *objPtr);
136    static void DeleteFlows(Tcl_Interp *interp);
137    static bool MapFlows();
138    static void RenderFlows();
139    static void ResetFlows();
140    static bool UpdateFlows();
141    static void AdvectFlows();
142
143    static FILE *stdin, *logfile, *recfile;
144    static int statsFile;
145    static unsigned int flags;
146    static bool debugFlag;
147    static bool axisOn;
148    static int winWidth;        //size of the render window
149    static int winHeight;       //size of the render window
150    static int renderWindow;
151    static unsigned char *screenBuffer;
152    static Texture2D *legendTexture;
153    static Grid *grid;
154    static R2Fonts *fonts;
155    static int updir;
156    static NvCamera *cam;
157    static graphics::RenderContext *renderContext;
158
159    static Tcl_HashTable tfTable;
160    static Tcl_HashTable volumeTable;
161    static Tcl_HashTable flowTable;
162    static Tcl_HashTable heightmapTable;
163
164    static double magMin, magMax;
165    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
166
167    static NvColorTableRenderer *colorTableRenderer;
168    static VolumeRenderer *volRenderer;
169#ifdef notdef
170    static NvFlowVisRenderer *flowVisRenderer;
171#endif
172    static VelocityArrowsSlice *velocityArrowsSlice;
173    static NvLIC *licRenderer;
174    static PlaneRenderer *planeRenderer;
175#if PLANE_CMD
176    static int numPlanes;
177    static Texture2D *plane[]; ///< Pointers to 2D planes
178#endif
179#ifdef USE_POINTSET_RENDERER
180    static PointSetRenderer *pointSetRenderer;
181    static std::vector<PointSet *> pointSet;
182#endif
183
184    static Tcl_Interp *interp;
185    static struct timeval startTime;           /* Start of elapsed time. */
186private:
187    static float _licSlice;  ///< Slice position [0,1]
188    static int _licAxis;     ///< Slice axis: 0:x, 1:y, 2:z
189
190    //frame buffer for final rendering
191    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
192};
193
194#endif
Note: See TracBrowser for help on using the repository browser.