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

Last change on this file since 3376 was 3376, checked in by gah, 11 years ago

new version of stats file handling without file locking

  • Property svn:eol-style set to native
File size: 5.9 KB
RevLine 
[2798]1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
[226]2/*
3 * ----------------------------------------------------------------------
4 *  nanovis.h: package header
5 *
6 * ======================================================================
7 *  AUTHOR:  Wei Qiao <qiaow@purdue.edu>
8 *           Purdue Rendering and Perceptualization Lab (PURPL)
9 *
[3177]10 *  Copyright (c) 2004-2012  HUBzero Foundation, LLC
[226]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 */
[2831]16#ifndef NANOVIS_H
17#define NANOVIS_H
[259]18
[850]19#include <tcl.h>
20
[226]21#include <GL/glew.h>
[2831]22
[226]23#include <math.h>
[2831]24#include <stddef.h> // For size_t
[226]25#include <stdio.h>
26
[2831]27#include <vector>
28#include <iostream>
29
[2818]30#include <rappture.h>
31
[251]32#include "config.h"
[226]33
[3362]34#define NANOVIS_VERSION         "1.1"
[251]35
[226]36//defines for the image based flow visualization
37#define NMESH 256       //resolution of flow mesh
38#define NPIX  512       //display size
39
[2831]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;
[1370]55class NvVectorField;
[2831]56class Grid;
57class R2Fonts;
58class NvCamera;
59class TransferFunction;
60class Volume;
61class FlowCmd;
62class FlowIterator;
[1370]63
[2822]64class NanoVis
65{
[2831]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    };
[2822]73
[2930]74    static void xinetdListen();
[2831]75    static void init(const char *path);
76    static void initGL();
[2877]77    static void initOffscreenBuffer();
78    static void resizeOffscreenBuffer(int w, int h);
[2930]79    static void displayOffscreenBuffer();
[2847]80    static void display();
[2951]81    static void draw3dAxis();
[2847]82    static void idle();
83    static void update();
[2951]84    static void removeAllData();
[2930]85
[3362]86    static const NvCamera *getCamera()
87    {
88        return cam;
89    }
[2847]90    static void pan(float dx, float dy);
91    static void zoom(float z);
[1299]92
[2877]93    static void eventuallyRedraw(unsigned int flag = 0);
[2847]94
[2877]95    static void setVolumeRanges();
96    static void setHeightmapRanges();
[3362]97
98#ifdef KEEPSTATS
[3376]99    static int openStatsFile(const char *path);
[3362]100    static int writeToStatsFile(const char *s, size_t length);
[2951]101#endif
[2877]102    static void ppmWrite(const char *prefix);
[1295]103    static void sendDataToClient(const char *command, const char *data,
[2831]104                                 size_t dlen);
[2877]105    static void bmpWrite(const char *prefix);
106    static void bmpWriteToFile(int frame_number, const char* directory_name);
[2847]107 
[2877]108    static TransferFunction *getTransfunc(const char *name);
109    static TransferFunction *defineTransferFunction(const char *name,
[2847]110                                                    size_t n, float *data);
111
[2877]112    static int renderLegend(TransferFunction *tf, double min, double max,
113                            int width, int height, const char *volArg);
[2847]114
[2877]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);
[1156]118
[2877]119    static void removeVolume(Volume *volPtr);
120
[835]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);
[2877]125    static void updateRot(int delta_x, int delta_y);
126    static void updateTrans(int delta_x, int delta_y, int delta_z);
[2930]127    static void resize(int w, int h);
128    static void render();
[835]129#endif
[1028]130
[2877]131    static void readScreen()
[2822]132    {
[2877]133        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
134                     screenBuffer);
[1028]135    }
[2930]136    static void bindOffscreenBuffer()
[2822]137    {
[2877]138        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
[1028]139    }
[1431]140
141    static FlowCmd *FirstFlow(FlowIterator *iterPtr);
142    static FlowCmd *NextFlow(FlowIterator *iterPtr);
[2831]143    static void InitFlows();
144    static int GetFlow(Tcl_Interp *interp, Tcl_Obj *objPtr,
145                       FlowCmd **flowPtrPtr);
[1431]146    static int CreateFlow(Tcl_Interp *interp, Tcl_Obj *objPtr);
147    static void DeleteFlows(Tcl_Interp *interp);
[2831]148    static bool MapFlows();
149    static void RenderFlows();
150    static void ResetFlows();
151    static bool UpdateFlows();
152    static void AdvectFlows();
153
[2846]154    static FILE *stdin, *logfile, *recfile;
[3376]155    static int statsFile;
[2846]156    static unsigned int flags;
[2877]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;
[2951]163    static Texture2D *legendTexture;
[2846]164    static Grid *grid;
165    static R2Fonts *fonts;
166    static int updir;
167    static NvCamera *cam;
168    static graphics::RenderContext *renderContext;
169
[2951]170    static Tcl_HashTable tfTable;
[2846]171    static Tcl_HashTable volumeTable;
[2951]172    static Tcl_HashTable flowTable;
173    static Tcl_HashTable heightmapTable;
[2846]174
175    static double magMin, magMax;
176    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
177
[2951]178    static NvColorTableRenderer *colorTableRenderer;
[2877]179    static VolumeRenderer *volRenderer;
[2951]180#ifdef notdef
[2846]181    static NvFlowVisRenderer *flowVisRenderer;
[2951]182#endif
[2846]183    static VelocityArrowsSlice *velocityArrowsSlice;
184    static NvLIC *licRenderer;
[2877]185    static PlaneRenderer *planeRenderer;
[2846]186#if PLANE_CMD
[2930]187    static int numPlanes;
[3362]188    static Texture2D *plane[]; ///< Pointers to 2D planes
[2846]189#endif
190#ifdef USE_POINTSET_RENDERER
[2877]191    static PointSetRenderer *pointSetRenderer;
[2846]192    static std::vector<PointSet *> pointSet;
193#endif
194
195    static Tcl_Interp *interp;
[3330]196    static struct timeval startTime;           /* Start of elapsed time. */
[2831]197private:
[3362]198    static float _licSlice;  ///< Slice position [0,1]
199    static int _licAxis;     ///< Slice axis: 0:x, 1:y, 2:z
[2877]200
[2831]201    //frame buffer for final rendering
[2877]202    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
[835]203};
[851]204
[2831]205#endif
Note: See TracBrowser for help on using the repository browser.