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 setColorbarLLX(const vector<float> crds) {colorbarLLX = crds;}
315  void setColorbarLLY(const vector<float> crds) {colorbarLLY = crds;}
316  void setColorbarSize(int i, float crd) {colorbarSize[i] = crd;}
317  void setColorbarNumTics(int i) {numColorbarTics = i;}
318  bool colorbarIsDirty() {return colorbarDirty;}
319  bool timeAnnotIsDirty() {return timeAnnotDirty;}
320  void setColorbarDirty(bool val){colorbarDirty = val;}
321  void setTimeAnnotDirty(bool val){timeAnnotDirty = val;}
322  void setColorbarDigits(int ndigs) {colorbarDigits = ndigs;}
323  void setColorbarFontsize(int fsize) {colorbarFontsize = fsize;}
324  void setAxisLabelsDirty(bool val){axisLabelsDirty = val;}
325  void setTextRenderersDirty(bool val){textRenderersDirty = val;}
326  bool textRenderersAreDirty() {return textRenderersDirty;}
327  bool axisLabelsAreDirty(){return axisLabelsDirty;}
328 
329 
330  bool mouseIsDown() {return mouseDownHere;}
331  void setMouseDown(bool downUp) {mouseDownHere = downUp;}
332 
333  void setNumRenderers(int num) {numRenderers = num;}
334  int getNumRenderers() { return numRenderers;}
335  Params::ParamsBaseType getRendererType(int i) {return renderType[i];}
336 
337  Renderer* getRenderer(int i) {return renderer[i];}
338  Renderer* getRenderer(RenderParams* p);
339 
340  //Renderers can be added early or late, using a "render Order" parameter.
341  //The order is between 0 and 10; lower order gets rendered first.
342  //Sorted renderers get sorted before each render
343  //
344  void insertSortedRenderer(RenderParams* p, Renderer* ren){insertRenderer(p, ren, 5);}
345  void prependRenderer(RenderParams* p, Renderer* ren) {insertRenderer(p, ren, 0);}
346  void appendRenderer(RenderParams* p, Renderer* ren){insertRenderer(p, ren, 10);}
347  void insertRenderer(RenderParams* p, Renderer* ren, int order);
348  bool removeRenderer(RenderParams* p); //Return true if successful
349  void removeAllRenderers();
350  void sortRenderers(int timestep); //Sort all the pri 0 renderers
351 
352  void removeDisabledRenderers(); //Remove renderers whose params are disabled
353  //Find a renderParams in renderer list, if it exists:
354  RenderParams* findARenderer(Params::ParamsBaseType renderertype);
355 
356  static int getCurrentMouseMode() {return currentMouseMode;}
357  static void setCurrentMouseMode(int t){currentMouseMode = t;}
358  //The glwindow keeps a copy of the params that are currently associated with the current
359  //instance. This needs to change during:
360  // -loading session
361  // -undo/redo
362  // -changing instance
363  // -reinit
364  // -new visualizer
365 
366  void setActiveViewpointParams(Params* p) {setActiveParams(p,Params::_viewpointParamsTag);}
367  void setActiveRegionParams(Params* p) {
368  setActiveParams(p,Params::_regionParamsTag);
369  getManip(Params::_regionParamsTag)->setParams(p);
370  }
371  void setActiveAnimationParams(Params* p) {setActiveParams(p,Params::_animationParamsTag);}
372 
373 
374  FlowParams* getActiveFlowParams() {return (FlowParams*)getActiveParams(Params::_flowParamsTag);}
375  ProbeParams* getActiveProbeParams() {return (ProbeParams*)getActiveParams(Params::_probeParamsTag);}
376  TwoDDataParams* getActiveTwoDDataParams() {return (TwoDDataParams*)getActiveParams(Params::_twoDDataParamsTag);}
377  TwoDImageParams* getActiveTwoDImageParams() {return (TwoDImageParams*)getActiveParams(Params::_twoDImageParamsTag);}
378 
379  vector<Params*> currentParams;
380  Params* getActiveParams(ParamsBase::ParamsBaseType pType) {return currentParams[pType];}
381  Params* getActiveParams(const std::string& tag) {return currentParams[Params::GetTypeFromTag(tag)];}
382  void setActiveParams(Params* p, ParamsBase::ParamsBaseType pType){
383  currentParams[pType] = p;
384  }
385  void setActiveParams(Params* p, const std::string& tag){
386  currentParams[Params::GetTypeFromTag(tag)] = p;
387  }
388 
389  //The GLWindow keeps track of the renderers with an ordered list of them
390  //as well as with a map from renderparams to renderer
391 
392  void mapRenderer(RenderParams* rp, Renderer* ren){rendererMapping[rp] = ren;}
393  bool unmapRenderer(RenderParams* rp);
394 
395  //Determine the approximate size of a pixel in terms of viewer coordinates.
396  float getPixelSize();
397  bool viewerCoordsChanged() {return newViewerCoords;}
398  void setViewerCoordsChanged(bool isNew) {newViewerCoords = isNew;}
399  bool isCapturingImage() {return (capturingImage != 0);}
400  bool isCapturingFlow() {return (capturingFlow);}
401  bool isSingleCapturingImage() {return (capturingImage == 1);}
402  void startImageCapture(QString& name, int startNum, bool isTif) {
403  capturingImage = 2;
404  captureNumImage = startNum;
405  captureNameImage = name;
406  newCaptureImage = true;
407  capturingTif = isTif;
408  previousFrameNum = -1;
409  previousTimeStep = -1;
410  update();
411  }
412  void startFlowCapture(QString& name) {
413  capturingFlow = true;
414  captureNameFlow = name;
415  update();
416  }
417  void singleCaptureImage(QString& name){
418  capturingImage = 1;
419  captureNameImage = name;
420  newCaptureImage = true;
421  update();
422  }
423  bool captureIsNewImage() { return newCaptureImage;}
424 
425  void setCaptureNewImage(bool isNew){ newCaptureImage = isNew;}
426 
427  void stopImageCapture() {capturingImage = 0;}
428  void stopFlowCapture() {capturingFlow = false;}
429  //Routine is called at the end of rendering. If capture is 1 or 2, it converts image
430  //to jpeg and saves file. If it ever encounters an error, it turns off capture.
431  //If capture is 1 (single frame capture) it turns off capture.
432  void doFrameCapture(string frame="");
433  QString& getFlowFilename(){return captureNameFlow;}
434 
435 
436  TranslateStretchManip* getManip(const std::string& paramTag){
437  int mode = getModeFromParams(ParamsBase::GetTypeFromTag(paramTag));
438  return manipHolder[mode];
439  }
440 
441 
442  void setPreRenderCB(renderCBFcn f){preRenderCB = f;}
443  void setPostRenderCB(renderCBFcn f){postRenderCB = f;}
444  static int getJpegQuality();
445  static void setJpegQuality(int qual);
446  static bool depthPeelEnabled() {return depthPeeling;}
447  static void enableDepthPeeling(bool val) {depthPeeling = val;}
448  static bool getDefaultAxisArrowsEnabled(){return defaultAxisArrowsEnabled;}
449  static void setDefaultAxisArrows(bool val){defaultAxisArrowsEnabled = val;}
450  static bool getDefaultTerrainEnabled(){return defaultTerrainEnabled;}
451  static bool getDefaultSpinAnimateEnabled(){return defaultSpinAnimateEnabled;}
452  static void setDefaultShowTerrain(bool val){defaultTerrainEnabled = val;}
453  static void setDefaultSpinAnimate(bool val){defaultSpinAnimateEnabled = val;}
454  static void setDefaultPrefs();
455  int getWindowNum() {return winNum;}
456 
457  //Static methods so that the vizwinmgr can tell the glwindow about
458  //current active visualizer, and about region sharing
459  static int getActiveWinNum() { return activeWindowNum;}
460  static void setActiveWinNum(int winnum) {activeWindowNum = winnum;}
461  bool windowIsActive(){return (winNum == activeWindowNum);}
462  static bool activeWinSharesRegion() {return regionShareFlag;}
463  static void setRegionShareFlag(bool regionIsShared){regionShareFlag = regionIsShared;}
464 
465 
466  const GLdouble* getProjectionMatrix() { return projectionMatrix;}
467 
468  void getNearFarClippingPlanes(GLfloat *nearplane, GLfloat *farplane) {
469  *nearplane = nearDist; *farplane = farDist;
470  }
471 
472 
473  const GLint* getViewport() {return viewport;}
474 
475  enum OGLVendorType {
476  UNKNOWN = 0,
477  MESA,
478  NVIDIA,
479  ATI,
480  INTEL
481  };
482  static OGLVendorType GetVendor();
483 
484  void startSpin(int renderMS);
485  //Terminate spin, return true if successful
486  bool stopSpin();
487  bool spinning(){return isSpinning;}
488 
489  void clearRendererBypass(Params::ParamsBaseType t);
490  //Following is intended to prevent conflicts between concurrent
491  //opengl threads. Probably it should be protected by a semaphore
492  //For now, leave it and see if problems occur.
493  static bool isRendering(){return nowPainting;}
494  void setValuesFromGui(ViewpointParams* vpparams);
495  static void setSpinAnimation(bool on){spinAnimate = on;}
496  static bool spinAnimationEnabled(){return spinAnimate;}
497  QMutex renderMutex; //prevent recursive rendering
498  bool isControlled;
499  QGLFormat _myFmt;
500  //Depth peeling data
501  GLint maxbuffers;
502  GLuint fboA;
503  GLuint fboB;
504  GLuint currentBuffer;
505  GLuint currentDepth;
506  GLint currentLayer;
507  GLuint depthA, depthB;
508  GLuint *layers;
509  int depthWidth, depthHeight, depthTexUnit;
510  ShaderMgr* getShaderMgr() {return manager;}
511  void depthPeelPaintEvent();
512  void renderScene(float extents[6], float minFull[3], float maxFull[3], int timeStep);
513  void setUpPaintEvent();
514  bool checkForStereo();
515  void regPaintEvent(float *extents, float *minFull, float *maxFull);
516  int adjustTo3D2(string eye);
517  int adjustTo3D(string eye);
518  bool peelInitialized;
519  bool isDepthPeeling(){return depthPeeling;}
520  int getColorbarIndex(ParamsBase::ParamsBaseType t){
521  for (int i = 0; i< rendererTypeLookup.size(); i++){
522  if (rendererTypeLookup[i] == t) return i;
523  }
524  return -1;
525  }
526  int getNumTFs() { return rendererTypeLookup.size();}
527 protected:
528 
529  QImage glTimeStampImage;
530  SpinTimer *mySpinTimer;
531  ShaderMgr *manager;
532  //Mouse Mode tables. Static since independent of window:
533  static vector<ParamsBase::ParamsBaseType> paramsFromMode;
534  static vector<int> manipFromMode;
535  static vector<string> modeName;
536  static map<ParamsBase::ParamsBaseType, int> modeFromParams;
537  //There's a separate manipholder for each window
538  vector<TranslateStretchManip*> manipHolder;
539  //Register a manip, including an icon and text
540  //Icon must be specified as an xpm or null
541  //Manip type is : 0 for navigation (nothing) 1 for 3D translate/stretch, 2 for 2D translate/stretch, 3 for 3D rotate/stretch
542 
543  //Container for sorting renderer list:
544  class RenderListElt {
545  public:
546  Renderer* ren;
547  float camDist;
548  Params::ParamsBaseType renType;
549  };
550  static bool renderPriority(RenderListElt* ren1, RenderListElt* ren2){
551  return (ren1->camDist > ren2->camDist);
552  }
553  int hasColorbarIndex(RenderParams* p){
554  if (!p->isEnabled()) return -1;
555  if (!p->UsesMapperFunction()) return -1;
556  if (p != Params::GetCurrentParamsInstance(p->GetParamsBaseTypeId(), winNum)) return -1;
557  for (int i = 0; i< rendererTypeLookup.size(); i++){
558  if (rendererTypeLookup[i] == p->GetParamsBaseTypeId()){
559  if (colorbarEnabled[i]) return i;
560  else return -1;
561  }
562  }
563  return -1;
564  }
565  //This method converts lon lat to user coords, assuming a "flat" earth so axes will not wrap.
566  static void flatConvertFromLonLat(double x[2], double minLon, double maxLon, double minX, double maxX);
567  std::vector<QImage> axisLabels[3];
568 
569  bool axisLabelsDirty;
570  bool textRenderersDirty;
571  static bool depthPeeling;
572  int winNum;
573  int previousTimeStep;
574  int previousFrameNum;
575  static int jpegQuality;
576  //Following flag is set whenever there is mouse navigation, so that we can use
577  //the new viewer position
578  //at the next rendering
579  bool newViewerCoords;
580  static int currentMouseMode;
581  std::map<DirtyBitType,bool> vizDirtyBit;
582  Renderer* renderer[MAXNUMRENDERERS];
584  int renderOrder[MAXNUMRENDERERS];
585 
586  //Map params to renderer for set/get dirty bits, etc:
587 
588  std::map<RenderParams*,Renderer*> rendererMapping;
589 
590  int numRenderers;
591  //Picking helper functions, saved from last change in GL state. These
592  //Deal with the cube coordinates (known to the trackball)
593  //openGL model matrix is kept in the viewpointparams, since
594  //it may be shared (global)
595  //
596  GLdouble* getModelMatrix();
597 
598  GLfloat tcoord[2];
599 
600  GLfloat* setTexCrd(int i, int j);
601 
602  //These methods cannot be overridden, but the initialize and paint methods
603  //call the corresponding Renderer methods.
604  //
605  void initializeGL();
606 
607  void resizeGL( int w, int h );
608 
609  //Following QT 4 guidance (see bubbles example), opengl painting is performed
610  //in paintEvent(), so that we can paint nice text over the window.
611  // GLWindow::paintGL() is not implemented.
612  // The other changes include:
613  // GL_MULTISAMPLE is enabled
614  // GLWindow::updateGL() is replaced by GLWindow::update()
615  // resizeGL() contents have been moved to setUpViewport(), which is also called
616  // from paintEvent().
617  // setAutoFillBackground(false) is called in the GLWindow constructor
618 
619  void paintEvent(QPaintEvent* event);
620 #ifdef Darwin
621  bool event ( QEvent * e );
622 #endif
623 
624  void perspectiveGL( GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar );
625  void setUpViewport(int width, int height);
626  //Methods to support drawing domain bounds, axes etc.
627  //Set colors to use in domain-bound rendering:
628  void setSubregionFrameColorFlt(const QColor& c);
629  void setRegionFrameColorFlt(const QColor& c);
630  //Draw the region bounds and frame it in full domain.
631  //Arguments are in unit cube coordinates
632  void renderDomainFrame(float* extents, float* minFull, float* maxFull);
633 
634  void drawSubregionBounds(float* extents);
635  void drawAxisArrows(float* extents);
636  void drawAxisTics(int tstep);
637  void drawAxisLabels(int tstep);
638  void buildAxisLabels(int tstep);
639 
640  void placeLights();
641 
642  //Helper functions for drawing region bounds:
643  static float* cornerPoint(float* extents, int faceNum);
644  // Faces of the cube are numbered 0..5 based on view from pos z axis:
645  // back, front, bottom, top, left, right
646  static bool faceIsVisible(float* extents, float* viewerCoords, int faceNum);
647 
648 
649  //Render all the text at a timestep;
650  void renderText(int timestep);
651  float regionFrameColorFlt[3];
652  float subregionFrameColorFlt[3];
653 
654  float wCenter[3]; //World center coords
655  float maxDim; //Max of x, y, z size in world coords
656  bool perspective; //perspective vs parallel coords;
657  bool oldPerspective;
658  //Indicate if the current render is different from previous,
659  //Used for frame capture:
660  bool renderNew;
661  //Moved over from vizwin:
662  int capturingImage;
663  int captureNumImage;
664  bool capturingFlow;
665  bool capturingTif;
666  //Flag to set indicating start of capture sequence.
667  bool newCaptureImage;
668  QString captureNameImage;
669  QString captureNameFlow;
670  //Set the following to force a call to resizeGL at the next call to
671  //updateGL.
672  bool needsResize;
673  float farDist, nearDist;
674 
675  GLint viewport[4];
676  GLdouble projectionMatrix[16];
677  static bool nowPainting;
678 
679  //values in vizFeature
680  QColor colorbarBackgroundColor;
681 
682 
683  int timeAnnotType;
684  int timeAnnotTextSize;
685  float timeAnnotCoords[2];
686  QColor timeAnnotColor;
687 
688  bool axisArrowsEnabled;
689  bool axisAnnotationEnabled;
690  int colorbarDigits;
691  int colorbarFontsize;
692 
693  float axisArrowCoord[3];
694  double axisOriginCoord[3];
695  double minTic[3];
696  double maxTic[3];
697  double ticLength[3];
698  int ticDir[3];
699  int numTics[3];
700  int labelHeight, labelDigits;
701  float ticWidth;
702  QColor axisColor;
703  float displacement;
704 
705  vector<float> colorbarLLX;
706  vector<float> colorbarLLY;
707  vector<bool> colorbarEnabled;
708  vector<string>colorbarTitles;
709  float colorbarSize[2];
710  int numColorbarTics;
711  bool colorbarDirty;
712  bool timeAnnotDirty;
713  bool mouseDownHere;
714  bool latLonAnnot;
715 
716 
717  renderCBFcn preRenderCB;
718  renderCBFcn postRenderCB;
719 
720  static int activeWindowNum;
721  //This flag is true if the active window is sharing the region.
722  //If the current window is not active, it will still share the region, if
723  //the region is shared, and the active region is shared.
724  static bool regionShareFlag;
725  static bool defaultTerrainEnabled;
726  static bool defaultSpinAnimateEnabled;
727  static bool spinAnimate;
728  static bool defaultAxisArrowsEnabled;
729 
730 
731  int axisLabelNums[3];
732 
733  //state to save during handle slide:
734  // screen coords where mouse is pressed:
735  float mouseDownPoint[2];
736  // unit vector in direction of handle
737  float handleProjVec[2];
738  bool isSpinning;
739  GLuint _timeStampTexid;
740 
741 private:
742  bool _readyToDraw;
743  void makeWriter();
744 
745  map<int, map<Renderer*,vector<TextObject*> > >textObjectMap;
746 
747  map< int, map< pair<Renderer*, int> , vector<float*>* > >textCoordMap;
748  std::vector<int> rendererTypeLookup;
749 
750 
751 #endif //DOXYGEN_SKIP_THIS
752 
753 };
754 
755 };
756 
757 #endif // GLWINDOW_H
A class for performing OpenGL rendering in a VAPOR Visualizer.
Definition: glwindow.h:77
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
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
#define RENDER_API
Definition: common.h:64
static ParamsBaseType GetTypeFromTag(const string &tag)
VetsUtil base class.
Definition: MyBase.h:68
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
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