Computer Assited Medical Intervention Tool Kit  version 4.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-2016 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
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 {
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:
75  wireframeVisibility = value;
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;
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;
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 
174  if (pointsVisibility) {
175  if (surfaceVisibility) {
176  if (wireframeVisibility) {
178  } else {
179  return POINTS_AND_SURFACE;
180  }
181  } else {
182  if (wireframeVisibility) {
183  return WIREFRAME_AND_POINTS;
184  } else {
185  return POINTS;
186  }
187  }
188  } else {
189  if (surfaceVisibility) {
190  if (wireframeVisibility) {
191  return WIREFRAME_AND_SURFACE;
192  } else {
193  return SURFACE;
194  }
195  } else {
196  if (wireframeVisibility) {
197  return WIREFRAME;
198  } else {
199  return NONE;
200  }
201  }
202  }
203  }
204 
206  std::string getModeString() const {
207  std::string n;
208 
209  if (pointsVisibility) {
210  if (surfaceVisibility) {
211  if (wireframeVisibility) {
212  n = "WIREFRAME_AND_SURFACE_AND_POINTS";
213  } else {
214  n="POINTS_AND_SURFACE";
215  }
216  } else {
217  if (wireframeVisibility) {
218  n="WIREFRAME_AND_POINTS";
219  } else {
220  n="POINTS";
221  }
222  }
223  } else {
224  if (surfaceVisibility) {
225  if (wireframeVisibility) {
226  n="WIREFRAME_AND_SURFACE";
227  } else {
228  n="SURFACE";
229  }
230  } else {
231  if (wireframeVisibility) {
232  n="WIREFRAME";
233  } else {
234  n="NONE";
235  }
236  }
237  }
238 
239  return n;
240  }
241 
242 private:
243 
244  // Visibility flags
251 };
252 
253 #endif
Definition: RenderingMode.h:43
bool isVisible(const Mode mode) const
Return if a rendering mode is currently visible or not.
Definition: RenderingMode.h:101
RenderingMode(const Mode mode=SURFACE)
default constructor with initialisation
Definition: RenderingMode.h:52
bool pointsVisibility
Flag indicating weither the points mode is currenly visible or not.
Definition: RenderingMode.h:250
bool isVisible() const
Return true if at least a mode is currently visible, false otherwise.
Definition: RenderingMode.h:131
Definition: RenderingMode.h:45
Definition: RenderingMode.h:42
Definition: RenderingMode.h:46
Definition: RenderingMode.h:41
Mode
This is a duplicate of RenderingMode Mode....
Definition: RenderingMode.h:40
RenderingMode(const bool surface, const bool wireframe, const bool points)
another constructor provided for conveniance
Definition: RenderingMode.h:62
Definition: RenderingMode.h:47
void setMode(const Mode mode)
set a vizualisation mode
Definition: RenderingMode.h:137
Handle rendering options (surface and wireframe) of an Object3D.
Definition: RenderingMode.h:37
Definition: RenderingMode.h:44
bool surfaceVisibility
Flag indicating weither the surface mode is currenly visible or not.
Definition: RenderingMode.h:246
std::string getModeString() const
get the string equivalent to the enum rendering mode
Definition: RenderingMode.h:206
void setVisible(const Mode mode, const bool value)
Set a rendering mode visible or not.
Definition: RenderingMode.h:69
bool wireframeVisibility
Flag indicating weither the wireframe mode is currenly visible or not.
Definition: RenderingMode.h:248
RenderingMode::Mode getMode() const
get current mode
Definition: RenderingMode.h:173