OpenWalnut 1.3.1
|
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 WGEGRIDNODE_H 00026 #define WGEGRIDNODE_H 00027 00028 #include <osg/Geode> 00029 #include <osg/MatrixTransform> 00030 00031 #include "../../dataHandler/WGridRegular3D.h" 00032 #include "../../common/WSharedObject.h" 00033 #include "../../common/WProperties_Fwd.h" 00034 00035 #include "../widgets/labeling/WGELabel.h" 00036 00037 00038 00039 /** 00040 * This node is able to represent a grid in certain ways. It can show its boundary or the whole grid if desired. 00041 */ 00042 class WGEGridNode: public osg::MatrixTransform 00043 { 00044 public: 00045 /** 00046 * Convenience typedef for a osg::ref_ptr< WGEGridNode >. 00047 */ 00048 typedef osg::ref_ptr< WGEGridNode > SPtr; 00049 00050 /** 00051 * Convenience typedef for a osg::ref_ptr< const WGEGridNode >. 00052 */ 00053 typedef osg::ref_ptr< const WGEGridNode > ConstSPtr; 00054 00055 /** 00056 * Creates a node representing the specified grid. 00057 * 00058 * \param grid the grid to represent. 00059 */ 00060 explicit WGEGridNode( WGridRegular3D::ConstSPtr grid ); 00061 00062 /** 00063 * Destructor. 00064 */ 00065 virtual ~WGEGridNode(); 00066 00067 /** 00068 * Updates the node to use the new specified grid 00069 * 00070 * \param grid the new grid to use 00071 */ 00072 void setGrid( WGridRegular3D::ConstSPtr grid ); 00073 00074 /** 00075 * Returns the currently set grid. 00076 * 00077 * \return the current grid. 00078 */ 00079 WGridRegular3D::ConstSPtr getGrid() const; 00080 00081 /** 00082 * Returns whether labels on the corners are enabled or not. 00083 * 00084 * \return true if labels are enabled 00085 */ 00086 bool getEnableLabels() const; 00087 00088 /** 00089 * En- or disable labels on the boundary corners. 00090 * 00091 * \param enable true to enbable 00092 */ 00093 void setEnableLabels( bool enable = true ); 00094 00095 /** 00096 * Returns whether bbox mode is enabled or not. 00097 * 00098 * \return true if bbox rendering are enabled 00099 */ 00100 bool getEnableBBox() const; 00101 00102 /** 00103 * En- or disable bbox mode. 00104 * 00105 * \param enable true to enbable 00106 */ 00107 void setEnableBBox( bool enable = true ); 00108 00109 /** 00110 * Returns whether grid mode is enabled or not. 00111 * 00112 * \return true if grid rendering are enabled 00113 */ 00114 bool getEnableGrid() const; 00115 00116 /** 00117 * En- or disable grid mode. 00118 * 00119 * \param enable true to enbable 00120 */ 00121 void setEnableGrid( bool enable = true ); 00122 00123 /** 00124 * The currently set color used for rendering the bbox. 00125 * 00126 * \return the current color. 00127 */ 00128 const WColor& getBBoxColor() const; 00129 00130 /** 00131 * Sets the color of the rendered bbox. 00132 * 00133 * \param color the color 00134 */ 00135 void setBBoxColor( const WColor& color ); 00136 00137 /** 00138 * The currently set color used for rendering the grid. 00139 * 00140 * \return the current color. 00141 */ 00142 const WColor& getGridColor() const; 00143 00144 /** 00145 * Sets the color of the rendered grid. 00146 * 00147 * \param color the color 00148 */ 00149 void setGridColor( const WColor& color ); 00150 00151 protected: 00152 private: 00153 /** 00154 * The actual grid which should be represented by this node. 00155 */ 00156 WSharedObject< WGridRegular3D::ConstSPtr > m_grid; 00157 00158 /** 00159 * The geometry for the boundary. 00160 */ 00161 osg::ref_ptr< osg::Geode > m_boundaryGeode; 00162 00163 /** 00164 * The geometry for the whole grid. 00165 */ 00166 osg::ref_ptr< osg::Geode > m_innerGridGeode; 00167 00168 /** 00169 * The labels at the corner. 00170 */ 00171 WGELabel::SPtr m_borderLabels[8]; 00172 00173 /** 00174 * The geode keeping the labels 00175 */ 00176 osg::ref_ptr< osg::Geode > m_labelGeode; 00177 00178 /** 00179 * The actual callback handling changes in the grid 00180 * 00181 * \param node the node. This will be the this pointer. 00182 */ 00183 void callback( osg::Node* node ); 00184 00185 /** 00186 * If true, the labels and geometry gets adapted properly. 00187 */ 00188 bool m_gridUpdate; 00189 00190 /** 00191 * If true, the inner grid geometry gets recreated. 00192 */ 00193 bool m_gridGeometryUpdate; 00194 00195 /** 00196 * If true, labels get used. 00197 */ 00198 bool m_showLabels; 00199 00200 /** 00201 * True if the bbox should be rendered 00202 */ 00203 bool m_showBBox; 00204 00205 /** 00206 * True if the grid should be rendered. 00207 */ 00208 bool m_showGrid; 00209 00210 /** 00211 * The color of bbox/grid 00212 */ 00213 WColor m_bbColor; 00214 00215 /** 00216 * The color of the grid. 00217 */ 00218 WColor m_gridColor; 00219 }; 00220 00221 #endif // WGEGRIDNODE_H 00222