VAPoR  3.0.0
renderparams.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: renderparams.h
10 //
11 // Author: Alan Norton
12 // National Center for Atmospheric Research
13 // PO 3000, Boulder, Colorado
14 //
15 // Date: July 2014
16 //
17 // Description: Defines the RendererParams class.
18 // This is an abstract class for all the tabbed panel render params classes.
19 // Supports functionality common to all the tabbed panel render params.
20 
21 //
22 #ifndef RENDERPARAMS_H
23 #define RENDERPARAMS_H
24 
25 #include <vapor/XmlNode.h>
26 #include <vapor/ExpatParseMgr.h>
27 #include <vapor/ParamNode.h>
28 #include <map>
29 
30 #include "assert.h"
31 
32 #include <vapor/common.h>
33 #include <vapor/ParamsBase.h>
34 #include <vapor/RegularGrid.h>
35 #include "Box.h"
36 #include "params.h"
37 using namespace VetsUtil;
38 
39 namespace VAPoR{
40 
41 
42 class XmlNode;
43 class ParamNode;
44 class ViewpointParams;
45 class DataMgrV3_0;
46 class Command;
47 class MapperFunction;
48 
49 
57 class PARAMS_API RenderParams : public Params {
58 public:
62 
67  RenderParams(XmlNode *parent, const string &name, int winnum);
69 
72  virtual bool IsEnabled(){
73  int enabled = GetValueLong(_EnabledTag);
74  return (enabled != 0);
75  }
81  virtual void SetEnabled(bool val);
82 
86  virtual bool usingVariable(const std::string& varname) = 0;
87 
90  virtual void SetVariableName(string varName);
91 
94  const string GetVariableName();
95 
98  const string GetFirstVariableName();
99 
103  virtual void SetFieldVariableNames(vector <string> varNames);
104 
107  const vector<string> GetFieldVariableNames();
108 
112  const vector<long>off(1,0);
113  return (0 !=GetValueLong(_terrainMapTag,off));
114  }
115 
119  int SetTerrainMapped(bool val) {
120  int rc = SetValueLong(_terrainMapTag, "Enable terrain-mapping", (long)val);
121  setAllBypass(false);
122  return rc;
123  }
124 
127  virtual void SetRendererName(const string& renName);
130  virtual const string GetRendererName();
134  virtual int SetRefinementLevel(int numrefinements);
138  virtual int GetRefinementLevel();
142  virtual int GetCompressionLevel();
146  virtual int SetCompressionLevel(int val);
150  virtual bool IsOpaque() = 0;
151 
156  void setBypass(int timestep) {_bypassFlags[timestep] = 2;}
157 
162  void setPartialBypass(int timestep) {_bypassFlags[timestep] = 1;}
163 
168  void setAllBypass(bool val);
169 
173  bool doBypass(int ts) {return ((ts < _bypassFlags.size()) && _bypassFlags[ts]);}
174 
179  bool doAlwaysBypass(int ts) {return ((ts < _bypassFlags.size()) && _bypassFlags[ts]>1);}
180 
184  virtual int GetFidelityLevel();
188  virtual void SetFidelityLevel(int level);
192  virtual bool GetIgnoreFidelity();
196  virtual void SetIgnoreFidelity(bool val);
197 
200  void SetFidelityToDefaults();
201 
202  void SetHistoStretch(float factor){
203  SetValueDouble(_histoScaleTag,"Set histo stretch",(double)factor);
204  }
206  return GetValueDouble(_histoScaleTag);
207  }
208  double getMinEditBound(){
209  return GetRootNode()->GetElementDouble(_editBoundsTag)[0];
210  }
211  double getMaxEditBound(){
212  return GetRootNode()->GetElementDouble(_editBoundsTag)[1];
213  }
214  void setMinEditBound(double val){
215  vector<double>vals = GetValueDoubleVec(_editBoundsTag);
216  if (vals.size()<1) vals.push_back(val);
217  vals[0]=val;
218  SetValueDouble(_editBoundsTag,"change edit min bound",vals);
219  }
220  void setMaxEditBound(double val){
221  vector<double>vals = GetValueDoubleVec(_editBoundsTag);
222  while (vals.size()<2) vals.push_back(val);
223  vals[1]=val;
224  SetValueDouble(_editBoundsTag,"change edit max bound",vals);
225  }
226  void SetEditBounds(vector<double>bounds){
227  SetValueDouble(_editBoundsTag,"set edit bounds",bounds);
228  }
229  virtual MapperFunction* GetMapperFunc(){
230  return 0;
231  }
232  void SetCursorCoords(const vector<double>& coords){
233  SetValueDouble(_cursorCoordsTag,"set cursor coords",coords);
234  }
235  const vector<double> GetCursorCoords(){
236  return (GetValueDoubleVec(_cursorCoordsTag));
237  }
245  static void InsertParamsInstance(int pType, int winnum, int posn, RenderParams* dp){
246  vector<Params*>& instances = _paramsInstances[make_pair(pType,winnum)];
247  instances.insert(instances.begin()+posn, dp);
248  }
249 
250 
254  virtual int SetVariables3D(bool val) {
255  if (val == VariablesAre3D()) return 0;
256  int rc = SetValueLong(_variableDimensionTag,"Set variable dimensions",(long)(val ? 3:2));
257  setAllBypass(false);
258  return rc;
259  }
264  virtual bool VariablesAre3D() { return true; }
265 
269  const vector<long> GetGrid(){
270  const vector<long> defaultGrid(3,1);
271  return (GetValueLongVec(_gridTag,defaultGrid));
272  }
276  int SetGrid(const int grid[3]);
277 
281  int AlignGridToData(bool val) {
282  if (IsAlignedToData() == val) return 0;
283  return SetValueLong(_alignGridTag, "Set barb grid alignment",(val ? 1:0));
284  }
288  const vector<long> notAligned(1,0);
289  return (0 != GetValueLong(_alignGridTag,notAligned));
290  }
294  const vector<long> GetGridAlignStrides(){
295  const vector<long> defaultStrides(3,10);
296  return GetValueLongVec(_alignGridStridesTag,defaultStrides);
297  }
302  int SetGridAlignStrides(const vector<long>& strides);
303 
310  void getDataAlignment(double rakeExts[6],int rakeGrid[3], size_t timestep);
311 
316  virtual int SetHeightVariableName(const string& varName);
317 
320  virtual const string GetHeightVariableName();
321 #ifndef DOXYGEN_SKIP_THIS
322 
323  int SetLocal(bool lg){
324  assert(lg);
325  return false;
326  }
327 
328  bool IsLocal() {
329  return true;
330  }
331 
332  virtual ~RenderParams(){
333  }
334 
335 
336  void initializeBypassFlags();
337 
338 protected:
339  static const string _EnabledTag;
340  static const string _FidelityLevelTag;
341  static const string _IgnoreFidelityTag;
342  static const string _histoScaleTag;
343  static const string _editBoundsTag;
344  static const string _histoBoundsTag;
345  static const string _RendererNameTag;
346  static const string _cursorCoordsTag;
347  static const string _heightVariableNameTag;
348  static const string _variableDimensionTag;
349  static const string _terrainMapTag;
350  static const string _variableNameTag;
351  static const string _fieldVariableNamesTag;
352  static const string _gridTag;
353  static const string _alignGridTag;
354  static const string _alignGridStridesTag;
355 
356  vector<int> _bypassFlags;
357 #endif //DOXYGEN_SKIP_THIS
358 };
359 
360 }; //End namespace VAPoR
361 #endif //RENDERPARAMS_H
const vector< long > GetGrid()
Definition: renderparams.h:269
A pure virtual class for managing parameters used in visualization.
Definition: params.h:129
A Params subclass for managing parameters used by Renderers.
Definition: renderparams.h:57
void SetCursorCoords(const vector< double > &coords)
Definition: renderparams.h:232
bool doAlwaysBypass(int ts)
Definition: renderparams.h:179
const vector< long > GetGridAlignStrides()
Definition: renderparams.h:294
static void InsertParamsInstance(int pType, int winnum, int posn, RenderParams *dp)
Definition: renderparams.h:245
double getMaxEditBound()
Definition: renderparams.h:211
virtual bool VariablesAre3D()
Definition: renderparams.h:264
void setMinEditBound(double val)
Definition: renderparams.h:214
void SetEditBounds(vector< double >bounds)
Definition: renderparams.h:226
int AlignGridToData(bool val)
Definition: renderparams.h:281
virtual MapperFunction * GetMapperFunc()
Definition: renderparams.h:229
void SetHistoStretch(float factor)
Definition: renderparams.h:202
void setBypass(int timestep)
Definition: renderparams.h:156
int SetTerrainMapped(bool val)
Definition: renderparams.h:119
void setPartialBypass(int timestep)
Definition: renderparams.h:162
#define PARAMS_API
virtual int SetVariables3D(bool val)
Definition: renderparams.h:254
void setMaxEditBound(double val)
Definition: renderparams.h:220
Definition: DC.h:10
bool doBypass(int ts)
Definition: renderparams.h:173
const vector< double > GetCursorCoords()
Definition: renderparams.h:235
double getMinEditBound()
Definition: renderparams.h:208
virtual bool IsEnabled()
Definition: renderparams.h:72