VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
selectionGroupManager.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2013 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 
8 #pragma once
9 
10 #include <vrvUtil/signalslib.h>
11 #include <vrfGuiCore/vrfGuiCore.h>
16 #include <vrvCore/DtElementData.h>
17 #include <vrvCore/DtUniqueID.h>
20 #include <vrvCore/DtStateView.h>
21 #include <vrvCore/DtEntityState.h>
22 #include <vrfutil/rwUUID.h>
23 
24 #include <map>
25 #include <set>
26 
27 #include <boost/archive/xml_iarchive.hpp>
28 #include <boost/archive/xml_oarchive.hpp>
29 #include <boost/serialization/access.hpp>
30 #include <boost/serialization/nvp.hpp>
31 #include <boost/serialization/list.hpp>
32 #include <boost/serialization/map.hpp>
33 #include <boost/serialization/vector.hpp>
34 #include <boost/serialization/string.hpp>
35 
36 #include <vlutil/vlSmartPointers.h>
37 
38 namespace makVrv
39 {
40  class DtDe;
41 }
42 
43 class DtSimMessage;
44 
45 namespace makVrf
46 {
49 
54  {
55  public:
56  typedef std::set<DtUUID> GroupItems;
57  typedef std::map<std::string, GroupItems> SelectionGroups;
58 
59  public:
62 
64  virtual ~DtSelectionGroupManager();
65 
66  static DtSelectionGroupManager& instance(makVrv::DtDe& de);
67  static void registerInstance(makVrv::DtDe& de, DtSelectionGroupManager*);
68 
70  virtual void createSelectionGroup(const std::string&, bool signal = true);
71 
75  virtual void createSelectionGroupFromCurrentSelection(const std::string& groupName, bool select = false);
76 
78  virtual void clearSelectionGroup(const std::string&);
79 
81  virtual void removeSelectionGroup(const std::string&);
82 
84  virtual bool hasSelectionGroup(const std::string&) const;
85 
88  virtual void renameSelectionGroup(const std::string& from, const std::string& to);
89 
91  virtual void addItemToSelectionGroup(const std::string&, const DtUUID&, bool signal = true);
92 
94  virtual bool atLeastOneItemNotInSelectionGroup(const std::string&, const GroupItems& names) const;
95  virtual bool atLeastOneItemNotInSelectionGroup(const std::string&, const std::vector<DtUUID>& names) const;
96 
98  virtual bool anyItemsInSelectionGroup(const std::string&, const GroupItems& names) const;
99  virtual bool anyItemsInSelectionGroup(const std::string&, const std::vector<DtUUID>& names) const;
100 
102  virtual void addItemsToSelectionGroup(const std::string&, const GroupItems& names, bool signal = true);
103  virtual void addItemsToSelectionGroup(const std::string&, const std::vector<DtUUID>& names, bool signal = true);
104 
106  virtual bool itemInAnySelectionGroup(const DtUUID&) const;
107 
109  virtual void removeItemFromSelectionGroup(const std::string&, const DtUUID&);
110 
112  virtual void removeItemsFromSelectionGroup(const std::string&, const GroupItems& names);
113  virtual void removeItemsFromSelectionGroup(const std::string&, const std::vector<DtUUID>& names);
114 
116  virtual const SelectionGroups& selectionGroups() const;
117 
119  virtual bool load(const std::string&);
120 
122  virtual bool save(const std::string&);
123 
125  virtual std::string toStringBuffer();
126 
128  virtual bool fromStringBuffer(const std::string&);
129 
131  virtual void removeAll();
132 
134  virtual GroupItems itemsInSelectionGroup(const std::string&) const;
135 
137  virtual bool itemIsInSelectionGroup(const std::string& group, const DtUUID&) const;
138 
141  virtual void selectItemsInSelectionGroup(const std::string&);
142 
144  virtual const std::string& selectedSelectionGroup() const;
145 
147  virtual void processCreateSelectionGroup(DtSimMessage*);
148 
151  virtual bool canRenameSelectionGroup(const std::string&) const;
152 
154  virtual void allScenarioObjectsDiscovered();
155 
156  public:
161  boost::signal<void (std::string)> signal_selectionGroupAdded;
162 
164  boost::signal<void (std::string, std::string)> signal_selectionGroupRenamed;
165 
167  boost::signal<void (std::string)> signal_selectionGroupRemoved;
168 
170  boost::signal<void (std::string)> signal_selectionGroupCleared;
171 
173  boost::signal<void (std::string, GroupItems)> signal_itemsAddedToSelectionGroup;
174 
176  boost::signal<void (std::string, GroupItems)> signal_itemsRemovedFromSelectionGroup;
177 
179  boost::signal<void (DtUUID)> signal_itemRemovedFromGroups;
180 
182  boost::signal<void ()> signal_loading;
183 
185  boost::signal<void ()> signal_loaded;
186 
188  boost::signal<void ()> signal_selectionGroupsCleared;
189 
191  boost::signal<void (std::string, std::string)> signal_itemRenamed;
192 
194  boost::signal<void (std::string)> signal_selectionGroupSelected;
195 
197 
198  protected:
201  virtual void slot_stateRemoved(const makVrv::DtStateView<makVrv::DtVrlinkSimulatedBaseState>*);
202 
203  protected:
204  friend class boost::serialization::access;
205 
209  template<class Archive>
210  void serialize(Archive & ar, const unsigned int version)
211  {
212  if (version >= 2)
213  {
214  ar & BOOST_SERIALIZATION_NVP(mySelectionGroupsUUID);
215  }
216  else
217  {
218  typedef std::set<std::string> OldGroupItems;
219  typedef std::map<std::string, OldGroupItems> OldSelectionGroups;
220 
221  OldSelectionGroups mySelectionGroups;
222 
223  ar & BOOST_SERIALIZATION_NVP(mySelectionGroups);
224 
225  if (Archive::is_loading::value)
226  {
227  OldSelectionGroups::const_iterator iter = mySelectionGroups.begin();
228  bool hasItems = false;
229 
230  while (iter != mySelectionGroups.end())
231  {
232  GroupItems newGroupItems;
233  OldGroupItems::const_iterator oldIter = iter->second.begin();
234 
235  while (oldIter != iter->second.end())
236  {
237  DtUUID uuid(DtUUID::nullUUID());
238 
239  uuid.setStringUUID(*oldIter);
240  newGroupItems.insert(uuid);
241  ++oldIter;
242  }
243 
244  hasItems |= (newGroupItems.size() != 0);
245  mySelectionGroupsUUID[iter->first] = newGroupItems;
246  ++iter;
247  }
248 
249  if (hasItems)
250  {
251  myWaitingForDiscovery = true;
252  }
253  }
254  }
255  }
256 
257  protected:
263  };
264 
268  {
269  public:
272 
274  virtual ~DtVrfSelectionGroupFilter();
275 
276  protected:
277  virtual DtVrfSelectionFilter* clone() const;
278 
279  virtual void setForce(int)
280  {
281  };
282 
283  virtual bool isValid(const makVrv::DtVrlinkSimulatedBaseState*, const DtVrfObjectDataState* = 0) const;
284 
285  protected:
287  };
288 }
289 

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)