144 return vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
150 int* pos = this->GetInteractor()->GetEventPosition();
152 vtkSmartPointer<vtkCellPicker> picker =
153 vtkSmartPointer<vtkCellPicker>::New();
154 picker->SetTolerance(0.0005);
157 picker->Pick(pos[0], pos[1], 0, this->GetDefaultRenderer());
159 double* worldPosition = picker->GetPickPosition();
160 INFO(
"Cell id is: {:d}", picker->GetCellId());
162 if (picker->GetCellId() != -1)
164 INFO(
"Pick position is: {:f} {:f} {:f}", worldPosition[0],
165 worldPosition[1], worldPosition[2]);
167 vtkSmartPointer<vtkIdTypeArray> ids =
168 vtkSmartPointer<vtkIdTypeArray>::New();
169 ids->SetNumberOfValues(1);
170 ids->SetValue(0, picker->GetCellId());
172 vtkSmartPointer<vtkSelectionNode> selectionNode =
173 vtkSmartPointer<vtkSelectionNode>::New();
174 selectionNode->SetFieldType(vtkSelectionNode::CELL);
175 selectionNode->SetContentType(vtkSelectionNode::INDICES);
176 selectionNode->SetSelectionList(ids);
178 vtkSmartPointer<vtkSelection> selection =
179 vtkSmartPointer<vtkSelection>::New();
180 selection->AddNode(selectionNode);
182 vtkSmartPointer<vtkExtractSelection> extractSelection =
183 vtkSmartPointer<vtkExtractSelection>::New();
184 extractSelection->SetInputData(0,
_data);
185 extractSelection->SetInputData(1, selection);
186 extractSelection->Update();
189 vtkSmartPointer<vtkUnstructuredGrid> selected =
190 vtkSmartPointer<vtkUnstructuredGrid>::New();
191 selected->ShallowCopy(extractSelection->GetOutput());
193 INFO(
"There are {:d} points in the selection.",
194 selected->GetNumberOfPoints());
195 INFO(
"There are {:d} cells in the selection.",
196 selected->GetNumberOfCells());
201 vtkAlgorithm* data_set = picker->GetActor()
203 ->GetInputConnection(0, 0)
205 ->GetInputConnection(0, 0)
208 dynamic_cast<vtkUnstructuredGridAlgorithm*
>(data_set);
212 static_cast<unsigned>(picker->GetCellId()));
220 this->Interactor->GetRenderWindow()
228 this->Interactor->GetRenderWindow()
238 vtkInteractorStyleTrackballCamera::OnLeftButtonDown();
246 return vtkInteractorStyleTrackballCamera::OnRightButtonDown();
252 int* pos = this->GetInteractor()->GetEventPosition();
254 vtkSmartPointer<vtkCellPicker> picker =
255 vtkSmartPointer<vtkCellPicker>::New();
256 picker->SetTolerance(0.0005);
259 picker->Pick(pos[0], pos[1], 0, this->GetDefaultRenderer());
261 double* worldPosition = picker->GetPickPosition();
262 INFO(
"Cell id is: {:d}", picker->GetCellId());
264 if (picker->GetCellId() != -1)
266 vtkRenderer* renderer = this->Interactor->GetRenderWindow()
268 ->GetFirstRenderer();
269 vtkCamera* cam = renderer->GetActiveCamera();
270 cam->SetFocalPoint(worldPosition);
277 vtkInteractorStyleTrackballCamera::OnRightButtonDown();