|
NorMIT-nav
2023.01.05-dev+develop.0da12
An IGT application
|
Go to the documentation of this file.
15 #include "boost/bind.hpp"
17 #include <vtkCamera.h>
18 #include <vtkRenderer.h>
19 #include <vtkProperty.h>
20 #include <vtkImageData.h>
21 #include <vtkLineSource.h>
23 #include <vtkProbeFilter.h>
24 #include <vtkSphereSource.h>
25 #include <vtkRenderWindow.h>
26 #include <vtkCallbackCommand.h>
27 #include <vtkPolyDataMapper.h>
29 #include <vtkEventQtSlotConnect.h>
39 #include <vtkRenderWindowInteractor.h>
41 #include "vtkVolumePicker.h"
44 #ifdef CX_BUILD_MEHDI_VTKMULTIVOLUME
45 #include "vtkMultiVolumePicker.h"
60 mDataManager(dataManager),
61 mPickedPoint(), mSphereRadius(2)
108 disconnect(
mTool.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this,
116 connect(
mTool.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this,
153 int hit = picker->Pick(clickPosition[0], clickPosition[1], 0, renderer);
164 std::map<QString, DataPtr> allData =
mDataManager->getDatas();
165 for (std::map<QString, DataPtr>::iterator iter = allData.begin(); iter != allData.end(); ++iter)
167 MeshPtr mesh = boost::dynamic_pointer_cast<Mesh>(iter->second);
168 if (mesh && mesh->getVtkPolyData() == data)
171 ImagePtr image = boost::dynamic_pointer_cast<Image>(iter->second);
172 if (image && image->getBaseVtkImageData() == data)
177 Vector3D pick_w(picker->GetPickPosition());
182 ||(
mTool && (data ==
mTool->getGraphicsPolyData() )))
217 iren->GetEventPosition(pickedPoint);
220 if (renderer == NULL)
223 Vector3D clickPoint(pickedPoint[0], pickedPoint[1], 0);
269 void* vtkNotUsed(calldata))
276 case vtkCommand::LeftButtonPressEvent:
279 case vtkCommand::LeftButtonReleaseEvent:
280 self->OnLeftButtonUp();
282 case vtkCommand::MouseMoveEvent:
295 ren->SetDisplayPoint(p_d.data());
296 ren->DisplayToWorld();
297 ren->GetWorldPoint(worldPt);
298 return Vector3D(worldPt)/worldPt[3];
308 ren->SetWorldPoint(p_w[0], p_w[1], p_w[2], 1.0);
309 ren->WorldToDisplay();
310 ren->GetDisplayPoint(p_d.data());
327 Vector3D p_current_d(interactor->GetEventPosition()[0], interactor->GetEventPosition()[1], p_prev_d[2]);
335 return p_current_w - p_prev_w;
386 i->AddObserver(vtkCommand::LeftButtonPressEvent, this->
mCallbackCommand, 1.0);
387 i->AddObserver(vtkCommand::LeftButtonReleaseEvent, this->
mCallbackCommand, 1.0);
409 reportDebug(
"Cannot add rep actor to a NULL view.");
vtkCallbackCommandPtr mCallbackCommand
void pickLandmark(const Vector3D &clickPosition, vtkRendererPtr renderer)
When you don't use the renderwindowinteractor.
void disconnectInteractor()
bool mSnapToSurface
if set, clicking on a Data surface will pick that point
Namespace for all CustusX production code.
Listens to changes in viewport and camera matrix.
virtual void addRepActorsToViewRenderer(ViewPtr view)
connects to the renderwindowinteractor
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkRendererPtr getRenderer()
void reportDebug(QString msg)
PatientModelServicePtr mDataManager
vtkSmartPointer< class vtkVolumePicker > vtkMultiVolumePickerPtr
ToolPtr mTool
the connected tool
Vector3D getDisplacement()
Vector3D ComputeWorldToDisplay(Vector3D p_w)
GraphicalPoint3DPtr mGraphicalPoint
PickerRep(PatientModelServicePtr dataManager)
use New instead
void setTool(ToolPtr tool)
set the tool to listen to
boost::shared_ptr< class Mesh > MeshPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void setGlyphCenter(Vector3D pos)
Vector3D ComputeDisplayToWorld(Vector3D p_d)
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class Image > ImagePtr
Vector3D getPosition() const
ViewportListenerPtr mViewportListener
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
disconnects from the renderwindowinteractor
boost::shared_ptr< class View > ViewPtr
Default implementation of Rep.
Helper for rendering a point in 3D.
void setSphereRadius(double radius)
boost::shared_ptr< class PickerRep > PickerRepPtr
void pickLandmarkSlot(vtkObject *renderWindowInteractor)
When you use the renderwindowinteractor.
void pointPicked(Vector3D p_r)
vtkSmartPointer< class vtkRenderWindowInteractor > vtkRenderWindowInteractorPtr
void dataPicked(QString uid)
the rep sends out a signal when the user picks a point on it
boost::shared_ptr< class Tool > ToolPtr
bool mConnected
Interactor connected.
GeometricRepPtr mGlyphRep
Picking of points in an image.
static GeometricRepPtr New(const QString &uid="")
Transform3D createTransformTranslate(const Vector3D &translation)
static PickerRepPtr New(PatientModelServicePtr dataManager, const QString &uid="")
for creating new instances
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
virtual QString getType() const
returns a string identifying this class type
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
virtual void onModifiedStartRender()
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
void setGlyph(MeshPtr glyph)
vtkSmartPointer< class vtkDataSet > vtkDataSetPtr
virtual ~PickerRep()
empty
Vector3D mPickedPoint
the last point that was successfully sampled from intersection with an image