Fraxinus  17.12-rc1
An IGT application
cxPickerRep.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 
34 #ifndef CXPICKERREP_H_
35 #define CXPICKERREP_H_
36 
37 #include "cxResourceVisualizationExport.h"
38 
39 #include "cxRepImpl.h"
40 #include "cxTransform3D.h"
41 #include "vtkForwardDeclarations.h"
42 
43 #include "cxGraphicalPrimitives.h"
44 #include "cxViewportListener.h"
45 #include "cxForwardDeclarations.h"
46 
47 class vtkCommand;
48 typedef vtkSmartPointer<class vtkCallbackCommand> vtkCallbackCommandPtr;
49 
50 namespace cx
51 {
52 typedef boost::shared_ptr<class PickerRep> PickerRepPtr;
53 typedef boost::shared_ptr<class Image> ImagePtr;
54 typedef boost::shared_ptr<class Tool> ToolPtr;
55 
70 class cxResourceVisualization_EXPORT PickerRep: public RepImpl
71 {
72 Q_OBJECT
73 
74 public:
75  static PickerRepPtr New(PatientModelServicePtr dataManager, const QString& uid="");
76  virtual ~PickerRep();
77 
78  virtual QString getType() const;
79 
80  void setTool(ToolPtr tool);
81 
82  void setEnabled(bool on);
83  void setGlyph(MeshPtr glyph);
84 
85  void pickLandmark(const Vector3D& clickPosition, vtkRendererPtr renderer);
86  Vector3D getPosition() const;
87  void setSphereRadius(double radius);
88 
89 signals:
90  void pointPicked(Vector3D p_r);
91  void dataPicked(QString uid);
92 
93 public slots:
94  void pickLandmarkSlot(vtkObject* renderWindowInteractor);
95 
96 protected:
97  PickerRep(PatientModelServicePtr dataManager);
98  virtual void addRepActorsToViewRenderer(ViewPtr view);
99  virtual void removeRepActorsFromViewRenderer(ViewPtr view);
100  void connectInteractor();
101  void disconnectInteractor();
102  void scaleSphere();
103  virtual void onModifiedStartRender();
104  void toolHasChanged();
105  static void ProcessEvents(vtkObject* object,
106  unsigned long event,
107  void* clientdata,
108  void* calldata);
109  void OnLeftButtonDown();
110  void OnLeftButtonUp();
111  void OnMouseMove();
112  Vector3D getDisplacement();
113  Vector3D ComputeDisplayToWorld(Vector3D p_d);
114  Vector3D ComputeWorldToDisplay(Vector3D p_w);
115  void setGlyphCenter(Vector3D pos);
116 
117  bool mEnabled;
118  bool mConnected;
119  ToolPtr mTool;
126 
128 
133 };
134 
135 typedef boost::shared_ptr<PickerRep> PickerRepPtr;
136 
137 }//namespace
138 #endif /* CXPICKERREP_H_ */
boost::shared_ptr< class GraphicalPoint3D > GraphicalPoint3DPtr
boost::shared_ptr< class ViewportListener > ViewportListenerPtr
boost::shared_ptr< class Image > ImagePtr
Definition: cxDicomWidget.h:48
bool mConnected
Interactor connected.
Definition: cxPickerRep.h:118
double mSphereRadius
Definition: cxPickerRep.h:121
boost::shared_ptr< class View > ViewPtr
vtkSmartPointer< class vtkCallbackCommand > vtkCallbackCommandPtr
vtkSmartPointer< class vtkCallbackCommand > vtkCallbackCommandPtr
Definition: cxPickerRep.h:47
boost::shared_ptr< class PickerRep > PickerRepPtr
Picking of points in an image.
Definition: cxPickerRep.h:70
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
MeshPtr mGlyph
Definition: cxPickerRep.h:122
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Default implementation of Rep.
Definition: cxRepImpl.h:63
bool mSnapToSurface
if set, clicking on a Data surface will pick that point
Definition: cxPickerRep.h:127
Vector3D mClickedPoint
Definition: cxPickerRep.h:124
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
GraphicalPoint3DPtr mGraphicalPoint
Definition: cxPickerRep.h:129
ViewportListenerPtr mViewportListener
Definition: cxPickerRep.h:130
PatientModelServicePtr mDataManager
Definition: cxPickerRep.h:132
GeometricRepPtr mGlyphRep
Definition: cxPickerRep.h:123
ToolPtr mTool
the connected tool
Definition: cxPickerRep.h:119
boost::shared_ptr< class Mesh > MeshPtr
Vector3D mPickedPoint
the last point that was successfully sampled from intersection with an image
Definition: cxPickerRep.h:120
vtkCallbackCommandPtr mCallbackCommand
Definition: cxPickerRep.h:131
boost::shared_ptr< class GeometricRep > GeometricRepPtr
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr