Computer Assited Medical Intervention Tool Kit  version 5.0
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-2021 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>
38 public:
40  enum Mode {
41  NONE,
42  POINTS,
44  SURFACE,
47  WIREFRAME,
49  };
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:
76  break;
77  case POINTS:
78  pointsVisibility = value;
79  break;
80  case POINTS_AND_SURFACE:
81  wireframeVisibility = !value;
83  break;
86  break;
89  pointsVisibility = !value;
90  break;
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;
112  case POINTS_AND_SURFACE:
114  break;
117  break;
120  break;
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
134  }
135 
137  void setMode(const Mode mode) {
138  switch (mode) {
139  case NONE:
141  break;
142  case POINTS:
144  pointsVisibility = true;
145  break;
146  case POINTS_AND_SURFACE:
147  wireframeVisibility = false;
149  break;
150  case SURFACE:
151  surfaceVisibility = true;
153  break;
156  break;
159  pointsVisibility = false;
160  break;
163  surfaceVisibility = false;
164  break;
165  case WIREFRAME:
167  wireframeVisibility = true;
168  break;
169  }
170  }
171 
173  RenderingMode::Mode getMode() const {
174  if (pointsVisibility) {
175  if (surfaceVisibility) {
176  if (wireframeVisibility) {
178  }
179  else {
180  return POINTS_AND_SURFACE;
181  }
182  }
183  else {
184  if (wireframeVisibility) {
185  return WIREFRAME_AND_POINTS;
186  }
187  else {
188  return POINTS;
189  }
190  }
191  }
192  else {
193  if (surfaceVisibility) {
194  if (wireframeVisibility) {
195  return WIREFRAME_AND_SURFACE;
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) {
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 
256 private:
257 
258  // Visibility flags
260  bool surfaceVisibility;
262  bool wireframeVisibility;
264  bool pointsVisibility;
265 };
266 
267 #endif
RenderingMode::WIREFRAME
@ WIREFRAME
Definition: RenderingMode.h:93
RenderingMode::surfaceVisibility
bool surfaceVisibility
Flag indicating weither the surface mode is currenly visible or not.
Definition: RenderingMode.h:283
RenderingMode::isVisible
bool isVisible() const
Return true if at least a mode is currently visible, false otherwise.
Definition: RenderingMode.h:154
RenderingMode::SURFACE
@ SURFACE
Definition: RenderingMode.h:90
RenderingMode::WIREFRAME_AND_SURFACE
@ WIREFRAME_AND_SURFACE
Definition: RenderingMode.h:91
RenderingMode::getMode
RenderingMode::Mode getMode() const
get current mode
Definition: RenderingMode.h:196
RenderingMode.h
RenderingMode::setVisible
void setVisible(const Mode mode, const bool value)
Set a rendering mode visible or not.
Definition: RenderingMode.h:92
RenderingMode
Handle rendering options (surface and wireframe) of an Object3D.
Definition: RenderingMode.h:37
RenderingMode::WIREFRAME_AND_POINTS
@ WIREFRAME_AND_POINTS
Definition: RenderingMode.h:92
RenderingMode::NONE
@ NONE
Definition: RenderingMode.h:87
PhysicalModelIO.h
RenderingMode::setMode
void setMode(const Mode mode)
set a vizualisation mode
Definition: RenderingMode.h:160
RenderingMode::pointsVisibility
bool pointsVisibility
Flag indicating weither the points mode is currenly visible or not.
Definition: RenderingMode.h:287
RenderingMode::Mode
Mode
This is a duplicate of RenderingMode Mode....
Definition: RenderingMode.h:63
RenderingMode::WIREFRAME_AND_SURFACE_AND_POINTS
@ WIREFRAME_AND_SURFACE_AND_POINTS
Definition: RenderingMode.h:94
RenderingMode::POINTS
@ POINTS
Definition: RenderingMode.h:88
RenderingMode::wireframeVisibility
bool wireframeVisibility
Flag indicating weither the wireframe mode is currenly visible or not.
Definition: RenderingMode.h:285
RenderingMode::POINTS_AND_SURFACE
@ POINTS_AND_SURFACE
Definition: RenderingMode.h:89
RenderingMode::getModeString
std::string getModeString() const
get the string equivalent to the enum rendering mode
Definition: RenderingMode.h:236
RenderingMode::RenderingMode
RenderingMode(const Mode mode=SURFACE)
default constructor with initialisation
Definition: RenderingMode.h:75