VAPOR3 3.9.4
PythonVariables.h
Go to the documentation of this file.
1#ifndef PYTHOVARIABLES_H
2#define PYTHOVARIABLES_H
3
5
6#include "ui_PythonVariablesGUI.h"
8#include "VaporTable.h"
9
10#include <QThread>
11#include <QDialog>
12#include <QMenuBar>
13#include <QComboBox>
14#include <QMenu>
15
16//
17// QObjects do not support nested classes, so use a namespace
18//
20class NewItemDialog;
22
23static const string _scriptType = "Python";
24} // namespace PythonVariables_
25
26class PythonVariables : public QDialog, Ui_PythonVariablesGUI {
27 Q_OBJECT
28
29public:
30 PythonVariables(QWidget *parent);
32 void Update(bool internal = false);
34 void ShowMe();
35
36private slots:
37 void _newScript();
38 void _openScript();
39 void _deleteScript();
40 void _importScript();
41 void _exportScript();
42 bool _getFilePath(QString &filePath, bool operation = true);
43 void _testScript();
44 void _saveScript();
45 void _closeScript();
46
47 void _createNewVariable();
48 void _deleteVariable();
49 void _scriptChanged();
50
51 void _coordInputVarChanged(int row, int col);
52 void _2DInputVarChanged(int row, int col);
53 void _3DInputVarChanged(int row, int col);
54
55 void _findEnabledCoordinateVariables(const std::vector<string> variables, const std::vector<bool> variablesEnabled);
56 void _coordinatesCheckboxClicked(int state);
57
58private:
59 const QColor *_background;
60
61 VAPoR::ControlExec *_controlExec;
62
63 PythonVariables_::NewItemDialog * _newItemDialog;
64 PythonVariables_::OpenAndDeleteDialog *_openAndDeleteDialog;
65
66 VaporTable *_coordInputVarTable;
67 VaporTable *_2DInputVarTable;
68 VaporTable *_3DInputVarTable;
69 VaporTable *_summaryTable;
70 VaporTable *_outputVarTable;
71
72 string _script;
73 string _scriptName;
74 string _dataMgrName;
75
76 bool _justSaved;
77 bool _includeCoordVars;
78
79 std::vector<string> _coordVars;
80 std::vector<bool> _coordVarsEnabled;
81 std::vector<string> _2DVars;
82 std::vector<bool> _2DVarsEnabled;
83 std::vector<string> _3DVars;
84 std::vector<bool> _3DVarsEnabled;
85 std::vector<string> _outputVars;
86 std::vector<string> _outputGrids;
87 std::vector<string> _inputGrids;
88 std::vector<string> _otherGrids;
89
90 void _connectWidgets();
91 void _setGUIEnabled(bool enabled);
92 void _makeInputTableValues(std::vector<string> &tableValuesCoords, std::vector<string> &tableValues2D, std::vector<string> &tableValues3D, std::vector<string> &summaryValues) const;
93 void _makeOutputTableValues(std::vector<string> &outputValues) const;
94 std::vector<string> _makeDialogOptions(std::vector<string> grids);
95 std::vector<string> _buildInputVars() const;
96 int _checkForDuplicateNames(std::vector<string> names, string name);
97 bool _isGridSelected(string grid, std::vector<string> selectedVars, std::vector<bool> varEnabled) const;
98 void _saveToSession();
99
100 void _updateNewItemDialog();
101 void _updateLabelColor(int r, int g, int b, QLabel *label);
102
103 void _reset();
104};
105
106namespace PythonVariables_ {
107
108class NewItemDialog : public QDialog {
109 Q_OBJECT
110
111public:
112 enum { SCRIPT = 0, OUTVAR = 1 };
113
114 NewItemDialog(QWidget *parent = 0);
116
117 void Update(int type, std::vector<string> optionNames, std::vector<int> categoryItems = std::vector<int>());
118 string GetItemName() const;
119 string GetOptionName() const;
120
121private:
122 void _connectWidgets();
123 void _setupGUI();
124 void _adjustToType(int type);
125 void _disableComboItem(int index);
126
127 string _itemName;
128 string _optionName;
129
130 QLabel * _itemNameLabel;
131 QLineEdit * _itemNameEdit;
132 QLabel * _optionNameLabel;
133 QComboBox * _optionNameCombo;
134 QPushButton *_okButton;
135 QPushButton *_cancelButton;
136
137private slots:
138 void _okClicked();
139};
140
141class OpenAndDeleteDialog : public QDialog {
142 Q_OBJECT
143
144public:
145 enum {
146 _OPEN = 0,
147 _DELETE = 1 // DELETE is a reserved keyword on Windows
148 };
149
150 OpenAndDeleteDialog(QWidget *parent = 0);
152
153 int Update(int type, VAPoR::ControlExec *controlExec);
154
155 string GetDataMgrName() const;
156 string GetScriptName() const;
157
158private:
159 void _setupGUI();
160
161 string _dataMgrName;
162 string _scriptName;
163
164 QLabel * _dataMgrNameLabel;
165 QComboBox * _dataMgrNameCombo;
166 QLabel * _scriptNameLabel;
167 QComboBox * _scriptNameCombo;
168 QPushButton *_okButton;
169 QPushButton *_cancelButton;
170
171 VAPoR::ControlExec *_controlExec;
172
173private slots:
174 void _okClicked();
175 void _updateOptions(int index);
176};
177
178} // namespace PythonVariables_
179
180#endif // PYTHOVARIABLES_H
NewItemDialog(QWidget *parent=0)
void Update(int type, std::vector< string > optionNames, std::vector< int > categoryItems=std::vector< int >())
int Update(int type, VAPoR::ControlExec *controlExec)
void InitControlExec(VAPoR::ControlExec *ce)
void Update(bool internal=false)
PythonVariables(QWidget *parent)
Provides API for VAPOR visualizer User Interfaces (UIs)
static const string _scriptType