00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _PB_DATA_MAPPING_
00025 #define _PB_DATA_MAPPING_
00026
00027 #include <MeshViz/graph/PbBase.h>
00028
00029 #include <Inventor/SbColor.h>
00030
00058 class PbDataMapping : public PbBase {
00059
00060 public:
00061
00062 typedef float PbHLSColor[3] ;
00063
00064
00065
00069 PbDataMapping() ;
00070
00074 ~PbDataMapping() ;
00075
00079 PbDataMapping(const PbDataMapping &dataMapping) ;
00080
00084 PbDataMapping& operator=(const PbDataMapping &dataMapping) ;
00085
00091 const SbColor *getRGBColor(float value) const;
00092
00098 const float *getHLSColor(float value) const;
00099
00106 const SbColor *getRGBColor(float value, float &transparency) const;
00107
00114 const float *getHLSColor(float value, float &transparency) const;
00115
00116
00117
00121 void setMinThreshold(float threshold_min) ;
00122
00126 void setMinThreshold(float threshold_min, const SbColor &cmin, float transp_min=0.0) ;
00127
00132 void setMinThreshold(float threshold_min, PbHLSColor cmin, float transp_min=0.0) ;
00133
00137 void setMaxThreshold(float threshold_max) ;
00138
00142 void setMaxThreshold(float threshold_max, const SbColor &cmax, float transp_max=0.0) ;
00143
00148 void setMaxThreshold(float threshold_max, PbHLSColor cmax, float transp_max=0.0) ;
00149
00156 const SbColor* getMinRGBThreshold(float &threshold_min) const ;
00157
00163 const float* getMinHLSThreshold(float &threshold_min) const ;
00164
00170 const SbColor* getMinRGBThreshold(float &threshold_min, float &transp_min) const ;
00171
00177 const float* getMinHLSThreshold(float &threshold_min, float &transp_min) const ;
00178
00185 const SbColor* getMaxRGBThreshold(float &threshold_max) const ;
00186
00192 const float* getMaxHLSThreshold(float &threshold_max) const ;
00193
00199 const SbColor* getMaxRGBThreshold(float &threshold_max, float &transp_max) const ;
00200
00206 const float* getMaxHLSThreshold(float &threshold_max, float &transp_max) const ;
00207
00211 void enableThresholds(SbBool min, SbBool max) ;
00212
00216 void thresholdsEnabled(SbBool &min, SbBool &max) const
00217 { min = m_minEnabled ; max = m_maxEnabled ;}
00218
00223 void enableTransparency(SbBool flag);
00224
00228 SbBool isTransparencyEnabled() const
00229 { return m_transparencyEnabled ; }
00230
00235 void setTransparencyValueDeletedParts(float value);
00236
00241 float getTransparencyValueDeletedParts() const;
00242
00243
00244
00245
00246 private:
00247
00248 enum ClassType {
00249 DATA_MAPPING,
00250 LINEAR_DATA_MAPPING,
00251 NON_LINEAR_DATA_MAPPING1,
00252 NON_LINEAR_DATA_MAPPING2
00253 } ;
00254
00255 virtual ClassType getClassType() const
00256 { return DATA_MAPPING ; }
00257
00258 uint32_t getId() const { return m_uniqueId; }
00259
00260 private:
00261
00262 void notifyChange();
00263
00264
00265
00266
00267 static void colorInterpolation(const SbColor &c1, float v1,
00268 const SbColor &c2, float v2,
00269 float vi, SbColor *ci) ;
00270 static void colorInterpolation(const SbColor &c1, float t1, float v1,
00271 const SbColor &c2, float t2, float v2,
00272 float vi, SbColor *ci, float &ti) ;
00273 static void transparencyInterpolation(float t1, float v1,
00274 float t2, float v2,
00275 float vi, float ti) ;
00276
00277 float m_transparencyValueDeletedParts;
00278 SbColor *m_colorValue ;
00279 virtual const SbColor* computeColor(float value) const=0;
00280 virtual const SbColor* computeColor(float value, float &transparency) const=0;
00281 SbBool m_transparencyEnabled;
00282
00283
00284 uint32_t m_uniqueId;
00285
00286 private:
00287 static uint32_t sm_nextUniqueId;
00288
00289
00290 void copy(const PbDataMapping &dataMapping, SbBool isConstructorPerCopy) ;
00291
00292 float m_thresholdMin, m_thresholdMax, m_transparencyMin, m_transparencyMax;
00293 SbColor m_colorMin, m_colorMax ;
00294 SbBool m_minEnabled, m_maxEnabled, m_isMinColor, m_isMaxColor;
00295 } ;
00296
00297
00298
00299 #endif
00300
00301
00302
00303