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*,
const char* fontPath,
int textSize,
float textColor[4],
float bgColor[4],
int type,
string text);
160 void addText(
Renderer*,
int objectNum,
float posn[3]);
166 #ifndef DOXYGEN_SKIP_THIS
167 GLWindow( QGLFormat& fmt, QWidget* parent,
int winnum);
171 Trackball* getTBall() {
return myTBall;}
172 void setPerspective(
bool isPersp) {perspective = isPersp;}
173 bool getPerspective() {
return perspective;}
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];}
199 bool pointIsOnQuad(
float cor1[3],
float cor2[3],
float cor3[3],
float cor4[3],
float pickPt[2]);
206 int pointIsOnBox(
float corners[8][3],
float pickPt[2]);
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];
218 bool projectPointToWin(
double cubeCoords[3],
double winCoords[2]);
225 bool projectPointToLine(
float mouseCoords[2],
float projCoords[2]);
228 bool startHandleSlide(
float mouseCoords[2],
int handleNum, Params* p);
233 bool pixelToVector(
float winCoords[2],
const float cameraPos[3],
float dirVec[3]);
236 bool getPixelData(
unsigned char* data);
238 void setRenderNew() {renderNew =
true;}
239 void draw3DCursor(
const float position[3]);
241 void renderTimeStamp(
bool rebuild);
242 void buildTimeStampImage();
245 bool useLatLonAnnotation() {
return latLonAnnot;}
246 void setLatLonAnnotation(
bool val){ latLonAnnot = val;}
250 QColor& getColorbarBackgroundColor() {
return colorbarBackgroundColor;}
251 bool axisArrowsAreEnabled() {
return axisArrowsEnabled;}
252 bool axisAnnotationIsEnabled() {
return axisAnnotationEnabled;}
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;}
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;}
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];
293 void setColorbarBackgroundColor(QColor& c) {colorbarBackgroundColor = c;}
296 void enableAxisArrows(
bool enable) {axisArrowsEnabled = enable;}
297 void enableAxisAnnotation(
bool enable) {axisAnnotationEnabled = enable;}
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;}
331 bool mouseIsDown() {
return mouseDownHere;}
332 void setMouseDown(
bool downUp) {mouseDownHere = downUp;}
334 void setNumRenderers(
int num) {numRenderers = num;}
335 int getNumRenderers() {
return numRenderers;}
338 Renderer* getRenderer(
int i) {
return renderer[i];}
339 Renderer* getRenderer(RenderParams* p);
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);
350 void removeAllRenderers();
351 void sortRenderers(
int timestep);
353 void removeDisabledRenderers();
357 static int getCurrentMouseMode() {
return currentMouseMode;}
358 static void setCurrentMouseMode(
int t){currentMouseMode = t;}
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);
372 void setActiveAnimationParams(Params* p) {setActiveParams(p,Params::_animationParamsTag);}
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);}
380 vector<Params*> currentParams;
384 currentParams[pType] = p;
386 void setActiveParams(Params* p,
const std::string& tag){
393 void mapRenderer(RenderParams* rp, Renderer* ren){rendererMapping[rp] = ren;}
394 bool unmapRenderer(RenderParams* rp);
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) {
405 captureNumImage = startNum;
406 captureNameImage = name;
407 newCaptureImage =
true;
408 capturingTif = isTif;
409 previousFrameNum = -1;
410 previousTimeStep = -1;
413 void startFlowCapture(QString& name) {
414 capturingFlow =
true;
415 captureNameFlow = name;
418 void singleCaptureImage(QString& name){
420 captureNameImage = name;
421 newCaptureImage =
true;
424 bool captureIsNewImage() {
return newCaptureImage;}
426 void setCaptureNewImage(
bool isNew){ newCaptureImage = isNew;}
428 void stopImageCapture() {capturingImage = 0;}
429 void stopFlowCapture() {capturingFlow =
false;}
433 void doFrameCapture();
434 QString& getFlowFilename(){
return captureNameFlow;}
437 TranslateStretchManip* getManip(
const std::string& paramTag){
439 return manipHolder[mode];
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;}
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;}
467 const GLdouble* getProjectionMatrix() {
return projectionMatrix;}
469 void getNearFarClippingPlanes(GLfloat *nearplane, GLfloat *farplane) {
470 *nearplane = nearDist; *farplane = farDist;
474 const GLint* getViewport() {
return viewport;}
483 static OGLVendorType GetVendor();
485 void startSpin(
int renderMS);
488 bool spinning(){
return isSpinning;}
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;}
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 regPaintEvent();
514 bool peelInitialized;
515 bool isDepthPeeling(){
return depthPeeling;}
517 for (
int i = 0; i< rendererTypeLookup.size(); i++){
518 if (rendererTypeLookup[i] == t)
return i;
524 QImage glTimeStampImage;
525 SpinTimer *mySpinTimer;
528 static vector<ParamsBase::ParamsBaseType> paramsFromMode;
529 static vector<int> manipFromMode;
530 static vector<string> modeName;
531 static map<ParamsBase::ParamsBaseType, int> modeFromParams;
533 vector<TranslateStretchManip*> manipHolder;
539 class RenderListElt {
545 static bool renderPriority(RenderListElt* ren1, RenderListElt* ren2){
546 return (ren1->camDist > ren2->camDist);
548 int hasColorbarIndex(RenderParams* p){
549 if (!p->isEnabled())
return -1;
550 if (!p->UsesMapperFunction())
return -1;
552 for (
int i = 0; i< rendererTypeLookup.size(); i++){
553 if (rendererTypeLookup[i] == p->GetParamsBaseTypeId()){
554 if (colorbarEnabled[i])
return i;
561 static void flatConvertFromLonLat(
double x[2],
double minLon,
double maxLon,
double minX,
double maxX);
562 std::vector<QImage> axisLabels[3];
564 bool axisLabelsDirty;
565 bool textRenderersDirty;
566 static bool depthPeeling;
568 int previousTimeStep;
569 int previousFrameNum;
570 static int jpegQuality;
574 bool newViewerCoords;
575 static int currentMouseMode;
576 std::map<DirtyBitType,bool> vizDirtyBit;
583 std::map<RenderParams*,Renderer*> rendererMapping;
591 GLdouble* getModelMatrix();
595 GLfloat* setTexCrd(
int i,
int j);
602 void resizeGL(
int w,
int h );
614 void paintEvent(QPaintEvent* event);
616 bool event ( QEvent * e );
620 void setUpViewport(
int width,
int height);
623 void setSubregionFrameColorFlt(
const QColor& c);
624 void setRegionFrameColorFlt(
const QColor& c);
627 void renderDomainFrame(
float* extents,
float* minFull,
float* maxFull);
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);
638 static float* cornerPoint(
float* extents,
int faceNum);
641 static bool faceIsVisible(
float* extents,
float* viewerCoords,
int faceNum);
646 float regionFrameColorFlt[3];
647 float subregionFrameColorFlt[3];
662 bool newCaptureImage;
663 QString captureNameImage;
664 QString captureNameFlow;
668 float farDist, nearDist;
671 GLdouble projectionMatrix[16];
672 static bool nowPainting;
675 QColor colorbarBackgroundColor;
679 int timeAnnotTextSize;
680 float timeAnnotCoords[2];
681 QColor timeAnnotColor;
683 bool axisArrowsEnabled;
684 bool axisAnnotationEnabled;
686 int colorbarFontsize;
688 float axisArrowCoord[3];
689 double axisOriginCoord[3];
695 int labelHeight, labelDigits;
700 vector<float> colorbarLLX;
701 vector<float> colorbarLLY;
702 vector<bool> colorbarEnabled;
703 vector<string>colorbarTitles;
704 float colorbarSize[2];
715 static int activeWindowNum;
719 static bool regionShareFlag;
720 static bool defaultTerrainEnabled;
721 static bool defaultSpinAnimateEnabled;
722 static bool spinAnimate;
723 static bool defaultAxisArrowsEnabled;
726 int axisLabelNums[3];
730 float mouseDownPoint[2];
732 float handleProjVec[2];
734 GLuint _timeStampTexid;
740 map<Renderer*,vector<TextObject*> > textObjectMap;
741 map<Renderer*, bool> textValidFlag;
742 map< pair<Renderer*, int> , vector<float*>* > textCoordMap;
743 std::vector<int> rendererTypeLookup;
746 #endif //DOXYGEN_SKIP_THIS
A class for performing OpenGL rendering in a VAPOR Visualizer.
static Params * GetCurrentParamsInstance(int pType, int winnum)
bool(* renderCBFcn)(int winnum, bool newCoords)
ViewpointParams * getActiveViewpointParams()
bool isTextValid(Renderer *ren)
A class for describing a 3D axis-aligned region in user space.
void setTextValid(Renderer *ren, bool val)
AnimationParams * getActiveAnimationParams()
A class for describing the viewpoint and lights.
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.