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

Last change on this file since 3177 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

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