-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathGDecoration.h
184 lines (145 loc) · 4.63 KB
/
GDecoration.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*This file is part of the FEBio Studio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio-Studio.txt for details.
Copyright (c) 2021 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.*/
#pragma once
#include <FSCore/math3d.h>
#include <FSCore/color.h>
#include <FSCore/box.h>
#include <vector>
//-------------------------------------------------------------------
// A GDecoration is something that will be drawn onto the Graphics View
class GDecoration
{
public:
GDecoration() { bvisible = true; m_col = GLColor(255, 255, 0); m_col2 = GLColor(0, 0, 0); }
virtual ~GDecoration(){}
virtual void render() = 0;
bool isVisible() const { return bvisible; }
void setVisible(bool b) { bvisible = b; }
void setColor(GLColor c) { m_col = c; }
void setColor2(GLColor c) { m_col2 = c; }
protected:
bool bvisible;
GLColor m_col, m_col2;
};
//-------------------------------------------------------------------
class GPointDecoration : public GDecoration
{
public:
GPointDecoration() { m_renderAura = false; }
GPointDecoration(const vec3f& r) : m_pos(r) { m_renderAura = false; }
void render();
void setPosition(const vec3f& r) { m_pos = r; }
vec3f& position() { return m_pos; }
void renderAura(bool b) { m_renderAura = b; }
private:
vec3f m_pos;
bool m_renderAura;
};
//-------------------------------------------------------------------
class GLineDecoration : public GDecoration
{
public:
GLineDecoration() { p1 = p2 = 0; m_del = false; }
GLineDecoration(GPointDecoration* point1, GPointDecoration* point2) : p1(point1), p2(point2), m_del(false) {}
GLineDecoration(const vec3f& a, const vec3f& b);
~GLineDecoration();
void render();
private:
bool m_del;
GPointDecoration* p1;
GPointDecoration* p2;
};
//-------------------------------------------------------------------
class GTriangleDecoration : public GDecoration
{
public:
GTriangleDecoration() { p1 = p2 = p3 = 0; m_del = false; }
~GTriangleDecoration()
{
if (m_del)
{
delete p1;
delete p2;
delete p3;
}
}
GTriangleDecoration(GPointDecoration* point1, GPointDecoration* point2, GPointDecoration* point3) : p1(point1), p2(point2), p3(point3) { m_del = false; }
GTriangleDecoration(const vec3f& a, const vec3f& b, const vec3f& c)
{
m_del = true;
p1 = new GPointDecoration(a);
p2 = new GPointDecoration(b);
p3 = new GPointDecoration(c);
}
void render();
private:
bool m_del;
GPointDecoration* p1;
GPointDecoration* p2;
GPointDecoration* p3;
};
//-------------------------------------------------------------------
class GArcDecoration : public GDecoration
{
public:
GArcDecoration(const vec3f& c, const vec3f& p0, const vec3f& p1, int ndivs = 10, double scale = 0.25);
void render();
private:
vec3f m_c;
vec3f m_e0;
vec3f m_e1;
double m_scale;
int m_divs;
};
//-------------------------------------------------------------------
class GSphereDecoration : public GDecoration
{
public:
GSphereDecoration(const vec3f& a, double R);
void render();
private:
vec3d m_c;
double m_R;
};
//-------------------------------------------------------------------
class GCompositeDecoration : public GDecoration
{
public:
GCompositeDecoration();
~GCompositeDecoration();
void AddDecoration(GDecoration* deco);
void render();
private:
std::vector<GDecoration*> m_deco;
};
//-------------------------------------------------------------------
class GPlaneCutDecoration : public GDecoration
{
public:
GPlaneCutDecoration();
~GPlaneCutDecoration();
void setBoundingBox(BOX box);
void setPlane(double n0, double n1, double n2, double d);
void render();
private:
BOX m_box;
double m_a[4];
};