1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
#ifndef OSGINVOKER_H_H6T4R8HU
#define OSGINVOKER_H_H6T4R8HU
#include <uscxml/Interpreter.h>
#include <DOM/Events/MutationEvent.hpp>
#include <DOM/Events/EventListener.hpp>
#include <DOM/Events/Event.hpp>
#include "CompositeDisplay.h"
#include <osg/MatrixTransform>
#include <osgDB/ReadFile>
#include <set>
#ifdef BUILD_AS_PLUGINS
#include "uscxml/plugins/Plugins.h"
#endif
namespace uscxml {
class OSGInvoker : public InvokerImpl, public Arabica::DOM::Events::EventListener<std::string> {
public:
OSGInvoker();
virtual ~OSGInvoker();
virtual boost::shared_ptr<IOProcessorImpl> create(Interpreter* interpreter);
virtual std::set<std::string> getNames() {
std::set<std::string> names;
names.insert("3d");
names.insert("scenegraph");
names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#3d");
return names;
}
virtual Data getDataModelVariables();
virtual void send(const SendRequest& req);
virtual void cancel(const std::string sendId);
virtual void invoke(const InvokeRequest& req);
virtual void handleEvent(Arabica::DOM::Events::Event<std::string>& event);
virtual void runOnMainThread();
protected:
void processDisplay(const Arabica::DOM::Node<std::string>& element);
void updateDisplay(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
void processViewport(const Arabica::DOM::Node<std::string>& element);
void updateViewport(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
void processCamera(const Arabica::DOM::Node<std::string>& element);
void updateCamera(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
void processTranslation(const Arabica::DOM::Node<std::string>& element);
void updateTranslation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
void processRotation(const Arabica::DOM::Node<std::string>& element);
void updateRotation(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
static osg::Matrix rotationFromElement(const Arabica::DOM::Node<std::string>& element);
void processScale(const Arabica::DOM::Node<std::string>& element);
void updateScale(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
void processNode(const Arabica::DOM::Node<std::string>& element);
void updateNode(osg::Node* node, Arabica::DOM::Events::Event<std::string>& event);
void processChildren(const std::set<std::string>& validChildren, const Arabica::DOM::Node<std::string>& element);
void getViewport(const Arabica::DOM::Node<std::string>& element,
unsigned int& x,
unsigned int& y,
unsigned int& width,
unsigned int& height,
int& screenId);
void getViewport(const Arabica::DOM::Node<std::string>& element,
unsigned int& x,
unsigned int& y,
unsigned int& width,
unsigned int& height,
CompositeDisplay* display);
void getViewport(const Arabica::DOM::Node<std::string>& element,
unsigned int& x,
unsigned int& y,
unsigned int& width,
unsigned int& height,
unsigned int fullWidth,
unsigned int fullHeight);
osgViewer::View* getView(const Arabica::DOM::Node<std::string>& element);
std::map<Arabica::DOM::Node<std::string>, CompositeDisplay*> _displays;
typedef std::map<Arabica::DOM::Node<std::string>, CompositeDisplay*> _displays_t;
std::map<Arabica::DOM::Node<std::string>, osgViewer::View*> _views;
typedef std::map<Arabica::DOM::Node<std::string>, osgViewer::View*> _views_t;
std::map<Arabica::DOM::Node<std::string>, osg::Node*> _nodes;
typedef std::map<Arabica::DOM::Node<std::string>, osg::Node*> _nodes_t;
tthread::recursive_mutex _mutex;
};
#ifdef BUILD_AS_PLUGINS
PLUMA_INHERIT_PROVIDER(OSGInvoker, InvokerImpl);
#endif
}
#endif /* end of include guard: OSGINVOKER_H_H6T4R8HU */
|