OpenCMISS-Zinc C++ API Documentation
scenefilter.hpp
Go to the documentation of this file.
1 
4 /* OpenCMISS-Zinc Library
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public
7 * License, v. 2.0. If a copy of the MPL was not distributed with this
8 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
9 #ifndef CMZN_SCENEFILTER_HPP__
10 #define CMZN_SCENEFILTER_HPP__
11 
12 #include "opencmiss/zinc/scenefilter.h"
13 #include "opencmiss/zinc/context.hpp"
14 #include "opencmiss/zinc/graphics.hpp"
15 #include "opencmiss/zinc/region.hpp"
16 
17 namespace OpenCMISS
18 {
19 namespace Zinc
20 {
21 
22 class ScenefilterOperator;
23 
34 {
35 protected:
36  cmzn_scenefilter_id id;
37 
38 public:
39 
40  Scenefilter() : id(0)
41  { }
42 
43  // takes ownership of C handle, responsibility for destroying it
44  explicit Scenefilter(cmzn_scenefilter_id in_filter_id) :
45  id(in_filter_id)
46  { }
47 
48  Scenefilter(const Scenefilter& scenefilter) :
49  id(cmzn_scenefilter_access(scenefilter.id))
50  { }
51 
52  Scenefilter& operator=(const Scenefilter& scenefilter)
53  {
54  cmzn_scenefilter_id temp_id = cmzn_scenefilter_access(scenefilter.id);
55  if (0 != id)
56  {
57  cmzn_scenefilter_destroy(&id);
58  }
59  id = temp_id;
60  return *this;
61  }
62 
63  ~Scenefilter()
64  {
65  if (0 != id)
66  {
67  cmzn_scenefilter_destroy(&id);
68  }
69  }
70 
76  bool isValid() const
77  {
78  return (0 != id);
79  }
80 
86  cmzn_scenefilter_id getId() const
87  {
88  return id;
89  }
90 
97  bool isManaged()
98  {
99  return cmzn_scenefilter_is_managed(id);
100  }
101 
114  int setManaged(bool value)
115  {
116  return cmzn_scenefilter_set_managed(id, value);
117  }
118 
126  bool evaluateGraphics(const Graphics& graphics)
127  {
128  return cmzn_scenefilter_evaluate_graphics(id, graphics.getId());
129  }
130 
136  bool isInverse()
137  {
138  return cmzn_scenefilter_is_inverse(id);
139  }
140 
148  int setInverse(bool value)
149  {
150  return cmzn_scenefilter_set_inverse(id, value);
151  }
152 
159  char *getName()
160  {
161  return cmzn_scenefilter_get_name(id);
162  }
163 
170  int setName(const char *name)
171  {
172  return cmzn_scenefilter_set_name(id, name);
173  }
174 
183 };
184 
185 inline bool operator==(const Scenefilter& a, const Scenefilter& b)
186 {
187  return a.getId() == b.getId();
188 }
189 
199 {
200 public:
201 
203  { }
204 
205  // takes ownership of C handle, responsibility for destroying it
206  explicit ScenefilterOperator(cmzn_scenefilter_operator_id operator_filter_id) :
207  Scenefilter(reinterpret_cast<cmzn_scenefilter_id>(operator_filter_id))
208  { }
209 
215  cmzn_scenefilter_operator_id getDerivedId()
216  {
217  return reinterpret_cast<cmzn_scenefilter_operator_id>(id);
218  }
219 
228  int appendOperand(const Scenefilter& operand)
229  {
230  return cmzn_scenefilter_operator_append_operand(getDerivedId(), operand.getId());
231  }
232 
238  {
239  return Scenefilter(cmzn_scenefilter_operator_get_first_operand(getDerivedId()));
240  }
241 
250  {
251  return Scenefilter(cmzn_scenefilter_operator_get_next_operand(getDerivedId(), refOperand.getId()));
252  }
253 
260  bool isOperandActive(const Scenefilter& operand)
261  {
262  return cmzn_scenefilter_operator_is_operand_active(getDerivedId(), operand.getId());
263  }
264 
272  int setOperandActive(const Scenefilter& operand, bool isActive)
273  {
274  return cmzn_scenefilter_operator_set_operand_active(getDerivedId(), operand.getId(), isActive);
275  }
276 
286  int insertOperandBefore(const Scenefilter& operand, const Scenefilter& refOperand)
287  {
288  return cmzn_scenefilter_operator_insert_operand_before(getDerivedId(), operand.getId(), refOperand.getId());
289  }
290 
297  int removeOperand(const Scenefilter& operand)
298  {
299  return cmzn_scenefilter_operator_remove_operand(getDerivedId(), operand.getId());
300  }
301 };
302 
304 {
305  return ScenefilterOperator(cmzn_scenefilter_cast_operator(id));
306 }
307 
314 {
315 protected:
316  cmzn_scenefiltermodule_id id;
317 
318 public:
319 
320  Scenefiltermodule() : id(0)
321  { }
322 
323  // takes ownership of C handle, responsibility for destroying it
324  explicit Scenefiltermodule(cmzn_scenefiltermodule_id in_filtermodule_id) :
325  id(in_filtermodule_id)
326  { }
327 
328  Scenefiltermodule(const Scenefiltermodule& scenefiltermodule) :
329  id(cmzn_scenefiltermodule_access(scenefiltermodule.id))
330  { }
331 
332  Scenefiltermodule& operator=(const Scenefiltermodule& scenefiltermodule)
333  {
334  cmzn_scenefiltermodule_id temp_id = cmzn_scenefiltermodule_access(
335  scenefiltermodule.id);
336  if (0 != id)
337  {
338  cmzn_scenefiltermodule_destroy(&id);
339  }
340  id = temp_id;
341  return *this;
342  }
343 
345  {
346  if (0 != id)
347  {
348  cmzn_scenefiltermodule_destroy(&id);
349  }
350  }
351 
357  bool isValid() const
358  {
359  return (0 != id);
360  }
361 
367  cmzn_scenefiltermodule_id getId() const
368  {
369  return id;
370  }
371 
380  {
381  return Scenefilter(cmzn_scenefiltermodule_create_scenefilter_visibility_flags(id));
382  }
383 
392  {
393  return Scenefilter(cmzn_scenefiltermodule_create_scenefilter_field_domain_type(id,
394  static_cast<cmzn_field_domain_type>(domainType)));
395  }
396 
404  {
405  return Scenefilter(cmzn_scenefiltermodule_create_scenefilter_graphics_name(id, matchName));
406  }
407 
415  {
416  return Scenefilter(cmzn_scenefiltermodule_create_scenefilter_graphics_type(id,
417  static_cast<cmzn_graphics_type>(graphicsType)));
418  }
419 
428  {
429  return Scenefilter(cmzn_scenefiltermodule_create_scenefilter_region(
430  id, matchRegion.getId()));
431  }
432 
440  {
441  return ScenefilterOperator(reinterpret_cast<cmzn_scenefilter_operator_id>(
442  cmzn_scenefiltermodule_create_scenefilter_operator_and(id)));
443  }
444 
452  {
453  return ScenefilterOperator(reinterpret_cast<cmzn_scenefilter_operator_id>(
454  cmzn_scenefiltermodule_create_scenefilter_operator_or(id)));
455  }
456 
464  {
465  return Scenefilter(cmzn_scenefiltermodule_find_scenefilter_by_name(id, name));
466  }
467 
478  {
479  return cmzn_scenefiltermodule_begin_change(id);
480  }
481 
491  int endChange()
492  {
493  return cmzn_scenefiltermodule_end_change(id);
494  }
495 
502  {
503  return Scenefilter(cmzn_scenefiltermodule_get_default_scenefilter(id));
504  }
505 
513  {
514  return cmzn_scenefiltermodule_set_default_scenefilter(id, filter.getId());
515  }
516 };
517 
519 {
520  return Scenefiltermodule(cmzn_context_get_scenefiltermodule(id));
521 }
522 
523 } // namespace Zinc
524 }
525 
526 #endif
Scenefilter createScenefilterRegion(const Region &matchRegion)
Definition: scenefilter.hpp:427
cmzn_scenefilter_id getId() const
Definition: scenefilter.hpp:86
Scenefilter getFirstOperand()
Definition: scenefilter.hpp:237
int setDefaultScenefilter(const Scenefilter &filter)
Definition: scenefilter.hpp:512
Scenefilter findScenefilterByName(const char *name)
Definition: scenefilter.hpp:463
int endChange()
Definition: scenefilter.hpp:491
Scenefilter createScenefilterFieldDomainType(Field::DomainType domainType)
Definition: scenefilter.hpp:391
bool isValid() const
Definition: scenefilter.hpp:357
int insertOperandBefore(const Scenefilter &operand, const Scenefilter &refOperand)
Definition: scenefilter.hpp:286
bool isValid() const
Definition: scenefilter.hpp:76
cmzn_scenefilter_operator_id getDerivedId()
Definition: scenefilter.hpp:215
A hierarchical block/namespace owning domains and fields.
Definition: region.hpp:33
Base graphics type: produces 3-D graphics visualising domains and fields.
Definition: graphics.hpp:45
cmzn_region_id getId() const
Definition: region.hpp:84
Module managing all scene filters.
Definition: scenefilter.hpp:313
An operator OR or AND specific scene filter type.
Definition: scenefilter.hpp:198
int removeOperand(const Scenefilter &operand)
Definition: scenefilter.hpp:297
Scenefilter createScenefilterGraphicsName(const char *matchName)
Definition: scenefilter.hpp:403
Scenefilter getDefaultScenefilter()
Definition: scenefilter.hpp:501
int setName(const char *name)
Definition: scenefilter.hpp:170
bool isManaged()
Definition: scenefilter.hpp:97
DomainType
Definition: field.hpp:210
ScenefilterOperator createScenefilterOperatorAnd()
Definition: scenefilter.hpp:439
Scenefilter getNextOperand(const Scenefilter &refOperand)
Definition: scenefilter.hpp:249
Scenefilter createScenefilterVisibilityFlags()
Definition: scenefilter.hpp:379
ScenefilterOperator castOperator()
Definition: scenefilter.hpp:303
int setOperandActive(const Scenefilter &operand, bool isActive)
Definition: scenefilter.hpp:272
Scenefiltermodule getScenefiltermodule()
Definition: scenefilter.hpp:518
int appendOperand(const Scenefilter &operand)
Definition: scenefilter.hpp:228
int setManaged(bool value)
Definition: scenefilter.hpp:114
bool isInverse()
Definition: scenefilter.hpp:136
int setInverse(bool value)
Definition: scenefilter.hpp:148
Type
Definition: graphics.hpp:131
The OpenCMISS namespace.
Definition: context.hpp:20
Scene filters determines which graphics are drawn.
Definition: scenefilter.hpp:33
cmzn_scenefiltermodule_id getId() const
Definition: scenefilter.hpp:367
Scenefilter createScenefilterGraphicsType(Graphics::Type graphicsType)
Definition: scenefilter.hpp:414
bool evaluateGraphics(const Graphics &graphics)
Definition: scenefilter.hpp:126
char * getName()
Definition: scenefilter.hpp:159
bool isOperandActive(const Scenefilter &operand)
Definition: scenefilter.hpp:260
cmzn_graphics_id getId() const
Definition: graphics.hpp:153
int beginChange()
Definition: scenefilter.hpp:477
ScenefilterOperator createScenefilterOperatorOr()
Definition: scenefilter.hpp:451