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" 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);
161 vtkDataSetPtr data = picker->GetDataSet();
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.");
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)
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr