OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkPicker.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkPicker.h,v $
5   Language:  C++
6   Date:      $Date: 2002/08/26 02:31:16 $
7   Version:   $Revision: 1.48 $
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 vtkPicker - superclass for 3D geometric pickers (uses ray cast)
19 // .SECTION Description
20 // vtkPicker is used to select instances of vtkProp3D by shooting a ray 
21 // into a graphics window and intersecting with the actor's bounding box. 
22 // The ray is defined from a point defined in window (or pixel) coordinates, 
23 // and a point located from the camera's position.
24 //
25 // vtkPicker may return more than one vtkProp3D, since more than one bounding 
26 // box may be intersected. vtkPicker returns the list of props that were hit, 
27 // the pick coordinates in world and untransformed mapper space, and the 
28 // prop (vtkProp3D) and mapper that are "closest" to the camera. The closest 
29 // prop is the one whose center point (i.e., center of bounding box) 
30 // projected on the ray is closest to the camera.
31
32 // .SECTION See Also
33 // vtkPicker is used for quick geometric picking. If you desire to pick
34 // points or cells, use the subclass vtkPointPicker or vtkCellPicker,
35 // respectively.  Or you may use hardware picking to pick any type of vtkProp
36 // - see vtkPropPicker or vtkWorldPointPicker.
37
38 #ifndef __vtkPicker_h
39 #define __vtkPicker_h
40
41 #include "vtkAbstractPropPicker.h"
42
43 class vtkAbstractMapper3D;
44 class vtkDataSet;
45 class vtkTransform;
46 class vtkActorCollection;
47 class vtkProp3DCollection;
48 class vtkPoints;
49
50 class VTK_RENDERING_EXPORT vtkPicker : public vtkAbstractPropPicker
51 {
52 public:
53   static vtkPicker *New();
54   vtkTypeRevisionMacro(vtkPicker,vtkAbstractPropPicker);
55   void PrintSelf(ostream& os, vtkIndent indent);
56
57   // Description:
58   // Specify tolerance for performing pick operation. Tolerance is specified
59   // as fraction of rendering window size. (Rendering window size is measured
60   // across diagonal.)
61   vtkSetMacro(Tolerance,float);
62   vtkGetMacro(Tolerance,float);
63
64   // Description:
65   // Return position in mapper (i.e., non-transformed) coordinates of 
66   // pick point.
67   vtkGetVectorMacro(MapperPosition,float,3);
68
69   // Description:
70   // Return mapper that was picked (if any).
71   vtkGetObjectMacro(Mapper,vtkAbstractMapper3D);
72
73   // Description:
74   // Get a pointer to the dataset that was picked (if any). If nothing 
75   // was picked then NULL is returned.
76   vtkGetObjectMacro(DataSet,vtkDataSet);
77
78   // Description:
79   // Return a collection of all the prop 3D's that were intersected
80   // by the pick ray. This collection is not sorted.
81   vtkProp3DCollection *GetProp3Ds() {return this->Prop3Ds;};
82
83   // Description:
84   // Return a collection of all the actors that were intersected.
85   // This collection is not sorted. (This is a convenience method
86   // to maintain backward compatibility.)
87   vtkActorCollection *GetActors();
88
89   // Description:
90   // Return a list of the points the the actors returned by GetActors
91   // were intersected at. The order of this list will match the order of
92   // GetActors.
93   vtkPoints *GetPickedPositions() {return this->PickedPositions;};
94   
95   // Description:
96   // Perform pick operation with selection point provided. Normally the 
97   // first two values for the selection point are x-y pixel coordinate, and
98   // the third value is =0. Return non-zero if something was successfully 
99   // picked.
100   virtual int Pick(float selectionX, float selectionY, float selectionZ, 
101                    vtkRenderer *renderer);  
102
103   // Description: 
104   // Perform pick operation with selection point provided. Normally the first
105   // two values for the selection point are x-y pixel coordinate, and the
106   // third value is =0. Return non-zero if something was successfully picked.
107   int Pick(float selectionPt[3], vtkRenderer *ren)
108     {return this->Pick(selectionPt[0], selectionPt[1], selectionPt[2], ren);};
109       
110 protected:
111   vtkPicker();
112   ~vtkPicker();
113
114   void MarkPicked(vtkAssemblyPath *path, vtkProp3D *p, vtkAbstractMapper3D *m, 
115                   float tMin, float mapperPos[3]);
116   virtual float IntersectWithLine(float p1[3], float p2[3], float tol, 
117                                   vtkAssemblyPath *path, vtkProp3D *p, 
118                                   vtkAbstractMapper3D *m);
119   virtual void Initialize();
120
121   float Tolerance; //tolerance for computation (% of window)
122   float MapperPosition[3]; //selection point in untransformed coordinates
123
124   vtkAbstractMapper3D *Mapper; //selected mapper (if the prop has a mapper)
125   vtkDataSet *DataSet; //selected dataset (if there is one)
126
127   float GlobalTMin; //parametric coordinate along pick ray where hit occured
128   vtkTransform *Transform; //use to perform ray transformation
129   vtkActorCollection *Actors; //candidate actors (based on bounding box)
130   vtkProp3DCollection *Prop3Ds; //candidate actors (based on bounding box)
131   vtkPoints *PickedPositions; // candidate positions
132   
133 private:
134   vtkPicker(const vtkPicker&);  // Not implemented.
135   void operator=(const vtkPicker&);  // Not implemented.
136 };
137
138
139 #endif
140
141