VAPOR3 3.9.4
PShowIf.h
Go to the documentation of this file.
1#pragma once
2
3#include "PWidgetWrapper.h"
4#include "PGroup.h"
5#include <memory>
6
17
18class PShowIf : public PWidgetWrapper {
19 PGroup *_group;
20 bool _negate = false;
21 bool _hasThen = false;
22 bool _hasElse = false;
23
24public:
25 PShowIf(std::string tag);
26 PShowIf *Equals(long l);
27 PShowIf *Equals(std::string s);
28 PShowIf *DimensionEquals(unsigned int dim);
29 // PShowIf *Or(PShowIf *);
33 PShowIf *Then(const PGroup::List &list);
34 PShowIf *Else(const PGroup::List &list);
35
36protected:
37 bool isShown() const override;
38
39private:
40 bool evaluate() const;
41
42 class Helper : public PWidgetWrapper {
43 const PShowIf *_parent;
44 const bool _negate;
45
46 public:
47 Helper(PShowIf *parent, PWidget *widget, bool negate = false);
48
49 protected:
50 bool isShown() const override;
51 };
52
53 struct Test {
54 const std::string _tag;
55 Test(std::string tag) : _tag(tag) {}
56 virtual bool Evaluate(VAPoR::ParamsBase *params) const = 0;
57 virtual ~Test() {}
58 };
59
60 struct TestLongEquals : public Test {
61 const long _val;
62 TestLongEquals(std::string tag, long val) : Test(tag), _val(val) {}
63 bool Evaluate(VAPoR::ParamsBase *params) const override;
64 };
65
66 struct TestStringEquals : public Test {
67 const std::string _val;
68 TestStringEquals(std::string tag, std::string val) : Test(tag), _val(val) {}
69 bool Evaluate(VAPoR::ParamsBase *params) const override;
70 };
71
72 struct TestDimensionEquals : public Test {
73 const long _val;
74 TestDimensionEquals(long val) : Test(""), _val(val) {}
75 bool Evaluate(VAPoR::ParamsBase *params) const override;
76 };
77
78 std::unique_ptr<Test> _test;
79};
std::initializer_list< Widget * > List
Definition: PGroup.h:14
Shows and hides PWidgets based on a logic test.
Definition: PShowIf.h:18
PShowIf(std::string tag)
PShowIf * Equals(long l)
PShowIf * Then(PWidget *p)
PShowIf * Then(const PGroup::List &list)
PShowIf * Not()
PShowIf * Else(PWidget *p)
bool isShown() const override
PShowIf * Equals(std::string s)
PShowIf * Else(const PGroup::List &list)
PShowIf * DimensionEquals(unsigned int dim)
Provides a streamlined interface for a PWidget that wraps another PWidget.
Definition: PWidgetWrapper.h:9
Nodes with state in Xml tree representation.
Definition: ParamsBase.h:50