VAPoR  0.1
glwindow.h
Go to the documentation of this file.
1 //************************************************************************
2 // *
3 // Copyright (C) 2004 *
4 // University Corporation for Atmospheric Research *
5 // All Rights Reserved *
6 // *
7 //************************************************************************/
8 //
9 // File: glwindow.h
10 //
11 // Author: Alan Norton
12 // National Center for Atmospheric Research
13 // PO 3000, Boulder, Colorado
14 //
15 // Date: July 2004
16 //
17 // Description: Definition of GLWindow class:
18 // A GLWindow object is embedded in each visualizer window. It performs basic
19 // navigation and resize, and defers drawing to the viz window's list of
20 // registered renderers.
21 
22 #ifndef GLWINDOW_H
23 #define GLWINDOW_H
24 #include <map>
25 #include "trackball.h"
26 #include <qthread.h>
27 #include <QMutex>
28 #include <jpeglib.h>
29 #include "qcolor.h"
30 #include "qlabel.h"
31 #include "params.h"
32 #include "manip.h"
33 #include <vapor/MyBase.h>
34 #include <vapor/common.h>
35 #include "datastatus.h"
36 #include "ShaderMgr.h"
37 
38 //No more than 20 renderers in a window:
39 //Eventually this may be dynamic.
40 #define MAXNUMRENDERERS 20
41 
42 class QLabel;
43 class QThread;
44 
45 
46 namespace VAPoR {
47 typedef bool (*renderCBFcn)(int winnum, bool newCoords);
48 class SpinTimer;
49 class ViewpointParams;
50 class RegionParams;
51 class DvrParams;
52 class AnimationParams;
53 class FlowParams;
54 class ProbeParams;
55 class TwoDDataParams;
56 class TwoDImageParams;
57 class Renderer;
58 class TranslateStretchManip;
59 class TranslateRotateManip;
60 class FlowRenderer;
61 class VolumeRenderer;
62 class TextObject;
63 
77 class RENDER_API GLWindow : public MyBase, public QGLWidget
78 {
79 public:
80 
85  void setDirtyBit(DirtyBitType t, bool val);
86 
91  bool vizIsDirty(DirtyBitType t);
92 
95  ViewpointParams* getActiveViewpointParams() {return (ViewpointParams*)getActiveParams(Params::_viewpointParamsTag);}
96 
99  RegionParams* getActiveRegionParams() {return (RegionParams*)getActiveParams(Params::_regionParamsTag);}
100 
103  AnimationParams* getActiveAnimationParams() {return (AnimationParams*)getActiveParams(Params::_animationParamsTag);}
104 
106  void TransformToUnitBox();
107 
108  //MouseMode support
113  static int getModeManipType(int modeIndex){
114  return manipFromMode[modeIndex];
115  }
120  return paramsFromMode[modeIndex];
121  }
122 
126  static int getModeFromParams(ParamsBase::ParamsBaseType t){return modeFromParams[t];}
127 
132  static const string& getModeName(int index) {return modeName[index];}
133 
139  static int AddMouseMode(const std::string paramsTag, int manipType, const char* name);
140 
153  static void ConvertAxes(bool toLatLon, const int ticDirs[3], const double fromMinTic[3], const double fromMaxTic[3], const double fromOrigin[3], const double fromTicLength[3],
154  double toMinTic[3],double toMaxTic[3], double toOrigin[3], double toTicLength[3]);
155 
156  //Added for FTGL
157  //Add a textObject to the set of text to be used. Return its index.
158  int addTextObject(Renderer*, int timestep, const char* fontPath, int textSize, float textColor[4], float bgColor[4], int type, string text);
159  void changeTextObjectType(int type);
160  //Add an instance of text at specified position, using specified object
161  void addText(Renderer*, int timestep, int objectNum, float posn[3]);
162  void clearTextObjects(Renderer*);
163  void clearTextObjects(Renderer*, int timestep);
164 
165 #ifndef DOXYGEN_SKIP_THIS
166  GLWindow( QGLFormat& fmt, QWidget* parent, int winnum);
167  ~GLWindow();
168  Trackball* myTBall;
169 
170  Trackball* getTBall() {return myTBall;}
171  void setPerspective(bool isPersp) {perspective = isPersp;}
172  bool getPerspective() {return perspective;}
173 
174  //Enum describes various mouse modes:
175  enum mouseModeType {
176  unknownMode=1000,
177  navigateMode=0,
178  regionMode=1,
179  probeMode=3,
180  twoDDataMode=4,
181  twoDImageMode=5,
182  rakeMode=2,
183  barbMode=7,
184  isolineMode=6
185  };
186 
187  //Reset the GL perspective, so that the near and far clipping planes are wide enough
188  //to view twice the entire region from the current camera position. If the camera is
189  //inside the doubled region, region, make the near clipping plane 1% of the region size.
190 
191  void resetView(ViewpointParams* vpParams);
192  void setMaxSize(float wsize) {maxDim = wsize;}
193  void setCenter(float cntr[3]) { wCenter[0] = cntr[0]; wCenter[1] = cntr[1]; wCenter[2] = cntr[2];}
194  //Test if the screen projection of a 3D quad encloses a point on the screen.
195  //The 4 corners of the quad must be specified in counter-clockwise order
196  //as viewed from the outside (pickable side) of the quad.
197  //
198  bool pointIsOnQuad(float cor1[3],float cor2[3],float cor3[3],float cor4[3], float pickPt[2]);
199 
200  //Determine if a point is over (and not inside) a box, specified by 8 3-D coords.
201  //the first four corners are the counter-clockwise (from outside) vertices of one face,
202  //the last four are the corresponding back vertices, clockwise from outside
203  //Returns index of face (0..5), or -1 if not on Box
204  //
205  int pointIsOnBox(float corners[8][3], float pickPt[2]);
206 
207  //Project a 3D point (in cube coord system) to window coords.
208  //Return true if in front of camera
209  //
210  bool projectPointToWin(float cubeCoords[3], float winCoords[2]){
211  double cCoords[3], wCoords[2];
212  for (int i = 0; i<3; i++) cCoords[i] = cubeCoords[i];
213  bool rc = projectPointToWin(cCoords,wCoords);
214  winCoords[0]=wCoords[0];winCoords[1]=wCoords[1];
215  return rc;
216  }
217  bool projectPointToWin(double cubeCoords[3], double winCoords[2]);
218 
219  // Project the current mouse coordinates to a line in screen space.
220  // The line starts at the mouseDownPosition, and points in the
221  // direction resulting from projecting to the screen the axis
222  // associated with the dragHandle. Returns false on error.
223 
224  bool projectPointToLine(float mouseCoords[2], float projCoords[2]);
225 
226  //Params argument is the params that owns the manip
227  bool startHandleSlide(float mouseCoords[2], int handleNum, Params* p);
228 
229  //Determine a unit direction vector associated with a pixel. Uses OpenGL screencoords
230  // I.e. y = 0 at bottom. Returns false on failure.
231  //
232  bool pixelToVector(float winCoords[2], const float cameraPos[3], float dirVec[3]);
233 
234  //Get the current image in the front buffer;
235  bool getPixelData(unsigned char* data, string frame="");
236 
237  void setRenderNew() {renderNew = true;}
238  void draw3DCursor(const float position[3]);
239 
240  void renderTimeStamp(bool rebuild);
241  void buildTimeStampImage();
242 
243  //Get/set methods for vizfeatures
244  bool useLatLonAnnotation() {return latLonAnnot;}
245  void setLatLonAnnotation(bool val){ latLonAnnot = val;}
246  QColor getBackgroundColor() {return DataStatus::getInstance()->getBackgroundColor();}
247  QColor getRegionFrameColor() {return DataStatus::getInstance()->getRegionFrameColor();}
248  QColor getSubregionFrameColor() {return DataStatus::getInstance()->getSubregionFrameColor();}
249  QColor& getColorbarBackgroundColor() {return colorbarBackgroundColor;}
250  bool axisArrowsAreEnabled() {return axisArrowsEnabled;}
251  bool axisAnnotationIsEnabled() {return axisAnnotationEnabled;}
252 
253  const vector<bool> getColorbarEnabled() {return colorbarEnabled;}
254  void setColorbarEnabled(const vector<bool> vb) {colorbarEnabled = vb;}
255  void setColorbarTitles(const vector<string> vs) {colorbarTitles = vs;}
256  const vector<string> getColorbarTitles() {return colorbarTitles;}
257 
258  bool regionFrameIsEnabled() {return DataStatus::getInstance()->regionFrameIsEnabled();}
259  bool subregionFrameIsEnabled() {return DataStatus::getInstance()->subregionFrameIsEnabled();}
260  float getAxisArrowCoord(int i){return axisArrowCoord[i];}
261  double getAxisOriginCoord(int i){return axisOriginCoord[i];}
262  double getMinTic(int i){return minTic[i];}
263  double getMaxTic(int i){return maxTic[i];}
264  double getTicLength(int i){return ticLength[i];}
265  int getNumTics(int i){return numTics[i];}
266  int getTicDir(int i){return ticDir[i];}
267  int getLabelHeight() {return labelHeight;}
268  int getLabelDigits() {return labelDigits;}
269  float getTicWidth(){return ticWidth;}
270  QColor& getAxisColor() {return axisColor;}
271  const vector<float> getColorbarLLX() {return colorbarLLX;}
272  const vector<float> getColorbarLLY() {return colorbarLLY;}
273  float getColorbarSize(int i) {return colorbarSize[i];}
274  int getColorbarNumTics() {return numColorbarTics;}
275  int getColorbarDigits() {return colorbarDigits;}
276  int getColorbarFontsize() {return colorbarFontsize;}
277 
278 
279  int getTimeAnnotType() {return timeAnnotType;}
280  int getTimeAnnotTextSize() {return timeAnnotTextSize;}
281  float getTimeAnnotCoord(int j){return timeAnnotCoords[j];}
282  QColor getTimeAnnotColor(){return timeAnnotColor;}
283  void setTimeAnnotTextSize(int size){timeAnnotTextSize = size;}
284  void setTimeAnnotColor(QColor c) {timeAnnotColor = c;}
285  void setTimeAnnotType(int t) {timeAnnotType = t;}
286  void setTimeAnnotCoords(float crds[2]){
287  timeAnnotCoords[0] = crds[0];
288  timeAnnotCoords[1] = crds[1];
289  }
290 
291  void setBackgroundColor(QColor& c) {DataStatus::getInstance()->setBackgroundColor(c);}
292  void setColorbarBackgroundColor(QColor& c) {colorbarBackgroundColor = c;}
293  void setRegionFrameColor(QColor& c) {DataStatus::getInstance()->setRegionFrameColor(c);}
294  void setSubregionFrameColor(QColor& c) {DataStatus::getInstance()->setSubregionFrameColor(c);}
295  void enableAxisArrows(bool enable) {axisArrowsEnabled = enable;}
296  void enableAxisAnnotation(bool enable) {axisAnnotationEnabled = enable;}
297 
298  void enableRegionFrame(bool enable) {DataStatus::getInstance()->enableRegionFrame(enable);}
299  void enableSubregionFrame(bool enable) {DataStatus::getInstance()->enableSubregionFrame(enable);}
300 
301  void setAxisArrowCoord(int i, float val){axisArrowCoord[i] = val;}
302  void setAxisOriginCoord(int i, double val){axisOriginCoord[i] = val;}
303  void setNumTics(int i, int val) {numTics[i] = val;}
304  void setTicDir(int i, int val) {ticDir[i] = val;}
305  void setMinTic(int i, double val) {minTic[i] = val;}
306  void setMaxTic(int i, double val) {maxTic[i] = val;}
307  void setTicLength(int i, double val) {ticLength[i] = val;}
308  void setLabelHeight(int h){labelHeight = h;}
309  void setLabelDigits(int d) {labelDigits = d;}
310  void setTicWidth(float w) {ticWidth = w;}
311  void setAxisColor(QColor& c) {axisColor = c;}
312  void setDisplacement(float val){displacement = val;}
313  float getDisplacement() {return displacement;}
314  void setColorbarAutoTitles(bool i) {colorbarAutoTitles = i;}
315  bool getColorbarAutoTitles() {return colorbarAutoTitles;}
316  void setColorbarLLX(const vector<float> crds) {colorbarLLX = crds;}
317  void setColorbarLLY(const vector<float> crds) {colorbarLLY = crds;}
318  void setColorbarSize(int i, float crd) {colorbarSize[i] = crd;}
319  void setColorbarNumTics(int i) {numColorbarTics = i;}
320  bool colorbarIsDirty() {return colorbarDirty;}
321  bool timeAnnotIsDirty() {return timeAnnotDirty;}
322  void setColorbarDirty(bool val){colorbarDirty = val;}
323  void setTimeAnnotDirty(bool val){timeAnnotDirty = val;}
324  void setColorbarDigits(int ndigs) {colorbarDigits = ndigs;}
325  void setColorbarFontsize(int fsize) {colorbarFontsize = fsize;}
326  void setAxisLabelsDirty(bool val){axisLabelsDirty = val;}
327  void setTextRenderersDirty(bool val){textRenderersDirty = val;}
328  bool textRenderersAreDirty() {return textRenderersDirty;}
329  bool axisLabelsAreDirty(){return axisLabelsDirty;}
330 
331 
332  bool mouseIsDown() {return mouseDownHere;}
333  void setMouseDown(bool downUp) {mouseDownHere = downUp;}
334 
335  void setNumRenderers(int num) {numRenderers = num;}
336  int getNumRenderers() { return numRenderers;}
337  Params::ParamsBaseType getRendererType(int i) {return renderType[i];}
338 
339  Renderer* getRenderer(int i) {return renderer[i];}
340  Renderer* getRenderer(RenderParams* p);
341 
342  //Renderers can be added early or late, using a "render Order" parameter.
343  //The order is between 0 and 10; lower order gets rendered first.
344  //Sorted renderers get sorted before each render
345  //
346  void insertSortedRenderer(RenderParams* p, Renderer* ren){insertRenderer(p, ren, 5);}
347  void prependRenderer(RenderParams* p, Renderer* ren) {insertRenderer(p, ren, 0);}
348  void appendRenderer(RenderParams* p, Renderer* ren){insertRenderer(p, ren, 10);}
349  void insertRenderer(RenderParams* p, Renderer* ren, int order);
350  bool removeRenderer(RenderParams* p); //Return true if successful
351  void removeAllRenderers();
352  void sortRenderers(int timestep); //Sort all the pri 0 renderers
353 
354  void removeDisabledRenderers(); //Remove renderers whose params are disabled
355  //Find a renderParams in renderer list, if it exists:
356  RenderParams* findARenderer(Params::ParamsBaseType renderertype);
357 
358  static int getCurrentMouseMode() {return currentMouseMode;}
359  static void setCurrentMouseMode(int t){currentMouseMode = t;}
360  //The glwindow keeps a copy of the params that are currently associated with the current
361  //instance. This needs to change during:
362  // -loading session
363  // -undo/redo
364  // -changing instance
365  // -reinit
366  // -new visualizer
367 
368  void setActiveViewpointParams(Params* p) {setActiveParams(p,Params::_viewpointParamsTag);}
369  void setActiveRegionParams(Params* p) {
370  setActiveParams(p,Params::_regionParamsTag);
371  getManip(Params::_regionParamsTag)->setParams(p);
372  }
373  void setActiveAnimationParams(Params* p) {setActiveParams(p,Params::_animationParamsTag);}
374 
375 
376  FlowParams* getActiveFlowParams() {return (FlowParams*)getActiveParams(Params::_flowParamsTag);}
377  ProbeParams* getActiveProbeParams() {return (ProbeParams*)getActiveParams(Params::_probeParamsTag);}
378  TwoDDataParams* getActiveTwoDDataParams() {return (TwoDDataParams*)getActiveParams(Params::_twoDDataParamsTag);}
379  TwoDImageParams* getActiveTwoDImageParams() {return (TwoDImageParams*)getActiveParams(Params::_twoDImageParamsTag);}
380 
381  vector<Params*> currentParams;
382  Params* getActiveParams(ParamsBase::ParamsBaseType pType) {return currentParams[pType];}
383  Params* getActiveParams(const std::string& tag) {return currentParams[Params::GetTypeFromTag(tag)];}
384  void setActiveParams(Params* p, ParamsBase::ParamsBaseType pType){
385  currentParams[pType] = p;
386  }
387  void setActiveParams(Params* p, const std::string& tag){
388  currentParams[Params::GetTypeFromTag(tag)] = p;
389  }
390 
391  //The GLWindow keeps track of the renderers with an ordered list of them
392  //as well as with a map from renderparams to renderer
393 
394  void mapRenderer(RenderParams* rp, Renderer* ren){rendererMapping[rp] = ren;}
395  bool unmapRenderer(RenderParams* rp);
396 
397  //Determine the approximate size of a pixel in terms of viewer coordinates.
398  float getPixelSize();
399  bool viewerCoordsChanged() {return newViewerCoords;}
400  void setViewerCoordsChanged(bool isNew) {newViewerCoords = isNew;}
401  bool isCapturingImage() {return (capturingImage != 0);}
402  bool isCapturingFlow() {return (capturingFlow);}
403  bool isSingleCapturingImage() {return (capturingImage == 1);}
404  void startImageCapture(QString& name, int startNum, bool isTif) {
405  capturingImage = 2;
406  captureNumImage = startNum;
407  captureNameImage = name;
408  newCaptureImage = true;
409  capturingTif = isTif;
410  previousFrameNum = -1;
411  previousTimeStep = -1;
412  update();
413  }
414  void startFlowCapture(QString& name) {
415  capturingFlow = true;
416  captureNameFlow = name;
417  update();
418  }
419  void singleCaptureImage(QString& name){
420  capturingImage = 1;
421  captureNameImage = name;
422  newCaptureImage = true;
423  update();
424  }
425  bool captureIsNewImage() { return newCaptureImage;}
426 
427  void setCaptureNewImage(bool isNew){ newCaptureImage = isNew;}
428 
429  void stopImageCapture() {capturingImage = 0;}
430  void stopFlowCapture() {capturingFlow = false;}
431  //Routine is called at the end of rendering. If capture is 1 or 2, it converts image
432  //to jpeg and saves file. If it ever encounters an error, it turns off capture.
433  //If capture is 1 (single frame capture) it turns off capture.
434  void doFrameCapture(string frame="");
435  QString& getFlowFilename(){return captureNameFlow;}
436 
437 
438  TranslateStretchManip* getManip(const std::string& paramTag){
439  int mode = getModeFromParams(ParamsBase::GetTypeFromTag(paramTag));
440  return manipHolder[mode];
441  }
442 
443  ColorbarManip* getColorbarManip() {return _cbManip;}
444 
445 
446  void setPreRenderCB(renderCBFcn f){preRenderCB = f;}
447  void setPostRenderCB(renderCBFcn f){postRenderCB = f;}
448  static int getJpegQuality();
449  static void setJpegQuality(int qual);
450  static bool depthPeelEnabled() {return depthPeeling;}
451  static void enableDepthPeeling(bool val) {depthPeeling = val;}
452  static bool getDefaultAxisArrowsEnabled(){return defaultAxisArrowsEnabled;}
453  static void setDefaultAxisArrows(bool val){defaultAxisArrowsEnabled = val;}
454  static bool getDefaultTerrainEnabled(){return defaultTerrainEnabled;}
455  static bool getDefaultSpinAnimateEnabled(){return defaultSpinAnimateEnabled;}
456  static void setDefaultShowTerrain(bool val){defaultTerrainEnabled = val;}
457  static void setDefaultSpinAnimate(bool val){defaultSpinAnimateEnabled = val;}
458  static void setDefaultPrefs();
459  int getWindowNum() {return winNum;}
460 
461  //Static methods so that the vizwinmgr can tell the glwindow about
462  //current active visualizer, and about region sharing
463  static int getActiveWinNum() { return activeWindowNum;}
464  static void setActiveWinNum(int winnum) {activeWindowNum = winnum;}
465  bool windowIsActive(){return (winNum == activeWindowNum);}
466  static bool activeWinSharesRegion() {return regionShareFlag;}
467  static void setRegionShareFlag(bool regionIsShared){regionShareFlag = regionIsShared;}
468 
469 
470  const GLdouble* getProjectionMatrix() { return projectionMatrix;}
471 
472  void getNearFarClippingPlanes(GLfloat *nearplane, GLfloat *farplane) {
473  *nearplane = nearDist; *farplane = farDist;
474  }
475 
476 
477  const GLint* getViewport() {return viewport;}
478 
479  enum OGLVendorType {
480  UNKNOWN = 0,
481  MESA,
482  NVIDIA,
483  ATI,
484  INTEL
485  };
486  static OGLVendorType GetVendor();
487 
488  void startSpin(int renderMS);
489  //Terminate spin, return true if successful
490  bool stopSpin();
491  bool spinning(){return isSpinning;}
492 
493  void clearRendererBypass(Params::ParamsBaseType t);
494  //Following is intended to prevent conflicts between concurrent
495  //opengl threads. Probably it should be protected by a semaphore
496  //For now, leave it and see if problems occur.
497  static bool isRendering(){return nowPainting;}
498  void setValuesFromGui(ViewpointParams* vpparams);
499  static void setSpinAnimation(bool on){spinAnimate = on;}
500  static bool spinAnimationEnabled(){return spinAnimate;}
501  QMutex renderMutex; //prevent recursive rendering
502  bool isControlled;
503  QGLFormat _myFmt;
504  //Depth peeling data
505  GLint maxbuffers;
506  GLuint fboA;
507  GLuint fboB;
508  GLuint currentBuffer;
509  GLuint currentDepth;
510  GLint currentLayer;
511  GLuint depthA, depthB;
512  GLuint *layers;
513  int depthWidth, depthHeight, depthTexUnit;
514  ShaderMgr* getShaderMgr() {return manager;}
515  void depthPeelPaintEvent();
516  void renderScene(float extents[6], float minFull[3], float maxFull[3], int timeStep);
517  void setUpPaintEvent();
518  bool checkForStereo();
519  void regPaintEvent(float *extents, float *minFull, float *maxFull);
520  int adjustTo3D(string eye);
521  bool peelInitialized;
522  bool isDepthPeeling(){return depthPeeling;}
523  int getColorbarIndex(ParamsBase::ParamsBaseType t){
524  for (int i = 0; i< rendererTypeLookup.size(); i++){
525  if (rendererTypeLookup[i] == t) return i;
526  }
527  return -1;
528  }
529  int getNumTFs() { return rendererTypeLookup.size();}
530 protected:
531 
532  QImage glTimeStampImage;
533  SpinTimer *mySpinTimer;
534  ShaderMgr *manager;
535  //Mouse Mode tables. Static since independent of window:
536  static vector<ParamsBase::ParamsBaseType> paramsFromMode;
537  static vector<int> manipFromMode;
538  static vector<string> modeName;
539  static map<ParamsBase::ParamsBaseType, int> modeFromParams;
540  //There's a separate manipholder for each window
541  vector<TranslateStretchManip*> manipHolder;
542  ColorbarManip* _cbManip;
543  //Register a manip, including an icon and text
544  //Icon must be specified as an xpm or null
545  //Manip type is : 0 for navigation (nothing) 1 for 3D translate/stretch, 2 for 2D translate/stretch, 3 for 3D rotate/stretch, 4 for colorbar
546 
547  //Container for sorting renderer list:
548  class RenderListElt {
549  public:
550  Renderer* ren;
551  float camDist;
552  Params::ParamsBaseType renType;
553  };
554  static bool renderPriority(RenderListElt* ren1, RenderListElt* ren2){
555  return (ren1->camDist > ren2->camDist);
556  }
557  int hasColorbarIndex(RenderParams* p){
558  if (!p->isEnabled()) return -1;
559  if (!p->UsesMapperFunction()) return -1;
560  if (p != Params::GetCurrentParamsInstance(p->GetParamsBaseTypeId(), winNum)) return -1;
561  for (int i = 0; i< rendererTypeLookup.size(); i++){
562  if (rendererTypeLookup[i] == p->GetParamsBaseTypeId()){
563  if (colorbarEnabled[i]) return i;
564  else return -1;
565  }
566  }
567  return -1;
568  }
569  //This method converts lon lat to user coords, assuming a "flat" earth so axes will not wrap.
570  static void flatConvertFromLonLat(double x[2], double minLon, double maxLon, double minX, double maxX);
571  std::vector<QImage> axisLabels[3];
572 
573  bool axisLabelsDirty;
574  bool textRenderersDirty;
575  static bool depthPeeling;
576  int winNum;
577  int previousTimeStep;
578  int previousFrameNum;
579  static int jpegQuality;
580  //Following flag is set whenever there is mouse navigation, so that we can use
581  //the new viewer position
582  //at the next rendering
583  bool newViewerCoords;
584  static int currentMouseMode;
585  std::map<DirtyBitType,bool> vizDirtyBit;
586  Renderer* renderer[MAXNUMRENDERERS];
588  int renderOrder[MAXNUMRENDERERS];
589 
590  //Map params to renderer for set/get dirty bits, etc:
591 
592  std::map<RenderParams*,Renderer*> rendererMapping;
593 
594  int numRenderers;
595  //Picking helper functions, saved from last change in GL state. These
596  //Deal with the cube coordinates (known to the trackball)
597  //openGL model matrix is kept in the viewpointparams, since
598  //it may be shared (global)
599  //
600  GLdouble* getModelMatrix();
601 
602  GLfloat tcoord[2];
603 
604  GLfloat* setTexCrd(int i, int j);
605 
606  //These methods cannot be overridden, but the initialize and paint methods
607  //call the corresponding Renderer methods.
608  //
609  void initializeGL();
610 
611  void resizeGL( int w, int h );
612 
613  //Following QT 4 guidance (see bubbles example), opengl painting is performed
614  //in paintEvent(), so that we can paint nice text over the window.
615  // GLWindow::paintGL() is not implemented.
616  // The other changes include:
617  // GL_MULTISAMPLE is enabled
618  // GLWindow::updateGL() is replaced by GLWindow::update()
619  // resizeGL() contents have been moved to setUpViewport(), which is also called
620  // from paintEvent().
621  // setAutoFillBackground(false) is called in the GLWindow constructor
622 
623  void paintEvent(QPaintEvent* event);
624 #ifdef Darwin
625  bool event ( QEvent * e );
626 #endif
627 
628  void perspectiveGL( GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar );
629  void setUpViewport(int width, int height);
630  //Methods to support drawing domain bounds, axes etc.
631  //Set colors to use in domain-bound rendering:
632  void setSubregionFrameColorFlt(const QColor& c);
633  void setRegionFrameColorFlt(const QColor& c);
634  //Draw the region bounds and frame it in full domain.
635  //Arguments are in unit cube coordinates
636  void renderDomainFrame(float* extents, float* minFull, float* maxFull);
637 
638  void drawSubregionBounds(float* extents);
639  void drawAxisArrows(float* extents);
640  void drawAxisTics(int tstep);
641  void drawAxisLabels(int tstep);
642  void buildAxisLabels(int tstep);
643 
644  void placeLights();
645 
646  //Helper functions for drawing region bounds:
647  static float* cornerPoint(float* extents, int faceNum);
648  // Faces of the cube are numbered 0..5 based on view from pos z axis:
649  // back, front, bottom, top, left, right
650  static bool faceIsVisible(float* extents, float* viewerCoords, int faceNum);
651 
652 
653  //Render all the text at a timestep;
654  void renderText(int timestep);
655  float regionFrameColorFlt[3];
656  float subregionFrameColorFlt[3];
657 
658  float wCenter[3]; //World center coords
659  float maxDim; //Max of x, y, z size in world coords
660  bool perspective; //perspective vs parallel coords;
661  bool oldPerspective;
662  //Indicate if the current render is different from previous,
663  //Used for frame capture:
664  bool renderNew;
665  //Moved over from vizwin:
666  int capturingImage;
667  int captureNumImage;
668  bool capturingFlow;
669  bool capturingTif;
670  //Flag to set indicating start of capture sequence.
671  bool newCaptureImage;
672  QString captureNameImage;
673  QString captureNameFlow;
674  //Set the following to force a call to resizeGL at the next call to
675  //updateGL.
676  bool needsResize;
677  float farDist, nearDist;
678 
679  GLint viewport[4];
680  GLdouble projectionMatrix[16];
681  static bool nowPainting;
682 
683  //values in vizFeature
684  QColor colorbarBackgroundColor;
685 
686 
687  int timeAnnotType;
688  int timeAnnotTextSize;
689  float timeAnnotCoords[2];
690  QColor timeAnnotColor;
691 
692  bool axisArrowsEnabled;
693  bool axisAnnotationEnabled;
694  int colorbarDigits;
695  int colorbarFontsize;
696 
697  float axisArrowCoord[3];
698  double axisOriginCoord[3];
699  double minTic[3];
700  double maxTic[3];
701  double ticLength[3];
702  int ticDir[3];
703  int numTics[3];
704  int labelHeight, labelDigits;
705  float ticWidth;
706  QColor axisColor;
707  float displacement;
708 
709  bool colorbarAutoTitles;
710  vector<float> colorbarLLX;
711  vector<float> colorbarLLY;
712  vector<bool> colorbarEnabled;
713  vector<string>colorbarTitles;
714  float colorbarSize[2];
715  int numColorbarTics;
716  bool colorbarDirty;
717  bool timeAnnotDirty;
718  bool mouseDownHere;
719  bool latLonAnnot;
720 
721 
722  renderCBFcn preRenderCB;
723  renderCBFcn postRenderCB;
724 
725  static int activeWindowNum;
726  //This flag is true if the active window is sharing the region.
727  //If the current window is not active, it will still share the region, if
728  //the region is shared, and the active region is shared.
729  static bool regionShareFlag;
730  static bool defaultTerrainEnabled;
731  static bool defaultSpinAnimateEnabled;
732  static bool spinAnimate;
733  static bool defaultAxisArrowsEnabled;
734 
735 
736  int axisLabelNums[3];
737 
738  //state to save during handle slide:
739  // screen coords where mouse is pressed:
740  float mouseDownPoint[2];
741  // unit vector in direction of handle
742  float handleProjVec[2];
743  bool isSpinning;
744  GLuint _timeStampTexid;
745 
746 private:
747  bool _readyToDraw;
748  void makeWriter();
749 
750  map<int, map<Renderer*,vector<TextObject*> > >textObjectMap;
751 
752  map< int, map< pair<Renderer*, int> , vector<float*>* > >textCoordMap;
753  std::vector<int> rendererTypeLookup;
754 
755 
756 #endif //DOXYGEN_SKIP_THIS
757 
758 };
759 
760 };
761 
762 #endif // GLWINDOW_H
A class for performing OpenGL rendering in a VAPOR Visualizer.
Definition: glwindow.h:77
A pure virtual class for managing parameters used in visualization.
Definition: params.h:75
A Params subclass for managing parameters used by Renderers.
Definition: params.h:569
virtual bool UsesMapperFunction()
Definition: params.h:676
static Params * GetCurrentParamsInstance(int pType, int winnum)
Definition: params.h:157
ViewpointParams * getActiveViewpointParams()
Definition: glwindow.h:95
#define MAXNUMRENDERERS
Definition: glwindow.h:40
A class for describing a 3D axis-aligned region in user space.
Definition: regionparams.h:52
ParamsBaseType GetParamsBaseTypeId()
Definition: ParamsBase.h:164
AnimationParams * getActiveAnimationParams()
Definition: glwindow.h:103
A class for describing the viewpoint and lights.
bool(* renderCBFcn)(int winnum, bool newCoords)
Definition: glwindow.h:47
DirtyBitType
Definition: params.h:46
static ParamsBaseType GetTypeFromTag(const string &tag)
static DataStatus * getInstance()
Definition: datastatus.h:58
RegionParams * getActiveRegionParams()
Definition: glwindow.h:99
static int getModeManipType(int modeIndex)
Definition: glwindow.h:113
A class that specifies parameters used in animation.
static const string & getModeName(int index)
Definition: glwindow.h:132
bool isEnabled()
Definition: params.h:581
static int getModeFromParams(ParamsBase::ParamsBaseType t)
Definition: glwindow.h:126
static ParamsBase::ParamsBaseType getModeParamType(int modeIndex)
Definition: glwindow.h:119
A class that performs rendering in the GLWindow.
Definition: renderer.h:45