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