OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
region.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_REGION_HPP__
10 #define CMZN_REGION_HPP__
11 
12 #include "zinc/region.h"
13 #include "zinc/context.hpp"
14 
15 namespace OpenCMISS
16 {
17 namespace Zinc
18 {
19 
20 class Fieldmodule;
21 class Scene;
22 class StreaminformationRegion;
23 
33 class Region
34 {
35 protected:
36  cmzn_region_id id;
37 
38 public:
39 
40  Region() : id(0)
41  { }
42 
43  // takes ownership of C handle, responsibility for destroying it
44  explicit Region(cmzn_region_id in_region_id) : id(in_region_id)
45  { }
46 
47  Region(const Region& region) : id(cmzn_region_access(region.id))
48  { }
49 
50  Region& operator=(const Region& region)
51  {
52  cmzn_region_id temp_id = cmzn_region_access(region.id);
53  if (0 != id)
54  {
55  cmzn_region_destroy(&id);
56  }
57  id = temp_id;
58  return *this;
59  }
60 
61  ~Region()
62  {
63  if (0 != id)
64  {
65  cmzn_region_destroy(&id);
66  }
67  }
68 
74  bool isValid() const
75  {
76  return (0 != id);
77  }
78 
84  cmzn_region_id getId() const
85  {
86  return id;
87  }
88 
103  {
104  return cmzn_region_begin_change(id);
105  }
106 
117  int endChange()
118  {
119  return cmzn_region_end_change(id);
120  }
121 
133  {
134  return cmzn_region_begin_hierarchical_change(id);
135  }
136 
148  {
149  return cmzn_region_end_hierarchical_change(id);
150  }
151 
160  Region createChild(const char *name)
161  {
162  return Region(cmzn_region_create_child(id, name));
163  }
164 
174  Region createSubregion(const char *path)
175  {
176  return Region(cmzn_region_create_subregion(id, path));
177  }
178 
187  {
188  return Region(cmzn_region_create_region(id));
189  }
190 
197  inline Fieldmodule getFieldmodule() const;
198 
207  int readFile(const char *fileName)
208  {
209  return cmzn_region_read_file(id, fileName);
210  }
211 
218  char *getName()
219  {
220  return cmzn_region_get_name(id);
221  }
222 
231  int setName(const char *name)
232  {
233  return cmzn_region_set_name(id, name);
234  }
235 
242  {
243  return Region(cmzn_region_get_parent(id));
244  }
245 
252  {
253  return Region(cmzn_region_get_first_child(id));
254  }
255 
262  {
263  return Region(cmzn_region_get_next_sibling(id));
264  }
265 
272  {
273  return Region(cmzn_region_get_previous_sibling(id));
274  }
275 
286  int appendChild(Region newChild)
287  {
288  return cmzn_region_append_child(id, newChild.id);
289  }
290 
302  int insertChildBefore(const Region& newChild, const Region& refChild)
303  {
304  return cmzn_region_insert_child_before(id, newChild.id, refChild.id);
305  }
306 
314  int removeChild(const Region& oldChild)
315  {
316  return cmzn_region_remove_child(id, oldChild.id);
317  }
318 
325  Region findChildByName(const char *name)
326  {
327  return Region(cmzn_region_find_child_by_name(id, name));
328  }
329 
340  Region findSubregionAtPath(const char *path)
341  {
342  return Region(cmzn_region_find_subregion_at_path(id, path));
343  }
344 
351  bool containsSubregion(const Region& subregion)
352  {
353  return cmzn_region_contains_subregion(id, subregion.id);
354  }
355 
364  int writeFile(const char *fileName)
365  {
366  return cmzn_region_write_file(id, fileName);
367  }
368 
376  inline Scene getScene();
377 
385 
396  inline int read(const StreaminformationRegion& streaminformationRegion);
397 
407  inline int write(const StreaminformationRegion& streaminformationRegion);
408 
409 };
410 
411 inline bool operator==(const Region& a, const Region& b)
412 {
413  return a.getId() == b.getId();
414 }
415 
417 {
418  return Region(cmzn_context_get_default_region(id));
419 }
420 
422 {
423  return Region(cmzn_context_create_region(id));
424 }
425 
426 } // namespace Zinc
427 }
428 
429 #endif
int setName(const char *name)
Definition: region.hpp:231
Region findSubregionAtPath(const char *path)
Definition: region.hpp:340
int writeFile(const char *fileName)
Definition: region.hpp:364
Container/manager for graphics visualising a region.
Definition: scene.hpp:34
bool isValid() const
Definition: region.hpp:74
Fieldmodule getFieldmodule() const
Definition: fieldmodule.hpp:1567
Region createSubregion(const char *path)
Definition: region.hpp:174
int appendChild(Region newChild)
Definition: region.hpp:286
Region getPreviousSibling()
Definition: region.hpp:271
Region createChild(const char *name)
Definition: region.hpp:160
A region-specific stream information object.
Definition: streamregion.hpp:31
A hierarchical block/namespace owning domains and fields.
Definition: region.hpp:33
Region findChildByName(const char *name)
Definition: region.hpp:325
cmzn_region_id getId() const
Definition: region.hpp:84
int removeChild(const Region &oldChild)
Definition: region.hpp:314
bool containsSubregion(const Region &subregion)
Definition: region.hpp:351
StreaminformationRegion createStreaminformationRegion()
Definition: streamregion.hpp:190
int beginHierarchicalChange()
Definition: region.hpp:132
Region getDefaultRegion()
Definition: region.hpp:416
int write(const StreaminformationRegion &streaminformationRegion)
Definition: streamregion.hpp:201
Region getParent()
Definition: region.hpp:241
int insertChildBefore(const Region &newChild, const Region &refChild)
Definition: region.hpp:302
int endHierarchicalChange()
Definition: region.hpp:147
int endChange()
Definition: region.hpp:117
Region getFirstChild()
Definition: region.hpp:251
Scene getScene()
Definition: scene.hpp:512
Container/manager of fields and domains within a region.
Definition: fieldmodule.hpp:126
int beginChange()
Definition: region.hpp:102
int readFile(const char *fileName)
Definition: region.hpp:207
int read(const StreaminformationRegion &streaminformationRegion)
Definition: streamregion.hpp:196
Region createRegion()
Definition: region.hpp:186
Region createRegion()
Definition: region.hpp:421
char * getName()
Definition: region.hpp:218
Region getNextSibling()
Definition: region.hpp:261