Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00032 #ifndef __vtkKWEPaintbrushPropertyManager_h
00033 #define __vtkKWEPaintbrushPropertyManager_h
00034
00035 #include "VTKEdgeConfigure.h"
00036 #include "vtkKWEPaintbrushEnums.h"
00037 #include "vtkObject.h"
00038 #include <vtkstd/map>
00039
00040 class vtkKWEPaintbrushSketch;
00041 class vtkKWEPaintbrushDrawing;
00042 class vtkKWEPaintbrushProperty;
00043 class vtkKWEPaintbrushBlend;
00044 class vtkProperty;
00045
00046 class VTKEdge_WIDGETS_EXPORT vtkKWEPaintbrushPropertyManager : public vtkObject
00047 {
00048
00049 friend class vtkKWEPaintbrushDrawing;
00050 friend class vtkKWEPaintbrushBlend;
00051 friend class vtkKWEPaintbrushWidget;
00052
00053 public:
00054 vtkTypeRevisionMacro(vtkKWEPaintbrushPropertyManager,vtkObject);
00055 void PrintSelf(ostream& os, vtkIndent indent);
00056
00058
00062 vtkGetObjectMacro( PaintbrushDrawing, vtkKWEPaintbrushDrawing );
00064
00066
00072 vtkSetMacro( HighlightType, int );
00073 vtkGetMacro( HighlightType, int );
00075
00078 void Update();
00079
00081
00085 void Initialize();
00086 void AddUsedColor( vtkProperty * p );
00087 void RetrieveSketchColor( vtkKWEPaintbrushSketch *s, unsigned char c[3] );
00088 vtkKWEPaintbrushProperty * RequestColorForSketch( vtkKWEPaintbrushSketch *s );
00090
00092
00093 class vtkKWEPaintbrushLabelMapColor
00094 {
00095 public:
00096 unsigned char Color[3];
00097 double Opacity;
00098 vtkKWEPaintbrushLabelMapColor() { Color[0] = Color[1] = Color[2] = 0; }
00099 vtkKWEPaintbrushLabelMapColor( unsigned char r,
00100 unsigned char g,
00101 unsigned char b,
00102 double opacity )
00103 { Color[0] = r; Color[1] = g; Color[2] = b; Opacity = opacity; }
00104 vtkKWEPaintbrushLabelMapColor( unsigned char rgba[3], double o )
00105 { Color[0] = rgba[0]; Color[1] = rgba[1]; Color[2] = rgba[2]; Opacity=o; }
00106 bool operator==(const vtkKWEPaintbrushLabelMapColor &a) const
00107 { return ( this->Color[0] == a.Color[0] &&
00108 this->Color[1] == a.Color[1] &&
00109 this->Color[2] == a.Color[2] ); }
00110 };
00111 typedef vtkstd::map< vtkKWEPaintbrushEnums::LabelType,
00112 vtkKWEPaintbrushLabelMapColor > LabelToColorMapType;
00114
00115 protected:
00116 static vtkKWEPaintbrushPropertyManager *New( vtkKWEPaintbrushDrawing * );
00117 static vtkKWEPaintbrushPropertyManager *New();
00118 vtkKWEPaintbrushPropertyManager();
00119 ~vtkKWEPaintbrushPropertyManager();
00120
00123 void UpdateLabelToColorMap();
00124
00125
00126 class vtkKWEPaintbrushColors
00127 {
00128 public:
00129 double R, G, B, Opacity; unsigned int Idx;
00130 vtkKWEPaintbrushColors() { Opacity = 1.0; Idx = 0; }
00131 vtkKWEPaintbrushColors( double r, double g, double b, int idx = 0 )
00132 { R=r; G=g; B=b; Idx=idx; Opacity=0.0; }
00133 bool operator==(const vtkKWEPaintbrushColors &a) const
00134 { return (fabs(this->R - a.R) < 0.01 &&
00135 fabs(this->G - a.G) < 0.01 &&
00136 fabs(this->B - a.B) < 0.01); }
00137 };
00138
00139 typedef vtkKWEPaintbrushColors ColorType;
00140
00141 void AddUsedColor( const ColorType & );
00142 ColorType RequestColor();
00143
00145
00147 void GrabFocus( vtkKWEPaintbrushSketch * );
00148 void ReleaseFocus();
00150
00151 private:
00152 vtkKWEPaintbrushPropertyManager(const vtkKWEPaintbrushPropertyManager&);
00153 void operator=(const vtkKWEPaintbrushPropertyManager&);
00154
00155 vtkKWEPaintbrushDrawing * PaintbrushDrawing;
00156 struct vtkKWEPaintbrushColorsCompare
00157 {
00158 bool operator()(const ColorType& s1, const ColorType& s2) const
00159 {
00160 return s1.Idx < s2.Idx;
00161 }
00162 };
00163
00164 typedef vtkstd::map< vtkKWEPaintbrushSketch *,
00165 ColorType > SketchToColorMapType;
00166 typedef vtkstd::map< ColorType,
00167 unsigned int,
00168 vtkKWEPaintbrushColorsCompare > ColorsMapType;
00169 SketchToColorMapType SketchToColorMap;
00170 ColorsMapType Colors;
00171 int HighlightType;
00172
00173
00174
00175
00176
00177
00178 unsigned char LabelToColorMapUC[256][3];
00179 double LabelToOpacityMapUC[256];
00180 LabelToColorMapType LabelToColorMap;
00181 };
00182
00183 #endif
00184