diff --git a/BasePlugin/PluginFunctions.cc b/BasePlugin/PluginFunctions.cc index 9b44aa49d0a1b7646d185f3d4bb187945d540727..0e9d1387dd82b1e2f8e61de6b2fc3fcd7ba787e2 100644 --- a/BasePlugin/PluginFunctions.cc +++ b/BasePlugin/PluginFunctions.cc @@ -111,6 +111,10 @@ static ViewObjectMarker* defaultMarker_ = 0; */ static QGLWidget* shareGLWidget_ = 0; +/** This is a unique id for the running OpenFlipper instance. Use it to identify yourself on the network +*/ +static int viewerId_ = 0; + void setDataRoot( BaseObject* _root ) { objectRoot_ = _root; } @@ -119,9 +123,18 @@ int viewers( ) { return examiner_widgets_.size(); } +int viewerId() { + return viewerId_; +} + void setViewers( std::vector< glViewer* > _viewerWidgets ) { PluginFunctions::examiner_widgets_ = _viewerWidgets; PluginFunctions::examiner_widget_ = examiner_widgets_[0]; + + // Generate a (hopefully) unique viewer id + QTime time = QTime::currentTime(); + qsrand( time.hour() * 10 + time.minute() * 100 + time.second() * 1000 + time.msec() * 10000 ); + viewerId_ = qrand(); } void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProperties ) { diff --git a/BasePlugin/PluginFunctions.hh b/BasePlugin/PluginFunctions.hh index f3d5c3530803812a25ad0302b88bea69d14ad0b4..16cb78bcaec7c7a278896c73f4126feb1eb3ef43 100644 --- a/BasePlugin/PluginFunctions.hh +++ b/BasePlugin/PluginFunctions.hh @@ -556,6 +556,15 @@ BaseObjectData* baseObjectData( BaseObject* _object ); /** @} */ + +/** \brief Return unique viewer id + * + * This function returns a id which is unique to all running Openflippers on that machine. + * This id changes when you restart the viewer! + */ +DLLEXPORT +int viewerId(); + /// Get the root of the object structure DLLEXPORT BaseObject*& objectRoot();