SIVIC API  0.9.26
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
svkAreaPicker.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2009-2014 The Regents of the University of California.
3  * All Rights Reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * • Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * • Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12  * • None of the names of any campus of the University of California, the name
13  * "The Regents of the University of California," or the names of any of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
26  * OF SUCH DAMAGE.
27  */
28 
29 
30 
31 /*
32  * $URL$
33  * $Rev$
34  * $Author$
35  * $Date$
36  *
37  * Authors:
38  * Jason C. Crane, Ph.D.
39  * Beck Olson
40  *
41  * NOTE: This class is deprecated and no longer in use.
42  */
43 
44 /*=========================================================================
45 
46  Program: Visualization Toolkit
47  Module: $RCSfile: svkAreaPicker.h,v $
48 
49  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
50  All rights reserved.
51  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
52 
53  This software is distributed WITHOUT ANY WARRANTY; without even
54  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
55  PURPOSE. See the above copyright notice for more information.
56 
57 =========================================================================*/
58 // .NAME svkAreaPicker - Picks props behind a selection rectangle on a viewport.
59 //
60 // .SECTION Description
61 // The svkAreaPicker picks all vtkProp3Ds that lie behind the screen space
62 // rectangle from x0,y0 and x1,y1. The selection is based upon the bounding
63 // box of the prop and is thus not exact.
64 //
65 // Like vtkPicker, a pick results in a list of Prop3Ds because many props may
66 // lie within the pick frustum. You can also get an AssemblyPath, which in this
67 // case is defined to be the path to the one particular prop in the Prop3D list
68 // that lies nearest to the near plane.
69 //
70 // This picker also returns the selection frustum, defined as either a
71 // vtkPlanes, or a set of eight corner vertices in world space. The vtkPlanes
72 // version is an ImplicitFunction, which is suitable for use with the
73 // vtkExtractGeometry. The six frustum planes are in order: left, right,
74 // bottom, top, near, far
75 //
76 // Because this picker picks everything within a volume, the world pick point
77 // result is ill-defined. Therefore if you ask this class for the world pick
78 // position, you will get the centroid of the pick frustum. This may be outside
79 // of all props in the prop list.
80 //
81 // .SECTION See Also
82 // vtkInteractorStyleRubberBandPick, vtkExtractSelectedFrustum.
83 
84 #ifndef __svkAreaPicker_h
85 #define __svkAreaPicker_h
86 
87 #include "vtkAbstractPropPicker.h"
88 
89 
90 class vtkRenderer;
91 class vtkPoints;
92 class vtkPlanes;
93 class vtkProp3DCollection;
94 class vtkAbstractMapper3D;
95 class vtkDataSet;
96 class vtkExtractSelectedFrustum;
97 class vtkProp;
98 class vtkImageActor;
99 
100 class VTK_RENDERING_EXPORT svkAreaPicker : public vtkAbstractPropPicker
101 {
102 public:
103  static svkAreaPicker *New();
104  vtkTypeMacro(svkAreaPicker,vtkAbstractPropPicker);
105  void PrintSelf(ostream& os, vtkIndent indent);
106 
107  // Description:
108  // Set the default screen rectangle to pick in.
109  void SetPickCoords(double x0, double y0, double x1, double y1);
110 
111  // Description:
112  // Set the default renderer to pick on.
113  void SetRenderer(vtkRenderer *);
114 
115  // Description:
116  // Perform an AreaPick within the default screen rectangle and renderer.
117  virtual int Pick();
118 
119  // Description:
120  // Perform pick operation in volume behind the given screen coordinates.
121  // Props intersecting the selection frustum will be accesible via GetProp3D.
122  // GetPlanes returns a vtkImplicitFunciton suitable for vtkExtractGeometry.
123  virtual int AreaPick(double x0, double y0, double x1, double y1, vtkRenderer *renderer = NULL);
124 
125  // Description:
126  // Perform pick operation in volume behind the given screen coordinate.
127  // This makes a thin frustum around the selected pixel.
128  // Note: this ignores Z in order to pick everying in a volume from z=0 to z=1.
129  virtual int Pick(double x0, double y0, double vtkNotUsed(z0), vtkRenderer *renderer = NULL)
130  {return this->AreaPick(x0, y0, x0+1.0, y0+1.0, renderer);};
131 
132  // Description:
133  // Return mapper that was picked (if any).
134  vtkGetObjectMacro(Mapper,vtkAbstractMapper3D);
135 
136  // Description:
137  // Get a pointer to the dataset that was picked (if any). If nothing
138  // was picked then NULL is returned.
139  vtkGetObjectMacro(DataSet,vtkDataSet);
140 
141  // Description:
142  // Return a collection of all the prop 3D's that were intersected
143  // by the pick ray. This collection is not sorted.
144  vtkProp3DCollection *GetProp3Ds() {return this->Prop3Ds;};
145 
146  // Description:
147  // Return the six planes that define the selection frustum. The implicit
148  // function defined by the planes evaluates to negative inside and positive
149  // outside.
150  vtkGetObjectMacro(Frustum, vtkPlanes);
151 
152  // Description:
153  // Return eight points that define the selection frustum.
154  vtkGetObjectMacro(ClipPoints, vtkPoints);
155 
156 protected:
157  svkAreaPicker();
158  ~svkAreaPicker();
159 
160  virtual void Initialize();
161  void DefineFrustum(double x0, double y0, double x1, double y1, vtkRenderer *renderer);
162  virtual int PickProps(vtkRenderer *renderer);
163  int TypeDecipher(vtkProp *, vtkImageActor **, vtkAbstractMapper3D **);
164 
165  int ABoxFrustumIsect(double bounds[], double &mindist);
166 
167  vtkPoints *ClipPoints;
168  vtkPlanes *Frustum;
169 
170  vtkProp3DCollection *Prop3Ds; //candidate actors (based on bounding box)
171  vtkAbstractMapper3D *Mapper; //selected mapper (if the prop has a mapper)
172  vtkDataSet *DataSet; //selected dataset (if there is one)
173 
174  //used internally to do prop intersection tests
175  vtkExtractSelectedFrustum *FrustumExtractor;
176 
177  double X0;
178  double Y0;
179  double X1;
180  double Y1;
181 
182 private:
183  svkAreaPicker(const svkAreaPicker&); // Not implemented.
184  void operator=(const svkAreaPicker&); // Not implemented.
185 };
186 
187 
188 #endif
189 
190 
double Y1
Definition: svkAreaPicker.h:180
vtkPlanes * Frustum
Definition: svkAreaPicker.h:168
Definition: svkAreaPicker.h:100
vtkDataSet * DataSet
Definition: svkAreaPicker.h:172
vtkProp3DCollection * GetProp3Ds()
Definition: svkAreaPicker.h:144
vtkProp3DCollection * Prop3Ds
Definition: svkAreaPicker.h:170
double X0
Definition: svkAreaPicker.h:177
double X1
Definition: svkAreaPicker.h:179
vtkExtractSelectedFrustum * FrustumExtractor
Definition: svkAreaPicker.h:175
double Y0
Definition: svkAreaPicker.h:178
vtkAbstractMapper3D * Mapper
Definition: svkAreaPicker.h:171
vtkPoints * ClipPoints
Definition: svkAreaPicker.h:167
virtual int Pick(double x0, double y0, double vtkNotUsed(z0), vtkRenderer *renderer=NULL)
Definition: svkAreaPicker.h:129