OpenCMISS-Zinc C++ API Documentation
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Pages
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 "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 
115  {
116  return static_cast<ChangeFlag>(cmzn_selectionevent_get_change_flags(id));
117  }
118 
119 };
120 
130 {
131 friend class Selectionnotifier;
132 private:
133  Selectioncallback(const Selectioncallback&); // not implemented
134  Selectioncallback& operator=(const Selectioncallback&); // not implemented
135 
136  static void C_callback(cmzn_selectionevent_id selectionevent_id, void *callbackVoid)
137  {
138  Selectionevent selectionevent(cmzn_selectionevent_access(selectionevent_id));
139  Selectioncallback *callback = reinterpret_cast<Selectioncallback *>(callbackVoid);
140  (*callback)(selectionevent);
141  }
142 
143  virtual void operator()(const Selectionevent &selectionevent) = 0;
144 
145 protected:
147  { }
148 
149 public:
150  virtual ~Selectioncallback()
151  { }
152 };
153 
161 {
162 protected:
163  cmzn_selectionnotifier_id id;
164 
165 public:
166 
167  Selectionnotifier() : id(0)
168  { }
169 
170  // takes ownership of C handle, responsibility for destroying it
171  explicit Selectionnotifier(cmzn_selectionnotifier_id in_selectionnotifier_id) :
172  id(in_selectionnotifier_id)
173  { }
174 
175  Selectionnotifier(const Selectionnotifier& selectionNotifier) :
176  id(cmzn_selectionnotifier_access(selectionNotifier.id))
177  { }
178 
179  Selectionnotifier& operator=(const Selectionnotifier& selectionNotifier)
180  {
181  cmzn_selectionnotifier_id temp_id = cmzn_selectionnotifier_access(selectionNotifier.id);
182  if (0 != id)
183  {
184  cmzn_selectionnotifier_destroy(&id);
185  }
186  id = temp_id;
187  return *this;
188  }
189 
191  {
192  if (0 != id)
193  {
194  cmzn_selectionnotifier_destroy(&id);
195  }
196  }
197 
203  bool isValid() const
204  {
205  return (0 != id);
206  }
207 
213  cmzn_selectionnotifier_id getId() const
214  {
215  return id;
216  }
217 
229  {
230  return cmzn_selectionnotifier_set_callback(
231  id, callback.C_callback, static_cast<void*>(&callback));
232  }
233 
241  {
242  return cmzn_selectionnotifier_clear_callback(id);
243  }
244 };
245 
246 } // namespace Zinc
247 }
248 
249 #endif
bool isValid() const
Definition: selection.hpp:203
bool isValid() const
Definition: selection.hpp:89
int setCallback(Selectioncallback &callback)
Definition: selection.hpp:228
Information about changes to the selection group in the scene.
Definition: selection.hpp:25
ChangeFlags getChangeFlags() const
Definition: selection.hpp:114
Manages individual user notification of changes to the selection group.
Definition: selection.hpp:160
int clearCallback()
Definition: selection.hpp:240
cmzn_selectionnotifier_id getId() const
Definition: selection.hpp:213
ChangeFlag
Definition: selection.hpp:47
Base class functor for Selection notifier callbacks:
Definition: selection.hpp:129
int ChangeFlags
Definition: selection.hpp:63
cmzn_selectionevent_id getId() const
Definition: selection.hpp:99