Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9e05119
* Refactored directory structure to hide away different Screen types …
johnmangan Jul 15, 2013
fab6fa6
* Added classes for the Observer pattern (labeled as Listener/Shouter…
johnmangan Jul 17, 2013
471e6fa
* Adding CDBApp project to CalVR in support of creating the CvrState …
johnmangan Jul 17, 2013
5a0bbbb
* Added the DatabaseHandler and StateManager classes.
johnmangan Jul 19, 2013
c2e66ff
Merge branch 'master' of https://github.com/CalVR/calvr into collab
johnmangan Jul 19, 2013
d90c400
* Updated cdbapp component references to use the cdb namespace.
johnmangan Jul 22, 2013
60535ba
* Fixed side-effects caused by asserts in CvrState.
johnmangan Aug 12, 2013
5e262b8
* Added the MetadataState class.
johnmangan Aug 12, 2013
da8db2c
* FileLoaderCallbacks are no longer meant to register scene objects n…
johnmangan Aug 26, 2013
97a6480
* Scoped recent files under the cvr namespace.
johnmangan Sep 6, 2013
acd00ed
* Added the SpatialState class.
johnmangan Sep 6, 2013
311418f
* Incorporated SpatialStates into SceneObjects.
johnmangan Sep 6, 2013
ec78aa4
Merge branch 'master' into collab
johnmangan Sep 6, 2013
8532693
* Refactored the StateManager into a Singleton.
johnmangan Sep 9, 2013
bcdc200
* Removed compiler warnings.
johnmangan Sep 11, 2013
a16076b
* Slight refactorings of StateManager to fit CalVR manager templates.
johnmangan Sep 13, 2013
458e920
* Added the public, static Register function to SpatialState.
johnmangan Sep 13, 2013
51d749c
* Added the CollaborationState class.
johnmangan Sep 13, 2013
50e7fc9
* Updated the SceneObject class to incorporate the notion of a Collab…
johnmangan Sep 13, 2013
abe5ce8
* Updated FileHandler and SceneManager to handle collaborative sessio…
johnmangan Sep 13, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions CMakeModules/FindCDBAPP.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FIND_PATH(CDBAPP_INCLUDE_DIR cdbapp/ApplicationDatabaseInterface.h
PATHS
$ENV{CDBAPP_HOME}
NO_DEFAULT_PATH
PATH_SUFFIXES include
)

FIND_PATH(CDBAPP_INCLUDE_DIR cdbapp/ApplicationDatabaseInterface.h
PATHS
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
)

FIND_LIBRARY(CDBAPP_LIBRARY
NAMES cdbapp
PATHS $ENV{CDBAPP_HOME}
NO_DEFAULT_PATH
PATH_SUFFIXES lib64 lib
)
FIND_LIBRARY(CDBAPP_LIBRARY
NAMES cdbapp
PATHS
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
/usr/freeware
PATH_SUFFIXES lib64 lib
)

SET(CDBAPP_FOUND "NO")
IF(CDBAPP_LIBRARY AND CDBAPP_INCLUDE_DIR)
SET(CDBAPP_FOUND "YES")
ENDIF(CDBAPP_LIBRARY AND CDBAPP_INCLUDE_DIR)
2 changes: 2 additions & 0 deletions include/cvrKernel/CalVR.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class MenuManager;
class FileHandler;
class PluginManager;
class ThreadedLoader;
class StateManager;

/**
* @addtogroup kernel cvrKernel
Expand Down Expand Up @@ -124,6 +125,7 @@ class CVRKERNEL_EXPORT CalVR
FileHandler * _file;
PluginManager * _plugins;
ThreadedLoader * _threadedLoader;
StateManager * _stateManager;
};

/**
Expand Down
71 changes: 71 additions & 0 deletions include/cvrKernel/DatabaseHandler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* DatabaseHandler.h
*
* Used to send and receive states between a collaboration server and CalVR.
*
* Created on: Apr 29, 2012
* Author: John Mangan <jmangan@eng.ucsd.edu>
*
* CalVR Port: Jul 16, 2013
* Author: John Mangan <jmangan@eng.ucsd.edu>
*/

#ifndef DATABASE_HANDLER_H_
#define DATABASE_HANDLER_H_

#include <string>
#include <map>
#include <list>
#include <stdint.h>

#include <cdbapp/ApplicationDatabaseInterface.h>
#include <cvrKernel/States/CvrState.h>

namespace cvr {

class DatabaseHandler : public Listener<CvrState>
{
public:

void
Connect(std::string const& connectionAddress);

void
Disconnect(void);

bool
LoadStateChanges( std::list< std::string >& loadedStates );

void
SendHeardStates(void);

protected:

/* Hearing CvrStates (External concepts):
* - Store CvrState as a JSON string to be passed to the the collaboration server (database).
*/
void
Hear(CvrState* cvrState);

cdb::ApplicationDatabaseInterface mDatabase;
uint64_t mLastLoadTimestep;
std::map< std::string, std::string > mHeardStates;

};

inline void
DatabaseHandler::Connect(std::string const& connectionAddress)
{
mDatabase.Connect(connectionAddress);
mLastLoadTimestep = 0;
}

inline void
DatabaseHandler::Disconnect(void)
{
mDatabase.Disconnect();
}

}

#endif /* DATABASE_HANDLER_H_ */
30 changes: 23 additions & 7 deletions include/cvrKernel/FileHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
namespace cvr
{

class SceneObject;
class MetadataState;

class CVRKERNEL_EXPORT FileLoadCallback;

// TODO: add unload function call
Expand All @@ -38,14 +41,25 @@ class CVRKERNEL_EXPORT FileHandler

/**
* @brief try to load a file
* @param file file to load
* @return true if file is loaded
* @param file filepath of file to load
* @return NULL if file could not be loaded, SceneObject* otherwise that is neither registered nor attached to the scene
*
* Will determine if the extension is registered with a callback and attempt
* to load with it. If callback not present, or fails, osg readNodeFile is tried
* and the result is attached to the object root.
* and the result is attached to a SceneObject.
*/
bool loadFile(std::string file);
SceneObject* loadFile(std::string file);

/**
* @brief try to load a file
* @param metadata MetadataState containing data of the file to load
* @return NULL if file could not be loaded, SceneObject* otherwise that is neither registered nor attached to the scene
*
* Will determine if the extension is registered with a callback and attempt
* to load with it. If callback not present, or fails, osg readNodeFile is tried
* and the result is attached to a SceneObject.
*/
SceneObject* loadFile(MetadataState* metadata);

/**
* @brief register a callback for when a file with a certain extension is loaded
Expand All @@ -71,12 +85,14 @@ class CVRKERNEL_EXPORT FileHandler

static FileHandler * _myPtr; ///< static self pointer

SceneObject* loadFileDriver(std::string file);

std::map<std::string,FileLoadCallback *> _extMap; ///< map of file extension to callback
};

/**
* @brief Interface class to receive a callback from the FileHandler when a file with a certain
* extension is being loaded
* extension is being loaded.
*/
class CVRKERNEL_EXPORT FileLoadCallback
{
Expand All @@ -90,9 +106,9 @@ class CVRKERNEL_EXPORT FileLoadCallback
virtual ~FileLoadCallback();

/**
* @brief function called when a file with a registered extension is loaded
* @brief function called when a file with a registered extension is loaded. It is expected that the returned SceneObject is neither registered nor attached to the scene.
*/
virtual bool loadFile(std::string file) = 0;
virtual SceneObject* loadFile(std::string file) = 0;
private:
std::vector<std::string> _exts; ///< list of extensions registed to this callback
};
Expand Down
13 changes: 12 additions & 1 deletion include/cvrKernel/SceneManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#include <cvrKernel/Export.h>
#include <cvrUtil/DepthPartitionNode.h>
#include <cvrKernel/States/CvrState.h>
#include <cvrUtil/Listener.h>
#include <cvrKernel/FileHandler.h>

#include <osg/ClipNode>
#include <osg/MatrixTransform>
Expand Down Expand Up @@ -58,7 +61,7 @@ template <typename T> class VectorWithPosition : public std::vector <T>
/**
* @brief Creates and manages the main scenegraph
*/
class CVRKERNEL_EXPORT SceneManager
class CVRKERNEL_EXPORT SceneManager : public Listener<CvrState>
{
friend class CVRViewer;
friend class CVRPlugin;
Expand Down Expand Up @@ -284,6 +287,9 @@ class CVRKERNEL_EXPORT SceneManager

bool getPointOnTiledWall(const osg::Matrix & mat, osg::Vec3 & wallPoint);

friend SceneObject* FileHandler::loadFile(std::string);
friend SceneObject* FileHandler::loadFile(MetadataState*);

protected:
SceneManager();

Expand All @@ -305,6 +311,8 @@ class CVRKERNEL_EXPORT SceneManager
void preDraw();
void postDraw();

void Hear(CvrState* cvrstate);

static SceneManager * _myPtr; ///< static self pointer

bool _showAxis; ///< should debug axis be shown
Expand Down Expand Up @@ -337,6 +345,9 @@ class CVRKERNEL_EXPORT SceneManager
bool _uniqueMapInUse;
std::map<std::string,std::vector<SceneObject*> > _pluginObjectMap; ///< set of all registered SceneObjects grouped by plugin name

std::map< std::string, SceneObject* > _metadataToSceneObjects;
std::map< std::string, std::set< std::string > > _metaOrphans;

float _menuScale;
float _menuMinDistance;
float _menuMaxDistance;
Expand Down
58 changes: 55 additions & 3 deletions include/cvrKernel/SceneObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
#include <cvrMenu/PopupMenu.h>
#include <cvrKernel/SceneManager.h>
#include <cvrKernel/InteractionManager.h>
#include <cvrKernel/States/CvrState.h>
#include <cvrUtil/Listener.h>

#include <osg/MatrixTransform>
#include <osg/Geode>
#include <osg/Matrix>
#include <osg/BoundingBox>

#include <set>
#include <string>
#include <iostream>

Expand All @@ -23,6 +26,9 @@ namespace cvr

class MenuCheckbox;
class MenuRangeValue;
class MetadataState;
class SpatialState;
class CollaborationState;

/**
* @addtogroup kernel
Expand All @@ -34,7 +40,7 @@ class MenuRangeValue;
*
* Handles movement, navigation and interaction. These objects can be nested.
*/
class CVRKERNEL_EXPORT SceneObject : public MenuCallback
class CVRKERNEL_EXPORT SceneObject : public MenuCallback, public Listener<CvrState>
{
friend class SceneManager;
public:
Expand Down Expand Up @@ -95,6 +101,17 @@ class CVRKERNEL_EXPORT SceneObject : public MenuCallback
*/
void setMovable(bool mov);


/**
* @brief Get if this object shoudl be collaborated.
*/
bool getCollaborate();

/**
* @brief Set if this object shoudl be collaborated.
*/
void setCollaborate(bool collab);

/**
* @brief Get if this object is clippable
*/
Expand Down Expand Up @@ -271,6 +288,18 @@ class CVRKERNEL_EXPORT SceneObject : public MenuCallback
*/
void removeNavigationMenuItem();

/**
* @brief Add a MenuCheckbox to this object's context menu that toggles
* if this object is collaborative
* @param label Label to use for the MenuItem
*/
void addCollaborateMenuItem(std::string label = "Collaborate");

/**
* @brief Remove collaborate MenuCheckbox if it has been added to the context menu
*/
void removeCollaborateMenuItem();

/**
* @brief Add a MenuRangeValue to this object's context menu that controls the scale
* of the object
Expand Down Expand Up @@ -394,6 +423,16 @@ class CVRKERNEL_EXPORT SceneObject : public MenuCallback
*/
void closeMenu();

void addCvrState( CvrState* const state );

void removeCvrState( CvrState* const state );

std::set< CvrState* > getCvrStatesByType( std::string type );

MetadataState* getMetadataState(void);
SpatialState* getSpatialState(void);
CollaborationState* getCollaborationState(void);

protected:
bool getRegistered()
{
Expand Down Expand Up @@ -426,6 +465,17 @@ class CVRKERNEL_EXPORT SceneObject : public MenuCallback
void updateBoundsGeometry();
void updateMatrices();
void splitMatrix();
void checkAndUpdateNavigation();
void checkAndUpdateCollaboration();

/**
* @brief If it hears it's own SpatialState, it overrides all spatial
* with the newly heard state.
*/
void Hear(CvrState* cvrstate);

SpatialState* getOrCreateSpatialState(void);
CollaborationState* getOrCreateCollaborationState(void);

void interactionCountInc();
void interactionCountDec();
Expand All @@ -435,25 +485,25 @@ class CVRKERNEL_EXPORT SceneObject : public MenuCallback
osg::ref_ptr<osg::MatrixTransform> _boundsTransform;
osg::ref_ptr<osg::Geode> _boundsGeode;
osg::ref_ptr<osg::Geode> _boundsGeodeActive;
osg::Matrix _transMat, _scaleMat;

osg::Matrix _obj2root, _root2obj;
osg::Matrix _invTransform;

PopupMenu * _myMenu;
MenuCheckbox * _moveMenuItem;
MenuCheckbox * _navMenuItem;
MenuCheckbox * _collabMenuItem;
MenuRangeValue * _scaleMenuItem;

std::string _name;
bool _navigation;
bool _movable;
bool _clip;
bool _contextMenu;
bool _showBounds;
bool _registered;
bool _attached;
bool _eventActive;
bool _collaborated;

int _moveButton;
int _menuButton;
Expand All @@ -474,6 +524,8 @@ class CVRKERNEL_EXPORT SceneObject : public MenuCallback
SceneObject * _parent;

int _interactionCount;

std::map< std::string, std::set< CvrState* > > _cvrStates;
};

/**
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef CALVR_SCREEN_FIXED_VIEWER_H
#define CALVR_SCREEN_FIXED_VIEWER_H

#include <cvrKernel/ScreenBase.h>
#include <cvrKernel/Screens/ScreenBase.h>

namespace cvr
{
Expand Down
Loading