VAPOR3 3.9.4
ControlExecutive.h
Go to the documentation of this file.
1
2#ifndef ControlExec_h
3#define ControlExec_h
4
5#include <string>
6#include <vector>
7#include <map>
8
9#include <vapor/ParamsMgr.h>
10#include <vapor/GLManager.h>
11#include <vapor/DataStatus.h>
12
13using namespace std;
14namespace VAPoR {
15
16class CalcEngineMgr;
17class Visualizer;
18class DataStatus;
19
23//
24
26public:
35 //
36 ControlExec(std::vector<string> appParamsNames = std::vector<string>(), std::vector<string> appRenderParamsNames = std::vector<string>(), size_t cacheSize = 1000, int nThreads = 0);
37 virtual ~ControlExec();
38
41 //
42 virtual void LoadState();
43
50 //
51 virtual void LoadState(const XmlNode *node);
52
53 class RelAndAbsPathsExistException : public std::exception {
54 public:
55 const std::string AbsolutePath;
56 const std::string RelativePath;
57 RelAndAbsPathsExistException(const std::string &absolute, const std::string &relative)
58 : AbsolutePath(absolute), RelativePath(relative) {}
59 };
60 enum class LoadStateRelAndAbsPathsExistAction { Ask, LoadAbs, LoadRel };
61
75 //
76 virtual int LoadState(string stateFile, LoadStateRelAndAbsPathsExistAction relAndAbsPathsExistAction = LoadStateRelAndAbsPathsExistAction::LoadAbs);
77
85 //
86 void SetNumThreads(size_t nthreads);
87
88 size_t GetNumThreads() const;
89
97 //
98 void SetCacheSize(size_t sizeMB);
99
126 //
127 int NewVisualizer(string name);
128
130 //
131 string GetNewVisualizerUndoTag() const { return ("NewVisualizer"); }
132
147 //
148 void RemoveVisualizer(string name, bool hasOpenGLContext = false);
149
151 //
152 string GetRemoveVisualizerUndoTag() const { return ("RemoveVisualizer"); }
153
163 //
164 int InitializeViz(string name, GLManager *glManager);
165
178 //
179 int ResizeViz(string name, int width, int height);
180
181 void ClearRenderCache(const string &winName, const string &inst);
183
185
189 int GetNumVisualizers() const { return (int)_visualizers.size(); }
190
193 vector<string> GetVisualizerNames() const;
194
214 int Paint(string name, bool force = false);
215
217
234 //
235 int ActivateRender(string winName, string dataSetName, string renderType, string renderName, bool on);
236
237 int ActivateRender(string winName, string dataSetName, const RenderParams *rp, string renderName, bool on);
238
240 //
241 string GetActivateRendererUndoTag() const { return ("ActivateRenderer"); }
242
250 void RemoveRenderer(string winName, string dataSetName, string renderType, string renderName, bool hasOpenGLContext);
251
253 //
254 string GetRemoveRendererUndoTag() const { return ("RemoveRenderer"); }
255
263 void RemoveAllRenderers(string winName, bool hasOpenGLContext = false);
264
267 //
268 ParamsMgr *GetParamsMgr() const { return _paramsMgr; }
269
281 //
282 int SaveSession(string file);
283
284#ifdef VAPOR3_0_0_ALPHA
295 //
296 int SavePreferences(string file);
297
310 //
311 int RestorePreferences(string file);
312#endif
313
334 //
335 int OpenData(const std::vector<string> &files, const std::vector<string> &options, string dataSetName, string type = "vdc");
336
339 void CloseData(string dataSetName);
340
344 //
345 std::vector<string> GetDataNames() const { return (_dataStatus->GetDataMgrNames()); }
346
350 DataStatus *GetDataStatus() const { return _dataStatus; }
351
357 //
358 RenderParams *GetRenderParams(string winName, string dataSetName, string renderType, string instName) const;
359
365 std::vector<string> GetRenderClassNames(string winName) const;
366
372 std::vector<string> GetRenderInstances(string winName, string renderType) const;
373
378 static vector<string> GetAllRenderClasses();
379
390 //
391 bool RenderLookup(string instName, string &winName, string &dataSetName, string &rendererType) const;
392
393 string MakeRendererNameUnique(string name) const;
394
410 //
411 int DrawText(string winName, string text, int x, int y, int size, float color[3], int type = 0);
412 int DrawTextNormalizedCoords(string winName, string text, float x, float y, int size, float color[3], int type = 0);
413
428 //
429 int DrawText(string text, int x, int y, int size, float color[3], int type = 0);
430 int DrawTextNormalizedCoords(string text, float x, float y, int size, float color[3], int type = 0);
431
433 int ClearText(string winName);
434
450 bool Undo();
451
465 //
466 bool Redo();
467
471
475 size_t UndoSize() const { return (_paramsMgr->UndoSize()); }
476
480 size_t RedoSize() const { return (_paramsMgr->RedoSize()); }
481
491 //
492 void SetSaveStateEnabled(bool enabled) { _paramsMgr->SetSaveStateEnabled(enabled); }
493
494 bool GetSaveStateEnabled() const { return (_paramsMgr->GetSaveStateEnabled()); }
495
500 void RebaseStateSave() { _paramsMgr->RebaseStateSave(); }
501
513 int EnableImageCapture(string filename, string winName, bool fast=false);
514
524
530 int EnableAnimationCapture(string winName, bool doEnable, string filename = "");
531
550 //
551 static string MakeStringConformant(string s);
552
607 //
608 int AddFunction(string scriptType, string dataSetName, string scriptName, string script, const vector<string> &inputVarNames, const vector<string> &outputVarNames,
609 const vector<string> &outputVarMeshes, bool coordFlag = false);
610
627 //
628 void RemoveFunction(string scriptType, string dataSetName, string scriptName);
629
651 //
652 bool GetFunction(string scriptType, string dataSetName, string scriptName, string &script, vector<string> &inputVarNames, vector<string> &outputVarNames, vector<string> &outputVarMeshes,
653 bool &coordFlag) const;
654
659 //
660 string GetFunctionStdout(string scriptType, string dataSetName, string scriptName) const;
661
670 std::vector<string> GetFunctionNames(string scriptType, string dataSetName) const;
671
672 void CreateRenderers() { openDataHelper(true); }
673
674private:
675 ParamsMgr * _paramsMgr;
676 DataStatus * _dataStatus;
677 CalcEngineMgr * _calcEngineMgr;
678 std::map<string, Visualizer *> _visualizers;
679
680 GLManager::Vendor _cachedVendor = GLManager::Vendor::Unknown;
681
686 Visualizer *getVisualizer(string winName) const
687 {
688 std::map<string, Visualizer *>::const_iterator it;
689 it = _visualizers.find(winName);
690 if (it == _visualizers.end()) return NULL;
691 return it->second;
692 }
693
694 int openDataHelper(bool reportErrs);
695 bool _undoRedoRenderer(bool undoFlag);
696 bool _undoRedoVisualizer(bool undoFlag);
697
698 int activateClassRenderers(string vizName, string dataSetName, string pClassName, vector<string> instNames, bool reportErrs);
699
700 void _removeRendererHelper(string winName, string dataSetName, string paramsType, string renderName, bool removeFromParamsFlag, bool hasOpenGLContext);
701
702 void _autoStretchExtents(string dataSetName);
703
704 void _setDefaultOrigin(string datasetName);
705};
706}; // namespace VAPoR
707
708#endif // ControlExec_h
A class for managing CalcEngine class instances.
Definition: CalcEngineMgr.h:16
RelAndAbsPathsExistException(const std::string &absolute, const std::string &relative)
Provides API for VAPOR visualizer User Interfaces (UIs)
void RemoveRenderer(string winName, string dataSetName, string renderType, string renderName, bool hasOpenGLContext)
bool GetSaveStateEnabled() const
virtual int LoadState(string stateFile, LoadStateRelAndAbsPathsExistAction relAndAbsPathsExistAction=LoadStateRelAndAbsPathsExistAction::LoadAbs)
bool GetFunction(string scriptType, string dataSetName, string scriptName, string &script, vector< string > &inputVarNames, vector< string > &outputVarNames, vector< string > &outputVarMeshes, bool &coordFlag) const
vector< string > GetVisualizerNames() const
size_t UndoSize() const
void SetNumThreads(size_t nthreads)
void RemoveFunction(string scriptType, string dataSetName, string scriptName)
int DrawTextNormalizedCoords(string winName, string text, float x, float y, int size, float color[3], int type=0)
void ClearAllRenderCaches()
int SaveSession(string file)
std::vector< string > GetDataNames() const
void ClearRenderCache(const string &winName, const string &inst)
size_t GetNumThreads() const
virtual void LoadState(const XmlNode *node)
string GetRemoveVisualizerUndoTag() const
Return tag pushed to the undo stack when RemoveVisualizer() is called.
std::vector< string > GetFunctionNames(string scriptType, string dataSetName) const
int GetNumVisualizers() const
void SetSaveStateEnabled(bool enabled)
int DrawText(string text, int x, int y, int size, float color[3], int type=0)
int NewVisualizer(string name)
virtual ~ControlExec()
int ResizeViz(string name, int width, int height)
string GetRemoveRendererUndoTag() const
Return tag pushed to the undo stack when RemoveRenderer() is called.
int ClearText(string winName)
bool RenderLookup(string instName, string &winName, string &dataSetName, string &rendererType) const
int ActivateRender(string winName, string dataSetName, const RenderParams *rp, string renderName, bool on)
GLManager::Vendor GetGPUVendor() const
int DrawTextNormalizedCoords(string text, float x, float y, int size, float color[3], int type=0)
ParamsMgr * GetParamsMgr() const
DataStatus * GetDataStatus() const
size_t RedoSize() const
string GetFunctionStdout(string scriptType, string dataSetName, string scriptName) const
void CloseData(string dataSetName)
string GetActivateRendererUndoTag() const
Return tag pushed to the undo stack when ActivateRender() is called.
ControlExec(std::vector< string > appParamsNames=std::vector< string >(), std::vector< string > appRenderParamsNames=std::vector< string >(), size_t cacheSize=1000, int nThreads=0)
string MakeRendererNameUnique(string name) const
int EnableAnimationCapture(string winName, bool doEnable, string filename="")
int Paint(string name, bool force=false)
string GetNewVisualizerUndoTag() const
Return tag pushed to the undo stack when NewVisualizer() is called.
void RemoveAllRenderers(string winName, bool hasOpenGLContext=false)
static string MakeStringConformant(string s)
std::vector< string > GetRenderInstances(string winName, string renderType) const
int ActivateRender(string winName, string dataSetName, string renderType, string renderName, bool on)
Activate or Deactivate a renderer.
static vector< string > GetAllRenderClasses()
int OpenData(const std::vector< string > &files, const std::vector< string > &options, string dataSetName, string type="vdc")
virtual void LoadState()
int InitializeViz(string name, GLManager *glManager)
void RemoveVisualizer(string name, bool hasOpenGLContext=false)
int AddFunction(string scriptType, string dataSetName, string scriptName, string script, const vector< string > &inputVarNames, const vector< string > &outputVarNames, const vector< string > &outputVarMeshes, bool coordFlag=false)
int EnableImageCapture(string filename, string winName, bool fast=false)
int DrawText(string winName, string text, int x, int y, int size, float color[3], int type=0)
std::vector< string > GetRenderClassNames(string winName) const
RenderParams * GetRenderParams(string winName, string dataSetName, string renderType, string instName) const
void SetCacheSize(size_t sizeMB)
A class for describing the currently loaded dataset.
Definition: DataStatus.h:50
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53
A Params subclass for managing parameters used by Renderers.
Definition: RenderParams.h:43
A class for performing OpenGL rendering in VAPOR GUI Window.
Definition: Visualizer.h:46
An Xml tree.
Definition: XmlNode.h:49
Wasp base class.
Definition: MyBase.h:67
#define RENDER_API
Definition: common.h:78
Contains references to context scope OpenGL data.
Definition: GLManager.h:18