VAPOR3 3.9.4
PWidget.h
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <functional>
5#include "UWidget.h"
6#include <vapor/VAssert.h>
7
8namespace VAPoR {
9class ParamsBase;
10class ParamsMgr;
11class DataMgr;
12} // namespace VAPoR
13
14class PDynamicMixin;
15class SettingsParams;
16template<class, typename> class PWidgetHLIBase;
17
23
24class PWidget : public UWidget {
25 Q_OBJECT
26
27 VAPoR::ParamsBase *_params = nullptr;
28 VAPoR::ParamsMgr * _paramsMgr = nullptr;
29 VAPoR::DataMgr * _dataMgr = nullptr;
30 const std::string _tag;
31
32 bool _showBasedOnParam = false;
33 std::string _showBasedOnParamTag = "";
34 int _showBasedOnParamValue;
35
36 bool _enableBasedOnParam = false;
37 std::string _enableBasedOnParamTag = "";
38 int _enableBasedOnParamValue;
39
40 bool _dynamicUpdateIsOn = false;
41 bool _dynamicUpdateInsideGroup = false;
42
43 bool _usingHLI = false;
44 std::function<void(void *, long)> _setterLong;
45 std::function<long(void *)> _getterLong;
46 std::function<void(void *, double)> _setterDouble;
47 std::function<double(void *)> _getterDouble;
48 std::function<void(void *, const std::string &)> _setterString;
49 std::function<std::string(void *)> _getterString;
50
51public:
52 PWidget(const std::string &tag, QWidget *widget);
54 void Update(VAPoR::ParamsBase *params, VAPoR::ParamsMgr *paramsMgr = nullptr, VAPoR::DataMgr *dataMgr = nullptr) override;
55
58 PWidget *ShowBasedOnParam(const std::string &tag, int whenEqualTo = true);
60 PWidget *EnableBasedOnParam(const std::string &tag, int whenEqualTo = true);
63 PWidget *SetTooltip(const std::string &text);
64 void setToolTip(const QString &) = delete;
65
66protected:
67 virtual void updateGUI() const = 0;
68 virtual bool requireParamsMgr() const { return false; }
69 virtual bool requireDataMgr() const { return false; }
70 virtual bool isShown() const { return true; }
71 virtual bool isEnabled() const { return true; }
72
73 const std::string &getTag() const;
78
79 void setParamsDouble(double v);
80 void setParamsLong(long v);
81 void setParamsString(const std::string &v);
82 double getParamsDouble() const;
83 long getParamsLong() const;
84 std::string getParamsString() const;
85
86private:
87 void dynamicUpdateBegin();
88 void dynamicUpdateFinish();
89 void _setParamsDouble(double v);
90 void _setParamsLong(long v);
91 void _setParamsString(const std::string &v);
92
93 friend class PDynamicMixin;
94 template<class, typename> friend class PWidgetHLIBase;
95
96protected:
97 template<class T> T *getParams() const
98 {
99 T *p = dynamic_cast<T *>(getParams());
100 VAssert(p);
101 return p;
102 }
103};
#define VAssert(expr)
Definition: VAssert.h:9
double getParamsDouble() const
void Update(VAPoR::ParamsBase *params, VAPoR::ParamsMgr *paramsMgr=nullptr, VAPoR::DataMgr *dataMgr=nullptr) override
Follows the Vapor GUI update function convention. Update the element.
void setToolTip(const QString &)=delete
std::string getParamsString() const
PWidget * ShowBasedOnParam(const std::string &tag, int whenEqualTo=true)
VAPoR::ParamsMgr * getParamsMgr() const
PWidget * EnableBasedOnParam(const std::string &tag, int whenEqualTo=true)
virtual void updateGUI() const =0
PWidget * SetTooltip(const std::string &text)
PWidget(const std::string &tag, QWidget *widget)
const std::string & getTag() const
void setParamsDouble(double v)
virtual bool isEnabled() const
Definition: PWidget.h:71
long getParamsLong() const
void setParamsLong(long v)
VAPoR::DataMgr * getDataMgr() const
T * getParams() const
Definition: PWidget.h:97
virtual bool requireParamsMgr() const
Definition: PWidget.h:68
void setParamsString(const std::string &v)
virtual bool requireDataMgr() const
Definition: PWidget.h:69
virtual bool isShown() const
Definition: PWidget.h:70
SettingsParams * getSettingsParams() const
VAPoR::ParamsBase * getParams() const
A class for describing settings at settings.
A widget that standardizes support for params updates.
Definition: UWidget.h:10
A cache based data reader.
Definition: DataMgr.h:110
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:50
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53