Computer Assisted Medical Intervention Tool Kit  version 5.1
 
Loading...
Searching...
No Matches
RenderingMode.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2023 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
6 *
7 * Visit http://camitk.imag.fr for more information
8 *
9 * This file is part of CamiTK.
10 *
11 * CamiTK is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * CamiTK is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * $CAMITK_LICENCE_END$
24 ****************************************************************************/
25
26#ifndef RENDERING_MODE_H
27#define RENDERING_MODE_H
28//#include "PhysicalModelIO.h"
29#include <string>
38public:
50
52 RenderingMode(const Mode mode = SURFACE) {
53 // set the visibility flags
54 setMode(mode);
55 }
56
62 RenderingMode(const bool surface, const bool wireframe, const bool points) {
63 setVisible(SURFACE, surface);
64 setVisible(WIREFRAME, wireframe);
65 setVisible(POINTS, points);
66 }
67
69 void setVisible(const Mode mode, const bool value) {
70 switch (mode) {
71 case SURFACE:
72 surfaceVisibility = value;
73 break;
74 case WIREFRAME:
75 wireframeVisibility = value;
76 break;
77 case POINTS:
78 pointsVisibility = value;
79 break;
81 wireframeVisibility = !value;
82 surfaceVisibility = pointsVisibility = value;
83 break;
85 surfaceVisibility = wireframeVisibility = pointsVisibility = value;
86 break;
88 surfaceVisibility = wireframeVisibility = value;
89 pointsVisibility = !value;
90 break;
92 pointsVisibility = wireframeVisibility = value;
93 surfaceVisibility = !value;
94 break;
95 default:
96 break;
97 }
98 }
99
101 bool isVisible(const Mode mode) const {
102 switch (mode) {
103 case SURFACE:
104 return surfaceVisibility;
105 break;
106 case WIREFRAME:
107 return wireframeVisibility;
108 break;
109 case POINTS:
110 return pointsVisibility;
111 break;
113 return (surfaceVisibility && pointsVisibility);
114 break;
116 return (wireframeVisibility && surfaceVisibility);
117 break;
119 return (wireframeVisibility && pointsVisibility);
120 break;
122 return (wireframeVisibility && surfaceVisibility && pointsVisibility);
123 break;
124 default:
125 return false;
126 break;
127 }
128 }
129
131 bool isVisible() const {
132 // true if at least a mode is visible
133 return (surfaceVisibility || wireframeVisibility || pointsVisibility);
134 }
135
137 void setMode(const Mode mode) {
138 switch (mode) {
139 case NONE:
140 surfaceVisibility = wireframeVisibility = pointsVisibility = false;
141 break;
142 case POINTS:
143 surfaceVisibility = wireframeVisibility = false;
144 pointsVisibility = true;
145 break;
147 wireframeVisibility = false;
148 surfaceVisibility = pointsVisibility = true;
149 break;
150 case SURFACE:
151 surfaceVisibility = true;
152 wireframeVisibility = pointsVisibility = false;
153 break;
155 surfaceVisibility = wireframeVisibility = pointsVisibility = true;
156 break;
158 surfaceVisibility = wireframeVisibility = true;
159 pointsVisibility = false;
160 break;
162 pointsVisibility = wireframeVisibility = true;
163 surfaceVisibility = false;
164 break;
165 case WIREFRAME:
166 surfaceVisibility = pointsVisibility = false;
167 wireframeVisibility = true;
168 break;
169 }
170 }
171
174 if (pointsVisibility) {
175 if (surfaceVisibility) {
176 if (wireframeVisibility) {
178 }
179 else {
180 return POINTS_AND_SURFACE;
181 }
182 }
183 else {
184 if (wireframeVisibility) {
186 }
187 else {
188 return POINTS;
189 }
190 }
191 }
192 else {
193 if (surfaceVisibility) {
194 if (wireframeVisibility) {
196 }
197 else {
198 return SURFACE;
199 }
200 }
201 else {
202 if (wireframeVisibility) {
203 return WIREFRAME;
204 }
205 else {
206 return NONE;
207 }
208 }
209 }
210 }
211
213 std::string getModeString() const {
214 std::string n;
215
216 if (pointsVisibility) {
217 if (surfaceVisibility) {
218 if (wireframeVisibility) {
219 n = "WIREFRAME_AND_SURFACE_AND_POINTS";
220 }
221 else {
222 n = "POINTS_AND_SURFACE";
223 }
224 }
225 else {
226 if (wireframeVisibility) {
227 n = "WIREFRAME_AND_POINTS";
228 }
229 else {
230 n = "POINTS";
231 }
232 }
233 }
234 else {
235 if (surfaceVisibility) {
236 if (wireframeVisibility) {
237 n = "WIREFRAME_AND_SURFACE";
238 }
239 else {
240 n = "SURFACE";
241 }
242 }
243 else {
244 if (wireframeVisibility) {
245 n = "WIREFRAME";
246 }
247 else {
248 n = "NONE";
249 }
250 }
251 }
252
253 return n;
254 }
255
256private:
257
258 // Visibility flags
260 bool surfaceVisibility;
262 bool wireframeVisibility;
264 bool pointsVisibility;
265};
266
267#endif
Handle rendering options (surface and wireframe) of an Object3D.
Definition RenderingMode.h:37
void setMode(const Mode mode)
set a vizualisation mode
Definition RenderingMode.h:137
void setVisible(const Mode mode, const bool value)
Set a rendering mode visible or not.
Definition RenderingMode.h:69
RenderingMode(const bool surface, const bool wireframe, const bool points)
another constructor provided for conveniance
Definition RenderingMode.h:62
RenderingMode(const Mode mode=SURFACE)
default constructor with initialisation
Definition RenderingMode.h:52
bool isVisible(const Mode mode) const
Return if a rendering mode is currently visible or not.
Definition RenderingMode.h:101
Mode
This is a duplicate of RenderingMode Mode....
Definition RenderingMode.h:40
@ WIREFRAME_AND_SURFACE_AND_POINTS
Definition RenderingMode.h:48
@ WIREFRAME_AND_SURFACE
Definition RenderingMode.h:45
@ WIREFRAME_AND_POINTS
Definition RenderingMode.h:46
@ WIREFRAME
Definition RenderingMode.h:47
@ POINTS
Definition RenderingMode.h:42
@ NONE
Definition RenderingMode.h:41
@ POINTS_AND_SURFACE
Definition RenderingMode.h:43
@ SURFACE
Definition RenderingMode.h:44
bool isVisible() const
Return true if at least a mode is currently visible, false otherwise.
Definition RenderingMode.h:131
std::string getModeString() const
get the string equivalent to the enum rendering mode
Definition RenderingMode.h:213
RenderingMode::Mode getMode() const
get current mode
Definition RenderingMode.h:173