28 #include <vapor/common.h>
29 #include <vapor/DataMgr.h>
30 #include <vapor/MetadataVDC.h>
59 if (!theDataStatus) theDataStatus =
new DataStatus;
98 if (!dataMgr)
return false;
99 if (timestep < (
int)minTimeStep || timestep > (
int)maxTimeStep)
return false;
100 if (!variableExists[sesvarnum])
return false;
101 return (getMaxLevel3D(sesvarnum,timestep) >= 0);
109 if (!dataMgr)
return false;
110 if (timestep < (
int)minTimeStep || timestep > (
int)maxTimeStep)
return false;
111 if (!variableExists2D[sesvarnum])
return false;
112 return (getMaxLevel2D(sesvarnum,timestep) >= 0);
119 if (!dataMgr)
return false;
120 if (timestep < (
int)minTimeStep || timestep > (
int)maxTimeStep)
return false;
121 for (
int i = 0; i<variableExists.size(); i++){
122 if (variableExists[i] && getMaxLevel3D(i,timestep) >= 0)
132 if (!dataMgr)
return false;
133 if (timestep < 0 || timestep >= numTimesteps)
return false;
134 for (
int i = 0; i<variableExists2D.size(); i++){
135 if (variableExists2D[i] && getMaxLevel2D(i,timestep) >= 0)
145 if (!dataMgr)
return false;
146 if (timestep < 0 || timestep >= numTimesteps)
return false;
147 for (
int i = 0; i<variableExists.size(); i++){
148 if (variableExists[i] && getMaxLevel3D(i,timestep) >= 0)
151 for (
int i = 0; i<variableExists2D.size(); i++){
152 if (variableExists2D[i] && getMaxLevel2D(i,timestep) >= 0)
161 for (
int t = (
int)minTimeStep; t <= (int)maxTimeStep; t++) {
162 if (dataIsPresent3D(t))
return true;
170 for (
int t = (
int)minTimeStep; t <= (int)maxTimeStep; t++) {
171 if (dataIsPresent2D(t))
return true;
185 double getDataMax3D(
int sesvarNum,
int timestep,
bool mustGet =
true);
196 double getDataMax2D(
int sesvarNum,
int timestep,
bool mustGet =
true);
207 double getDataMin3D(
int sesvarNum,
int timestep,
bool mustGet =
true);
218 double getDataMin2D(
int sesvarNum,
int timestep,
bool mustGet =
true);
224 double getDefaultDataMax3D(
int varnum,
bool mustGet =
true);
230 double getDefaultDataMin3D(
int varnum,
bool mustGet =
true);
236 double getDefaultDataMax2D(
int varnum,
bool mustGet =
true);
242 double getDefaultDataMin2D(
int varnum,
bool mustGet =
true);
250 int maxXFormPresent3D(
int sesvarnum,
int timestep);
258 int maxXFormPresent2D(
int sesvarnum,
int timestep);
266 int maxLODPresent3D(
int sesvarnum,
int timestep);
274 int maxLODPresent2D(
int sesvarnum,
int timestep);
284 int sesvarnum = getSessionVariableNum3D(varname);
286 sesvarnum = getSessionVariableNum2D(varname);
288 if (sesvarnum < 0)
return -1;
290 if (dim == 3)
return maxXFormPresent3D(sesvarnum,timestep);
291 else return maxXFormPresent2D(sesvarnum,timestep);
302 int sesvarnum = getSessionVariableNum3D(varname);
304 sesvarnum = getSessionVariableNum2D(varname);
306 if (sesvarnum < 0)
return -1;
308 if (dim == 3)
return maxLODPresent3D(sesvarnum,timestep);
309 else return maxLODPresent2D(sesvarnum,timestep);
317 if (varnum < variableExists.size())
return variableExists[varnum];
326 if (varnum < variableExists2D.size())
return variableExists2D[varnum];
339 bool fieldDataOK(
int refLevel,
int lod,
int tstep,
int varx,
int vary,
int varz);
362 if (getMaxLevel3D(sessionVarNum,timestep) >= lod)
363 maxLevel3D[sessionVarNum][timestep] = lod -1;
366 if (getMaxLevel3D(sessionVarNum,timestep) >= refLevel)
367 maxLevel3D[sessionVarNum][timestep] = refLevel -1;
379 if (getMaxLevel2D(sessionVarNum,timestep) >= lod)
380 maxLevel2D[sessionVarNum][timestep] = lod -1;
383 if (getMaxLevel2D(sessionVarNum,timestep) >= refLevel)
384 maxLevel2D[sessionVarNum][timestep] = refLevel -1;
401 static int getSessionVariableNum3D(
const std::string& str);
406 static int getSessionVariableNum2D(
const std::string& str);
420 {
if( varnum >= activeVariableNums3D.size())
return -1;
421 return activeVariableNums3D[varnum];}
427 {
if( varnum >= activeVariableNums2D.size())
return -1;
428 return activeVariableNums2D[varnum];}
433 static int mapSessionToActiveVarNum3D(
int sesvar);
438 static int mapSessionToActiveVarNum2D(
int sesvar);
446 if (activeVariableNums3D.size()<= activevarnum)
return variableNames[0];
447 return (variableNames[activeVariableNums3D[activevarnum]]);}
455 if (activeVariableNums2D.size()<= activevarnum)
return variableNames2D[0];
456 return (variableNames2D[activeVariableNums2D[activevarnum]]);}
461 int getActiveVarNum3D(std::string varname)
const;
466 int getActiveVarNum2D(std::string varname)
const;
489 #ifndef DOXYGEN_SKIP_THIS
493 QApplication* getApp() {
return theApp;}
496 bool reset(DataMgr* dm,
size_t cachesize, QApplication* app);
497 static void setDefaultPrefs();
499 void stretchExtents(
float factor[3]){
500 for (
int i = 0; i< 3; i++) {
501 stretchedExtents[i] = extents[i]*factor[i];
502 stretchedExtents[i+3] = extents[i+3]*factor[i];
503 stretchFactors[i] = factor[i];
504 fullStretchedSizes[i] = fullSizes[i]*factor[i];
507 static size_t getCacheMB() {
return cacheMB;}
508 static void setInteractiveRefinementLevel(
int lev) {
509 interactiveRefLevel = lev;
511 static int getInteractiveRefinementLevel() {
return interactiveRefLevel;}
514 int getFirstTimestep(
int sesvarnum);
515 int getFirstTimestep2D(
int sesvarnum);
516 size_t getFullDataSize(
int dim){
return fullDataSize[dim];}
517 size_t getFullSizeAtLevel(
int lev,
int dim)
518 {
return dataAtLevel[lev][dim];}
519 float getVoxelSize(
int lev,
int dim){
520 return ((extents[dim+3]-extents[dim])/(
float)getFullSizeAtLevel(lev,dim));
522 const size_t* getFullDataSize() {
return fullDataSize;}
525 int get2DOrientation(
int mdVarNum);
528 static const std::string getProjectionString() {
return projString;}
531 void getLocalExtentsCartesian(
float extents[6]);
535 static const QColor getBackgroundColor() {
return backgroundColor;}
536 static const QColor getRegionFrameColor() {
return regionFrameColor;}
537 static const QColor getSubregionFrameColor() {
return subregionFrameColor;}
538 static void setBackgroundColor(
const QColor c) {backgroundColor = c;}
539 static void setRegionFrameColor(
const QColor c) {regionFrameColor = c;}
540 static void setSubregionFrameColor(
const QColor c) {subregionFrameColor = c;}
541 static void enableRegionFrame(
bool enable) {regionFrameEnabled = enable;}
542 static void enableSubregionFrame(
bool enable) {subregionFrameEnabled = enable;}
543 static bool regionFrameIsEnabled() {
return regionFrameEnabled;}
544 static bool subregionFrameIsEnabled() {
return subregionFrameEnabled;}
547 static int mergeVariableName(
const std::string& str);
548 static int mergeVariableName2D(
const std::string& str);
551 static void addVarName(
const std::string newName) {
552 for (
int i = 0; i<variableNames.size(); i++)
553 if (variableNames[i] == newName)
return;
554 variableNames.push_back(newName);
556 static void addVarName2D(
const std::string newName) {
557 for (
int i = 0; i<variableNames2D.size(); i++)
558 if (variableNames2D[i] == newName)
return;
559 variableNames2D.push_back(newName);
564 static int getNumMetadataVariables() {
return numMetadataVariables;}
565 static int getNumMetadataVariables2D() {
return numMetadataVariables2D;}
567 static int mapMetadataToSessionVarNum(
int varnum)
568 {
if(!mapMetadataVars)
return 0;
569 return mapMetadataVars[varnum];}
570 static int mapMetadataToSessionVarNum2D(
int varnum)
571 {
if(!mapMetadataVars2D)
return 0;
572 return mapMetadataVars2D[varnum];}
573 static int mapSessionToMetadataVarNum(
int var);
577 static std::string& getMetadataVarName(
int mdvarnum) {
578 if (!mapMetadataVars)
return variableNames[0];
579 return (variableNames[mapMetadataVars[mdvarnum]]);}
580 static std::string& getMetadataVarName2D(
int mdvarnum) {
581 if (!mapMetadataVars2D)
return variableNames2D[0];
582 return (variableNames2D[mapMetadataVars2D[mdvarnum]]);}
583 int getMetadataVarNum(std::string varname);
584 int getMetadataVarNum2D(std::string varname);
586 static int getNumSessionVariables(){
return (
int)variableNames.size();}
587 static int getNumSessionVariables2D(){
return (
int)variableNames2D.size();}
588 static void clearVariableNames() {
589 variableNames.clear();
590 variableNames2D.clear();
593 static void removeMetadataVars(){
594 if (mapMetadataVars)
delete [] mapMetadataVars;
595 if (mapMetadataVars2D)
delete [] mapMetadataVars2D;
599 static void clearMetadataVars() {
600 mapMetadataVars = 0; numMetadataVariables = 0;
601 mapMetadataVars2D = 0; numMetadataVariables2D = 0;
603 static void clearDerivedVars() {
605 derivedMethodMap.clear();
606 derived2DInputMap.clear();
607 derived3DInputMap.clear();
608 derived2DOutputMap.clear();
609 derived3DOutputMap.clear();
611 static void purgeAllCachedDerivedVariables();
614 void getMaxStretchedExtentsInCube(
float maxExtents[3]);
615 const float* getStretchFactors() {
return stretchFactors;}
617 bool renderReady() {
return renderOK;}
618 void setRenderReady(
bool nowOK) {renderOK = nowOK;}
620 bool sphericalTransform();
622 vector<string> getVariableNames() {
return variableNames;}
623 vector<string> getVariableNames2D() {
return variableNames2D;}
626 static void specifyTextureSize(
bool val) {textureSizeSpecified = val;}
627 static bool textureSizeIsSpecified(){
return textureSizeSpecified;}
628 static int getTextureSize() {
return textureSize;}
629 static void setTextureSize(
int val) { textureSize = val;}
632 static void setWarnMissingData(
bool val) {doWarnIfDataMissing = val;}
633 static void setTrackMouse(
bool val) {trackMouseInTfe = val;}
634 static void setUseLowerAccuracy(
bool val){doUseLowerAccuracy = val;}
636 const string& getSessionVersion(){
return sessionVersion;}
637 void setSessionVersion(std::string& ver){sessionVersion = ver;}
642 static bool convertToLonLat(
double coords[],
int npoints = 1);
643 static bool convertFromLonLat(
double coords[],
int npoints = 1);
644 static bool convertLocalToLonLat(
int timestep,
double coords[],
int npoints = 1);
645 static bool convertLocalFromLonLat(
int timestep,
double coords[],
int npoints = 1);
650 static void clearActiveVars() {
651 activeVariableNums2D.clear();
652 activeVariableNums3D.clear();
656 static const string _backgroundColorAttr;
657 static const string _regionFrameColorAttr;
658 static const string _subregionFrameColorAttr;
659 static const string _regionFrameEnabledAttr;
660 static const string _subregionFrameEnabledAttr;
661 static const string _useLowerRefinementAttr;
662 static const string _missingDataWarningAttr;
663 static const string _trackMouseAttr;
667 int addDerivedScript(
const std::vector<string> &,
const std::vector<string> &,
const std::vector<string> &,
668 const std::vector<string> &,
const std::string &,
bool useMetadata =
true);
670 static int getNumDerivedScripts(){
671 return (derivedMethodMap.size());
674 int replaceDerivedScript(
int id,
const vector<string> &in2DVars,
const vector<string> &out2DVars,
const vector<string>& in3Dvars,
const vector<string>& out3Dvars,
const string& script);
678 static const map<int,vector<string> >& getDerived2DOutputMap() {
return derived2DOutputMap;}
679 static const map<int,vector<string> >& getDerived3DOutputMap() {
return derived3DOutputMap;}
681 bool removeDerivedScript(
int index);
683 static bool isDerivedVariable(std::string varname) {
684 return (getDerivedScriptId(varname) >= 0);
686 static const std::string getDerivedMethod(std::string varname) {
687 int id = getDerivedScriptId(varname);
688 if (
id <0)
return string(
"");
689 return (getDerivedScript(
id));
692 static bool setDerivedMethod(
const std::string varname,
const std::string& method){
693 int id = getDerivedScriptId(varname);
694 if (
id <0)
return false;
695 derivedMethodMap[id] = method;
699 static int getDerivedScriptId(
const string& outvar) ;
700 static const string& getDerivedScript(
int id) ;
701 static int getMaxDerivedScriptId();
702 static const string& getDerivedScriptName(
int id);
703 static const vector<string>& getDerived2DInputVars(
int id) ;
704 static const vector<string>& getDerived3DInputVars(
int id) ;
705 static const vector<string>& getDerived2DOutputVars(
int id) ;
706 static const vector<string>& getDerived3DOutputVars(
int id) ;
707 static const string& getDerivedScript(
const string& outvar) {
708 return getDerivedScript(getDerivedScriptId(outvar));
715 int setDerivedVariable3D(
const string& derivedVarName);
716 int setDerivedVariable2D(
const string& derivedVarName);
719 static bool removeDerivedVariable2D(
const string& derivedVarName);
720 static bool removeDerivedVariable3D(
const string& derivedVarName);
721 static bool pre22Session(){
return sessionBefore22;}
722 static void setPre22Session(
bool value){ sessionBefore22 = value;}
723 static void setPre22Offset(
float offset[3]){
724 pre22Offset[0] = offset[0];pre22Offset[1] = offset[1];pre22Offset[2] = offset[2];
726 static float* getPre22Offset(){
return pre22Offset;}
728 int getMaxLevel3D(
int sesvarnum,
int timestep);
729 int getMaxLevel2D(
int sesvarnum,
int timestep);
732 static DataStatus* theDataStatus;
733 static const vector<string> emptyVec;
734 static const string _emptyString;
737 static map<int,string> derivedMethodMap;
739 static map<int,vector<string> > derived2DInputMap;
741 static map<int,vector<string> > derived3DInputMap;
743 static map<int,vector<string> > derived2DOutputMap;
745 static map<int,vector<string> > derived3DOutputMap;
747 void calcDataRange(
int sesvarnum,
int ts);
748 void calcDataRange2D(
int sesvarnum,
int ts);
751 std::vector<bool> variableExists;
752 std::vector<bool> variableExists2D;
755 std::vector<int*> maxLevel3D;
756 std::vector<int*> maxLevel2D;
759 QApplication* theApp;
763 std::vector<float*> dataMin;
764 std::vector<float*> dataMax;
765 std::vector<float*> dataMin2D;
766 std::vector<float*> dataMax2D;
775 static int numOriented2DVars[3];
779 size_t fullDataSize[3];
780 std::vector<size_t*> dataAtLevel;
783 float stretchedExtents[6];
784 float stretchFactors[3];
786 float fullStretchedSizes[3];
793 static std::vector<std::string> variableNames;
795 static int numMetadataVariables;
796 static int* mapMetadataVars;
797 static std::vector<std::string> variableNames2D;
798 static int numMetadataVariables2D;
799 static int* mapMetadataVars2D;
800 static vector<int> activeVariableNums2D;
801 static vector<int> activeVariableNums3D;
803 string sessionVersion;
807 static int textureSize;
808 static bool textureSizeSpecified;
810 static QColor backgroundColor;
811 static QColor regionFrameColor;
812 static QColor subregionFrameColor;
813 static bool regionFrameEnabled;
814 static bool subregionFrameEnabled;
816 static bool doWarnIfDataMissing;
817 static bool trackMouseInTfe;
818 static bool doUseLowerAccuracy;
820 static size_t cacheMB;
822 static int interactiveRefLevel;
823 static std::string projString;
826 static bool sessionBefore22;
827 static float pre22Offset[3];
837 #endif //DOXYGEN_SKIP_THIS
841 #endif //DATASTATUS_H
void invalidateDataMgr()
Invalidate current data manager:
A class for describing the currently loaded dataset.
const float * getFullStretchedSizes()
bool dataIsPresent3D(int sesvarnum, int timestep)
bool dataIsPresent3D(int timestep)
bool variableIsPresent3D(int varnum)
static int getNumActiveVariables2D()
A cache based data reader.
static int getNumActiveVariables3D()
void setDataMissing3D(int timestep, int refLevel, int lod, int sessionVarNum)
static bool useLowerAccuracy()
int maxXFormPresent(const string &varname, int timestep)
void setDataMissing2D(int timestep, int refLevel, int lod, int sessionVarNum)
static std::string & getActiveVarName3D(int activevarnum)
bool dataIsPresent2D(int sesvarnum, int timestep)
bool dataIsPresent(int timestep)
const float * getStretchedExtents()
int maxLODPresent(const string &varname, int timestep)
static std::string & getActiveVarName2D(int activevarnum)
static bool warnIfDataMissing()
static std::string & getVariableName2D(int sesvarNum)
const float * getFullSizes()
static DataStatus * getInstance()
static std::string & getVariableName3D(int sesvarNum)
static int mapActiveToSessionVarNum2D(int varnum)
bool variableIsPresent2D(int varnum)
const float * getLocalExtents()
static int mapActiveToSessionVarNum3D(int varnum)
bool dataIsPresent2D(int timestep)