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);
 
  253     static bool checkVarMinMax(
MapperFunction* mf, 
int sesVarNum,  
bool is3D, 
bool useDefault, 
float minmax[2], 
int ts = 0);
 
  261     int maxXFormPresent3D(
int sesvarnum, 
int timestep);
 
  269     int maxXFormPresent2D(
int sesvarnum, 
int timestep);
 
  277     int maxLODPresent3D(
int sesvarnum, 
int timestep);
 
  285     int maxLODPresent2D(
int sesvarnum, 
int timestep);
 
  295         int sesvarnum = getSessionVariableNum3D(varname);
 
  297             sesvarnum = getSessionVariableNum2D(varname);
 
  299             if (sesvarnum < 0) 
return -1;
 
  301         if (dim == 3)
return maxXFormPresent3D(sesvarnum,timestep);
 
  302         else return maxXFormPresent2D(sesvarnum,timestep);
 
  313         int sesvarnum = getSessionVariableNum3D(varname);
 
  315             sesvarnum = getSessionVariableNum2D(varname);
 
  317             if (sesvarnum < 0) 
return -1;
 
  319         if (dim == 3)
return maxLODPresent3D(sesvarnum,timestep);
 
  320         else return maxLODPresent2D(sesvarnum,timestep);
 
  328         if (varnum < variableExists.size()) 
return variableExists[varnum];
 
  337         if (varnum < variableExists2D.size()) 
return variableExists2D[varnum];
 
  350     bool fieldDataOK(
int refLevel, 
int lod, 
int tstep, 
int varx, 
int vary, 
int varz);
 
  373             if (getMaxLevel3D(sessionVarNum,timestep) >= lod)
 
  374             maxLevel3D[sessionVarNum][timestep] = lod -1;
 
  377         if (getMaxLevel3D(sessionVarNum,timestep) >= refLevel)
 
  378             maxLevel3D[sessionVarNum][timestep] = refLevel -1;
 
  390             if (getMaxLevel2D(sessionVarNum,timestep) >= lod)
 
  391             maxLevel2D[sessionVarNum][timestep] = lod -1;
 
  394         if (getMaxLevel2D(sessionVarNum,timestep) >= refLevel)
 
  395             maxLevel2D[sessionVarNum][timestep] = refLevel -1;
 
  412     static int getSessionVariableNum3D(
const std::string& str);
 
  417     static int getSessionVariableNum2D(
const std::string& str);
 
  431         { 
if( varnum >= activeVariableNums3D.size()) 
return -1; 
 
  432         return activeVariableNums3D[varnum];}
 
  438         { 
if( varnum >= activeVariableNums2D.size()) 
return -1; 
 
  439         return activeVariableNums2D[varnum];}
 
  444     static int mapSessionToActiveVarNum3D(
int sesvar);
 
  449     static int mapSessionToActiveVarNum2D(
int sesvar);
 
  457         if (activeVariableNums3D.size()<= activevarnum) 
return variableNames[0];
 
  458         return (variableNames[activeVariableNums3D[activevarnum]]);}
 
  466         if (activeVariableNums2D.size()<= activevarnum) 
return variableNames2D[0];
 
  467         return (variableNames2D[activeVariableNums2D[activevarnum]]);}
 
  472     int getActiveVarNum3D(std::string varname) 
const;
 
  477     int getActiveVarNum2D(std::string varname) 
const;
 
  504 #ifndef DOXYGEN_SKIP_THIS 
  508     QApplication* getApp() {
return theApp;}
 
  511     bool reset(DataMgr* dm, 
size_t cachesize, QApplication* app);
 
  512     static void setDefaultPrefs();
 
  514     void stretchExtents(
float factor[3]){
 
  515         for (
int i = 0; i< 3; i++) {
 
  516             stretchedExtents[i] = extents[i]*factor[i];
 
  517             stretchedExtents[i+3] = extents[i+3]*factor[i];
 
  518             stretchFactors[i] = factor[i];
 
  519             fullStretchedSizes[i] = fullSizes[i]*factor[i];
 
  522     static size_t getCacheMB() {
return cacheMB;}
 
  523     static void setInteractiveRefinementLevel(
int lev) {
 
  524         interactiveRefLevel = lev;
 
  526     static int getInteractiveRefinementLevel() {
return interactiveRefLevel;}
 
  529     int getFirstTimestep(
int sesvarnum);
 
  530     int getFirstTimestep2D(
int sesvarnum);
 
  531     size_t getFullDataSize(
int dim){
return fullDataSize[dim];}
 
  532     size_t getFullSizeAtLevel(
int lev, 
int dim) 
 
  533         { 
return dataAtLevel[lev][dim];}
 
  534     float getVoxelSize(
int lev, 
int dim){
 
  535         return ((extents[dim+3]-extents[dim])/(
float)getFullSizeAtLevel(lev,dim));
 
  537     const size_t* getFullDataSize() {
return fullDataSize;}
 
  540     int get2DOrientation(
int mdVarNum); 
 
  543     static const std::string getProjectionString() {
return projString;}
 
  546     void getLocalExtentsCartesian(
float extents[6]);
 
  550     static const QColor getBackgroundColor() {
return backgroundColor;}
 
  551     static const QColor getRegionFrameColor() {
return regionFrameColor;}
 
  552     static const QColor getSubregionFrameColor() {
return subregionFrameColor;}
 
  553     static void setBackgroundColor(
const QColor c) {backgroundColor = c;}
 
  554     static void setRegionFrameColor(
const QColor c) {regionFrameColor = c;}
 
  555     static void setSubregionFrameColor(
const QColor c) {subregionFrameColor = c;}
 
  556     static void enableRegionFrame(
bool enable) {regionFrameEnabled = enable;}
 
  557     static void enableSubregionFrame(
bool enable) {subregionFrameEnabled = enable;}
 
  558     static bool regionFrameIsEnabled() {
return regionFrameEnabled;}
 
  559     static bool subregionFrameIsEnabled() {
return subregionFrameEnabled;}
 
  562     static int mergeVariableName(
const std::string& str);
 
  563     static int mergeVariableName2D(
const std::string& str);
 
  566     static void addVarName(
const std::string newName) {
 
  567         for (
int i = 0; i<variableNames.size(); i++)
 
  568             if (variableNames[i] == newName) 
return;
 
  569         variableNames.push_back(newName);
 
  571     static void addVarName2D(
const std::string newName) {
 
  572         for (
int i = 0; i<variableNames2D.size(); i++)
 
  573             if (variableNames2D[i] == newName) 
return;
 
  574         variableNames2D.push_back(newName);
 
  579     static int getNumMetadataVariables() {
return numMetadataVariables;}
 
  580     static int getNumMetadataVariables2D() {
return numMetadataVariables2D;}
 
  582     static int mapMetadataToSessionVarNum(
int varnum) 
 
  583         { 
if(!mapMetadataVars) 
return 0; 
 
  584         return mapMetadataVars[varnum];}
 
  585     static int mapMetadataToSessionVarNum2D(
int varnum) 
 
  586         { 
if(!mapMetadataVars2D) 
return 0; 
 
  587         return mapMetadataVars2D[varnum];}
 
  588     static int mapSessionToMetadataVarNum(
int var);
 
  592     static std::string& getMetadataVarName(
int mdvarnum) {
 
  593         if (!mapMetadataVars) 
return variableNames[0];
 
  594         return (variableNames[mapMetadataVars[mdvarnum]]);}
 
  595     static std::string& getMetadataVarName2D(
int mdvarnum) {
 
  596         if (!mapMetadataVars2D) 
return variableNames2D[0];
 
  597         return (variableNames2D[mapMetadataVars2D[mdvarnum]]);}
 
  598     int getMetadataVarNum(std::string varname);
 
  599     int getMetadataVarNum2D(std::string varname);
 
  601     static int getNumSessionVariables(){
return (
int)variableNames.size();}
 
  602     static int getNumSessionVariables2D(){
return (
int)variableNames2D.size();}
 
  603     static void clearVariableNames() {
 
  604         variableNames.clear();
 
  605         variableNames2D.clear();
 
  608     static void removeMetadataVars(){
 
  609         if (mapMetadataVars) 
delete [] mapMetadataVars;
 
  610         if (mapMetadataVars2D) 
delete [] mapMetadataVars2D;
 
  614     static void clearMetadataVars() {
 
  615         mapMetadataVars = 0; numMetadataVariables = 0;
 
  616         mapMetadataVars2D = 0; numMetadataVariables2D = 0;
 
  618     static void clearDerivedVars() {
 
  620         derivedMethodMap.clear();
 
  621         derived2DInputMap.clear();
 
  622         derived3DInputMap.clear();
 
  623         derived2DOutputMap.clear();
 
  624         derived3DOutputMap.clear();
 
  626     static void purgeAllCachedDerivedVariables();
 
  629     void getMaxStretchedExtentsInCube(
float maxExtents[3]);
 
  630     const float* getStretchFactors() {
return stretchFactors;}
 
  632     bool renderReady() {
return renderOK;}
 
  633     void setRenderReady(
bool nowOK) {renderOK = nowOK;}
 
  635     bool sphericalTransform();
 
  637     vector<string> getVariableNames() {
return variableNames;}
 
  638     vector<string> getVariableNames2D() {
return variableNames2D;}
 
  641     static void specifyTextureSize(
bool val) {textureSizeSpecified = val;}
 
  642     static bool textureSizeIsSpecified(){
return textureSizeSpecified;}
 
  643     static int getTextureSize() {
return textureSize;}
 
  644     static void setTextureSize(
int val) { textureSize = val;}
 
  647     static void setWarnMissingData(
bool val) {doWarnIfDataMissing = val;}
 
  648     static void setTrackMouse(
bool val) {trackMouseInTfe = val;}
 
  649     static void setUseLowerAccuracy(
bool val){doUseLowerAccuracy = val;}
 
  650     static void setUseQuadInterpolation(
bool val){doUseQuadInterpolation = val;}
 
  652     const string& getSessionVersion(){ 
return sessionVersion;}
 
  653     void setSessionVersion(std::string& ver){sessionVersion = ver;}
 
  658     static bool convertToLonLat(
double coords[], 
int npoints = 1);
 
  659     static bool convertFromLonLat(
double coords[], 
int npoints = 1);
 
  660     static bool convertLocalToLonLat(
int timestep, 
double coords[], 
int npoints = 1);
 
  661     static bool convertLocalFromLonLat(
int timestep,
double coords[], 
int npoints = 1);
 
  666     static void clearActiveVars() {
 
  667         activeVariableNums2D.clear();
 
  668         activeVariableNums3D.clear();
 
  672     static const string _backgroundColorAttr;
 
  673     static const string _regionFrameColorAttr;
 
  674     static const string _subregionFrameColorAttr;
 
  675     static const string _regionFrameEnabledAttr;
 
  676     static const string _subregionFrameEnabledAttr;
 
  677     static const string _useLowerRefinementAttr;
 
  678     static const string _useQuadInterpolationAttr;
 
  679     static const string _missingDataWarningAttr;
 
  680     static const string _trackMouseAttr;
 
  684     int addDerivedScript(
const std::vector<string> &,
const std::vector<string> &,
const std::vector<string> &,
 
  685         const std::vector<string> &,
const std::string &, 
bool useMetadata = 
true);
 
  687     static int getNumDerivedScripts(){
 
  688         return (derivedMethodMap.size());
 
  691     int replaceDerivedScript(
int id, 
const vector<string> &in2DVars, 
const vector<string> &out2DVars, 
const vector<string>& in3Dvars, 
const vector<string>& out3Dvars, 
const string& script);
 
  695     static const map<int,vector<string> >& getDerived2DOutputMap() {
return derived2DOutputMap;}
 
  696     static const map<int,vector<string> >& getDerived3DOutputMap() {
return derived3DOutputMap;}
 
  698     bool removeDerivedScript(
int index);
 
  700     static bool isDerivedVariable(std::string varname) {
 
  701         return (getDerivedScriptId(varname) >= 0);
 
  703     static const std::string getDerivedMethod(std::string varname) {
 
  704         int id = getDerivedScriptId(varname);
 
  705         if (
id <0) 
return string(
"");
 
  706         return (getDerivedScript(
id)); 
 
  709      static bool setDerivedMethod(
const std::string varname, 
const std::string& method){
 
  710          int id = getDerivedScriptId(varname);
 
  711          if (
id <0) 
return false;
 
  712          derivedMethodMap[id] = method;
 
  716     static int getDerivedScriptId(
const string& outvar) ;
 
  717     static const string& getDerivedScript(
int id) ;
 
  718     static int getMaxDerivedScriptId();
 
  719     static const string& getDerivedScriptName(
int id);
 
  720     static const vector<string>& getDerived2DInputVars(
int id) ;
 
  721     static const vector<string>& getDerived3DInputVars(
int id) ;
 
  722     static const vector<string>& getDerived2DOutputVars(
int id) ;
 
  723     static const vector<string>& getDerived3DOutputVars(
int id) ;
 
  724     static const string& getDerivedScript(
const string& outvar) {
 
  725         return getDerivedScript(getDerivedScriptId(outvar));
 
  732     int setDerivedVariable3D(
const string& derivedVarName);
 
  733     int setDerivedVariable2D(
const string& derivedVarName);
 
  736     static bool removeDerivedVariable2D(
const string& derivedVarName);
 
  737     static bool removeDerivedVariable3D(
const string& derivedVarName);
 
  738     static bool pre22Session(){
return sessionBefore22;}
 
  739     static void setPre22Session(
bool value){ sessionBefore22 = value;}
 
  740     static void setPre22Offset(
float offset[3]){
 
  741         pre22Offset[0] = offset[0];pre22Offset[1] = offset[1];pre22Offset[2] = offset[2];
 
  743     static float* getPre22Offset(){
return pre22Offset;}
 
  745     int getMaxLevel3D(
int sesvarnum,
int timestep);
 
  746     int getMaxLevel2D(
int sesvarnum,
int timestep);
 
  749     static DataStatus* theDataStatus;
 
  750     static const vector<string> emptyVec;
 
  751     static const string _emptyString;
 
  754     static map<int,string> derivedMethodMap;
 
  756     static map<int,vector<string> > derived2DInputMap;
 
  758     static map<int,vector<string> > derived3DInputMap;
 
  760     static map<int,vector<string> > derived2DOutputMap;
 
  762     static map<int,vector<string> > derived3DOutputMap;
 
  764     void calcDataRange(
int sesvarnum, 
int ts);
 
  765     void calcDataRange2D(
int sesvarnum, 
int ts);
 
  768     std::vector<bool> variableExists;
 
  769     std::vector<bool> variableExists2D;
 
  772     std::vector<int*> maxLevel3D;
 
  773     std::vector<int*> maxLevel2D;
 
  776     QApplication* theApp;
 
  780     std::vector<float*> dataMin;
 
  781     std::vector<float*> dataMax;
 
  782     std::vector<float*> dataMin2D;
 
  783     std::vector<float*> dataMax2D;
 
  792     static int numOriented2DVars[3];
 
  796     size_t fullDataSize[3];
 
  797     std::vector<size_t*> dataAtLevel;
 
  800     float stretchedExtents[6];
 
  801     float stretchFactors[3];
 
  803     float fullStretchedSizes[3];
 
  810     static std::vector<std::string> variableNames;
 
  812     static int numMetadataVariables;
 
  813     static int* mapMetadataVars;
 
  814     static std::vector<std::string> variableNames2D;
 
  815     static int numMetadataVariables2D;
 
  816     static int* mapMetadataVars2D;
 
  817     static vector<int> activeVariableNums2D;
 
  818     static vector<int> activeVariableNums3D;
 
  820     string sessionVersion;
 
  824     static int textureSize;
 
  825     static bool textureSizeSpecified;
 
  827     static QColor backgroundColor;
 
  828     static QColor regionFrameColor;
 
  829     static QColor subregionFrameColor;
 
  830     static bool regionFrameEnabled;
 
  831     static bool subregionFrameEnabled;
 
  833     static bool doWarnIfDataMissing;
 
  834     static bool trackMouseInTfe;
 
  835     static bool doUseLowerAccuracy;
 
  836     static bool doUseQuadInterpolation;
 
  838     static size_t cacheMB;
 
  840     static int interactiveRefLevel;
 
  841     static std::string projString;
 
  844     static bool sessionBefore22;  
 
  845     static float pre22Offset[3];
 
  855 #endif //DOXYGEN_SKIP_THIS 
  859 #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)
 
static bool useQuadInterpolation()
 
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)