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/mapping/interfaces/MiColorMapping.h>
00028
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 MdSurfaceMeshRectilinear;
00045
00046 class MxScalarSetIj;
00047 class MdSurfaceMesh;
00048 class MdLevelColorMapping;
00049 class MdLinearColorMapping;
00050 class MdPredefinedColorMapping;
00051
00052
00091 class MESHVIZXLM_DMAP_API MoLegend : public MoMeshBaseRepresentation {
00092
00093 SO_NODE_HEADER(MoLegend) ;
00094
00095 public:
00096
00100 MoLegend() ;
00101
00106 SoSFVec2f bottomLeft;
00107
00112 SoSFVec2f topRight;
00113
00119 SoSFDouble minValue;
00120
00126 SoSFDouble maxValue;
00127
00132 SoSFBool vertical;
00133
00137 SoSFString title;
00138
00142 SoSFFloat titleFontSize;
00143
00147 SoSFColor titleColor;
00148
00152 enum Position {
00153 POS_BOTTOM,
00154 POS_TOP,
00155 POS_RIGHT,
00156 POS_LEFT
00157 } ;
00158
00163 SoSFEnum titlePosition;
00164
00170 SoSFBool displayValues;
00171
00172
00178 SoSFInt32 numValues;
00179
00183 SoSFColor valuesColor;
00184
00188 SoSFFloat valuesFontSize;
00189
00193 enum Notation {
00194 NOTATION_DEFAULT,
00195 NOTATION_FIXED,
00196 NOTATION_SCIENTIFIC
00197 };
00198
00208 SoSFEnum valueNotation;
00209
00229 SoSFUInt32 valuePrecision;
00230
00231
00232 private:
00233 virtual void doAction(SoAction *action);
00234
00235 private:
00236 static void initClass() ;
00237 static void exitClass() ;
00238
00239 private:
00240 virtual ~MoLegend() ;
00241
00242 void fillLegend(SoState* state);
00243 void fillLevelCM(SoState* state, const MdLevelColorMapping& levelCM);
00244 void fillLinearCM(SoState* state, const MdLinearColorMapping& linearCM);
00245 void fillPredefCM(SoState* state, const MdPredefinedColorMapping& predefCM);
00246 void fillCustomCM(SoState* state, const MiColorMapping<double,SbColorRGBA>& customCM);
00247 void createMesh(SoState* state, int ind, std::vector<float>& coords0, std::vector<float> coords1, float xmin, float xmax, double vmin, double vmax);
00248 void getLegendRange(const MiColorMapping<double, SbColorRGBA>& cmap,double& vmin,double& vmax);
00249
00250 void drawTitle(SoState* state);
00251 void drawValues(SoState* state,double vmin, double vmax);
00252
00253 void clear();
00254
00255 MdSurfaceMesh* m_surface;
00256 SoSeparator* m_textGroup;
00257 SoSeparator* m_valuesGroup;
00258 MdSurfaceMeshRectilinear* m_legendMesh;
00259 MxScalarSetIj* m_scalarSet;
00260 private:
00262 SoRef<SoCache> m_cache;
00263 void buildCache( SoState *state );
00264 SbBool checkCache( SoState *state );
00265 } ;
00266
00267 #ifdef _WIN32
00268 #pragma warning(pop)
00269 #endif
00270
00271 #endif
00272
00273
00274
00275