CMS 3D CMS Logo

IgSoFieldPlane.h

Go to the documentation of this file.
00001 #ifndef IG_OPEN_INVENTOR_IG_SO_FIELD_PLANE_H
00002 # define IG_OPEN_INVENTOR_IG_SO_FIELD_PLANE_H
00003 
00004 //<<<<<< INCLUDES                                                       >>>>>>
00005 
00006 # include "Iguana/Inventor/interface/config.h"
00007 # include <Inventor/SbBox.h>
00008 # include <Inventor/nodes/SoSwitch.h>
00009 # include <Inventor/fields/SoSFPlane.h>
00010 # include <Inventor/fields/SoSFUInt32.h>
00011 # include <Inventor/fields/SoSFBool.h>
00012 # include <Inventor/fields/SoSFEnum.h>
00013 # include <Inventor/fields/SoSFFloat.h>
00014 # include <vector>
00015 
00016 //<<<<<< PUBLIC DEFINES                                                 >>>>>>
00017 //<<<<<< PUBLIC CONSTANTS                                               >>>>>>
00018 
00019 static unsigned const X_AXIS = 0;
00020 static unsigned const Z_AXIS = 1;
00021 
00022 //<<<<<< PUBLIC TYPES                                                   >>>>>>
00023 
00024 class IgSoPlaneManip;
00025 class IgSoFieldPlaneMap;
00026 class SoIndexedLineSet;
00027 class SoSensor;
00028 class SoFieldSensor;
00029 class IgSbField;
00030 class IgSbColorMap;
00031 
00032 //<<<<<< PUBLIC VARIABLES                                               >>>>>>
00033 //<<<<<< PUBLIC FUNCTIONS                                               >>>>>>
00034 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
00035 
00036 #ifdef WIN32
00037 #include <SoWinLeaveScope.h>
00038 #endif // WIN32
00039 
00041 class IG_OPEN_INVENTOR_API IgSoFieldPlane : public SoSwitch
00042 {
00043     SO_NODE_HEADER (IgSoFieldPlane);
00044 public:
00045         enum Component {
00046                 XYZ_ALL,        //< Total magnitude
00047                 XYZ_X,          //< Magnitude in x-axis
00048                 XYZ_Y,          //< Magnitude in y-axis
00049                 XYZ_Z,          //< Magnitude in z-axis
00050                 XYZ_PHI,        //< Magnitude in angle (cylindrical)
00051                 XYZ_R           //< Magnitude in radius (cylindrical)
00052         };
00053 
00054         // members which are observed by sensors
00055         SoSFPlane  plane;
00056         SoSFUInt32 mapDensityX;
00057         SoSFUInt32 mapDensityZ;
00058         SoSFUInt32 segRatioX;
00059         SoSFUInt32 segRatioZ;
00060         
00061         SoSFFloat  winSizeX;
00062         SoSFFloat  winSizeZ;
00063         SoSFUInt32 winDensityX;
00064         SoSFUInt32 winDensityZ;
00065         SoSFFloat  winOriginX;
00066         SoSFFloat  winOriginZ;
00067         
00068         SoSFEnum   component;
00069         SoSFFloat  maxvalue;
00070         SoSFUInt32 invisible;
00071         SoSFUInt32 alpha;
00072         SoSFBool   show;
00073         SoSFBool   manip;
00074         SoSFBool   showMap;
00075         SoSFBool   showSegments;
00076         SoSFBool   gradientScale;
00077 
00078         // SoSFBool             showContours;
00079         // SoSFBool             showSurfaces;
00080         
00081         IgSoFieldPlane (void);
00082         // implicit copy constructor
00083         // implicit assignment operator
00084         
00085         static void             initClass (void);
00086         
00087         void            colorMap (const IgSbColorMap *map);
00088         void            field (const IgSbField *field, SbBox3f world);
00089 
00090 protected:
00091     virtual ~IgSoFieldPlane (void);
00092 
00093     virtual void        attachSensors (void);
00094     virtual void        detachSensors (void);
00095     
00096 private:
00097 
00098         void buildStructure (void);
00099         void update (void);
00100         void updateCorners (void);
00101         void refreshColors (void);
00102         void resampleSegments (void);
00103         void convertMagFieldColors (double &minMag, double &maxMag);
00104         void convertGradientScaleColors (double &minMag, double &maxMag);
00105         void calcColorMags ();
00106         void determineCorners (unsigned bitmask);
00107         void transferValuesToMap ();
00108         void correctDetailedSize ();
00109         unsigned initializeParameters ();
00110         unsigned correctOriginAndGetMask ();
00111         
00112         
00113         static void showChanged  (void *me, SoSensor *sensor);
00114         static void showMapChanged  (void *me, SoSensor *sensor);
00115         static void showSegmentsChanged  (void *me, SoSensor *sensor);
00116         static void     gradientScaleChanged (void *me, SoSensor *sensor);
00117         static void     planeChanged  (void *me, SoSensor *sensor);
00118         static void     mplaneChanged (void *me, SoSensor *sensor);
00119         static void     resampleSegmentsCB (void *me, SoSensor *sensor);
00120         
00121         const IgSbColorMap *m_cmap;
00122         const IgSbField    *m_field;
00123         SbBox3f             m_world;
00124         IgSoPlaneManip     *m_manip;
00125         IgSoFieldPlaneMap  *m_fieldPlane;
00126         SoIndexedLineSet   *m_segments;
00127         SoGroup            *m_gradientScale;
00128         SoFieldSensor      *m_showSensor;
00129         SoFieldSensor      *m_planeSensor;
00130         SoFieldSensor      *m_mapDensityXSensor;
00131         SoFieldSensor      *m_mapDensityZSensor;
00132         SoFieldSensor      *m_segRatioXSensor;
00133         SoFieldSensor      *m_segRatioZSensor;
00134         
00135         SoFieldSensor      *m_winSizeXSensor;
00136         SoFieldSensor      *m_winSizeZSensor;
00137         SoFieldSensor      *m_winDensityXSensor;
00138         SoFieldSensor      *m_winDensityZSensor;
00139         SoFieldSensor      *m_winOriginXSensor;
00140         SoFieldSensor      *m_winOriginZSensor;
00141         
00142         SoFieldSensor      *m_componentSensor;
00143         SoFieldSensor      *m_maxvalueSensor;
00144         SoFieldSensor      *m_invisibleSensor;
00145         SoFieldSensor      *m_alphaSensor;
00146         SoFieldSensor      *m_mplaneSensor;
00147         SoFieldSensor      *m_showMapSensor;
00148         SoFieldSensor      *m_showSegmentsSensor;
00149         SoFieldSensor      *m_gradientScaleSensor;
00150         
00151         std::vector<std::vector<double> > m_colorsMags;
00152         
00153         // current detailed window parameters
00154         struct WindowInfo
00155         {
00156                 float    size[2];
00157                 unsigned density[2];
00158                 float    origin[2];
00159                 unsigned baseDiv[2];
00160         };
00161         
00162         struct RegionInfo
00163         {
00164                 SbVec3f lowerLeft;
00165                 SbVec3f upperRight;
00166                 SbVec3f lowerRight;
00167                 
00168                 unsigned density[2];
00169         };
00170         
00171         WindowInfo m_window;
00172         RegionInfo m_regions[5];
00173         bool       m_sizeIsZero;
00174         bool       m_densityXTooLow;
00175         bool       m_densityZTooLow;
00176         SbVec3f    m_xBaseDir;
00177         SbVec3f    m_zBaseDir;
00178 
00179 };
00180 #ifdef WIN32
00181 #include <SoWinEnterScope.h>
00182 #endif // WIN32
00183 
00184 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
00185 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
00186 
00187 #endif // IG_OPEN_INVENTOR_IG_SO_FIELD_PLANE_H

Generated on Tue Jun 9 17:38:43 2009 for CMSSW by  doxygen 1.5.4