OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WGEBORDERLAYOUT_H 00026 #define WGEBORDERLAYOUT_H 00027 00028 #include <osg/Drawable> 00029 #include <osg/Geode> 00030 #include <osgText/Text> 00031 #include <osg/Projection> 00032 00033 #include "../../WGEGroupNode.h" 00034 #include "WGELabel.h" 00035 00036 /** 00037 * This class contains a label layout for positioning labels at the side of the screen. There is a line from the point of interest to the label 00038 * on the side of the screen. 00039 */ 00040 class WGEBorderLayout: public WGEGroupNode 00041 { 00042 friend class SafeUpdateCallback; 00043 public: 00044 /** 00045 * Default constructor. 00046 */ 00047 WGEBorderLayout(); 00048 00049 /** 00050 * Destructor. 00051 */ 00052 virtual ~WGEBorderLayout(); 00053 00054 /** 00055 * Adds the specified object to the list of layouted objects. 00056 * 00057 * \param obj the layoutable object. 00058 * \todo(ebaum): this is ugly, use a common baseclass instead 00059 */ 00060 virtual void addLayoutable( osg::ref_ptr< WGELabel > obj ); 00061 00062 protected: 00063 /** 00064 * The geode containing all drawables. 00065 */ 00066 osg::ref_ptr< osg::Geode > m_geode; 00067 00068 /** 00069 * Contains all lead lines. 00070 */ 00071 osg::ref_ptr< osg::Geode > m_lineGeode; 00072 00073 /** 00074 * The projection to the screen 00075 */ 00076 osg::ref_ptr< osg::Projection > m_screen; 00077 00078 /** 00079 * Node callback to actually layout the objects. 00080 */ 00081 class SafeUpdateCallback : public osg::NodeCallback 00082 { 00083 public: // NOLINT 00084 /** 00085 * Constructor. 00086 * 00087 * \param layout just set the creating layout as pointer for later reference. 00088 */ 00089 explicit SafeUpdateCallback( osg::ref_ptr< WGEBorderLayout > layout ): m_layouter( layout ) 00090 { 00091 }; 00092 00093 /** 00094 * operator () - called during the update traversal. 00095 * 00096 * \param node the osg node 00097 * \param nv the node visitor 00098 */ 00099 virtual void operator()( osg::Node* node, osg::NodeVisitor* nv ); 00100 00101 /** 00102 * The layouter owning this callback 00103 * \todo(ebaum) the layoiter insance will never be freed -> cyclic dependency 00104 */ 00105 osg::ref_ptr< WGEBorderLayout > m_layouter; 00106 }; 00107 00108 private: 00109 }; 00110 00111 #endif // WGEBORDERLAYOUT_H 00112