00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MoLegend_
00024 #define _MoLegend_
00025
00026 #include <MeshVizXLM/mapping/nodes/MoMeshBaseRepresentation.h>
00027 #include <MeshVizXLM/implement/colormapping/MbLevelColorMapping.h>
00028 #include <MeshVizXLM/implement/colormapping/MbLinearColorMapping.h>
00029 #include <MeshVizXLM/MbVec3.h>
00030
00031 #include <Inventor/misc/SoRef.h>
00032 #include <Inventor/caches/SoCache.h>
00033 #include <Inventor/fields/SoSFDouble.h>
00034 #include <Inventor/fields/SoSFVec2f.h>
00035 #include <Inventor/fields/SoSFUInt32.h>
00036
00037 #ifdef _WIN32
00038 #pragma warning(push)
00039 #pragma warning(disable:4251)
00040 #endif
00041
00042 class SoState;
00043 class SbColorRGBA;
00044 class MbPredefinedColorMapping;
00045 template <typename _CoordT, typename _ScalarT, typename _Vec3T>
00046 class MbSurfaceMeshRectilinear;
00047 class MxScalarSetIj;
00048 class MdSurfaceMesh;
00049
00088 class MESHIVIZDM_API MoLegend : public MoMeshBaseRepresentation {
00089
00090 SO_NODE_HEADER(MoLegend) ;
00091
00092 public:
00093
00097 MoLegend() ;
00098
00103 SoSFVec2f bottomLeft;
00104
00109 SoSFVec2f topRight;
00110
00116 SoSFDouble minValue;
00117
00123 SoSFDouble maxValue;
00124
00129 SoSFBool vertical;
00130
00134 SoSFString title;
00135
00139 SoSFFloat titleFontSize;
00140
00144 SoSFColor titleColor;
00145
00149 enum Position {
00150 POS_BOTTOM,
00151 POS_TOP,
00152 POS_RIGHT,
00153 POS_LEFT
00154 } ;
00155
00160 SoSFEnum titlePosition;
00161
00167 SoSFBool displayValues;
00168
00169
00175 SoSFInt32 numValues;
00176
00180 SoSFColor valuesColor;
00181
00185 SoSFFloat valuesFontSize;
00186
00190 enum Notation {
00191 NOTATION_DEFAULT,
00192 NOTATION_FIXED,
00193 NOTATION_SCIENTIFIC
00194 };
00195
00205 SoSFEnum valueNotation;
00206
00226 SoSFUInt32 valuePrecision;
00227
00228
00229 private:
00230 virtual void doAction(SoAction *action);
00231
00232 private:
00233 static void initClass() ;
00234 static void exitClass() ;
00235
00236 private:
00237 virtual ~MoLegend() ;
00238
00239 void fillLegend(SoState* state);
00240 void fillLevelCM(SoState* state, const MbLevelColorMapping<double,SbColorRGBA>* levelCM);
00241 void fillLinearCM(SoState* state, const MbLinearColorMapping<double,SbColorRGBA,float>* linearCM);
00242 void fillPredefCM(SoState* state, const MbPredefinedColorMapping* predefCM);
00243 void fillCustomCM(SoState* state, const MiColorMapping<double,SbColorRGBA>* customCM);
00244 void createMesh(SoState* state, int ind, std::vector<float>& coords0, std::vector<float> coords1, float xmin, float xmax, double vmin, double vmax);
00245 void getLegendRange(const MiColorMapping<double, SbColorRGBA>* cmap,double& vmin,double& vmax);
00246
00247 void drawTitle(SoState* state);
00248 void drawValues(SoState* state,double vmin, double vmax);
00249
00250 void clear();
00251
00252 MdSurfaceMesh* m_surface;
00253 SoSeparator* m_textGroup;
00254 SoSeparator* m_valuesGroup;
00255 MbSurfaceMeshRectilinear<float,double,MbVec3f > * m_legendMesh;
00256 MxScalarSetIj* m_scalarSet;
00257 private:
00259 SoRef<SoCache> m_cache;
00260 void buildCache( SoState *state );
00261 SbBool checkCache( SoState *state );
00262 } ;
00263
00264 #ifdef _WIN32
00265 #pragma warning(pop)
00266 #endif
00267
00268 #endif
00269
00270
00271
00272