-
Notifications
You must be signed in to change notification settings - Fork 0
/
formual.h
136 lines (119 loc) · 2.11 KB
/
formual.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#include<string>
#include<list>
enum formType {basic, sqrt, inte, frac, mat};
class maker;
class baseForm
{
private:
bool verify()
{
return x1!=-1 && y1!=-1 && fontSize!=-1;
}
public:
virtual int getType()=0;
virtual void draw()=0;
float x1=-1;
float y1=-1;
int fontSize=-1;
//父节点管理子节点所有权
maker* supMaker=nullptr;
maker* subMaker=nullptr;
~formual()
{
delete supMaker;
delete subMaker;
}
};
class maker
{
private:
bool makerFlag; //true为上标
baseForm* form;
baseForm* parent;
public:
maker(bool markFlag, baseForm* form, baseForm* parent) :
markFlag(markFlag), form(form), parent(parent) {}
void draw()
{
//fix:根据上下标计算form的三个量
form->draw();
}
~marker()
{
delete form;
}
};
class formual : public baseForm
{
private:
string formStr;
public:
int getType() { return basic; }
formual(string formStr) : formStr(formStr) {}
void draw();
};
class sqrtForm : public baseForm
{
private:
baseForm* form;
public:
int getType() { return sqrt; }
sqrtForm(formual *form) : form(form) {}
//这里应该加一个是根号或是什么的flag
void draw();
~sqrtForm()
{
delete form;
}
};
class inteForm : public baseForm
{
private:
baseForm* upper;
baseForm* lower;
baseForm* expr;
public:
int getType() { return inte; }
inteForm(baseForm* upper=nullptr, baseForm* lower=nullptr, baseForm* expr=nullptr) :
upper(upper), lower(lower), expr(expr) {}
//这里应该加一个积分/求和积符号的flag
void draw();
~inteForm()
{
delete upper;
delete lower;
delete expr;
}
};
class fracForm : public baseForm
{
private:
baseForm* numForm;
baseForm* denForm;
public:
int getType() { return frac; }
fracForm(baseForm* numForm, baseForm* denForm) : numForm(numForm), denForm(denForm) {}
void draw();
~fracForm()
{
delete numForm;
delete denForm;
}
};
class matForm : public baseForm
{
private:
list<list<baseForm*>> allForm;
public:
int getType() { return mat; }
matForm(list<list<baseForm*>> allForm) : allForm(allForm) {}
void draw();
~matForm()
{
for(auto i : allForm)
{
for(baseForm* j : i)
delete j;
}
}
};