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
00057 class PbDataMapping : public PbBase {
00058
00059 public:
00060
00061 typedef float PbHLSColor[3] ;
00062
00063
00064
00068 PbDataMapping() ;
00069
00073 ~PbDataMapping() ;
00074
00078 PbDataMapping(const PbDataMapping &dataMapping) ;
00079
00083 PbDataMapping& operator=(const PbDataMapping &dataMapping) ;
00084
00090 const SbColor *getRGBColor(float value) const;
00091
00097 const float *getHLSColor(float value) const;
00098
00105 const SbColor *getRGBColor(float value, float &transparency) const;
00106
00113 const float *getHLSColor(float value, float &transparency) const;
00114
00115
00116
00120 void setMinThreshold(float threshold_min) ;
00121
00125 void setMinThreshold(float threshold_min, const SbColor &cmin, float transp_min=0.0) ;
00126
00131 void setMinThreshold(float threshold_min, PbHLSColor cmin, float transp_min=0.0) ;
00132
00136 void setMaxThreshold(float threshold_max) ;
00137
00141 void setMaxThreshold(float threshold_max, const SbColor &cmax, float transp_max=0.0) ;
00142
00147 void setMaxThreshold(float threshold_max, PbHLSColor cmax, float transp_max=0.0) ;
00148
00155 const SbColor* getMinRGBThreshold(float &threshold_min) const ;
00156
00162 const float* getMinHLSThreshold(float &threshold_min) const ;
00163
00169 const SbColor* getMinRGBThreshold(float &threshold_min, float &transp_min) const ;
00170
00176 const float* getMinHLSThreshold(float &threshold_min, float &transp_min) const ;
00177
00184 const SbColor* getMaxRGBThreshold(float &threshold_max) const ;
00185
00191 const float* getMaxHLSThreshold(float &threshold_max) const ;
00192
00198 const SbColor* getMaxRGBThreshold(float &threshold_max, float &transp_max) const ;
00199
00205 const float* getMaxHLSThreshold(float &threshold_max, float &transp_max) const ;
00206
00210 void enableThresholds(SbBool min, SbBool max) ;
00211
00215 void thresholdsEnabled(SbBool &min, SbBool &max) const
00216 { min = m_minEnabled ; max = m_maxEnabled ;}
00217
00222 void enableTransparency(SbBool flag);
00223
00227 SbBool isTransparencyEnabled() const
00228 { return m_transparencyEnabled ; }
00229
00234 void setTransparencyValueDeletedParts(float value);
00235
00240 float getTransparencyValueDeletedParts() const;
00241
00242
00243
00244
00245 private:
00246
00247 enum ClassType {
00248 DATA_MAPPING,
00249 LINEAR_DATA_MAPPING,
00250 NON_LINEAR_DATA_MAPPING1,
00251 NON_LINEAR_DATA_MAPPING2
00252 } ;
00253
00254 virtual ClassType getClassType() const
00255 { return DATA_MAPPING ; }
00256
00257 uint32_t getId() const { return m_uniqueId; }
00258
00259 private:
00260
00261 void notifyChange();
00262
00263
00264
00265
00266 static void colorInterpolation(const SbColor &c1, float v1,
00267 const SbColor &c2, float v2,
00268 float vi, SbColor *ci) ;
00269 static void colorInterpolation(const SbColor &c1, float t1, float v1,
00270 const SbColor &c2, float t2, float v2,
00271 float vi, SbColor *ci, float &ti) ;
00272 static void transparencyInterpolation(float t1, float v1,
00273 float t2, float v2,
00274 float vi, float ti) ;
00275
00276 float m_transparencyValueDeletedParts;
00277 SbColor *m_colorValue ;
00278 virtual const SbColor* computeColor(float value) const=0;
00279 virtual const SbColor* computeColor(float value, float &transparency) const=0;
00280 SbBool m_transparencyEnabled;
00281
00282
00283 uint32_t m_uniqueId;
00284
00285 private:
00286 static uint32_t sm_nextUniqueId;
00287
00288
00289 void copy(const PbDataMapping &dataMapping, SbBool isConstructorPerCopy) ;
00290
00291 float m_thresholdMin, m_thresholdMax, m_transparencyMin, m_transparencyMax;
00292 SbColor m_colorMin, m_colorMax ;
00293 SbBool m_minEnabled, m_maxEnabled, m_isMinColor, m_isMaxColor;
00294 } ;
00295
00296
00297
00298 #endif
00299
00300
00301
00302