OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
scene.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_SCENE_HPP__
10 #define CMZN_SCENE_HPP__
11 
12 #include "zinc/scene.h"
13 #include "zinc/field.hpp"
14 #include "zinc/graphics.hpp"
15 #include "zinc/light.hpp"
16 #include "zinc/region.hpp"
17 #include "zinc/scenefilter.hpp"
18 #include "zinc/selection.hpp"
19 #include "zinc/timekeeper.hpp"
20 
21 namespace OpenCMISS
22 {
23 namespace Zinc
24 {
25 
26 class StreaminformationScene;
27 class Sceneviewermodule;
28 class Scenepicker;
29 
36 class Scene
37 {
38 
39 protected:
40  cmzn_scene_id id;
41 
42 public:
43 
44  Scene() : id(0)
45  { }
46 
47  // takes ownership of C handle, responsibility for destroying it
48  explicit Scene(cmzn_scene_id scene_id) : id(scene_id)
49  { }
50 
51  Scene(const Scene& scene) : id(cmzn_scene_access(scene.id))
52  { }
53 
54  Scene& operator=(const Scene& scene)
55  {
56  cmzn_scene_id temp_id = cmzn_scene_access(scene.id);
57  if (0 != id)
58  {
59  cmzn_scene_destroy(&id);
60  }
61  id = temp_id;
62  return *this;
63  }
64 
65  ~Scene()
66  {
67  if (0 != id)
68  {
69  cmzn_scene_destroy(&id);
70  }
71  }
72 
78  bool isValid() const
79  {
80  return (0 != id);
81  }
82 
88  cmzn_scene_id getId() const
89  {
90  return id;
91  }
92 
103  {
104  return cmzn_scene_begin_change(id);
105  }
106 
116  int endChange()
117  {
118  return cmzn_scene_end_change(id);
119  }
120 
146  int convertToPointCloud(const Scenefilter& filter, const Nodeset& nodeset,
147  const Field& coordinateField, double lineDensity, double lineDensityScaleFactor,
148  double surfaceDensity, double surfaceDensityScaleFactor)
149  {
150  return cmzn_scene_convert_to_point_cloud(id, filter.getId(),
151  nodeset.getId(), coordinateField.getId(),
152  lineDensity, lineDensityScaleFactor,
153  surfaceDensity, surfaceDensityScaleFactor);
154  }
155 
170  int convertPointsToNodes(const Scenefilter& filter, const Nodeset& nodeset,
171  const Field& coordinateField)
172  {
173  return cmzn_scene_convert_points_to_nodes(id, filter.getId(),
174  nodeset.getId(), coordinateField.getId());
175  }
176 
184  {
185  return Graphics(cmzn_scene_create_graphics(id,
186  static_cast<cmzn_graphics_type>(graphicsType)));
187  }
188 
197  {
198  return GraphicsContours(cmzn_scene_create_graphics_contours(id));
199  }
200 
208  {
209  return GraphicsLines(cmzn_scene_create_graphics_lines(id));
210  }
211 
221  {
222  return GraphicsPoints(cmzn_scene_create_graphics_points(id));
223  }
224 
231  {
232  return GraphicsStreamlines(cmzn_scene_create_graphics_streamlines(id));
233  }
234 
242  {
243  return GraphicsSurfaces(cmzn_scene_create_graphics_surfaces(id));
244  }
245 
255  {
256  return Selectionnotifier(cmzn_scene_create_selectionnotifier(id));
257  }
258 
277  Graphics findGraphicsByName(const char *name)
278  {
279  return Graphics(cmzn_scene_find_graphics_by_name(id, name));
280  }
281 
288  {
289  return Graphics(cmzn_scene_get_first_graphics(id));
290  }
291 
298  Graphics getNextGraphics(const Graphics& refGraphics)
299  {
300  return Graphics(cmzn_scene_get_next_graphics(id, refGraphics.getId()));
301  }
302 
310  {
311  return Graphics(cmzn_scene_get_previous_graphics(id, refGraphics.getId()));
312  }
313 
320  {
321  return cmzn_scene_get_number_of_graphics(id);
322  }
323 
329  inline Region getRegion() const
330  {
331  return Region(cmzn_scene_get_region(id));
332  }
333 
340  {
341  return Fontmodule(cmzn_scene_get_fontmodule(id));
342  }
343 
352  {
353  return Glyphmodule(cmzn_scene_get_glyphmodule(id));
354  }
355 
364  {
365  return Lightmodule(cmzn_scene_get_lightmodule(id));
366  }
367 
377  {
378  return Materialmodule(cmzn_scene_get_materialmodule(id));
379  }
380 
388  {
389  return Scenefiltermodule(cmzn_scene_get_scenefiltermodule(id));
390  }
391 
399 
407  {
408  return Spectrummodule(cmzn_scene_get_spectrummodule(id));
409  }
410 
418  {
419  return Tessellationmodule(cmzn_scene_get_tessellationmodule(id));
420  }
421 
429  {
430  return Timekeepermodule(cmzn_scene_get_timekeepermodule(id));
431  }
432 
439  {
440  return Field(cmzn_scene_get_selection_field(id));
441  }
442 
453  int setSelectionField(const Field& selectionField)
454  {
455  return cmzn_scene_set_selection_field(id, selectionField.getId());
456  }
457 
478  int getSpectrumDataRange(const Scenefilter& filter, const Spectrum& spectrum,
479  int valuesCount, double *minimumValuesOut, double *maximumValuesOut)
480  {
481  return cmzn_scene_get_spectrum_data_range(id, filter.getId(),
482  spectrum.getId(), valuesCount, minimumValuesOut, maximumValuesOut);
483  }
484 
491  {
492  return cmzn_scene_get_visibility_flag(id);
493  }
494 
502  int setVisibilityFlag(bool visibilityFlag)
503  {
504  return cmzn_scene_set_visibility_flag(id, visibilityFlag);
505  }
506 
518  int moveGraphicsBefore(const Graphics& graphics, const Graphics& refGraphics)
519  {
520  return cmzn_scene_move_graphics_before(id, graphics.getId(), refGraphics.getId());
521  }
522 
529  {
530  return cmzn_scene_remove_all_graphics(id);
531  }
532 
539  int removeGraphics(const Graphics& graphics)
540  {
541  return cmzn_scene_remove_graphics(id, graphics.getId());
542  }
543 
551 
562  inline int write(const StreaminformationScene& streaminformationScene);
563 
573  inline int read(const StreaminformationScene& streaminformationScene);
574 
582 
583 };
584 
585 inline bool operator==(const Scene& a, const Scene& b)
586 {
587  return a.getId() == b.getId();
588 }
589 
591 {
592  return Scene(cmzn_region_get_scene(id));
593 }
594 
596 {
597  return Scene(cmzn_graphics_get_scene(id));
598 }
599 
600 } // namespace Zinc
601 }
602 
603 #endif
Graphics getFirstGraphics()
Definition: scene.hpp:287
Graphics getNextGraphics(const Graphics &refGraphics)
Definition: scene.hpp:298
cmzn_scenefilter_id getId() const
Definition: scenefilter.hpp:86
Lines visualise 1-D elements in the model.
Definition: graphics.hpp:848
int setVisibilityFlag(bool visibilityFlag)
Definition: scene.hpp:502
Materialmodule getMaterialmodule()
Definition: scene.hpp:376
Utility object for picking graphics and model objects.
Definition: scenepicker.hpp:32
int endChange()
Definition: scene.hpp:116
Module managing all light objects.
Definition: light.hpp:484
int removeGraphics(const Graphics &graphics)
Definition: scene.hpp:539
Surfaces visualise 2-D elements in the model.
Definition: graphics.hpp:1067
Scenepicker createScenepicker()
Definition: scenepicker.hpp:248
Glyphmodule getGlyphmodule()
Definition: scene.hpp:351
Base field type: an abstraction of a mathematical field.
Definition: field.hpp:49
Graphics createGraphics(Graphics::Type graphicsType)
Definition: scene.hpp:183
Module managing all fonts.
Definition: font.hpp:273
cmzn_nodeset_id getId() const
Definition: node.hpp:515
bool isValid() const
Definition: scene.hpp:78
Container/manager for graphics visualising a region.
Definition: scene.hpp:36
int getSpectrumDataRange(const Scenefilter &filter, const Spectrum &spectrum, int valuesCount, double *minimumValuesOut, double *maximumValuesOut)
Definition: scene.hpp:478
Points graphics visualise discrete locations in the model.
Definition: graphics.hpp:875
Lightmodule getLightmodule()
Definition: scene.hpp:363
Tessellationmodule getTessellationmodule()
Definition: scene.hpp:417
Manages individual user notification of changes to the selection group.
Definition: selection.hpp:158
A hierarchical block/namespace owning domains and fields.
Definition: region.hpp:33
int setSelectionField(const Field &selectionField)
Definition: scene.hpp:453
Base graphics type: produces 3-D graphics visualising domains and fields.
Definition: graphics.hpp:45
cmzn_spectrum_id getId() const
Definition: spectrum.hpp:638
Module managing all scene filters.
Definition: scenefilter.hpp:313
GraphicsPoints createGraphicsPoints()
Definition: scene.hpp:220
A scene-specific stream information object.
Definition: streamscene.hpp:31
int convertToPointCloud(const Scenefilter &filter, const Nodeset &nodeset, const Field &coordinateField, double lineDensity, double lineDensityScaleFactor, double surfaceDensity, double surfaceDensityScaleFactor)
Definition: scene.hpp:146
cmzn_field_id getId() const
Definition: field.hpp:101
bool getVisibilityFlag()
Definition: scene.hpp:490
GraphicsLines createGraphicsLines()
Definition: scene.hpp:207
Module object for creating and managing scene viewers.
Definition: sceneviewer.hpp:1187
Field getSelectionField()
Definition: scene.hpp:438
GraphicsContours createGraphicsContours()
Definition: scene.hpp:196
cmzn_scene_id getId() const
Definition: scene.hpp:88
int read(const StreaminformationScene &streaminformationScene)
Definition: streamscene.hpp:324
GraphicsStreamlines createGraphicsStreamlines()
Definition: scene.hpp:230
Module managing all spectrums.
Definition: spectrum.hpp:922
Module managing all materials.
Definition: material.hpp:350
Zinc Spectrum maps values of graphics data fields to colours.
Definition: spectrum.hpp:581
Scene getScene()
Definition: scene.hpp:590
Module managing all glyphs.
Definition: glyph.hpp:675
int moveGraphicsBefore(const Graphics &graphics, const Graphics &refGraphics)
Definition: scene.hpp:518
Sceneviewermodule getSceneviewermodule()
Definition: sceneviewer.hpp:1267
int write(const StreaminformationScene &streaminformationScene)
Definition: streamscene.hpp:319
Scenefiltermodule getScenefiltermodule()
Definition: scene.hpp:387
Graphics findGraphicsByName(const char *name)
Definition: scene.hpp:277
Fontmodule getFontmodule()
Definition: scene.hpp:339
Module managing all tessellation objects.
Definition: tessellation.hpp:323
Streamlines visualise the path of a fluid particle tracking along a vector field. ...
Definition: graphics.hpp:904
Spectrummodule getSpectrummodule()
Definition: scene.hpp:406
int removeAllGraphics()
Definition: scene.hpp:528
Module for finding and managing timekeepers.
Definition: timekeeper.hpp:222
int convertPointsToNodes(const Scenefilter &filter, const Nodeset &nodeset, const Field &coordinateField)
Definition: scene.hpp:170
Type
Definition: graphics.hpp:131
StreaminformationScene createStreaminformationScene()
Definition: streamscene.hpp:313
Scene filters determines which graphics are drawn.
Definition: scenefilter.hpp:33
Timekeepermodule getTimekeepermodule()
Definition: scene.hpp:428
int beginChange()
Definition: scene.hpp:102
The contours derived graphics type.
Definition: graphics.hpp:708
Scene getScene()
Definition: scene.hpp:595
cmzn_graphics_id getId() const
Definition: graphics.hpp:153
Region getRegion() const
Definition: scene.hpp:329
Graphics getPreviousGraphics(const Graphics &refGraphics)
Definition: scene.hpp:309
Selectionnotifier createSelectionnotifier()
Definition: scene.hpp:254
int getNumberOfGraphics()
Definition: scene.hpp:319
A set of nodes or points.
Definition: node.hpp:462
GraphicsSurfaces createGraphicsSurfaces()
Definition: scene.hpp:241