[32] | 1 | #pragma once |
---|
| 2 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer |
---|
| 3 | * |
---|
| 4 | * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under |
---|
| 5 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
---|
| 6 | * (at your option) any later version. The full license is in LICENSE file |
---|
| 7 | * included with this distribution, and on the openscenegraph.org website. |
---|
| 8 | * |
---|
| 9 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
| 10 | * You have to aquire licenses for all used proprietary modules. |
---|
| 11 | * |
---|
| 12 | * This library is distributed in the hope that it will be useful, |
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | * OpenSceneGraph Public License for more details. |
---|
| 16 | */ |
---|
| 17 | |
---|
[155] | 18 | // Vista 2D |
---|
[32] | 19 | #include "VistaView.h" |
---|
| 20 | |
---|
[155] | 21 | // C++ libraries |
---|
[153] | 22 | #include <string> |
---|
| 23 | |
---|
[155] | 24 | // XML Parser |
---|
| 25 | #include <stdio.h> |
---|
| 26 | #include <libxml/parser.h> |
---|
| 27 | #include <libxml/tree.h> |
---|
| 28 | |
---|
| 29 | // OSG Includes |
---|
[32] | 30 | #include <osg/Drawable> |
---|
| 31 | #include <osg/Geode> |
---|
| 32 | #include <osg/Projection> |
---|
| 33 | #include <osg/MatrixTransform> |
---|
| 34 | #include <osg/CoordinateSystemNode> |
---|
| 35 | |
---|
| 36 | #include <osgDB/FileUtils> |
---|
| 37 | |
---|
[155] | 38 | // osgVisual Includes |
---|
| 39 | #include <visual_util.h> |
---|
[32] | 40 | |
---|
| 41 | namespace osgVisual |
---|
| 42 | { |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | * \brief This class integrates Vista2D by Wetzel Technology into OSG. |
---|
| 46 | * |
---|
| 47 | * It wraps vista2D's OpenGL interface to be usable as a standart OSG Node. The Vista2D nodekit performs auto-linking |
---|
| 48 | * againt the Vista2D library, therefore only three shared libraries have to be copied to the binary folder of the project. |
---|
| 49 | * |
---|
| 50 | * Vista2D ist a software to design HID. This Nodekit enables OSG to display Vista2D project files. |
---|
| 51 | * |
---|
| 52 | * Please copy the following files to the binary folder of you application if you intend to use this nodekit: |
---|
| 53 | * libView.dll |
---|
| 54 | * fontLib.dll |
---|
| 55 | * freetype6.dll |
---|
| 56 | * |
---|
| 57 | * The implementation of this class is based on osg::Drawable. The drawimplementations contains the Vista2D wrap. |
---|
| 58 | * |
---|
| 59 | * @author Torben Dannhauer |
---|
| 60 | * @date Sep 2009 |
---|
| 61 | */ |
---|
| 62 | class visual_vista2D : public osg::Drawable |
---|
| 63 | { |
---|
| 64 | public: |
---|
| 65 | /** |
---|
| 66 | * \brief Construtor: Creates a Vista2D environment which should be wrapt by this node. |
---|
| 67 | * |
---|
| 68 | */ |
---|
| 69 | visual_vista2D(void); |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | * \brief Empty destructor. |
---|
| 73 | * |
---|
| 74 | */ |
---|
| 75 | ~visual_vista2D(void); |
---|
| 76 | |
---|
| 77 | /** |
---|
| 78 | * \brief This static function must be called to instantiate a vista2D project. |
---|
| 79 | * |
---|
| 80 | * @param vista2DFilename_ : Vista2D project file to display. |
---|
| 81 | * @param sceneGraphRoot_ : Scenegraph to add the vista2D note as child. |
---|
| 82 | * @return : True if successful. |
---|
| 83 | */ |
---|
[156] | 84 | bool init( osg::CoordinateSystemNode *sceneGraphRoot_, std::string configFileName ); |
---|
[32] | 85 | |
---|
| 86 | /** |
---|
| 87 | * \brief This function is requiered by subclassing osg::Drawable. |
---|
| 88 | * |
---|
| 89 | * @return : Cloned object. |
---|
| 90 | */ |
---|
| 91 | osg::Object* cloneType() const; |
---|
| 92 | |
---|
| 93 | /** |
---|
| 94 | * \brief This function is requiered by subclassing osg::Drawable. |
---|
| 95 | * |
---|
| 96 | * @param : Copyoperator how to copy the object |
---|
| 97 | * @return : Cloned object. |
---|
| 98 | */ |
---|
| 99 | osg::Object* clone(const osg::CopyOp&) const; |
---|
| 100 | |
---|
| 101 | private: |
---|
[153] | 102 | |
---|
[156] | 103 | bool processXMLConfiguration(); |
---|
[153] | 104 | |
---|
[32] | 105 | /** |
---|
| 106 | * \brief This function initialized the visual_vista2D object after instantiation by createVistaOverlay() |
---|
| 107 | */ |
---|
[156] | 108 | void startVista2D(); |
---|
[32] | 109 | |
---|
| 110 | /** |
---|
| 111 | * \brief This function implements the pure OpenGL draw by calling Vista2D's draw funtion. |
---|
| 112 | * |
---|
[156] | 113 | * Because Vista2D manipulates OpenGLs stateset, this function saves the |
---|
[32] | 114 | * OSG statset at the beginning and restores it after the drawing of Vista2D |
---|
| 115 | * |
---|
| 116 | * @param renderInfo : Renderinfo of the drawing |
---|
| 117 | */ |
---|
| 118 | void drawImplementation(osg::RenderInfo& renderInfo) const; |
---|
| 119 | |
---|
| 120 | /** |
---|
| 121 | * Pointer to Vista2D's view instance. |
---|
| 122 | */ |
---|
| 123 | Vista2D::VistaView* view; |
---|
[153] | 124 | |
---|
[156] | 125 | /** |
---|
| 126 | * XML config filename |
---|
| 127 | */ |
---|
| 128 | std::string configFileName; |
---|
[153] | 129 | |
---|
[156] | 130 | /** |
---|
| 131 | * Filename of the Vista2D project file. |
---|
| 132 | */ |
---|
| 133 | std::string vistaProjectfile; |
---|
[153] | 134 | |
---|
[156] | 135 | /** |
---|
| 136 | * Should the background of the Vista2D project be painted? |
---|
| 137 | */ |
---|
| 138 | bool paintBackground; |
---|
[153] | 139 | |
---|
[156] | 140 | /** |
---|
| 141 | * X-Position to draw. |
---|
| 142 | */ |
---|
| 143 | int position_x; |
---|
[153] | 144 | |
---|
[156] | 145 | /** |
---|
| 146 | * Y-Position to draw. |
---|
| 147 | */ |
---|
| 148 | int position_y; |
---|
[153] | 149 | |
---|
[156] | 150 | /** |
---|
| 151 | * Zoom factor to draw the project. |
---|
| 152 | */ |
---|
| 153 | double zoom; |
---|
| 154 | |
---|
| 155 | /** |
---|
| 156 | * Flag if Vista2D should animate the project according to it's data sources. |
---|
| 157 | */ |
---|
| 158 | bool playanimation; |
---|
[32] | 159 | }; |
---|
| 160 | |
---|
| 161 | } // END NAMESPACE |
---|