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 adjustTo3D(string eye);
517  bool peelInitialized;
518  bool isDepthPeeling(){return depthPeeling;}
519  int getColorbarIndex(ParamsBase::ParamsBaseType t){
520  for (int i = 0; i< rendererTypeLookup.size(); i++){
521  if (rendererTypeLookup[i] == t) return i;
522  }
523  return -1;
524  }
525  int getNumTFs() { return rendererTypeLookup.size();}
526 protected:
527 
528  QImage glTimeStampImage;
529  SpinTimer *mySpinTimer;
530  ShaderMgr *manager;
531  //Mouse Mode tables. Static since independent of window:
532  static vector<ParamsBase::ParamsBaseType> paramsFromMode;
533  static vector<int> manipFromMode;
534  static vector<string> modeName;
535  static map<ParamsBase::ParamsBaseType, int> modeFromParams;
536  //There's a separate manipholder for each window
537  vector<TranslateStretchManip*> manipHolder;
538  //Register a manip, including an icon and text
539  //Icon must be specified as an xpm or null
540  //Manip type is : 0 for navigation (nothing) 1 for 3D translate/stretch, 2 for 2D translate/stretch, 3 for 3D rotate/stretch
541 
542  //Container for sorting renderer list:
543  class RenderListElt {
544  public:
545  Renderer* ren;
546  float camDist;
547  Params::ParamsBaseType renType;
548  };
549  static bool renderPriority(RenderListElt* ren1, RenderListElt* ren2){
550  return (ren1->camDist > ren2->camDist);
551  }
552  int hasColorbarIndex(RenderParams* p){
553  if (!p->isEnabled()) return -1;
554  if (!p->UsesMapperFunction()) return -1;
555  if (p != Params::GetCurrentParamsInstance(p->GetParamsBaseTypeId(), winNum)) return -1;
556  for (int i = 0; i< rendererTypeLookup.size(); i++){
557  if (rendererTypeLookup[i] == p->GetParamsBaseTypeId()){
558  if (colorbarEnabled[i]) return i;
559  else return -1;
560  }
561  }
562  return -1;
563  }
564  //This method converts lon lat to user coords, assuming a "flat" earth so axes will not wrap.
565  static void flatConvertFromLonLat(double x[2], double minLon, double maxLon, double minX, double maxX);
566  std::vector<QImage> axisLabels[3];
567 
568  bool axisLabelsDirty;
569  bool textRenderersDirty;
570  static bool depthPeeling;
571  int winNum;
572  int previousTimeStep;
573  int previousFrameNum;
574  static int jpegQuality;
575  //Following flag is set whenever there is mouse navigation, so that we can use
576  //the new viewer position
577  //at the next rendering
578  bool newViewerCoords;
579  static int currentMouseMode;
580  std::map<DirtyBitType,bool> vizDirtyBit;
581  Renderer* renderer[MAXNUMRENDERERS];
583  int renderOrder[MAXNUMRENDERERS];
584 
585  //Map params to renderer for set/get dirty bits, etc:
586 
587  std::map<RenderParams*,Renderer*> rendererMapping;
588 
589  int numRenderers;
590  //Picking helper functions, saved from last change in GL state. These
591  //Deal with the cube coordinates (known to the trackball)
592  //openGL model matrix is kept in the viewpointparams, since
593  //it may be shared (global)
594  //
595  GLdouble* getModelMatrix();
596 
597  GLfloat tcoord[2];
598 
599  GLfloat* setTexCrd(int i, int j);
600 
601  //These methods cannot be overridden, but the initialize and paint methods
602  //call the corresponding Renderer methods.
603  //
604  void initializeGL();
605 
606  void resizeGL( int w, int h );
607 
608  //Following QT 4 guidance (see bubbles example), opengl painting is performed
609  //in paintEvent(), so that we can paint nice text over the window.
610  // GLWindow::paintGL() is not implemented.
611  // The other changes include:
612  // GL_MULTISAMPLE is enabled
613  // GLWindow::updateGL() is replaced by GLWindow::update()
614  // resizeGL() contents have been moved to setUpViewport(), which is also called
615  // from paintEvent().
616  // setAutoFillBackground(false) is called in the GLWindow constructor
617 
618  void paintEvent(QPaintEvent* event);
619 #ifdef Darwin
620  bool event ( QEvent * e );
621 #endif
622 
623  void perspectiveGL( GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar );
624  void setUpViewport(int width, int height);
625  //Methods to support drawing domain bounds, axes etc.
626  //Set colors to use in domain-bound rendering:
627  void setSubregionFrameColorFlt(const QColor& c);
628  void setRegionFrameColorFlt(const QColor& c);
629  //Draw the region bounds and frame it in full domain.
630  //Arguments are in unit cube coordinates
631  void renderDomainFrame(float* extents, float* minFull, float* maxFull);
632 
633  void drawSubregionBounds(float* extents);
634  void drawAxisArrows(float* extents);
635  void drawAxisTics(int tstep);
636  void drawAxisLabels(int tstep);
637  void buildAxisLabels(int tstep);
638 
639  void placeLights();
640 
641  //Helper functions for drawing region bounds:
642  static float* cornerPoint(float* extents, int faceNum);
643  // Faces of the cube are numbered 0..5 based on view from pos z axis:
644  // back, front, bottom, top, left, right
645  static bool faceIsVisible(float* extents, float* viewerCoords, int faceNum);
646 
647 
648  //Render all the text at a timestep;
649  void renderText(int timestep);
650  float regionFrameColorFlt[3];
651  float subregionFrameColorFlt[3];
652 
653  float wCenter[3]; //World center coords
654  float maxDim; //Max of x, y, z size in world coords
655  bool perspective; //perspective vs parallel coords;
656  bool oldPerspective;
657  //Indicate if the current render is different from previous,
658  //Used for frame capture:
659  bool renderNew;
660  //Moved over from vizwin:
661  int capturingImage;
662  int captureNumImage;
663  bool capturingFlow;
664  bool capturingTif;
665  //Flag to set indicating start of capture sequence.
666  bool newCaptureImage;
667  QString captureNameImage;
668  QString captureNameFlow;
669  //Set the following to force a call to resizeGL at the next call to
670  //updateGL.
671  bool needsResize;
672  float farDist, nearDist;
673 
674  GLint viewport[4];
675  GLdouble projectionMatrix[16];
676  static bool nowPainting;
677 
678  //values in vizFeature
679  QColor colorbarBackgroundColor;
680 
681 
682  int timeAnnotType;
683  int timeAnnotTextSize;
684  float timeAnnotCoords[2];
685  QColor timeAnnotColor;
686 
687  bool axisArrowsEnabled;
688  bool axisAnnotationEnabled;
689  int colorbarDigits;
690  int colorbarFontsize;
691 
692  float axisArrowCoord[3];
693  double axisOriginCoord[3];
694  double minTic[3];
695  double maxTic[3];
696  double ticLength[3];
697  int ticDir[3];
698  int numTics[3];
699  int labelHeight, labelDigits;
700  float ticWidth;
701  QColor axisColor;
702  float displacement;
703 
704  vector<float> colorbarLLX;
705  vector<float> colorbarLLY;
706  vector<bool> colorbarEnabled;
707  vector<string>colorbarTitles;
708  float colorbarSize[2];
709  int numColorbarTics;
710  bool colorbarDirty;
711  bool timeAnnotDirty;
712  bool mouseDownHere;
713  bool latLonAnnot;
714 
715 
716  renderCBFcn preRenderCB;
717  renderCBFcn postRenderCB;
718 
719  static int activeWindowNum;
720  //This flag is true if the active window is sharing the region.
721  //If the current window is not active, it will still share the region, if
722  //the region is shared, and the active region is shared.
723  static bool regionShareFlag;
724  static bool defaultTerrainEnabled;
725  static bool defaultSpinAnimateEnabled;
726  static bool spinAnimate;
727  static bool defaultAxisArrowsEnabled;
728 
729 
730  int axisLabelNums[3];
731 
732  //state to save during handle slide:
733  // screen coords where mouse is pressed:
734  float mouseDownPoint[2];
735  // unit vector in direction of handle
736  float handleProjVec[2];
737  bool isSpinning;
738  GLuint _timeStampTexid;
739 
740 private:
741  bool _readyToDraw;
742  void makeWriter();
743 
744  map<int, map<Renderer*,vector<TextObject*> > >textObjectMap;
745 
746  map< int, map< pair<Renderer*, int> , vector<float*>* > >textCoordMap;
747  std::vector<int> rendererTypeLookup;
748 
749 
750 #endif //DOXYGEN_SKIP_THIS
751 
752 };
753 
754 };
755 
756 #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