OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
scenepicker.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_SCENEPICKER_HPP__
10 #define CMZN_SCENEPICKER_HPP__
11 
12 #include "zinc/scenepicker.h"
13 #include "zinc/element.hpp"
14 #include "zinc/fieldgroup.hpp"
15 #include "zinc/graphics.hpp"
16 #include "zinc/node.hpp"
17 #include "zinc/scene.hpp"
18 #include "zinc/scenefilter.hpp"
19 #include "zinc/sceneviewer.hpp"
20 
21 namespace OpenCMISS
22 {
23 namespace Zinc
24 {
25 
33 {
34 protected:
35  cmzn_scenepicker_id id;
36 
37 public:
38 
39  Scenepicker() : id(0)
40  { }
41 
42  // takes ownership of C handle, responsibility for destroying it
43  explicit Scenepicker(cmzn_scenepicker_id in_scenepicker_id) :
44  id(in_scenepicker_id)
45  { }
46 
47  Scenepicker(const Scenepicker& scenepicker) :
48  id(cmzn_scenepicker_access(scenepicker.id))
49  { }
50 
51  Scenepicker& operator=(const Scenepicker& scenepicker)
52  {
53  cmzn_scenepicker_id temp_id = cmzn_scenepicker_access(scenepicker.id);
54  if (0 != id)
55  {
56  cmzn_scenepicker_destroy(&id);
57  }
58  id = temp_id;
59  return *this;
60  }
61 
62  ~Scenepicker()
63  {
64  if (0 != id)
65  {
66  cmzn_scenepicker_destroy(&id);
67  }
68  }
69 
75  bool isValid() const
76  {
77  return (0 != id);
78  }
79 
85  cmzn_scenepicker_id getId() const
86  {
87  return id;
88  }
89 
102  int setSceneviewerRectangle(const Sceneviewer& sceneviewer, Scenecoordinatesystem coordinateSystem, double x1,
103  double y1, double x2, double y2)
104  {
105  return cmzn_scenepicker_set_sceneviewer_rectangle(
106  id , sceneviewer.getId(),
107  static_cast<cmzn_scenecoordinatesystem>(coordinateSystem),
108  x1, y1, x2, y2);
109  }
110 
117  {
118  return Element(cmzn_scenepicker_get_nearest_element(id));
119  }
120 
127  {
128  return Node(cmzn_scenepicker_get_nearest_node(id));
129  }
130 
138  {
139  return Graphics(cmzn_scenepicker_get_nearest_element_graphics(id));
140  }
141 
149  {
150  return Graphics(cmzn_scenepicker_get_nearest_node_graphics(id));
151  }
152 
159  {
160  return Graphics(cmzn_scenepicker_get_nearest_graphics(id));
161  }
162 
172  {
173  return cmzn_scenepicker_add_picked_elements_to_field_group(id,
174  (reinterpret_cast<cmzn_field_group_id>(fieldGroup.getId())));
175  }
176 
185  int addPickedNodesToFieldGroup(const FieldGroup& fieldGroup)
186  {
187  return cmzn_scenepicker_add_picked_nodes_to_field_group(id,
188  (reinterpret_cast<cmzn_field_group_id>(fieldGroup.getId())));
189  }
190 
197  {
198  return Scene(cmzn_scenepicker_get_scene(id));
199  }
200 
207  int setScene(const Scene& scene)
208  {
209  return cmzn_scenepicker_set_scene(id, scene.getId());
210  }
211 
218  {
219  return Scenefilter(cmzn_scenepicker_get_scenefilter(id));
220  }
221 
229  int setScenefilter(const Scenefilter& filter)
230  {
231  return cmzn_scenepicker_set_scenefilter(id, filter.getId());
232  }
233 
234 };
235 
236 inline Scenepicker Scene::createScenepicker()
237 {
238  return Scenepicker(cmzn_scene_create_scenepicker(id));
239 }
240 
241 } // namespace Zinc
242 }
243 
244 #endif
cmzn_sceneviewer_id getId() const
Definition: sceneviewer.hpp:449
Graphics getNearestNodeGraphics()
Definition: scenepicker.hpp:148
Graphics getNearestGraphics()
Definition: scenepicker.hpp:158
A single finite element from a mesh.
Definition: element.hpp:205
cmzn_scenefilter_id getId() const
Definition: scenefilter.hpp:86
Utility object for picking graphics and model objects.
Definition: scenepicker.hpp:32
cmzn_scenepicker_id getId() const
Definition: scenepicker.hpp:85
Scenecoordinatesystem
Definition: scenecoordinatesystem.hpp:26
Scene getScene()
Definition: scenepicker.hpp:196
Container/manager for graphics visualising a region.
Definition: scene.hpp:34
Scenefilter getScenefilter()
Definition: scenepicker.hpp:217
Base graphics type: produces 3-D graphics visualising domains and fields.
Definition: graphics.hpp:45
cmzn_field_id getId() const
Definition: field.hpp:98
int addPickedNodesToFieldGroup(const FieldGroup &fieldGroup)
Definition: scenepicker.hpp:185
cmzn_scene_id getId() const
Definition: scene.hpp:86
Graphics getNearestElementGraphics()
Definition: scenepicker.hpp:137
int setScene(const Scene &scene)
Definition: scenepicker.hpp:207
A generic group field used for grouping local subobjects.
Definition: fieldgroup.hpp:35
Point object used to represent finite element nodes.
Definition: node.hpp:37
Scene filters determines which graphics are drawn.
Definition: scenefilter.hpp:33
bool isValid() const
Definition: scenepicker.hpp:75
The Zinc sceneviewer is responsible for rendering the graphical Scene.
Definition: sceneviewer.hpp:261
int setSceneviewerRectangle(const Sceneviewer &sceneviewer, Scenecoordinatesystem coordinateSystem, double x1, double y1, double x2, double y2)
Definition: scenepicker.hpp:102
Element getNearestElement()
Definition: scenepicker.hpp:116
int setScenefilter(const Scenefilter &filter)
Definition: scenepicker.hpp:229
Node getNearestNode()
Definition: scenepicker.hpp:126
int addPickedElementsToFieldGroup(const FieldGroup &fieldGroup)
Definition: scenepicker.hpp:171