VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/Label/vtkLabeledDataMapper.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkLabeledDataMapper.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 =========================================================================*/
00051 #ifndef vtkLabeledDataMapper_h
00052 #define vtkLabeledDataMapper_h
00053 
00054 #include "vtkRenderingLabelModule.h" // For export macro
00055 #include "vtkMapper2D.h"
00056 
00057 #include <cassert> // For assert macro
00058 
00059 class vtkDataObject;
00060 class vtkDataSet;
00061 class vtkTextMapper;
00062 class vtkTextProperty;
00063 class vtkTransform;
00064 
00065 #define VTK_LABEL_IDS        0
00066 #define VTK_LABEL_SCALARS    1
00067 #define VTK_LABEL_VECTORS    2
00068 #define VTK_LABEL_NORMALS    3
00069 #define VTK_LABEL_TCOORDS    4
00070 #define VTK_LABEL_TENSORS    5
00071 #define VTK_LABEL_FIELD_DATA 6
00072 
00073 class VTKRENDERINGLABEL_EXPORT vtkLabeledDataMapper : public vtkMapper2D
00074 {
00075 public:
00078   static vtkLabeledDataMapper *New();
00079 
00080   vtkTypeMacro(vtkLabeledDataMapper,vtkMapper2D);
00081   void PrintSelf(ostream& os, vtkIndent indent);
00082 
00084 
00092   vtkSetStringMacro(LabelFormat);
00093   vtkGetStringMacro(LabelFormat);
00095 
00097 
00102   vtkSetMacro(LabeledComponent,int);
00103   vtkGetMacro(LabeledComponent,int);
00105 
00107 
00110   void SetFieldDataArray(int arrayIndex);
00111   vtkGetMacro(FieldDataArray,int);
00113 
00115 
00118   void SetFieldDataName(const char *arrayName);
00119   vtkGetStringMacro(FieldDataName);
00121 
00124   virtual void SetInputData(vtkDataObject*);
00125 
00128   vtkDataSet *GetInput();
00129 
00131 
00135   vtkSetMacro(LabelMode, int);
00136   vtkGetMacro(LabelMode, int);
00137   void SetLabelModeToLabelIds() {this->SetLabelMode(VTK_LABEL_IDS);};
00138   void SetLabelModeToLabelScalars() {this->SetLabelMode(VTK_LABEL_SCALARS);};
00139   void SetLabelModeToLabelVectors() {this->SetLabelMode(VTK_LABEL_VECTORS);};
00140   void SetLabelModeToLabelNormals() {this->SetLabelMode(VTK_LABEL_NORMALS);};
00141   void SetLabelModeToLabelTCoords() {this->SetLabelMode(VTK_LABEL_TCOORDS);};
00142   void SetLabelModeToLabelTensors() {this->SetLabelMode(VTK_LABEL_TENSORS);};
00143   void SetLabelModeToLabelFieldData()
00144             {this->SetLabelMode(VTK_LABEL_FIELD_DATA);};
00146 
00148 
00151   virtual void SetLabelTextProperty(vtkTextProperty *p)
00152     { this->SetLabelTextProperty(p, 0); }
00153   virtual vtkTextProperty* GetLabelTextProperty()
00154     { return this->GetLabelTextProperty(0); }
00155   virtual void SetLabelTextProperty(vtkTextProperty *p, int type);
00156   virtual vtkTextProperty* GetLabelTextProperty(int type);
00158 
00160 
00161   void RenderOpaqueGeometry(vtkViewport* viewport, vtkActor2D* actor);
00162   void RenderOverlay(vtkViewport* viewport, vtkActor2D* actor);
00164 
00166   virtual void ReleaseGraphicsResources(vtkWindow *);
00167 
00169 
00170   vtkGetObjectMacro(Transform, vtkTransform);
00171   void SetTransform(vtkTransform* t);
00173 
00174   //BTX
00176   enum Coordinates
00177     {
00178     WORLD=0,           
00179     DISPLAY=1          
00180     };
00181   //ETX
00182 
00184 
00187   vtkGetMacro(CoordinateSystem,int);
00188   vtkSetClampMacro(CoordinateSystem,int,WORLD,DISPLAY);
00189   void CoordinateSystemWorld() { this->SetCoordinateSystem( vtkLabeledDataMapper::WORLD ); }
00190   void CoordinateSystemDisplay() { this->SetCoordinateSystem( vtkLabeledDataMapper::DISPLAY ); }
00192 
00194   virtual unsigned long GetMTime();
00195 
00197 
00198   vtkGetMacro(NumberOfLabels, int)
00200 
00202 
00203   void GetLabelPosition(int label, double pos[3])
00204   {
00205     assert("label index range" && label >= 0 && label < this->NumberOfLabels);
00206     pos[0] = this->LabelPositions[3 * label];
00207     pos[1] = this->LabelPositions[3 * label + 1];
00208     pos[2] = this->LabelPositions[3 * label + 2];
00209   }
00211 
00213   const char *GetLabelText(int label);
00214 
00215 protected:
00216   vtkLabeledDataMapper();
00217   ~vtkLabeledDataMapper();
00218 
00219   vtkDataSet *Input;
00220 
00221   char  *LabelFormat;
00222   int   LabelMode;
00223   int   LabeledComponent;
00224   int   FieldDataArray;
00225   char  *FieldDataName;
00226   int CoordinateSystem;
00227 
00228   vtkTimeStamp BuildTime;
00229 
00230   int NumberOfLabels;
00231   int NumberOfLabelsAllocated;
00232   vtkTextMapper **TextMappers;
00233   double* LabelPositions;
00234   vtkTransform *Transform;
00235 
00236   virtual int FillInputPortInformation(int, vtkInformation*);
00237 
00238   void AllocateLabels(int numLabels);
00239   void BuildLabels();
00240   void BuildLabelsInternal(vtkDataSet*);
00241 
00242   //BTX
00243   class Internals;
00244   Internals* Implementation;
00245   //ETX
00246 
00247 private:
00248   vtkLabeledDataMapper(const vtkLabeledDataMapper&);  // Not implemented.
00249   void operator=(const vtkLabeledDataMapper&);  // Not implemented.
00250 };
00251 
00252 #endif
00253