OpenCMISS-Zinc C++ API Documentation
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 "opencmiss/zinc/scenepicker.h"
13 #include "opencmiss/zinc/element.hpp"
14 #include "opencmiss/zinc/fieldgroup.hpp"
15 #include "opencmiss/zinc/graphics.hpp"
16 #include "opencmiss/zinc/node.hpp"
17 #include "opencmiss/zinc/scene.hpp"
18 #include "opencmiss/zinc/scenefilter.hpp"
19 #include "opencmiss/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 
106  int setSceneviewerRectangle(const Sceneviewer& sceneviewer, Scenecoordinatesystem scenecoordinatesystem, double x1,
107  double y1, double x2, double y2)
108  {
109  return cmzn_scenepicker_set_sceneviewer_rectangle(
110  id , sceneviewer.getId(),
111  static_cast<cmzn_scenecoordinatesystem>(scenecoordinatesystem),
112  x1, y1, x2, y2);
113  }
114 
121  {
122  return Element(cmzn_scenepicker_get_nearest_element(id));
123  }
124 
131  {
132  return Node(cmzn_scenepicker_get_nearest_node(id));
133  }
134 
142  {
143  return Graphics(cmzn_scenepicker_get_nearest_element_graphics(id));
144  }
145 
153  {
154  return Graphics(cmzn_scenepicker_get_nearest_node_graphics(id));
155  }
156 
163  {
164  return Graphics(cmzn_scenepicker_get_nearest_graphics(id));
165  }
166 
176  {
177  return cmzn_scenepicker_add_picked_elements_to_field_group(id,
178  (reinterpret_cast<cmzn_field_group_id>(fieldGroup.getId())));
179  }
180 
189  int addPickedNodesToFieldGroup(const FieldGroup& fieldGroup)
190  {
191  return cmzn_scenepicker_add_picked_nodes_to_field_group(id,
192  (reinterpret_cast<cmzn_field_group_id>(fieldGroup.getId())));
193  }
194 
201  {
202  return Scene(cmzn_scenepicker_get_scene(id));
203  }
204 
211  int setScene(const Scene& scene)
212  {
213  return cmzn_scenepicker_set_scene(id, scene.getId());
214  }
215 
222  {
223  return Scenefilter(cmzn_scenepicker_get_scenefilter(id));
224  }
225 
233  int setScenefilter(const Scenefilter& filter)
234  {
235  return cmzn_scenepicker_set_scenefilter(id, filter.getId());
236  }
237 
245  int getPickingVolumeCentre(double *coordinateValuesOut3)
246  {
247  return cmzn_scenepicker_get_picking_volume_centre(id, coordinateValuesOut3);
248  }
249 
250 };
251 
253 {
254  return Scenepicker(cmzn_scene_create_scenepicker(id));
255 }
256 
257 } // namespace Zinc
258 }
259 
260 #endif
cmzn_sceneviewer_id getId() const
Definition: sceneviewer.hpp:448
Graphics getNearestNodeGraphics()
Definition: scenepicker.hpp:152
int setSceneviewerRectangle(const Sceneviewer &sceneviewer, Scenecoordinatesystem scenecoordinatesystem, double x1, double y1, double x2, double y2)
Definition: scenepicker.hpp:106
Graphics getNearestGraphics()
Definition: scenepicker.hpp:162
A single finite element from a mesh.
Definition: element.hpp:34
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
Scenepicker createScenepicker()
Definition: scenepicker.hpp:252
Scenecoordinatesystem
Definition: scenecoordinatesystem.hpp:26
Scene getScene()
Definition: scenepicker.hpp:200
Container/manager for graphics visualising a region.
Definition: scene.hpp:38
Scenefilter getScenefilter()
Definition: scenepicker.hpp:221
Base graphics type: produces 3-D graphics visualising domains and fields.
Definition: graphics.hpp:45
cmzn_field_id getId() const
Definition: field.hpp:103
int getPickingVolumeCentre(double *coordinateValuesOut3)
Definition: scenepicker.hpp:245
int addPickedNodesToFieldGroup(const FieldGroup &fieldGroup)
Definition: scenepicker.hpp:189
cmzn_scene_id getId() const
Definition: scene.hpp:90
Graphics getNearestElementGraphics()
Definition: scenepicker.hpp:141
int setScene(const Scene &scene)
Definition: scenepicker.hpp:211
A generic group field used for grouping local subobjects.
Definition: fieldgroup.hpp:35
The OpenCMISS namespace.
Definition: context.hpp:20
Point object used to represent finite element nodes.
Definition: node.hpp:34
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:260
Element getNearestElement()
Definition: scenepicker.hpp:120
int setScenefilter(const Scenefilter &filter)
Definition: scenepicker.hpp:233
Node getNearestNode()
Definition: scenepicker.hpp:130
int addPickedElementsToFieldGroup(const FieldGroup &fieldGroup)
Definition: scenepicker.hpp:175