OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
coVRCollaboration.h
Go to the documentation of this file.
1 /* This file is part of COVISE.
2 
3  You can use it under the terms of the GNU Lesser General Public License
4  version 2.1 or later, see lgpl-2.1.txt.
5 
6  * License: LGPL 2+ */
7 
8 #ifndef VR_COLLABORATION_H
9 #define VR_COLLABORATION_H
10 
24 #include <util/coExport.h>
25 #include <util/common.h>
26 #include <set>
27 #include <osg/Matrix>
28 #include <vrbclient/SharedState.h>
29 #include "ui/Owner.h"
30 #include "MatrixSerializer.h"
31 
32 namespace osg
33 {
34 class Group;
35 }
36 
37 namespace opencover
38 {
39 
40 namespace ui
41 {
42 class Group;
43 class Menu;
44 class Button;
45 class Slider;
46 class SelectionList;
47 class Action;
48 }
49 
50 
51 class COVEREXPORT coVRCollaboration: public ui::Owner
52 {
53  static coVRCollaboration *s_instance;
55 
56 public:
57  enum SyncMode
58  {
61  TightCoupling
62  };
63 
64 private:
65  int readConfigFile();
66  void initCollMenu();
67  void setSyncInterval();
68  std::set<int> m_sessions;
69  bool syncXform = false;
70  bool syncScale = false;
71  bool wasLo = false;
72  float syncInterval;
73  bool oldMasterStatus = true;
74  float oldSyncInterval = -1;
75  bool oldAvatarVisibility = true;
76 
77 public:
78  virtual ~coVRCollaboration();
79  void config();
80  void showCollaborative(bool visible);
81  static coVRCollaboration *instance();
82  bool showAvatar;
86  float getSyncInterval();
87  // returns collaboration mode
88  SyncMode getSyncMode() const;
89 
90  void setSyncMode(const char *mode); // set one of "LOOSE", "MS", "TIGHT"
91 
92  void updateSharedStates(bool force = false);
93  // returns true if this COVER ist master in a collaborative session
94  bool isMaster();
95  // Collaborative menu:
96  bool m_visible = false;
97  ui::Menu *m_collaborativeMenu = nullptr;
98  ui::Group *m_partnerGroup = nullptr;
99  ui::Button *m_showAvatar = nullptr;
100  ui::Button *m_master = nullptr;
101  ui::Action *m_returnToMaster = nullptr;
102  ui::Slider *m_syncInterval = nullptr;
103  ui::SelectionList *m_collaborationMode = nullptr;
104  ui::Menu *menu() const;
105  ui::Group *partnerGroup() const;
106 
107  bool updateCollaborativeMenu();
108  void syncModeChanged(int mode);
109  void init();
110 
111  bool update();
112 
113  void SyncXform();
114  void UnSyncXform();
115  void SyncScale();
116  void UnSyncScale();
117  void sessionChanged(bool isPrivate);
118  void remoteTransform(osg::Matrix &mat);
119  void remoteScale(float d);
120 };
121 }
122 #endif
bool showAvatar
Definition: coVRCollaboration.h:82
Definition: coVRCollaboration.h:59
vrb::SharedState< osg::Matrix > avatarPosition
0: LooseCoupling, 1: MasterSlaveCoupling, 2 TightCoupling
Definition: coVRCollaboration.h:84
Definition: coVRCollaboration.h:51
vrb::SharedState< int > syncMode
Definition: coVRCollaboration.h:83
Definition: coVRCollaboration.h:60
SyncMode
Definition: coVRCollaboration.h:57
vrb::SharedState< float > scaleFactor
Definition: coVRCollaboration.h:85