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

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

Add background color protocol command to nanovis, also change resize protocol
to use 'size', so new commands are:

screen bgcolor r g b
screen size width height

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