VAPoR  0.1
regionparams.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: regionparams.h
10 //
11 // Author: Alan Norton
12 // National Center for Atmospheric Research
13 // PO 3000, Boulder, Colorado
14 //
15 // Date: September 2004
16 //
17 // Description: Defines the RegionParams class.
18 // This class supports parameters associted with the
19 // region panel, describing the rendering region
20 //
21 #ifndef REGIONPARAMS_H
22 #define REGIONPARAMS_H
23 
24 
25 #include <vector>
26 #include <map>
27 #include <qwidget.h>
28 #include <vapor/MyBase.h>
29 #include <vapor/common.h>
30 #include "params.h"
31 
32 
33 using namespace VetsUtil;
34 
35 namespace VAPoR {
36 
37 class ViewpointParams;
38 class XmlNode;
39 class ParamNode;
52 class PARAMS_API RegionParams : public Params {
53 
54 public:
55 
57  RegionParams(int winnum);
58 
60  ~RegionParams();
61 
69  void getRegionVoxelCoords(int reflevel, int lod, size_t min_dim[3], size_t max_dim[3], int timestep);
70 
88  int getAvailableVoxelCoords(int reflevel, int* lod, size_t min_dim[3], size_t max_dim[3],
89  size_t timestep,
90  const int* sesVarNums, int numVars, double* regMin = 0, double* regMax = 0);
91 
92 
103  static int PrepareCoordsForRetrieval(int numxforms, int lod, size_t timestep, const vector<string>& varnames,
104  double* regMin, double* regMax,
105  size_t min_dim[3], size_t max_dim[3]);
106 
107 
114  static float calcCurrentValue( const string& varname, const double point[3], int numRefinements, int lod, size_t timeStep);
119  float fullRegionMBs(int refLevel);
120 
121 #ifndef DOXYGEN_SKIP_THIS
122 
123  virtual Params* deepCopy(ParamNode* n = 0);
124  static ParamsBase* CreateDefaultInstance() {return new RegionParams(-1);}
125  const std::string& getShortName() {return _shortName;}
126  float getLocalRegionMin(int coord, int timestep){
127  double exts[6];
128  myBox->GetLocalExtents(exts, timestep);
129  return exts[coord];
130  }
131  float getLocalRegionMax(int coord, int timestep){
132  double exts[6];
133  myBox->GetLocalExtents(exts, timestep);
134  return exts[coord+3];
135  }
136  void getLocalRegionExtents(double exts[6],int timestep){
137  myBox->GetLocalExtents(exts,timestep);
138  return;
139  }
140  float getLocalRegionCenter(int indx, int timestep) {
141  return (0.5f*(getLocalRegionMin(indx,timestep)+getLocalRegionMax(indx,timestep)));
142  }
143 
144 
145  //Version of DataMgr::GetValidRegion that knows about layered data
146  //Callers must supply the full voxel extents, these get reduced depending on what data is available for
147  //the specified variable, or (for derived variables) the input variables to the script.
148  static int getValidRegion(size_t timestep, const char* varname, int minRefLevel, size_t min_coord[3], size_t max_coord[3]);
149 
150  //Determine how many megabytes will be needed for one variable at specified
151  //refinement level, specified box extents.
152 
153  static int getMBStorageNeeded(const double exts[6], int refLevel);
154  // Reinitialize due to new Session:
155  bool reinit(bool doOverride);
156  virtual void restart();
157  static void setDefaultPrefs() {} //No default preferences
158 
159  ParamNode* buildNode();
160  bool elementStartHandler(ExpatParseMgr*, int /* depth*/ , std::string& /*tag*/, const char ** /*attribs*/);
161  bool elementEndHandler(ExpatParseMgr*, int /*depth*/ , std::string& /*tag*/);
162  //See if the proposed number of transformations is OK. Return a valid value
163  int validateNumTrans(int n, int timestep);
164 
165 
166  virtual Box* GetBox() {return myBox;}
167  //Methods to set the region max and min from a float value.
168  //public so accessible from router
169  //
170  void setLocalRegionMin(int coord, float minval, int timestep, bool checkMax=true);
171  void setLocalRegionMax(int coord, float maxval, int timestep, bool checkMin=true);
172  void setInfoNumRefinements(int n){infoNumRefinements = n;}
173  void setInfoTimeStep(int n) {infoTimeStep = n;}
174  void setInfoVarNum(int n) {infoVarNum = n;}
175  const vector<double>& GetAllExtents(){ return myBox->GetRootNode()->GetElementDouble(Box::_extentsTag);}
176  const vector<long>& GetTimes(){ return myBox->GetRootNode()->GetElementLong(Box::_timesTag);}
177  void clearRegionsMap();
178  bool extentsAreVarying(){ return myBox->GetTimes().size()>1;}
179  //Insert a time in the list. Return false if it's already there
180  bool insertTime(int timestep);
181  //Remove a time from the time-varying timesteps. Return false if unsuccessful
182  bool removeTime(int timestep);
183 
184 protected:
185  static const string _shortName;
186  static const string _regionMinTag;
187  static const string _regionMaxTag;
188  static const string _regionCenterTag;
189  static const string _regionSizeTag;
190  static const string _regionAtTimeTag;
191  static const string _regionListTag;
192  static const string _maxSizeAttr;
193  static const string _numTransAttr;
194  static const string _fullHeightAttr;
195  static const string _timestepAttr;
196  static const string _extentsAttr;
197 
198  //Methods to make sliders and text valid and consistent for region:
199 
200  int infoNumRefinements, infoVarNum, infoTimeStep;
201 
202 
203  //Full grid height for layered data. 0 otherwise.
204  static size_t fullHeight;
205 
206  Box* myBox;
207 #endif //DOXYGEN_SKIP_THIS
208 };
209 
210 };
211 #endif //REGIONPARAMS_H
#define PARAMS_API
Definition: common.h:63
3D or 2D box with options for orientation angles and extents changing in time. Intended to be used in...
Definition: Box.h:34
A pure virtual class for managing parameters used in visualization.
Definition: params.h:75
A class for describing a 3D axis-aligned region in user space.
Definition: regionparams.h:52
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:57
Definition: Base64.h:6
An Xml tree.
Definition: ParamNode.h:30