1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: TestImplicitPlaneWidget.cxx
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14 =========================================================================*/
15 #include "vtkSmartPointer.h"
16
17 #include "vtkActor.h"
18 #include "vtkAppendPolyData.h"
19 #include "vtkClipPolyData.h"
20 #include "vtkCommand.h"
21 #include "vtkConeSource.h"
22 #include "vtkGlyph3D.h"
23 #include "vtkImplicitPlaneWidget.h"
24 #include "vtkInteractorEventRecorder.h"
25 #include "vtkLODActor.h"
26 #include "vtkPlane.h"
27 #include "vtkPolyData.h"
28 #include "vtkPolyDataMapper.h"
29 #include "vtkProperty.h"
30 #include "vtkRenderWindow.h"
31 #include "vtkRenderWindowInteractor.h"
32 #include "vtkRenderer.h"
33 #include "vtkSphereSource.h"
34
35 const char eventLog[] =
36 "# StreamVersion 1\n"
37 "CharEvent 108 202 0 0 105 1 i\n"
38 "KeyReleaseEvent 108 202 0 0 105 1 i\n"
39 "MouseMoveEvent 255 120 0 0 0 0 i\n"
40 "MouseMoveEvent 255 121 0 0 0 0 i\n"
41 "MouseMoveEvent 255 122 0 0 0 0 i\n"
42 "MouseMoveEvent 255 123 0 0 0 0 i\n"
43 "MouseMoveEvent 255 125 0 0 0 0 i\n"
44 "MouseMoveEvent 255 126 0 0 0 0 i\n"
45 "MouseMoveEvent 253 129 0 0 0 0 i\n"
46 "MouseMoveEvent 253 133 0 0 0 0 i\n"
47 "MouseMoveEvent 253 138 0 0 0 0 i\n"
48 "MouseMoveEvent 253 141 0 0 0 0 i\n"
49 "MouseMoveEvent 251 147 0 0 0 0 i\n"
50 "MouseMoveEvent 251 146 0 0 0 0 i\n"
51 "MouseMoveEvent 251 147 0 0 0 0 i\n"
52 "MouseMoveEvent 251 148 0 0 0 0 i\n"
53 "LeftButtonPressEvent 251 148 0 0 0 0 i\n"
54 "MouseMoveEvent 251 149 0 0 0 0 i\n"
55 "MouseMoveEvent 251 150 0 0 0 0 i\n"
56 "MouseMoveEvent 251 151 0 0 0 0 i\n"
57 "MouseMoveEvent 251 152 0 0 0 0 i\n"
58 "MouseMoveEvent 251 153 0 0 0 0 i\n"
59 "MouseMoveEvent 251 154 0 0 0 0 i\n"
60 "MouseMoveEvent 250 154 0 0 0 0 i\n"
61 "MouseMoveEvent 250 155 0 0 0 0 i\n"
62 "MouseMoveEvent 250 157 0 0 0 0 i\n"
63 "MouseMoveEvent 250 158 0 0 0 0 i\n"
64 "MouseMoveEvent 250 159 0 0 0 0 i\n"
65 "MouseMoveEvent 249 160 0 0 0 0 i\n"
66 "MouseMoveEvent 249 161 0 0 0 0 i\n"
67 "MouseMoveEvent 249 163 0 0 0 0 i\n"
68 "MouseMoveEvent 249 166 0 0 0 0 i\n"
69 "MouseMoveEvent 249 167 0 0 0 0 i\n"
70 "MouseMoveEvent 249 169 0 0 0 0 i\n"
71 "MouseMoveEvent 249 170 0 0 0 0 i\n"
72 "MouseMoveEvent 249 171 0 0 0 0 i\n"
73 "MouseMoveEvent 248 172 0 0 0 0 i\n"
74 "MouseMoveEvent 248 174 0 0 0 0 i\n"
75 "MouseMoveEvent 247 174 0 0 0 0 i\n"
76 "MouseMoveEvent 247 175 0 0 0 0 i\n"
77 "MouseMoveEvent 247 174 0 0 0 0 i\n"
78 "MouseMoveEvent 247 172 0 0 0 0 i\n"
79 "MouseMoveEvent 246 170 0 0 0 0 i\n"
80 "MouseMoveEvent 245 170 0 0 0 0 i\n"
81 "MouseMoveEvent 244 170 0 0 0 0 i\n"
82 "MouseMoveEvent 239 168 0 0 0 0 i\n"
83 "MouseMoveEvent 235 166 0 0 0 0 i\n"
84 "MouseMoveEvent 232 166 0 0 0 0 i\n"
85 "MouseMoveEvent 232 167 0 0 0 0 i\n"
86 "MouseMoveEvent 231 167 0 0 0 0 i\n"
87 "MouseMoveEvent 230 168 0 0 0 0 i\n"
88 "MouseMoveEvent 229 170 0 0 0 0 i\n"
89 "MouseMoveEvent 227 173 0 0 0 0 i\n"
90 "MouseMoveEvent 227 174 0 0 0 0 i\n"
91 "MouseMoveEvent 226 176 0 0 0 0 i\n"
92 "MouseMoveEvent 224 180 0 0 0 0 i\n"
93 "MouseMoveEvent 224 182 0 0 0 0 i\n"
94 "MouseMoveEvent 224 184 0 0 0 0 i\n"
95 "MouseMoveEvent 224 186 0 0 0 0 i\n"
96 "MouseMoveEvent 221 190 0 0 0 0 i\n"
97 "MouseMoveEvent 218 191 0 0 0 0 i\n"
98 "MouseMoveEvent 218 192 0 0 0 0 i\n"
99 "MouseMoveEvent 218 195 0 0 0 0 i\n"
100 "MouseMoveEvent 217 200 0 0 0 0 i\n"
101 "MouseMoveEvent 217 203 0 0 0 0 i\n"
102 "MouseMoveEvent 217 207 0 0 0 0 i\n"
103 "MouseMoveEvent 217 208 0 0 0 0 i\n"
104 "MouseMoveEvent 217 210 0 0 0 0 i\n"
105 "MouseMoveEvent 217 211 0 0 0 0 i\n"
106 "MouseMoveEvent 217 214 0 0 0 0 i\n"
107 "MouseMoveEvent 217 216 0 0 0 0 i\n"
108 "MouseMoveEvent 217 217 0 0 0 0 i\n"
109 "MouseMoveEvent 219 218 0 0 0 0 i\n"
110 "MouseMoveEvent 220 219 0 0 0 0 i\n"
111 "MouseMoveEvent 220 222 0 0 0 0 i\n"
112 "MouseMoveEvent 220 225 0 0 0 0 i\n"
113 "MouseMoveEvent 220 227 0 0 0 0 i\n"
114 "MouseMoveEvent 220 228 0 0 0 0 i\n"
115 "MouseMoveEvent 220 230 0 0 0 0 i\n"
116 "MouseMoveEvent 220 232 0 0 0 0 i\n"
117 "MouseMoveEvent 220 236 0 0 0 0 i\n"
118 "MouseMoveEvent 220 237 0 0 0 0 i\n"
119 "MouseMoveEvent 220 238 0 0 0 0 i\n"
120 "MouseMoveEvent 220 239 0 0 0 0 i\n"
121 "MouseMoveEvent 219 239 0 0 0 0 i\n"
122 "MouseMoveEvent 218 239 0 0 0 0 i\n"
123 "MouseMoveEvent 217 239 0 0 0 0 i\n"
124 "MouseMoveEvent 217 238 0 0 0 0 i\n"
125 "MouseMoveEvent 217 237 0 0 0 0 i\n"
126 "LeftButtonReleaseEvent 217 237 0 0 0 0 i\n"
127 "MouseMoveEvent 213 233 0 0 0 0 i\n"
128 "MouseMoveEvent 212 231 0 0 0 0 i\n"
129 "MouseMoveEvent 212 227 0 0 0 0 i\n"
130 "MouseMoveEvent 211 225 0 0 0 0 i\n"
131 "MouseMoveEvent 211 221 0 0 0 0 i\n"
132 "MouseMoveEvent 208 216 0 0 0 0 i\n"
133 "MouseMoveEvent 206 214 0 0 0 0 i\n"
134 "MouseMoveEvent 206 210 0 0 0 0 i\n"
135 "MouseMoveEvent 206 206 0 0 0 0 i\n"
136 "MouseMoveEvent 206 201 0 0 0 0 i\n"
137 "MouseMoveEvent 206 198 0 0 0 0 i\n"
138 "MouseMoveEvent 206 194 0 0 0 0 i\n"
139 "MouseMoveEvent 206 189 0 0 0 0 i\n"
140 "MouseMoveEvent 206 185 0 0 0 0 i\n"
141 "MouseMoveEvent 206 180 0 0 0 0 i\n"
142 "MouseMoveEvent 205 175 0 0 0 0 i\n"
143 "MouseMoveEvent 203 171 0 0 0 0 i\n"
144 "MouseMoveEvent 202 168 0 0 0 0 i\n"
145 "MouseMoveEvent 202 161 0 0 0 0 i\n"
146 "MouseMoveEvent 201 156 0 0 0 0 i\n"
147 "MouseMoveEvent 200 150 0 0 0 0 i\n"
148 "MouseMoveEvent 198 147 0 0 0 0 i\n"
149 "MouseMoveEvent 198 143 0 0 0 0 i\n"
150 "MouseMoveEvent 196 140 0 0 0 0 i\n"
151 "MouseMoveEvent 196 136 0 0 0 0 i\n"
152 "MouseMoveEvent 193 131 0 0 0 0 i\n"
153 "MouseMoveEvent 192 121 0 0 0 0 i\n"
154 "MouseMoveEvent 192 114 0 0 0 0 i\n"
155 "MouseMoveEvent 192 109 0 0 0 0 i\n"
156 "MouseMoveEvent 192 104 0 0 0 0 i\n"
157 "MouseMoveEvent 192 100 0 0 0 0 i\n"
158 "MouseMoveEvent 192 97 0 0 0 0 i\n"
159 "MouseMoveEvent 189 93 0 0 0 0 i\n"
160 "MouseMoveEvent 188 92 0 0 0 0 i\n"
161 "MouseMoveEvent 187 90 0 0 0 0 i\n"
162 "MouseMoveEvent 186 89 0 0 0 0 i\n"
163 "MouseMoveEvent 185 88 0 0 0 0 i\n"
164 "MouseMoveEvent 184 86 0 0 0 0 i\n"
165 "MouseMoveEvent 184 85 0 0 0 0 i\n"
166 "MouseMoveEvent 183 85 0 0 0 0 i\n"
167 "MouseMoveEvent 182 84 0 0 0 0 i\n"
168 "MouseMoveEvent 180 83 0 0 0 0 i\n"
169 "MouseMoveEvent 179 83 0 0 0 0 i\n"
170 "MouseMoveEvent 178 83 0 0 0 0 i\n"
171 "MouseMoveEvent 175 82 0 0 0 0 i\n"
172 "MouseMoveEvent 173 81 0 0 0 0 i\n"
173 "MouseMoveEvent 169 79 0 0 0 0 i\n"
174 "MouseMoveEvent 168 78 0 0 0 0 i\n"
175 "MouseMoveEvent 167 78 0 0 0 0 i\n"
176 "MouseMoveEvent 167 79 0 0 0 0 i\n"
177 "LeftButtonPressEvent 167 79 0 0 0 0 i\n"
178 "MouseMoveEvent 167 80 0 0 0 0 i\n"
179 "MouseMoveEvent 167 81 0 0 0 0 i\n"
180 "MouseMoveEvent 169 82 0 0 0 0 i\n"
181 "MouseMoveEvent 170 83 0 0 0 0 i\n"
182 "MouseMoveEvent 171 84 0 0 0 0 i\n"
183 "MouseMoveEvent 172 84 0 0 0 0 i\n"
184 "MouseMoveEvent 174 85 0 0 0 0 i\n"
185 "MouseMoveEvent 174 86 0 0 0 0 i\n"
186 "MouseMoveEvent 175 86 0 0 0 0 i\n"
187 "MouseMoveEvent 176 88 0 0 0 0 i\n"
188 "MouseMoveEvent 177 90 0 0 0 0 i\n"
189 "MouseMoveEvent 177 91 0 0 0 0 i\n"
190 "MouseMoveEvent 177 92 0 0 0 0 i\n"
191 "MouseMoveEvent 177 93 0 0 0 0 i\n"
192 "MouseMoveEvent 177 94 0 0 0 0 i\n"
193 "MouseMoveEvent 178 96 0 0 0 0 i\n"
194 "MouseMoveEvent 178 97 0 0 0 0 i\n"
195 "MouseMoveEvent 180 99 0 0 0 0 i\n"
196 "MouseMoveEvent 181 99 0 0 0 0 i\n"
197 "MouseMoveEvent 181 100 0 0 0 0 i\n"
198 "MouseMoveEvent 181 101 0 0 0 0 i\n"
199 "MouseMoveEvent 181 102 0 0 0 0 i\n"
200 "MouseMoveEvent 181 103 0 0 0 0 i\n"
201 "LeftButtonReleaseEvent 181 103 0 0 0 0 i\n"
202 "MouseMoveEvent 181 103 0 0 0 0 i\n"
203 "MouseMoveEvent 181 102 0 0 0 0 i\n"
204 "MouseMoveEvent 181 102 0 0 0 0 i\n"
205 "MouseMoveEvent 181 102 0 0 0 0 i\n"
206 "MouseMoveEvent 182 102 0 0 0 0 i\n"
207 "MouseMoveEvent 183 103 0 0 0 0 i\n"
208 "MouseMoveEvent 183 102 0 0 0 0 i\n"
209 "MouseMoveEvent 184 102 0 0 0 0 i\n"
210 "MouseMoveEvent 185 102 0 0 0 0 i\n"
211 "MouseMoveEvent 185 101 0 0 0 0 i\n"
212 "MouseMoveEvent 185 100 0 0 0 0 i\n"
213 "MouseMoveEvent 185 99 0 0 0 0 i\n"
214 "MiddleButtonPressEvent 185 99 0 0 0 0 i\n"
215 "MouseMoveEvent 185 100 0 0 0 0 i\n"
216 "MouseMoveEvent 182 101 0 0 0 0 i\n"
217 "MouseMoveEvent 181 102 0 0 0 0 i\n"
218 "MouseMoveEvent 180 103 0 0 0 0 i\n"
219 "MouseMoveEvent 179 105 0 0 0 0 i\n"
220 "MouseMoveEvent 176 107 0 0 0 0 i\n"
221 "MouseMoveEvent 173 105 0 0 0 0 i\n"
222 "MouseMoveEvent 173 106 0 0 0 0 i\n"
223 "MouseMoveEvent 173 107 0 0 0 0 i\n"
224 "MouseMoveEvent 173 108 0 0 0 0 i\n"
225 "MouseMoveEvent 173 110 0 0 0 0 i\n"
226 "MouseMoveEvent 172 112 0 0 0 0 i\n"
227 "MouseMoveEvent 172 113 0 0 0 0 i\n"
228 "MouseMoveEvent 172 114 0 0 0 0 i\n"
229 "MouseMoveEvent 172 115 0 0 0 0 i\n"
230 "MouseMoveEvent 173 116 0 0 0 0 i\n"
231 "MouseMoveEvent 173 117 0 0 0 0 i\n"
232 "MouseMoveEvent 174 118 0 0 0 0 i\n"
233 "MouseMoveEvent 174 119 0 0 0 0 i\n"
234 "MouseMoveEvent 174 120 0 0 0 0 i\n"
235 "MouseMoveEvent 174 121 0 0 0 0 i\n"
236 "MouseMoveEvent 174 122 0 0 0 0 i\n"
237 "MouseMoveEvent 175 122 0 0 0 0 i\n"
238 "MiddleButtonReleaseEvent 175 122 0 0 0 0 i\n"
239 "MouseMoveEvent 175 122 0 0 0 0 i\n"
240 "MouseMoveEvent 175 121 0 0 0 0 i\n"
241 "MouseMoveEvent 174 120 0 0 0 0 i\n"
242 "MouseMoveEvent 173 120 0 0 0 0 i\n"
243 "MouseMoveEvent 173 119 0 0 0 0 i\n"
244 "MouseMoveEvent 173 118 0 0 0 0 i\n"
245 "MouseMoveEvent 172 117 0 0 0 0 i\n"
246 "MouseMoveEvent 171 117 0 0 0 0 i\n"
247 "MouseMoveEvent 171 116 0 0 0 0 i\n"
248 "MouseMoveEvent 171 115 0 0 0 0 i\n"
249 "MouseMoveEvent 171 114 0 0 0 0 i\n"
250 "MouseMoveEvent 171 112 0 0 0 0 i\n"
251 "MouseMoveEvent 171 109 0 0 0 0 i\n"
252 "MouseMoveEvent 172 107 0 0 0 0 i\n"
253 "MouseMoveEvent 172 105 0 0 0 0 i\n"
254 "MouseMoveEvent 175 103 0 0 0 0 i\n"
255 "MouseMoveEvent 176 100 0 0 0 0 i\n"
256 "MouseMoveEvent 178 99 0 0 0 0 i\n"
257 "MouseMoveEvent 179 97 0 0 0 0 i\n"
258 "MouseMoveEvent 182 94 0 0 0 0 i\n"
259 "MouseMoveEvent 183 92 0 0 0 0 i\n"
260 "MouseMoveEvent 185 90 0 0 0 0 i\n"
261 "MouseMoveEvent 186 87 0 0 0 0 i\n"
262 "MouseMoveEvent 188 84 0 0 0 0 i\n"
263 "MouseMoveEvent 190 81 0 0 0 0 i\n"
264 "MouseMoveEvent 193 79 0 0 0 0 i\n"
265 "MouseMoveEvent 195 78 0 0 0 0 i\n"
266 "MouseMoveEvent 197 76 0 0 0 0 i\n"
267 "MouseMoveEvent 201 75 0 0 0 0 i\n"
268 "MouseMoveEvent 205 71 0 0 0 0 i\n"
269 "MouseMoveEvent 209 67 0 0 0 0 i\n"
270 "MouseMoveEvent 215 63 0 0 0 0 i\n"
271 "MouseMoveEvent 221 58 0 0 0 0 i\n"
272 "MouseMoveEvent 226 56 0 0 0 0 i\n"
273 "MouseMoveEvent 228 54 0 0 0 0 i\n"
274 "MouseMoveEvent 231 50 0 0 0 0 i\n"
275 "MouseMoveEvent 235 47 0 0 0 0 i\n"
276 "MouseMoveEvent 237 45 0 0 0 0 i\n"
277 "MouseMoveEvent 239 42 0 0 0 0 i\n"
278 "MouseMoveEvent 243 42 0 0 0 0 i\n"
279 "MouseMoveEvent 245 41 0 0 0 0 i\n"
280 "MouseMoveEvent 246 40 0 0 0 0 i\n"
281 "MouseMoveEvent 246 39 0 0 0 0 i\n"
282 "MouseMoveEvent 247 39 0 0 0 0 i\n"
283 "MouseMoveEvent 248 38 0 0 0 0 i\n"
284 "MouseMoveEvent 249 38 0 0 0 0 i\n"
285 "MouseMoveEvent 250 38 0 0 0 0 i\n"
286 "MouseMoveEvent 250 37 0 0 0 0 i\n"
287 "MouseMoveEvent 252 36 0 0 0 0 i\n"
288 "MouseMoveEvent 253 36 0 0 0 0 i\n"
289 "MouseMoveEvent 254 36 0 0 0 0 i\n"
290 "MouseMoveEvent 254 37 0 0 0 0 i\n"
291 "MouseMoveEvent 255 37 0 0 0 0 i\n"
292 "MouseMoveEvent 256 37 0 0 0 0 i\n"
293 "MouseMoveEvent 257 37 0 0 0 0 i\n"
294 "MouseMoveEvent 258 37 0 0 0 0 i\n"
295 "MouseMoveEvent 259 38 0 0 0 0 i\n"
296 "MouseMoveEvent 260 39 0 0 0 0 i\n"
297 "MouseMoveEvent 260 40 0 0 0 0 i\n"
298 "MouseMoveEvent 259 40 0 0 0 0 i\n"
299 "MouseMoveEvent 258 40 0 0 0 0 i\n"
300 "MouseMoveEvent 257 40 0 0 0 0 i\n"
301 "MouseMoveEvent 257 41 0 0 0 0 i\n"
302 "MouseMoveEvent 257 42 0 0 0 0 i\n"
303 "MouseMoveEvent 257 43 0 0 0 0 i\n"
304 "MouseMoveEvent 257 44 0 0 0 0 i\n"
305 "MouseMoveEvent 258 44 0 0 0 0 i\n"
306 "LeftButtonPressEvent 258 44 0 0 0 0 i\n"
307 "MouseMoveEvent 258 45 0 0 0 0 i\n"
308 "MouseMoveEvent 259 45 0 0 0 0 i\n"
309 "MouseMoveEvent 259 46 0 0 0 0 i\n"
310 "MouseMoveEvent 259 47 0 0 0 0 i\n"
311 "MouseMoveEvent 259 49 0 0 0 0 i\n"
312 "MouseMoveEvent 259 50 0 0 0 0 i\n"
313 "MouseMoveEvent 259 51 0 0 0 0 i\n"
314 "MouseMoveEvent 259 52 0 0 0 0 i\n"
315 "MouseMoveEvent 260 53 0 0 0 0 i\n"
316 "MouseMoveEvent 260 54 0 0 0 0 i\n"
317 "MouseMoveEvent 260 55 0 0 0 0 i\n"
318 "MouseMoveEvent 260 56 0 0 0 0 i\n"
319 "MouseMoveEvent 260 57 0 0 0 0 i\n"
320 "MouseMoveEvent 261 58 0 0 0 0 i\n"
321 "MouseMoveEvent 261 59 0 0 0 0 i\n"
322 "MouseMoveEvent 261 60 0 0 0 0 i\n"
323 "MouseMoveEvent 261 61 0 0 0 0 i\n"
324 "MouseMoveEvent 261 60 0 0 0 0 i\n"
325 "MouseMoveEvent 260 59 0 0 0 0 i\n"
326 "MouseMoveEvent 258 58 0 0 0 0 i\n"
327 "MouseMoveEvent 255 57 0 0 0 0 i\n"
328 "MouseMoveEvent 252 55 0 0 0 0 i\n"
329 "MouseMoveEvent 251 54 0 0 0 0 i\n"
330 "MouseMoveEvent 251 53 0 0 0 0 i\n"
331 "MouseMoveEvent 249 51 0 0 0 0 i\n"
332 "MouseMoveEvent 246 50 0 0 0 0 i\n"
333 "MouseMoveEvent 245 50 0 0 0 0 i\n"
334 "MouseMoveEvent 245 49 0 0 0 0 i\n"
335 "MouseMoveEvent 244 48 0 0 0 0 i\n"
336 "MouseMoveEvent 242 45 0 0 0 0 i\n"
337 "MouseMoveEvent 241 44 0 0 0 0 i\n"
338 "MouseMoveEvent 240 44 0 0 0 0 i\n"
339 "MouseMoveEvent 239 44 0 0 0 0 i\n"
340 "MouseMoveEvent 238 42 0 0 0 0 i\n"
341 "MouseMoveEvent 237 42 0 0 0 0 i\n"
342 "MouseMoveEvent 236 42 0 0 0 0 i\n"
343 "MouseMoveEvent 236 41 0 0 0 0 i\n"
344 "LeftButtonReleaseEvent 236 41 0 0 0 0 i\n"
345 "MouseMoveEvent 236 40 0 0 0 0 i\n"
346 "MouseMoveEvent 235 40 0 0 0 0 i\n"
347 "MouseMoveEvent 234 40 0 0 0 0 i\n"
348 "MouseMoveEvent 233 40 0 0 0 0 i\n"
349 "MouseMoveEvent 233 41 0 0 0 0 i\n"
350 "MouseMoveEvent 233 42 0 0 0 0 i\n"
351 "MouseMoveEvent 232 42 0 0 0 0 i\n"
352 "MouseMoveEvent 231 42 0 0 0 0 i\n"
353 "MouseMoveEvent 231 43 0 0 0 0 i\n"
354 "RightButtonPressEvent 231 43 0 0 0 0 i\n"
355 "MouseMoveEvent 231 42 0 0 0 0 i\n"
356 "MouseMoveEvent 231 41 0 0 0 0 i\n"
357 "MouseMoveEvent 231 40 0 0 0 0 i\n"
358 "MouseMoveEvent 230 40 0 0 0 0 i\n"
359 "MouseMoveEvent 229 38 0 0 0 0 i\n"
360 "MouseMoveEvent 227 33 0 0 0 0 i\n"
361 "MouseMoveEvent 226 27 0 0 0 0 i\n"
362 "MouseMoveEvent 222 23 0 0 0 0 i\n"
363 "MouseMoveEvent 214 19 0 0 0 0 i\n"
364 "MouseMoveEvent 208 14 0 0 0 0 i\n"
365 "MouseMoveEvent 208 15 0 0 0 0 i\n"
366 "MouseMoveEvent 208 14 0 0 0 0 i\n"
367 "MouseMoveEvent 208 13 0 0 0 0 i\n"
368 "MouseMoveEvent 210 11 0 0 0 0 i\n"
369 "MouseMoveEvent 213 9 0 0 0 0 i\n"
370 "MouseMoveEvent 214 8 0 0 0 0 i\n"
371 "MouseMoveEvent 214 7 0 0 0 0 i\n"
372 "MouseMoveEvent 215 7 0 0 0 0 i\n"
373 "MouseMoveEvent 215 6 0 0 0 0 i\n"
374 "MouseMoveEvent 215 5 0 0 0 0 i\n"
375 "MouseMoveEvent 216 2 0 0 0 0 i\n"
376 "MouseMoveEvent 218 1 0 0 0 0 i\n"
377 "LeaveEvent 220 -1 0 0 0 0 i\n"
378 "MouseMoveEvent 220 -1 0 0 0 0 i\n"
379 "MouseMoveEvent 221 -1 0 0 0 0 i\n"
380 "MouseMoveEvent 221 -2 0 0 0 0 i\n"
381 "MouseMoveEvent 220 -2 0 0 0 0 i\n"
382 "MouseMoveEvent 220 -3 0 0 0 0 i\n"
383 "MouseMoveEvent 220 -4 0 0 0 0 i\n"
384 "MouseMoveEvent 220 -5 0 0 0 0 i\n"
385 "MouseMoveEvent 220 -6 0 0 0 0 i\n"
386 "MouseMoveEvent 220 -7 0 0 0 0 i\n"
387 "MouseMoveEvent 220 -8 0 0 0 0 i\n"
388 "MouseMoveEvent 220 -9 0 0 0 0 i\n"
389 "MouseMoveEvent 220 -11 0 0 0 0 i\n"
390 "MouseMoveEvent 220 -12 0 0 0 0 i\n"
391 "MouseMoveEvent 220 -13 0 0 0 0 i\n"
392 "MouseMoveEvent 220 -12 0 0 0 0 i\n"
393 "MouseMoveEvent 220 -11 0 0 0 0 i\n"
394 "RightButtonReleaseEvent 220 -11 0 0 0 0 i\n"
395 "EnterEvent 218 0 0 0 0 0 i\n"
396 "MouseMoveEvent 218 0 0 0 0 0 i\n"
397 "MouseMoveEvent 218 1 0 0 0 0 i\n"
398 "MouseMoveEvent 218 2 0 0 0 0 i\n"
399 "MouseMoveEvent 217 2 0 0 0 0 i\n"
400 "MouseMoveEvent 217 4 0 0 0 0 i\n"
401 "MouseMoveEvent 217 5 0 0 0 0 i\n"
402 "MouseMoveEvent 217 6 0 0 0 0 i\n"
403 "MouseMoveEvent 217 7 0 0 0 0 i\n"
404 "MouseMoveEvent 217 8 0 0 0 0 i\n"
405 "MouseMoveEvent 217 9 0 0 0 0 i\n"
406 "MouseMoveEvent 216 11 0 0 0 0 i\n"
407 "MouseMoveEvent 216 12 0 0 0 0 i\n"
408 "MouseMoveEvent 215 12 0 0 0 0 i\n"
409 "MouseMoveEvent 215 11 0 0 0 0 i\n"
410 "MouseMoveEvent 215 12 0 0 0 0 i\n"
411 "MouseMoveEvent 215 13 0 0 0 0 i\n"
412 "MouseMoveEvent 215 14 0 0 0 0 i\n"
413 ;
414
415 // This does the actual work: updates the vtkPlane implicit function.
416 // This in turn causes the pipeline to update and clip the object.
417 // Callback for the interaction
418 class vtkTIPWCallback : public vtkCommand
419 {
420 public:
New()421 static vtkTIPWCallback *New()
422 { return new vtkTIPWCallback; }
Execute(vtkObject * caller,unsigned long,void *)423 void Execute(vtkObject *caller, unsigned long, void*) override
424 {
425 vtkImplicitPlaneWidget *planeWidget =
426 reinterpret_cast<vtkImplicitPlaneWidget*>(caller);
427 planeWidget->GetPlane(this->Plane);
428 this->Actor->VisibilityOn();
429 }
vtkTIPWCallback()430 vtkTIPWCallback():Plane(nullptr),Actor(nullptr) {}
431 vtkPlane *Plane;
432 vtkActor *Actor;
433
434 };
435
TestImplicitPlaneWidget(int vtkNotUsed (argc),char * vtkNotUsed (argv)[])436 int TestImplicitPlaneWidget(int vtkNotUsed(argc), char *vtkNotUsed(argv)[])
437 {
438 // Create a mace out of filters.
439 //
440 vtkSmartPointer<vtkSphereSource> sphere =
441 vtkSmartPointer<vtkSphereSource>::New();
442 vtkSmartPointer<vtkConeSource> cone =
443 vtkSmartPointer<vtkConeSource>::New();
444 vtkSmartPointer<vtkGlyph3D> glyph =
445 vtkSmartPointer<vtkGlyph3D>::New();
446 glyph->SetInputConnection(sphere->GetOutputPort());
447 glyph->SetSourceConnection(cone->GetOutputPort());
448 glyph->SetVectorModeToUseNormal();
449 glyph->SetScaleModeToScaleByVector();
450 glyph->SetScaleFactor(0.25);
451
452 // The sphere and spikes are appended into a single polydata.
453 // This just makes things simpler to manage.
454 vtkSmartPointer<vtkAppendPolyData> apd =
455 vtkSmartPointer<vtkAppendPolyData>::New();
456 apd->AddInputConnection(glyph->GetOutputPort());
457 apd->AddInputConnection(sphere->GetOutputPort());
458
459 vtkSmartPointer<vtkPolyDataMapper> maceMapper =
460 vtkSmartPointer<vtkPolyDataMapper>::New();
461 maceMapper->SetInputConnection(apd->GetOutputPort());
462
463 vtkSmartPointer<vtkLODActor> maceActor =
464 vtkSmartPointer<vtkLODActor>::New();
465 maceActor->SetMapper(maceMapper);
466 maceActor->VisibilityOn();
467
468 // This portion of the code clips the mace with the vtkPlanes
469 // implicit function. The clipped region is colored green.
470 vtkSmartPointer<vtkPlane> plane =
471 vtkSmartPointer<vtkPlane>::New();
472 vtkSmartPointer<vtkClipPolyData> clipper =
473 vtkSmartPointer<vtkClipPolyData>::New();
474 clipper->SetInputConnection(apd->GetOutputPort());
475 clipper->SetClipFunction(plane);
476 clipper->InsideOutOn();
477
478 vtkSmartPointer<vtkPolyDataMapper> selectMapper =
479 vtkSmartPointer<vtkPolyDataMapper>::New();
480 selectMapper->SetInputConnection(clipper->GetOutputPort());
481
482 vtkSmartPointer<vtkLODActor> selectActor =
483 vtkSmartPointer<vtkLODActor>::New();
484 selectActor->SetMapper(selectMapper);
485 selectActor->GetProperty()->SetColor(0,1,0);
486 selectActor->VisibilityOff();
487 selectActor->SetScale(1.01, 1.01, 1.01);
488
489 // Create the RenderWindow, Renderer and both Actors
490 //
491 vtkSmartPointer<vtkRenderer> ren1 =
492 vtkSmartPointer<vtkRenderer>::New();
493 vtkSmartPointer<vtkRenderWindow> renWin =
494 vtkSmartPointer<vtkRenderWindow>::New();
495 renWin->AddRenderer(ren1);
496
497 vtkSmartPointer<vtkRenderWindowInteractor> iren =
498 vtkSmartPointer<vtkRenderWindowInteractor>::New();
499 iren->SetRenderWindow(renWin);
500
501 // The SetInteractor method is how 3D widgets are associated with the render
502 // window interactor. Internally, SetInteractor sets up a bunch of callbacks
503 // using the Command/Observer mechanism (AddObserver()).
504 vtkSmartPointer<vtkTIPWCallback> myCallback =
505 vtkSmartPointer<vtkTIPWCallback>::New();
506 myCallback->Plane = plane;
507 myCallback->Actor = selectActor;
508
509 vtkSmartPointer<vtkImplicitPlaneWidget> planeWidget =
510 vtkSmartPointer<vtkImplicitPlaneWidget>::New();
511 planeWidget->SetInteractor(iren);
512 planeWidget->SetPlaceFactor(1.25);
513 glyph->Update();
514 planeWidget->SetInputConnection(glyph->GetOutputPort());
515 planeWidget->PlaceWidget();
516 planeWidget->AddObserver(vtkCommand::InteractionEvent,myCallback);
517
518 ren1->AddActor(maceActor);
519 ren1->AddActor(selectActor);
520
521 // Add the actors to the renderer, set the background and size
522 //
523 ren1->SetBackground(0.1, 0.2, 0.4);
524 renWin->SetSize(300, 300);
525
526 // record events
527 vtkSmartPointer<vtkInteractorEventRecorder> recorder =
528 vtkSmartPointer<vtkInteractorEventRecorder>::New();
529 recorder->SetInteractor(iren);
530 // recorder->SetFileName("c:/record.log");
531 // recorder->Record();
532 recorder->ReadFromInputStringOn();
533 recorder->SetInputString(eventLog);
534
535 // render the image
536 //
537 renWin->SetMultiSamples(0);
538 iren->Initialize();
539 renWin->Render();
540 recorder->Play();
541
542 // Remove the observers so we can go interactive. Without this the "-I"
543 // testing option fails.
544 recorder->Off();
545
546 iren->Start();
547
548 return EXIT_SUCCESS;
549 }
550