25 #include "trackball.h"
33 #include <vapor/MyBase.h>
34 #include <vapor/common.h>
36 #include "ShaderMgr.h"
40 #define MAXNUMRENDERERS 20
56 class TwoDImageParams;
58 class TranslateStretchManip;
59 class TranslateRotateManip;
106 void TransformToUnitBox();
114 return manipFromMode[modeIndex];
120 return paramsFromMode[modeIndex];
132 static const string&
getModeName(
int index) {
return modeName[index];}
139 static int AddMouseMode(
const std::string paramsTag,
int manipType,
const char* name);
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]);
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);
161 void addText(
Renderer*,
int timestep,
int objectNum,
float posn[3]);
163 void clearTextObjects(
Renderer*,
int timestep);
165 #ifndef DOXYGEN_SKIP_THIS
166 GLWindow( QGLFormat& fmt, QWidget* parent,
int winnum);
170 Trackball* getTBall() {
return myTBall;}
171 void setPerspective(
bool isPersp) {perspective = isPersp;}
172 bool getPerspective() {
return perspective;}
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];}
198 bool pointIsOnQuad(
float cor1[3],
float cor2[3],
float cor3[3],
float cor4[3],
float pickPt[2]);
205 int pointIsOnBox(
float corners[8][3],
float pickPt[2]);
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];
217 bool projectPointToWin(
double cubeCoords[3],
double winCoords[2]);
224 bool projectPointToLine(
float mouseCoords[2],
float projCoords[2]);
227 bool startHandleSlide(
float mouseCoords[2],
int handleNum, Params* p);
232 bool pixelToVector(
float winCoords[2],
const float cameraPos[3],
float dirVec[3]);
235 bool getPixelData(
unsigned char* data,
string frame=
"");
237 void setRenderNew() {renderNew =
true;}
238 void draw3DCursor(
const float position[3]);
240 void renderTimeStamp(
bool rebuild);
241 void buildTimeStampImage();
244 bool useLatLonAnnotation() {
return latLonAnnot;}
245 void setLatLonAnnotation(
bool val){ latLonAnnot = val;}
249 QColor& getColorbarBackgroundColor() {
return colorbarBackgroundColor;}
250 bool axisArrowsAreEnabled() {
return axisArrowsEnabled;}
251 bool axisAnnotationIsEnabled() {
return axisAnnotationEnabled;}
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;}
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;}
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];
292 void setColorbarBackgroundColor(QColor& c) {colorbarBackgroundColor = c;}
295 void enableAxisArrows(
bool enable) {axisArrowsEnabled = enable;}
296 void enableAxisAnnotation(
bool enable) {axisAnnotationEnabled = enable;}
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;}
330 bool mouseIsDown() {
return mouseDownHere;}
331 void setMouseDown(
bool downUp) {mouseDownHere = downUp;}
333 void setNumRenderers(
int num) {numRenderers = num;}
334 int getNumRenderers() {
return numRenderers;}
337 Renderer* getRenderer(
int i) {
return renderer[i];}
338 Renderer* getRenderer(RenderParams* p);
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);
349 void removeAllRenderers();
350 void sortRenderers(
int timestep);
352 void removeDisabledRenderers();
356 static int getCurrentMouseMode() {
return currentMouseMode;}
357 static void setCurrentMouseMode(
int t){currentMouseMode = t;}
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);
371 void setActiveAnimationParams(Params* p) {setActiveParams(p,Params::_animationParamsTag);}
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);}
379 vector<Params*> currentParams;
383 currentParams[pType] = p;
385 void setActiveParams(Params* p,
const std::string& tag){
392 void mapRenderer(RenderParams* rp, Renderer* ren){rendererMapping[rp] = ren;}
393 bool unmapRenderer(RenderParams* rp);
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) {
404 captureNumImage = startNum;
405 captureNameImage = name;
406 newCaptureImage =
true;
407 capturingTif = isTif;
408 previousFrameNum = -1;
409 previousTimeStep = -1;
412 void startFlowCapture(QString& name) {
413 capturingFlow =
true;
414 captureNameFlow = name;
417 void singleCaptureImage(QString& name){
419 captureNameImage = name;
420 newCaptureImage =
true;
423 bool captureIsNewImage() {
return newCaptureImage;}
425 void setCaptureNewImage(
bool isNew){ newCaptureImage = isNew;}
427 void stopImageCapture() {capturingImage = 0;}
428 void stopFlowCapture() {capturingFlow =
false;}
432 void doFrameCapture(
string frame=
"");
433 QString& getFlowFilename(){
return captureNameFlow;}
436 TranslateStretchManip* getManip(
const std::string& paramTag){
438 return manipHolder[mode];
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;}
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;}
466 const GLdouble* getProjectionMatrix() {
return projectionMatrix;}
468 void getNearFarClippingPlanes(GLfloat *nearplane, GLfloat *farplane) {
469 *nearplane = nearDist; *farplane = farDist;
473 const GLint* getViewport() {
return viewport;}
482 static OGLVendorType GetVendor();
484 void startSpin(
int renderMS);
487 bool spinning(){
return isSpinning;}
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;}
504 GLuint currentBuffer;
507 GLuint depthA, depthB;
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;}
521 for (
int i = 0; i< rendererTypeLookup.size(); i++){
522 if (rendererTypeLookup[i] == t)
return i;
526 int getNumTFs() {
return rendererTypeLookup.size();}
529 QImage glTimeStampImage;
530 SpinTimer *mySpinTimer;
533 static vector<ParamsBase::ParamsBaseType> paramsFromMode;
534 static vector<int> manipFromMode;
535 static vector<string> modeName;
536 static map<ParamsBase::ParamsBaseType, int> modeFromParams;
538 vector<TranslateStretchManip*> manipHolder;
544 class RenderListElt {
550 static bool renderPriority(RenderListElt* ren1, RenderListElt* ren2){
551 return (ren1->camDist > ren2->camDist);
553 int hasColorbarIndex(RenderParams* p){
554 if (!p->isEnabled())
return -1;
555 if (!p->UsesMapperFunction())
return -1;
557 for (
int i = 0; i< rendererTypeLookup.size(); i++){
558 if (rendererTypeLookup[i] == p->GetParamsBaseTypeId()){
559 if (colorbarEnabled[i])
return i;
566 static void flatConvertFromLonLat(
double x[2],
double minLon,
double maxLon,
double minX,
double maxX);
567 std::vector<QImage> axisLabels[3];
569 bool axisLabelsDirty;
570 bool textRenderersDirty;
571 static bool depthPeeling;
573 int previousTimeStep;
574 int previousFrameNum;
575 static int jpegQuality;
579 bool newViewerCoords;
580 static int currentMouseMode;
581 std::map<DirtyBitType,bool> vizDirtyBit;
588 std::map<RenderParams*,Renderer*> rendererMapping;
596 GLdouble* getModelMatrix();
600 GLfloat* setTexCrd(
int i,
int j);
607 void resizeGL(
int w,
int h );
619 void paintEvent(QPaintEvent* event);
621 bool event ( QEvent * e );
624 void perspectiveGL( GLdouble fovY, GLdouble aspect, GLdouble zNear, GLdouble zFar );
625 void setUpViewport(
int width,
int height);
628 void setSubregionFrameColorFlt(
const QColor& c);
629 void setRegionFrameColorFlt(
const QColor& c);
632 void renderDomainFrame(
float* extents,
float* minFull,
float* maxFull);
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);
643 static float* cornerPoint(
float* extents,
int faceNum);
646 static bool faceIsVisible(
float* extents,
float* viewerCoords,
int faceNum);
650 void renderText(
int timestep);
651 float regionFrameColorFlt[3];
652 float subregionFrameColorFlt[3];
667 bool newCaptureImage;
668 QString captureNameImage;
669 QString captureNameFlow;
673 float farDist, nearDist;
676 GLdouble projectionMatrix[16];
677 static bool nowPainting;
680 QColor colorbarBackgroundColor;
684 int timeAnnotTextSize;
685 float timeAnnotCoords[2];
686 QColor timeAnnotColor;
688 bool axisArrowsEnabled;
689 bool axisAnnotationEnabled;
691 int colorbarFontsize;
693 float axisArrowCoord[3];
694 double axisOriginCoord[3];
700 int labelHeight, labelDigits;
705 vector<float> colorbarLLX;
706 vector<float> colorbarLLY;
707 vector<bool> colorbarEnabled;
708 vector<string>colorbarTitles;
709 float colorbarSize[2];
720 static int activeWindowNum;
724 static bool regionShareFlag;
725 static bool defaultTerrainEnabled;
726 static bool defaultSpinAnimateEnabled;
727 static bool spinAnimate;
728 static bool defaultAxisArrowsEnabled;
731 int axisLabelNums[3];
735 float mouseDownPoint[2];
737 float handleProjVec[2];
739 GLuint _timeStampTexid;
745 map<int, map<Renderer*,vector<TextObject*> > >textObjectMap;
747 map< int, map< pair<Renderer*, int> , vector<float*>* > >textCoordMap;
748 std::vector<int> rendererTypeLookup;
751 #endif //DOXYGEN_SKIP_THIS
A class for performing OpenGL rendering in a VAPOR Visualizer.
static Params * GetCurrentParamsInstance(int pType, int winnum)
ViewpointParams * getActiveViewpointParams()
A class for describing a 3D axis-aligned region in user space.
AnimationParams * getActiveAnimationParams()
A class for describing the viewpoint and lights.
bool(* renderCBFcn)(int winnum, bool newCoords)
static ParamsBaseType GetTypeFromTag(const string &tag)
static DataStatus * getInstance()
RegionParams * getActiveRegionParams()
static int getModeManipType(int modeIndex)
A class that specifies parameters used in animation.
static const string & getModeName(int index)
static int getModeFromParams(ParamsBase::ParamsBaseType t)
static ParamsBase::ParamsBaseType getModeParamType(int modeIndex)
A class that performs rendering in the GLWindow.