36 #include "boost/bind.hpp"
38 #include <vtkCamera.h>
39 #include <vtkRenderer.h>
40 #include <vtkProperty.h>
41 #include <vtkImageData.h>
42 #include <vtkLineSource.h>
44 #include <vtkProbeFilter.h>
45 #include <vtkSphereSource.h>
46 #include <vtkRenderWindow.h>
47 #include <vtkCallbackCommand.h>
48 #include <vtkPolyDataMapper.h>
50 #include <vtkEventQtSlotConnect.h>
60 #include <vtkRenderWindowInteractor.h>
62 #include "vtkVolumePicker.h"
65 #ifdef CX_BUILD_MEHDI_VTKMULTIVOLUME
66 #include "vtkMultiVolumePicker.h"
81 mDataManager(dataManager),
82 mPickedPoint(), mSphereRadius(2)
129 disconnect(
mTool.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this,
137 connect(
mTool.get(), SIGNAL(toolTransformAndTimestamp(
Transform3D,
double)),
this,
174 int hit = picker->Pick(clickPosition[0], clickPosition[1], 0, renderer);
185 std::map<QString, DataPtr> allData =
mDataManager->getData();
186 for (std::map<QString, DataPtr>::iterator iter = allData.begin(); iter != allData.end(); ++iter)
188 MeshPtr mesh = boost::dynamic_pointer_cast<
Mesh>(iter->second);
189 if (mesh && mesh->getVtkPolyData() == data)
192 ImagePtr image = boost::dynamic_pointer_cast<
Image>(iter->second);
193 if (image && image->getBaseVtkImageData() == data)
198 Vector3D pick_w(picker->GetPickPosition());
203 ||(
mTool && (data ==
mTool->getGraphicsPolyData() )))
238 iren->GetEventPosition(pickedPoint);
241 if (renderer == NULL)
244 Vector3D clickPoint(pickedPoint[0], pickedPoint[1], 0);
290 void* vtkNotUsed(calldata))
297 case vtkCommand::LeftButtonPressEvent:
300 case vtkCommand::LeftButtonReleaseEvent:
301 self->OnLeftButtonUp();
303 case vtkCommand::MouseMoveEvent:
316 ren->SetDisplayPoint(p_d.data());
317 ren->DisplayToWorld();
318 ren->GetWorldPoint(worldPt);
319 return Vector3D(worldPt)/worldPt[3];
329 ren->SetWorldPoint(p_w[0], p_w[1], p_w[2], 1.0);
330 ren->WorldToDisplay();
331 ren->GetDisplayPoint(p_d.data());
348 Vector3D p_current_d(interactor->GetEventPosition()[0], interactor->GetEventPosition()[1], p_prev_d[2]);
356 return p_current_w - p_prev_w;
407 i->AddObserver(vtkCommand::LeftButtonPressEvent, this->
mCallbackCommand, 1.0);
408 i->AddObserver(vtkCommand::LeftButtonReleaseEvent, this->
mCallbackCommand, 1.0);
430 reportDebug(
"Cannot add rep actor to a NULL view.");
Vector3D ComputeDisplayToWorld(Vector3D p_d)
vtkRendererPtr getRenderer()
virtual QString getType() const
returns a string identifying this class type
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
vtkSmartPointer< class vtkRenderWindowInteractor > vtkRenderWindowInteractorPtr
boost::shared_ptr< class Image > ImagePtr
vtkSmartPointer< class vtkVolumePicker > vtkMultiVolumePickerPtr
bool mConnected
Interactor connected.
static boost::shared_ptr< REP > wrap_new(REP *object, QString uid)
void setTool(ToolPtr tool)
set the tool to listen to
Vector3D ComputeWorldToDisplay(Vector3D p_w)
void pickLandmark(const Vector3D &clickPosition, vtkRendererPtr renderer)
When you don't use the renderwindowinteractor.
virtual void onModifiedStartRender()
Helper for rendering a point in 3D.
boost::shared_ptr< class View > ViewPtr
Listens to changes in viewport and camera matrix.
void setGlyphCenter(Vector3D pos)
boost::shared_ptr< class PickerRep > PickerRepPtr
Picking of points in an image.
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
void setGlyph(MeshPtr glyph)
void disconnectInteractor()
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Transform3D createTransformTranslate(const Vector3D &translation)
static GeometricRepPtr New(const QString &uid="")
Default implementation of Rep.
bool mSnapToSurface
if set, clicking on a Data surface will pick that point
virtual void addRepActorsToViewRenderer(ViewPtr view)
connects to the renderwindowinteractor
vtkSmartPointer< class vtkDataSet > vtkDataSetPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
void pointPicked(Vector3D p_r)
GraphicalPoint3DPtr mGraphicalPoint
void setSphereRadius(double radius)
PickerRep(PatientModelServicePtr dataManager)
use New instead
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
ViewportListenerPtr mViewportListener
PatientModelServicePtr mDataManager
void pickLandmarkSlot(vtkObject *renderWindowInteractor)
When you use the renderwindowinteractor.
Vector3D getPosition() const
static PickerRepPtr New(PatientModelServicePtr dataManager, const QString &uid="")
for creating new instances
GeometricRepPtr mGlyphRep
Vector3D getDisplacement()
ToolPtr mTool
the connected tool
boost::shared_ptr< class Mesh > MeshPtr
void dataPicked(QString uid)
the rep sends out a signal when the user picks a point on it
virtual ~PickerRep()
empty
Vector3D mPickedPoint
the last point that was successfully sampled from intersection with an image
vtkCallbackCommandPtr mCallbackCommand
virtual void removeRepActorsFromViewRenderer(ViewPtr view)
disconnects from the renderwindowinteractor
void reportDebug(QString msg)
boost::shared_ptr< class Tool > ToolPtr