VTK
dox/Charts/Core/vtkColorLegend.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkColorLegend.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 
00023 #ifndef __vtkColorLegend_h
00024 #define __vtkColorLegend_h
00025 
00026 #include "vtkChartsCoreModule.h" // For export macro
00027 #include "vtkChartLegend.h"
00028 #include "vtkSmartPointer.h" // For SP ivars
00029 #include "vtkVector.h"       // For vtkRectf
00030 
00031 class vtkAxis;
00032 class vtkContextMouseEvent;
00033 class vtkImageData;
00034 class vtkScalarsToColors;
00035 class vtkCallbackCommand;
00036 
00037 class VTKCHARTSCORE_EXPORT vtkColorLegend: public vtkChartLegend
00038 {
00039 public:
00040   vtkTypeMacro(vtkColorLegend, vtkChartLegend);
00041   virtual void PrintSelf(ostream &os, vtkIndent indent);
00042   static vtkColorLegend* New();
00043 
00045 
00046   enum {
00047     VERTICAL = 0,
00048     HORIZONTAL
00049   };
00051 
00054   virtual void GetBounds(double bounds[4]);
00055 
00059   virtual void Update();
00060 
00064   virtual bool Paint(vtkContext2D *painter);
00065 
00067 
00069   virtual void SetTransferFunction(vtkScalarsToColors* transfer);
00070   virtual vtkScalarsToColors * GetTransferFunction();
00072 
00074   virtual void SetPoint(float x, float y);
00075 
00077   virtual void SetTextureSize(float w, float h);
00078 
00084   virtual void SetPosition(const vtkRectf& pos);
00085 
00088   virtual vtkRectf GetPosition();
00089 
00095   vtkRectf GetBoundingRect(vtkContext2D* painter);
00096 
00098 
00100   virtual void SetOrientation(int orientation);
00101   vtkGetMacro(Orientation, int);
00103 
00105 
00106   virtual void SetTitle(const vtkStdString &title);
00107   virtual vtkStdString GetTitle();
00109 
00111 
00113   vtkSetMacro(DrawBorder, bool);
00114   vtkGetMacro(DrawBorder, bool);
00115   vtkBooleanMacro(DrawBorder, bool);
00117 
00119   virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse);
00120 
00121 protected:
00122   vtkColorLegend();
00123   virtual ~vtkColorLegend();
00124 
00128   virtual void ComputeTexture();
00129 
00131 
00133   virtual void ScalarsToColorsModified(vtkObject* caller, unsigned long eid,
00134                                        void* calldata);
00135   static void OnScalarsToColorsModified(vtkObject* caller, unsigned long eid,
00136                                         void *clientdata, void* calldata);
00138 
00140   void UpdateAxisPosition();
00141 
00142   vtkScalarsToColors*                 TransferFunction;
00143   vtkSmartPointer<vtkImageData>       ImageData;
00144   vtkSmartPointer<vtkAxis>            Axis;
00145   vtkSmartPointer<vtkCallbackCommand> Callback;
00146   bool                                Interpolate;
00147   bool                                CustomPositionSet;
00148   bool                                DrawBorder;
00149   vtkRectf                            Position;
00150   int                                 Orientation;
00151 
00152 private:
00153   vtkColorLegend(const vtkColorLegend &); // Not implemented.
00154   void operator=(const vtkColorLegend &);   // Not implemented.
00155 };
00156 
00157 #endif