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

Last change on this file since 2849 was 2847, checked in by ldelgass, 12 years ago

Move a few defines used exclusively by lic renderer to implementation module
and out of nanovis.h

  • Property svn:eol-style set to native
File size: 6.0 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-2006  Purdue Research Foundation
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 "define.h"
33#include "global.h"
34#include "config.h"
35
36#define NANOVIS_VERSION         "1.0"
37
38//defines for the image based flow visualization
39#define NMESH 256       //resolution of flow mesh
40#define NPIX  512       //display size
41
42namespace graphics {
43    class RenderContext;
44}
45
46class VolumeRenderer;
47class PointSetRenderer;
48class NvParticleRenderer;
49class NvFlowVisRenderer;
50class PlaneRenderer;
51class VelocityArrowsSlice;
52class NvLIC;
53class PointSet;
54class Texture2D;
55class NvColorTableRenderer;
56class HeightMap;
57class NvVectorField;
58class Grid;
59class R2Fonts;
60class NvCamera;
61class TransferFunction;
62class Volume;
63class FlowCmd;
64class FlowIterator;
65
66class NanoVis
67{
68public:
69    enum NanoVisFlags {
70        REDRAW_PENDING = (1 << 0),
71        MAP_FLOWS = (1 << 1),
72        MAP_VOLUMES = (1 << 2),
73        MAP_HEIGHTMAPS = (1 << 3),
74    };
75
76    static void init(const char *path);
77    static void xinetd_listen();
78    static void initGL();
79    static void init_offscreen_buffer();
80    static void resize_offscreen_buffer(int w, int h);
81    static void resize(int w, int h);
82    static void render();
83    static void display();
84    static void idle();
85    static void update();
86    static void display_offscreen_buffer();
87    static void pan(float dx, float dy);
88    static void zoom(float z);
89
90    static void EventuallyRedraw(unsigned int flag = 0);
91
92    static void SetVolumeRanges();
93    static void SetHeightmapRanges();
94
95    static void init_lic();
96    static void initParticle();
97
98    static void ppm_write(const char *prefix);
99    static void sendDataToClient(const char *command, const char *data,
100                                 size_t dlen);
101    static void bmp_write(const char *prefix);
102    static void bmp_write_to_file(int frame_number, const char* directory_name);
103 
104    static TransferFunction *get_transfunc(const char *name);
105    static TransferFunction *DefineTransferFunction(const char *name,
106                                                    size_t n, float *data);
107
108    static int render_2d_contour(HeightMap *heightmap, int width, int height);
109
110    static int render_legend(TransferFunction *tf, double min, double max,
111                             int width, int height, const char *volArg);
112
113    static Volume *load_volume(const char *tag, int width, int height,
114                               int depth, int n, float* data, double vmin, double vmax,
115                               double nzero_min);
116    static void remove_volume(Volume *volPtr);
117
118#ifndef XINETD
119    static void keyboard(unsigned char key, int x, int y);
120    static void mouse(int button, int state, int x, int y);
121    static void motion(int x, int y);
122    static void update_rot(int delta_x, int delta_y);
123    static void update_trans(int delta_x, int delta_y, int delta_z);
124#endif
125
126    static void read_screen()
127    {
128        glReadPixels(0, 0, win_width, win_height, GL_RGB, GL_UNSIGNED_BYTE,
129                     screen_buffer);
130    }
131    static void offscreen_buffer_capture()
132    {
133        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _final_fbo);
134    }
135
136    static FlowCmd *FirstFlow(FlowIterator *iterPtr);
137    static FlowCmd *NextFlow(FlowIterator *iterPtr);
138    static void InitFlows();
139    static int GetFlow(Tcl_Interp *interp, Tcl_Obj *objPtr,
140                       FlowCmd **flowPtrPtr);
141    static int CreateFlow(Tcl_Interp *interp, Tcl_Obj *objPtr);
142    static void DeleteFlows(Tcl_Interp *interp);
143    static bool MapFlows();
144    static void RenderFlows();
145    static void ResetFlows();
146    static bool UpdateFlows();
147    static void AdvectFlows();
148
149    static FILE *stdin, *logfile, *recfile;
150
151    static unsigned int flags;
152    static bool debug_flag;
153    static bool axis_on;
154    static bool config_pending; // Indicates if the limits need to be recomputed.
155    static int win_width;       //size of the render window
156    static int win_height;      //size of the render window
157    static int render_window;
158    static unsigned char *screen_buffer;
159    static Grid *grid;
160    static R2Fonts *fonts;
161    static int updir;
162    static NvCamera *cam;
163    static graphics::RenderContext *renderContext;
164
165    static Tcl_HashTable volumeTable;
166
167    static std::vector<NvVectorField *> flow;
168    static Tcl_HashTable flowTable;
169    static double magMin, magMax;
170    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
171    static float xOrigin, yOrigin, zOrigin;
172
173    static VolumeRenderer *vol_renderer;
174    static NvFlowVisRenderer *flowVisRenderer;
175    static VelocityArrowsSlice *velocityArrowsSlice;
176    static NvLIC *licRenderer;
177    static PlaneRenderer *plane_renderer;
178#if PLANE_CMD
179    static Texture2D *plane[]; ///< Pointers to 2D planes
180#endif
181#ifdef USE_POINTSET_RENDERER
182    static PointSetRenderer *pointset_renderer;
183    static std::vector<PointSet *> pointSet;
184#endif
185
186    static Tcl_HashTable tfTable;
187    static Texture2D *legendTexture;
188    static NvColorTableRenderer *color_table_renderer;
189
190    static std::vector<HeightMap *> heightMap;
191    static Tcl_HashTable heightmapTable;
192
193    static float lic_slice_x;
194    static float lic_slice_y;
195    static float lic_slice_z;
196    static int lic_axis;        /* 0:x, 1:y, 2:z */
197
198    static Tcl_Interp *interp;
199    static Tcl_DString cmdbuffer;
200
201private:
202    //frame buffer for final rendering
203    static GLuint _final_fbo, _final_color_tex, _final_depth_rb;
204};
205
206#endif
Note: See TracBrowser for help on using the repository browser.