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 WROISPHERE_H 00026 #define WROISPHERE_H 00027 00028 #include <string> 00029 #include <utility> 00030 00031 #include <boost/thread.hpp> 00032 00033 #include "../common/math/linearAlgebra/WLinearAlgebra.h" 00034 #include "WPickHandler.h" 00035 #include "WGEViewer.h" 00036 00037 #include "WROI.h" 00038 00039 #include "WExportWGE.h" 00040 00041 /** 00042 * A sphere representing a region of interest. 00043 */ 00044 class WGE_EXPORT WROISphere : public WROI 00045 { 00046 public: 00047 /** 00048 * Yields sphere with desired center point and radius 00049 * \param position position of the center of the sphere 00050 * \param radius radius of the sphere 00051 */ 00052 WROISphere( WPosition position, float radius = 5.0 ); 00053 00054 /** 00055 * standard destructor 00056 */ 00057 virtual ~WROISphere(); 00058 00059 /** 00060 * getter 00061 * \return position 00062 */ 00063 WPosition getPosition() const; 00064 00065 /** 00066 * setter 00067 * \param position 00068 */ 00069 void setPosition( WPosition position ); 00070 00071 /** 00072 * setter 00073 * \param x 00074 * \param y 00075 * \param z 00076 */ 00077 void setPosition( float x, float y, float z ); 00078 00079 /** 00080 * Setter for standard color 00081 * \param color The new color. 00082 */ 00083 void setColor( osg::Vec4 color ); 00084 00085 /** 00086 * Setter for color in negated state 00087 * \param color The new color. 00088 */ 00089 void setNotColor( osg::Vec4 color ); 00090 00091 /** 00092 * removes the old drawable from the osg geode and adds a new one at the current position and size 00093 */ 00094 void redrawSphere(); 00095 00096 /** 00097 * sets the flag that allows or disallows movement along the x axis 00098 * 00099 * \param value the flag 00100 */ 00101 void setLockX( bool value = true ); 00102 00103 /** 00104 * sets the flag that allows or disallows movement along the y axis 00105 * 00106 * \param value the flag 00107 */ 00108 void setLockY( bool value = true ); 00109 00110 /** 00111 * sets the flag that allows or disallows movement along the z axis 00112 * 00113 * \param value the flag 00114 */ 00115 void setLockZ( bool value = true ); 00116 00117 /** 00118 * move the sphere with a given offset 00119 * 00120 * \param offset the distance to move 00121 */ 00122 void moveSphere( WVector3d offset ); 00123 00124 /** 00125 * setter 00126 * \param x sets the x component of the position of this sphere 00127 */ 00128 void setX( float x ); 00129 00130 /** 00131 * setter 00132 * \param y sets the y component of the position of this sphere 00133 */ 00134 void setY( float y ); 00135 00136 /** 00137 * setter 00138 * \param z sets the z component of the position of this sphere 00139 */ 00140 void setZ( float z ); 00141 00142 /** 00143 * setter 00144 * \param vector together witht he current position this sets line in space to which the movement of the 00145 * sphere is restricted 00146 */ 00147 void setLockVector( WVector3d vector ); 00148 00149 /** 00150 * setter 00151 * \param value if the the movement of the sphere is restricted to a given vector 00152 */ 00153 void setLockOnVector( bool value = true ); 00154 00155 protected: 00156 00157 private: 00158 static size_t maxSphereId; //!< Current maximum boxId over all spheres. 00159 size_t sphereId; //!< Id of the current sphere. 00160 00161 WPosition m_position; //!< The position of the sphere 00162 00163 WPosition m_originalPosition; //!< The position of the sphere when created, used for locking 00164 00165 float m_radius; //!< The radius of the sphere 00166 00167 bool m_isPicked; //!< Indicates whether the box is currently picked or not. 00168 00169 WPosition m_pickedPosition; //!< Caches the old picked position to a allow for comparison 00170 00171 WVector3d m_pickNormal; //!< Store the normal that occured when the pick action was started. 00172 00173 WVector2d m_oldPixelPosition; //!< Caches the old picked position to a allow for cmoparison 00174 00175 WPickInfo m_pickInfo; //!< Stores the pick information for potential redraw 00176 00177 boost::shared_ptr< WGEViewer > m_viewer; //!< makes viewer available all over this class. 00178 00179 osg::Vec4 m_color; //!< the color of the box 00180 00181 osg::Vec4 m_notColor; //!< the color of the box when negated 00182 00183 WVector3d m_lockPoint; //!< stores to point of origin of the lock vector 00184 00185 WVector3d m_lockVector; //!< stores the lock vector 00186 00187 bool m_lockOnVector; //!< flag indicatin wether the movement of the sphere is restricted 00188 00189 bool m_lockX; //!< flag indicatin wether the movement of the sphere is restricted 00190 bool m_lockY; //!< flag indicatin wether the movement of the sphere is restricted 00191 bool m_lockZ; //!< flag indicatin wether the movement of the sphere is restricted 00192 00193 00194 /** 00195 * note that there was a pick 00196 * \param pickInfo info from pick 00197 */ 00198 void registerRedrawRequest( WPickInfo pickInfo ); 00199 00200 /** 00201 * updates the graphics 00202 */ 00203 virtual void updateGFX(); 00204 }; 00205 00206 #endif // WROISPHERE_H