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