OGS
VtkPickCallback.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4// ** INCLUDES **
5#include "VtkPickCallback.h"
6
7#include <vtkActor.h>
8#include <vtkCellPicker.h>
9
10#include "BaseLib/Logging.h"
11
16
17void VtkPickCallback::Execute(vtkObject* caller,
18 unsigned long vtkNotUsed(eventId) /*eventId*/,
19 void* vtkNotUsed(callData) /*callData*/)
20{
21 auto* picker = static_cast<vtkCellPicker*>(caller);
22 if (picker->GetCellId() < 0)
23 {
24 // Nothing is picked
25 }
26 else
27 {
28 vtkActor* actor = picker->GetActor();
29 if (actor)
30 {
31 emit actorPicked(actor);
32 }
33
34 double* pos = picker->GetPickPosition();
35 INFO("Picked cell id is: {:d}", picker->GetCellId());
36 INFO("Picked position is: {:f} {:f} {:f}", pos[0], pos[1], pos[2]);
37 }
38}
39
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:28
void actorPicked(vtkProp3D *actor)
Is emitted when an vtkActor was picked.
static VtkPickCallback * New()
void Execute(vtkObject *caller, unsigned long eventId, void *callData) override