OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkCoordinate.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkCoordinate.h,v $
5   Language:  C++
6   Date:      $Date: 2002/06/07 22:11:04 $
7   Version:   $Revision: 1.29 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
13      This software is distributed WITHOUT ANY WARRANTY; without even 
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15      PURPOSE.  See the above copyright notice for more information.
16
17 =========================================================================*/
18 // .NAME vtkCoordinate - perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
19 // .SECTION Description
20 // vtkCoordinate represents position in a variety of coordinate systems, and
21 // converts position to other coordinate systems. It also supports relative
22 // positioning, so you can create a cascade of vtkCoordinate objects (no loops
23 // please!) that refer to each other. The typical usage of this object is
24 // to set the coordinate system in which to represent a position (e.g., 
25 // SetCoordinateSystemToNormalizedDisplay()), set the value of the coordinate
26 // (e.g., SetValue()), and then invoke the appropriate method to convert to 
27 // another coordinate system (e.g., GetComputedWorldValue()).
28 // 
29 // The coordinate systems in vtk are as follows:
30 //<PRE>
31 //  DISPLAY -             x-y pixel values in window
32 //  NORMALIZED DISPLAY -  x-y (0,1) normalized values
33 //  VIEWPORT -            x-y pixel values in viewport
34 //  NORMALIZED VIEWPORT - x-y (0,1) normalized value in viewport
35 //  VIEW -                x-y-z (-1,1) values in camera coordinates. (z is depth)
36 //  WORLD -               x-y-z global coordinate values
37 //  USERDEFINED -         x-y-z in User defined space
38 //</PRE>
39 //
40 // If you cascade vtkCoordinate objects, you refer to another vtkCoordinate
41 // object which in turn can refer to others, and so on. This allows you to
42 // create composite groups of things like vtkActor2D that are positioned
43 // relative to one another. Note that in cascaded sequences, each
44 // vtkCoordinate object may be specified in different coordinate systems!
45
46 // .SECTION See Also
47 // vtkProp2D vtkActor2D vtkScalarBarActor
48
49 #ifndef __vtkCoordinate_h
50 #define __vtkCoordinate_h
51
52 #include "vtkObject.h"
53 class vtkViewport;
54
55 #define VTK_DISPLAY             0
56 #define VTK_NORMALIZED_DISPLAY  1
57 #define VTK_VIEWPORT            2
58 #define VTK_NORMALIZED_VIEWPORT 3
59 #define VTK_VIEW                4
60 #define VTK_WORLD               5
61 #define VTK_USERDEFINED         6
62
63 class VTK_COMMON_EXPORT vtkCoordinate : public vtkObject
64 {
65 public:
66   vtkTypeRevisionMacro(vtkCoordinate,vtkObject);
67   void PrintSelf(ostream& os, vtkIndent indent);
68
69   // Description:
70   // Creates an instance of this class with the following defaults: 
71   // value of  (0,0,0) in world  coordinates.
72   static vtkCoordinate* New();
73
74   // Description:
75   // Set/get the coordinate system which this coordinate
76   // is defined in. The options are Display, Normalized Display,
77   // Viewport, Normalized Viewport, View, and World.
78   vtkSetMacro(CoordinateSystem, int);
79   vtkGetMacro(CoordinateSystem, int);
80   void SetCoordinateSystemToDisplay() {this->SetCoordinateSystem(VTK_DISPLAY);}
81   void SetCoordinateSystemToNormalizedDisplay() 
82         {this->SetCoordinateSystem(VTK_NORMALIZED_DISPLAY);}
83   void SetCoordinateSystemToViewport() 
84         {this->SetCoordinateSystem(VTK_VIEWPORT);}
85   void SetCoordinateSystemToNormalizedViewport() 
86         {this->SetCoordinateSystem(VTK_NORMALIZED_VIEWPORT);}
87   void SetCoordinateSystemToView() {this->SetCoordinateSystem(VTK_VIEW);}
88   void SetCoordinateSystemToWorld() {this->SetCoordinateSystem(VTK_WORLD);}
89     
90   const char *GetCoordinateSystemAsString ();
91
92   // Description:
93   // Set/get the value of this coordinate. This can be thought of as
94   // the position of this coordinate in its coordinate system.
95   vtkSetVector3Macro(Value,float);
96   vtkGetVector3Macro(Value,float);
97   void SetValue(float a, float b) { this->SetValue(a,b,0.0);}
98   
99   // Description:
100   // If this coordinate is relative to another coordinate,
101   // then specify that coordinate as the ReferenceCoordinate.
102   // If this is NULL the coordinate is assumed to be absolute.
103   virtual void SetReferenceCoordinate(vtkCoordinate*);
104   vtkGetObjectMacro(ReferenceCoordinate,vtkCoordinate);
105
106   // Description:
107   // If you want this coordinate to be relative to a specific
108   // vtkViewport (vtkRenderer, vtkImager) then you can specify
109   // that here.
110   void SetViewport(vtkViewport *viewport);
111   vtkGetObjectMacro(Viewport,vtkViewport);
112
113   // Description:
114   // Return the computed value in a specified coordinate system.
115   float *GetComputedWorldValue(vtkViewport *);
116   int *GetComputedViewportValue(vtkViewport *);
117   int *GetComputedDisplayValue(vtkViewport *);
118   int *GetComputedLocalDisplayValue(vtkViewport *);
119
120   float *GetComputedFloatViewportValue(vtkViewport *);
121   float *GetComputedFloatDisplayValue(vtkViewport *);
122
123   // Description:
124   // GetComputedValue() will return either World, Viewport or
125   // Display based on what has been set as the coordinate system.
126   // This is good for objects like vtkLineSource, where the
127   // user might want to use them as World or Viewport coordinates
128   float *GetComputedValue(vtkViewport *);
129
130   // Description:
131   // GetComputedUserDefinedValue() is to be used only when
132   // the coordinate system is VTK_USERDEFINED. The user
133   // must subclass vtkCoordinate and override this function,
134   // when set as the TransformCoordinate in 2D-Mappers, the user
135   // can customize display of 2D polygons
136   virtual float *GetComputedUserDefinedValue(vtkViewport *)
137     { return this->Value; }
138
139 protected:
140   vtkCoordinate();
141   ~vtkCoordinate();
142
143   float Value[3];
144   int   CoordinateSystem;
145   vtkCoordinate *ReferenceCoordinate;
146   vtkViewport *Viewport;
147   float ComputedWorldValue[3];
148   int   ComputedDisplayValue[2];
149   int   ComputedViewportValue[2];
150   int   Computing;
151
152   float ComputedFloatDisplayValue[2];
153   float ComputedFloatViewportValue[2];
154   float ComputedUserDefinedValue[3];
155
156 private:
157   vtkCoordinate(const vtkCoordinate&);  // Not implemented.
158   void operator=(const vtkCoordinate&);  // Not implemented.
159 };
160
161 #endif
162
163