/** * @file * @author 2012-2013 Stefan Radomski (stefan.radomski@cs.tu-darmstadt.de) * @copyright Simplified BSD * * @cond * This program is free software: you can redistribute it and/or modify * it under the terms of the FreeBSD license as published by the FreeBSD * project. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * You should have received a copy of the FreeBSD license along with this * program. If not, see . * @endcond */ #ifndef OSGINVOKER_H_H6T4R8HU #define OSGINVOKER_H_H6T4R8HU #include #include #include #include #include "CompositeDisplay.h" #include #include #include #include #ifdef BUILD_AS_PLUGINS #include "uscxml/plugins/Plugins.h" #endif namespace uscxml { class OSGInvoker : public InvokerImpl, public Arabica::DOM::Events::EventListener { public: OSGInvoker(); virtual ~OSGInvoker(); virtual boost::shared_ptr create(InterpreterImpl* interpreter); virtual std::list getNames() { std::list names; names.push_back("3d"); names.push_back("scenegraph"); names.push_back("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& event); virtual void runOnMainThread(); protected: void processDisplay(const Arabica::DOM::Element& element); void updateDisplay(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processViewport(const Arabica::DOM::Element& element); void updateViewport(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processCamera(const Arabica::DOM::Node& element); void updateCamera(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processTranslation(const Arabica::DOM::Element& element); void updateTranslation(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processRotation(const Arabica::DOM::Element& element); void updateRotation(osg::ref_ptr node, Arabica::DOM::Events::Event& event); static osg::Matrix rotationFromElement(const Arabica::DOM::Element& element); void processScale(const Arabica::DOM::Element& element); void updateScale(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processNode(const Arabica::DOM::Element& element); void updateNode(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processSphere(const Arabica::DOM::Element& element); void updateSphere(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processBox(const Arabica::DOM::Element& element); void updateBox(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processCapsule(const Arabica::DOM::Element& element); void updateCapsule(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processCone(const Arabica::DOM::Element& element); void updateCone(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processCylinder(const Arabica::DOM::Element& element); void updateCylinder(osg::ref_ptr node, Arabica::DOM::Events::Event& event); osg::Vec4 getColor(const Arabica::DOM::Element& element, const std::string& attr, bool& valid); osg::ref_ptr getMaterial(const Arabica::DOM::Element& element); osg::Vec4 parseVec4(const std::string& coeffs, int& number); void processChildren(const std::set& validChildren, const Arabica::DOM::Node& element); void getViewport(const Arabica::DOM::Element& element, unsigned int& x, unsigned int& y, unsigned int& width, unsigned int& height, int& screenId); void getViewport(const Arabica::DOM::Element& element, unsigned int& x, unsigned int& y, unsigned int& width, unsigned int& height, CompositeDisplay* display); void getViewport(const Arabica::DOM::Element& 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& element); std::map, CompositeDisplay*> _displays; typedef std::map, CompositeDisplay*> _displays_t; std::map, osgViewer::View*> _views; typedef std::map, osgViewer::View*> _views_t; std::map, osg::ref_ptr > _nodes; typedef std::map, osg::ref_ptr > _nodes_t; void setupColors(); std::map _colors; typedef std::map _colors_t; tthread::recursive_mutex _mutex; }; #ifdef BUILD_AS_PLUGINS PLUMA_INHERIT_PROVIDER(OSGInvoker, InvokerImpl); #endif } #endif /* end of include guard: OSGINVOKER_H_H6T4R8HU */