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

Last change on this file since 3630 was 3630, checked in by ldelgass, 11 years ago

Nanovis refactoring to fix problems with scaling and multiple results.
Do rendering in world space to properly place and scale multiple data sets.
Also fix flows to reduce resets of animations. More work toward removing
Cg dependency. Fix panning to convert viewport coords to world coords.

  • Property svn:eol-style set to native
File size: 5.2 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 *
[3502]10 *  Copyright (c) 2004-2013  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 */
[3614]16#ifndef NV_NANOVIS_H
17#define NV_NANOVIS_H
[259]18
[226]19#include <math.h>
[2831]20#include <stddef.h> // For size_t
[226]21#include <stdio.h>
[3605]22#include <sys/time.h>
23#include <sys/types.h> // For pid_t
[226]24
[3605]25#include <tcl.h>
26
27#include <GL/glew.h>
28
[2831]29#include <vector>
30#include <iostream>
[3567]31#include <tr1/unordered_map>
[2831]32
[3630]33#include <vrmath/BBox.h>
[3492]34#include <vrmath/Vector3f.h>
[2818]35
[251]36#include "config.h"
[3630]37#include "Camera.h"
38#include "FlowTypes.h"
[3605]39#include "md5.h"
[226]40
41//defines for the image based flow visualization
42#define NMESH 256       //resolution of flow mesh
43#define NPIX  512       //display size
44
[3463]45namespace nv {
[2831]46namespace graphics {
47    class RenderContext;
48}
[3463]49namespace util {
50    class Fonts;
51}
[3611]52
53class Flow;
54class Grid;
55class HeightMap;
56class LIC;
[3605]57class OrientationIndicator;
58class PlaneRenderer;
[2831]59class Texture2D;
60class TransferFunction;
[3611]61class VelocityArrowsSlice;
[2831]62class Volume;
[3611]63class VolumeRenderer;
[1370]64
[2822]65class NanoVis
66{
[2831]67public:
[3567]68    typedef std::string TransferFunctionId;
69    typedef std::string VolumeId;
70    typedef std::string FlowId;
71    typedef std::string HeightMapId;
72    typedef std::tr1::unordered_map<TransferFunctionId, TransferFunction *> TransferFunctionHashmap;
73    typedef std::tr1::unordered_map<VolumeId, Volume *> VolumeHashmap;
[3597]74    typedef std::tr1::unordered_map<FlowId, Flow *> FlowHashmap;
[3567]75    typedef std::tr1::unordered_map<HeightMapId, HeightMap *> HeightMapHashmap;
76
[3605]77    static bool init(const char *path);
78    static bool initGL();
79    static bool initOffscreenBuffer();
80    static bool resizeOffscreenBuffer(int w, int h);
[3478]81    static void setBgColor(float color[3]);
[3497]82    static void render();
[2847]83    static void update();
[2951]84    static void removeAllData();
[2930]85
[3611]86    static const Camera *getCamera()
[3362]87    {
[3630]88        return _camera;
[3362]89    }
[3630]90    static void panCamera(float dx, float dy);
91    static void zoomCamera(float z);
92    static void orientCamera(double *quat);
93    static void setCameraPosition(vrmath::Vector3f pos);
94    static void setCameraUpdir(Camera::AxisDirection dir);
[3492]95    static void resetCamera(bool resetOrientation = false);
[1299]96
[3630]97    static void eventuallyRedraw();
[2847]98 
[3567]99    static TransferFunction *getTransferFunction(const TransferFunctionId& id);
100    static TransferFunction *defineTransferFunction(const TransferFunctionId& id,
[2847]101                                                    size_t n, float *data);
102
[2877]103    static int renderLegend(TransferFunction *tf, double min, double max,
104                            int width, int height, const char *volArg);
[2847]105
[2877]106    static Volume *loadVolume(const char *tag, int width, int height, int depth,
[3597]107                              int numComponents, float *data, double vmin, double vmax,
[2877]108                              double nonZeroMin);
[1156]109
[3597]110    static void removeVolume(Volume *volume);
[2877]111
112    static void readScreen()
[2822]113    {
[3605]114        glPixelStorei(GL_PACK_ALIGNMENT, 1);
[2877]115        glReadPixels(0, 0, winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE,
116                     screenBuffer);
[1028]117    }
[2930]118    static void bindOffscreenBuffer()
[2822]119    {
[2877]120        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _finalFbo);
[1028]121    }
[1431]122
[3630]123    static void setVolumeRanges();
124    static void setHeightmapRanges();
125    static bool mapFlows();
126
[3597]127    static Flow *getFlow(const char *name);
128    static Flow *createFlow(Tcl_Interp *interp, const char *name);
[3605]129    static void deleteFlows(Tcl_Interp *interp);
[3567]130    static void deleteFlow(const char *name);
[3566]131    static void getFlowBounds(vrmath::Vector3f& min,
[3492]132                              vrmath::Vector3f& max,
133                              bool onlyVisible = false);
[3566]134    static void renderFlows();
135    static void resetFlows();
136    static bool updateFlows();
137    static void advectFlows();
[2831]138
[3605]139    static Tcl_Interp *interp;
140
[3630]141    static bool redrawPending;
[2877]142    static bool debugFlag;
[3567]143
144    static int winWidth;        ///< Width of the render window
145    static int winHeight;       ///< Height of the render window
[3630]146    static int renderWindow;    ///< GLUT handle for the render window
[2877]147    static unsigned char *screenBuffer;
[2951]148    static Texture2D *legendTexture;
[3611]149    static util::Fonts *fonts;
150    static graphics::RenderContext *renderContext;
[2846]151
[3567]152    static TransferFunctionHashmap tfTable; ///< maps transfunc name to TransferFunction object
153    static VolumeHashmap volumeTable;
154    static FlowHashmap flowTable;
155    static HeightMapHashmap heightMapTable;
[2846]156
[3630]157    static vrmath::BBox sceneBounds;
[2846]158
[2877]159    static VolumeRenderer *volRenderer;
[2846]160    static VelocityArrowsSlice *velocityArrowsSlice;
[3611]161    static LIC *licRenderer;
[2877]162    static PlaneRenderer *planeRenderer;
[3611]163    static OrientationIndicator *orientationIndicator;
[3605]164    static Grid *grid;
[3568]165
[2831]166private:
[3492]167    static void collectBounds(bool onlyVisible = false);
168
[3630]169    static Camera *_camera;
[2877]170
[2831]171    //frame buffer for final rendering
[2877]172    static GLuint _finalFbo, _finalColorTex, _finalDepthRb;
[835]173};
[851]174
[3611]175}
176
[2831]177#endif
Note: See TracBrowser for help on using the repository browser.