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 #include "../../WExportWGE.h" 00036 00037 /** 00038 * 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 00039 * on the side of the screen. 00040 */ 00041 class WGE_EXPORT WGEBorderLayout: public WGEGroupNode 00042 { 00043 friend class SafeUpdateCallback; 00044 public: 00045 00046 00047 /** 00048 * Default constructor. 00049 */ 00050 WGEBorderLayout(); 00051 00052 /** 00053 * Destructor. 00054 */ 00055 virtual ~WGEBorderLayout(); 00056 00057 /** 00058 * Adds the specified object to the list of layouted objects. 00059 * 00060 * \param obj the layoutable object. 00061 * \todo(ebaum): this is ugly, use a common baseclass instead 00062 */ 00063 virtual void addLayoutable( osg::ref_ptr< WGELabel > obj ); 00064 00065 protected: 00066 00067 /** 00068 * The geode containing all drawables. 00069 */ 00070 osg::ref_ptr< osg::Geode > m_geode; 00071 00072 /** 00073 * Contains all lead lines. 00074 */ 00075 osg::ref_ptr< osg::Geode > m_lineGeode; 00076 00077 /** 00078 * The projection to the screen 00079 */ 00080 osg::ref_ptr< osg::Projection > m_screen; 00081 00082 /** 00083 * Node callback to actually layout the objects. 00084 */ 00085 class SafeUpdateCallback : public osg::NodeCallback 00086 { 00087 public: // NOLINT 00088 00089 /** 00090 * Constructor. 00091 * 00092 * \param layout just set the creating layout as pointer for later reference. 00093 */ 00094 explicit SafeUpdateCallback( osg::ref_ptr< WGEBorderLayout > layout ): m_layouter( layout ) 00095 { 00096 }; 00097 00098 /** 00099 * operator () - called during the update traversal. 00100 * 00101 * \param node the osg node 00102 * \param nv the node visitor 00103 */ 00104 virtual void operator()( osg::Node* node, osg::NodeVisitor* nv ); 00105 00106 /** 00107 * The layouter owning this callback 00108 * \todo(ebaum) the layoiter insance will never be freed -> cyclic dependency 00109 */ 00110 osg::ref_ptr< WGEBorderLayout > m_layouter; 00111 }; 00112 00113 private: 00114 }; 00115 00116 #endif // WGEBORDERLAYOUT_H 00117