OpenCMISS-Zinc C++ API Documentation
selection.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_SELECTION_HPP__
10 #define CMZN_SELECTION_HPP__
11 
12 #include "opencmiss/zinc/selection.h"
13 
14 namespace OpenCMISS
15 {
16 namespace Zinc
17 {
18 
26 {
27 protected:
28  cmzn_selectionevent_id id;
29 
30 public:
31 
32  Selectionevent() : id(0)
33  { }
34 
35  // takes ownership of C handle, responsibility for destroying it
36  explicit Selectionevent(cmzn_selectionevent_id in_selection_event_id) :
37  id(in_selection_event_id)
38  { }
39 
40  Selectionevent(const Selectionevent& selectionEvent) :
41  id(cmzn_selectionevent_access(selectionEvent.id))
42  { }
43 
48  {
49  CHANGE_FLAG_NONE = CMZN_SELECTIONEVENT_CHANGE_FLAG_NONE,
51  CHANGE_FLAG_ADD = CMZN_SELECTIONEVENT_CHANGE_FLAG_ADD,
53  CHANGE_FLAG_REMOVE = CMZN_SELECTIONEVENT_CHANGE_FLAG_REMOVE,
55  CHANGE_FLAG_FINAL = CMZN_SELECTIONEVENT_CHANGE_FLAG_FINAL
57  };
58 
63  typedef int ChangeFlags;
64 
65  Selectionevent& operator=(const Selectionevent& selectionEvent)
66  {
67  cmzn_selectionevent_id temp_id = cmzn_selectionevent_access(selectionEvent.id);
68  if (0 != id)
69  {
70  cmzn_selectionevent_destroy(&id);
71  }
72  id = temp_id;
73  return *this;
74  }
75 
77  {
78  if (0 != id)
79  {
80  cmzn_selectionevent_destroy(&id);
81  }
82  }
83 
89  bool isValid() const
90  {
91  return (0 != id);
92  }
93 
99  cmzn_selectionevent_id getId() const
100  {
101  return id;
102  }
103 
112  ChangeFlags getChangeFlags() const
113  {
114  return static_cast<ChangeFlag>(cmzn_selectionevent_get_change_flags(id));
115  }
116 
117 };
118 
128 {
129 friend class Selectionnotifier;
130 private:
131  Selectioncallback(const Selectioncallback&); // not implemented
132  Selectioncallback& operator=(const Selectioncallback&); // not implemented
133 
134  static void C_callback(cmzn_selectionevent_id selectionevent_id, void *callbackVoid)
135  {
136  Selectionevent selectionevent(cmzn_selectionevent_access(selectionevent_id));
137  Selectioncallback *callback = reinterpret_cast<Selectioncallback *>(callbackVoid);
138  (*callback)(selectionevent);
139  }
140 
141  virtual void operator()(const Selectionevent &selectionevent) = 0;
142 
143 protected:
145  { }
146 
147 public:
148  virtual ~Selectioncallback()
149  { }
150 };
151 
159 {
160 protected:
161  cmzn_selectionnotifier_id id;
162 
163 public:
164 
165  Selectionnotifier() : id(0)
166  { }
167 
168  // takes ownership of C handle, responsibility for destroying it
169  explicit Selectionnotifier(cmzn_selectionnotifier_id in_selectionnotifier_id) :
170  id(in_selectionnotifier_id)
171  { }
172 
173  Selectionnotifier(const Selectionnotifier& selectionNotifier) :
174  id(cmzn_selectionnotifier_access(selectionNotifier.id))
175  { }
176 
177  Selectionnotifier& operator=(const Selectionnotifier& selectionNotifier)
178  {
179  cmzn_selectionnotifier_id temp_id = cmzn_selectionnotifier_access(selectionNotifier.id);
180  if (0 != id)
181  {
182  cmzn_selectionnotifier_destroy(&id);
183  }
184  id = temp_id;
185  return *this;
186  }
187 
189  {
190  if (0 != id)
191  {
192  cmzn_selectionnotifier_destroy(&id);
193  }
194  }
195 
201  bool isValid() const
202  {
203  return (0 != id);
204  }
205 
211  cmzn_selectionnotifier_id getId() const
212  {
213  return id;
214  }
215 
227  {
228  return cmzn_selectionnotifier_set_callback(
229  id, callback.C_callback, static_cast<void*>(&callback));
230  }
231 
239  {
240  return cmzn_selectionnotifier_clear_callback(id);
241  }
242 };
243 
244 } // namespace Zinc
245 }
246 
247 #endif
bool isValid() const
Definition: selection.hpp:201
bool isValid() const
Definition: selection.hpp:89
int setCallback(Selectioncallback &callback)
Definition: selection.hpp:226
Information about changes to the selection group in the scene.
Definition: selection.hpp:25
ChangeFlags getChangeFlags() const
Definition: selection.hpp:112
Manages individual user notification of changes to the selection group.
Definition: selection.hpp:158
int clearCallback()
Definition: selection.hpp:238
cmzn_selectionnotifier_id getId() const
Definition: selection.hpp:211
ChangeFlag
Definition: selection.hpp:47
Base class functor for Selection notifier callbacks:
Definition: selection.hpp:127
The OpenCMISS namespace.
Definition: context.hpp:20
int ChangeFlags
Definition: selection.hpp:63
cmzn_selectionevent_id getId() const
Definition: selection.hpp:99