-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparam.h
109 lines (102 loc) · 2.91 KB
/
param.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef PARAM_H
#define PARAM_H
#include<QtWidgets>
#include<initializer_list>
#include<complex>
#include"main.h"
//These classes are responsible for displaying a configurable parameter to the user
//Param itself cannot be instantiated and must be subclassed for each type of parameter
class Param:public QWidget{
Q_OBJECT
unsigned int links=0;//set of flags for linking Params to ComboParams
protected:
void*data;//The piece of data to be updated by the interface in the upd8 slot
QHBoxLayout*layout;//The layout that all components should be added to
QLabel*label;
public:
const signed char id;//should be between 1 and 127 inclusive
const char*const name;
Param(const signed char,const char*,void*,QWidget*parent=0);
signals:
void edited();
public slots:
void link(int);
virtual void tip(QString);
virtual void write()=0;
virtual void read()=0;
virtual void clear()=0;
};
class BoolParam:public Param{
QCheckBox*edit=new QCheckBox(this);
public:
BoolParam(const signed char,const char*,bool*,QWidget*parent=0);
void read();
void write();
void clear();
void tip(QString);
};
class IntParam:public Param{
QSpinBox*edit=new QSpinBox(this);
public:
IntParam(const signed char,const char*,int*,QWidget*parent=0);
void read();
void write();
void clear();
};
class DoubleParam:public Param{
QLineEdit*edit;
double multiplier=1;//number to multiply by to convert input to desired units
public:
DoubleParam(const signed char,const char*,double*,QWidget*parent=0);
void set(QString);
double setMultiplier(double);
QString get();
void read();
void write();
void clear();
};
class ComplexParam:public Param{
QLineEdit*edit,*editI;
public:
ComplexParam(const signed char,const char*,complex*,QWidget*parent=0);
void read();
void write();
void clear();
};
class VectorParam:public Param{
QLineEdit*editX,*editY,*editZ;
public:
VectorParam(const signed char,const char*,vector*,QWidget*parent=0);
void set(vector);
vector get();
void read();
void write();
void clear();
};
class FunctionParam:public Param{
QLineEdit*edit;
public:
FunctionParam(const signed char,const char*,char256*,QWidget*parent=0);
void read();
void write();
void clear();
};
class ComboParam:public Param{
Q_OBJECT
QComboBox*box;
public:
ComboParam(const signed char,const char*,char*,std::initializer_list<QString>,QWidget*parent=0);
void read();
void write();
void clear();
signals:
void currentIndexChanged(int);
};
//Overloaded convenience methods for generating Param widgets
BoolParam*newParam(const signed char,const char*,bool*,QWidget*parent=0);
IntParam*newParam(const signed char,const char*,int*,QWidget*parent=0);
DoubleParam*newParam(const signed char,const char*,double*,QWidget*parent=0);
ComplexParam*newParam(const signed char,const char*,complex*,QWidget*parent=0);
VectorParam*newParam(const signed char,const char*,vector*,QWidget*parent=0);
FunctionParam*newParam(const signed char,const char*,char256*,QWidget*parent=0);
#endif