VAPoR  3.0.0
instanceparams.h
Go to the documentation of this file.
1 //************************************************************************
2 // *
3 // Copyright (C) 2014 *
4 // University Corporation for Atmospheric Research *
5 // All Rights Reserved *
6 // *
7 //************************************************************************/
8 //
9 // File: instanceparams.h
10 //
11 // Author: Alan Norton
12 // National Center for Atmospheric Research
13 // PO 3000, Boulder, Colorado
14 //
15 // Date: April 2014
16 //
17 // Description: Defines the InstanceParams class.
18 // This Params class is global. Specifies the current instances associated with RenderParams.
19 // Also has various static methods for obtaining and setting properties of the Instance Params
20 // For each Params (tag) and each Visualizer (number), there is one or more instances
21 // and one of the instances is the Current instance.
22 // In addition, whenever a new instance is created or deleted, that new instance's paramnode is
23 // saved in the InstanceParams, to facilitate undo/redo of creation and deletion.
24 // The Paramnode in the Instance params is otherwise not changed
25 //
26 //
27 #ifndef INSTANCEPARAMS_H
28 #define INSTANCEPARAMS_H
29 
30 
31 #include <vector>
32 #include <map>
33 #include <algorithm>
34 #include <vapor/common.h>
35 #include "params.h"
36 #include <vapor/MyBase.h>
37 
38 
39 using namespace VetsUtil;
40 
41 namespace VAPoR {
42 
43 
81 
83 
84 public:
85 
95  static int AddInstance(const std::string rendererName, int viznum, RenderParams* p);
96 
105  static int RemoveSelectedInstance(int viz);
106 
111  static int GetSelectedIndex(int viz){
112  return ((InstanceParams*)Params::GetParamsInstance(_instanceParamsTag))->getSelectedIndex(viz);
113  }
119  static int GetSelectedInstance(int viz, int* pType, int* instance);
120 
125  static int SetSelectedIndex(int viz, int index){
126  return ((InstanceParams*)Params::GetParamsInstance(_instanceParamsTag))->setSelectedIndex(viz, index);
127  }
131  static RenderParams* GetSelectedRenderParams(int viz);
132 
137  static RenderParams* GetRenderParamsInstance(int viz, int renIndex);
138 
142  static int GetNumInstances(int viz);
143 
147 
150  InstanceParams(XmlNode* parent, int winnum);
151 
153  virtual ~InstanceParams();
154 
158  virtual void Validate(int type);
160  virtual void restart();
161 
169  static int AddVizWin(int viznum){
170  return (((InstanceParams*)Params::GetParamsInstance(_instanceParamsTag))->addVizWin(viznum));
171  }
183  static void UndoRedo(bool isUndo, int /*instance*/, Params* beforeP, Params* afterP, Params* auxBP=0, Params*auxAP=0);
184 
190  static int RemoveVizWin(int viznum);
191 
194  static ParamsBase* CreateDefaultInstance() {return new InstanceParams(0, -1);}
197  const std::string getShortName() {return _shortName;}
198  //Determine what visualizer has changed between prev and next InstanceParams,
199  //and whether it's Add(1), Remove(-1), or Select(0) change.
200  static int changeType(InstanceParams* p1, InstanceParams* p2, int* viz, int* type);
201 
202  //Convert a visualizer index into a string name, to be used for ParamNode tag
203  static ParamNode* getVizNode(int viz);
204  //Renumber the renderer instances associated with a visualizer, needed after
205  //a new instance is inserted or an existing instance is removed.
209  //Return 0 if successful.
210  static int renumberInstances(int viz, int changedType);
211 
213 
214 #ifndef DOXYGEN_SKIP_THIS
215 
216  static const string _instanceParamsTag;
217  static const string _shortName;
218  static const string _visualizersTag;
219 
220  static const string _renderParamsNodeTag;
221  static const string _instanceInfoTag;
222  static const string _selectionInfoTag;
223  int getCurrentInstance(std::string tag, int viz);
224 private:
225 
226  ParamNode* getRenderParamsNode();
227  void setRenderParamsNode(ParamNode* pnode);
228  void removeRenderParamsNode(){
229  GetRootNode()->GetNode(_renderParamsNodeTag)->DeleteAll();
230  }
231 
233  int addVizWin(int viznum);
234 
235  int setSelectedIndex(int viz, int index);
236  int getSelectedIndex(int viz);
237 
238 
239 #endif //DOXYGEN_SKIP_THIS
240 };
241 
242 };
243 #endif //VIZWINPARAMS_H
static int GetSelectedIndex(int viz)
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
A class for describing the renderer instances in use in VAPOR.
const std::string getShortName()
static int SetSelectedIndex(int viz, int index)
static int AddVizWin(int viznum)
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:90
static ParamsBase * CreateDefaultInstance()
#define PARAMS_API
A Params subclass for Params classes with one unique instance.
Definition: params.h:598
Definition: DC.h:10
An Xml tree.
Definition: ParamNode.h:30