source: nanovis/branches/1.1/nanovis.h

Last change on this file was 4904, checked in by ldelgass, 9 years ago

Merge serveral changes from trunk. Does not include threading, world space
changes, etc.

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