NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxCameraStyleForView.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) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #ifndef CXCameraStyleForViewFORVIEW_H
12 #define CXCameraStyleForViewFORVIEW_H
13 
14 #include "org_custusx_core_view_Export.h"
15 
16 #include "cxTransform3D.h"
17 #include "cxForwardDeclarations.h"
18 #include "cxViewService.h"
19 #include "cxViewGroupData.h"
21 #include "cxDoubleRange.h"
22 class QIcon;
23 class QWidget;
24 class QMenu;
25 class QActionGroup;
26 class vtkInteractorStyle;
27 
28 namespace cx
29 {
30 typedef boost::shared_ptr<class ViewportPreRenderListener> ViewportPreRenderListenerPtr;
31 typedef boost::shared_ptr<class CoreServices> CoreServicesPtr;
32 
33 typedef boost::shared_ptr<class CameraStyleForView> CameraStyleForViewPtr;
34 using cx::Transform3D;
35 
52 {
53 public:
54  JitterFilter();
55  double newValue(double value);
56 private:
57  DoubleRange range;
58  double currentValue;
59 };
60 
61 struct CameraInfo
62 {
64  explicit CameraInfo(vtkCameraPtr camera);
65  double distance() const { return (pos-focus).length(); }
66  Vector3D vpn() const { return (pos-focus).normal(); }
67 
71  double viewAngle; // vtk View angle in DEGREES
72 };
73 
74 bool similar(const CameraInfo& lhs, const CameraInfo& rhs, double tol=1.0E-6);
75 
87 class org_custusx_core_view_EXPORT CameraStyleForView: public QObject
88 {
89 Q_OBJECT
90 public:
91  explicit CameraStyleForView(CoreServicesPtr backend);
92  void setView(ViewPtr widget);
93 
96  void setCameraStyle(CameraStyleData style);
97  CameraStyleData getCameraStyle();
98 
99 private slots:
100  void setModified();
101  void activeToolChangedSlot();
102 
103 private:
104  ViewPtr getView() const;
105  vtkRendererPtr getRenderer() const;
106  vtkCameraPtr getCamera() const;
107  ToolRep3DPtr getToolRep() const;
108  bool isToolFollowingStyle() const;
109  void onPreRender();
110  void applyCameraStyle();
111 
112  void connectTool();
113  void disconnectTool();
114  void viewportChangedSlot();
115  RegionOfInterest getROI(QString uid) const;
116  void setInteractor(vtkSmartPointer<vtkInteractorStyle> style);
117 
118  CameraStyleData mStyle;
119  ToolPtr mFollowingTool;
120  ViewportListenerPtr mViewportListener;
121  ViewportPreRenderListenerPtr mPreRenderListener;
122  bool mBlockCameraUpdate;
123  ViewPtr mView;
124  CoreServicesPtr mBackend;
125 
126 // Vector3D mPreviousZoomCameraPos;
127  JitterFilter mZoomJitterFilter;
128 
129  Vector3D smoothZoomedCameraPosition(Vector3D pos);
130  void handleLights();
131  CameraInfo viewEntireAutoZoomROI(CameraInfo info);
132  void updateCamera(CameraInfo info);
133  Vector3D getToolTip_r();
134  Transform3D get_rMto();
135 };
136 
140 } //namespace cx
141 
142 #endif // CXCameraStyleForViewFORVIEW_H
cx::CameraStyleForViewPtr
boost::shared_ptr< class CameraStyleForView > CameraStyleForViewPtr
Definition: cxCameraStyleForView.h:33
cx::CameraInfo::distance
double distance() const
Definition: cxCameraStyleForView.h:65
cx::CameraInfo::vpn
Vector3D vpn() const
Definition: cxCameraStyleForView.h:66
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cxDoubleRange.h
cxForwardDeclarations.h
cxViewGroupData.h
cx::CameraStyleForView
Definition: cxCameraStyleForView.h:87
cx::ToolRep3DPtr
boost::shared_ptr< class ToolRep3D > ToolRep3DPtr
Definition: cxRecordSessionSelector.h:27
cx::ViewportListenerPtr
boost::shared_ptr< class ViewportListener > ViewportListenerPtr
Definition: cxForwardDeclarations.h:172
cxRegionOfInterestMetric.h
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxViewService.h
cx::CameraInfo::focus
Vector3D focus
Definition: cxCameraStyleForView.h:69
cx::JitterFilter::JitterFilter
JitterFilter()
Definition: cxCameraStyleForView.cpp:466
cx::JitterFilter::newValue
double newValue(double value)
Definition: cxCameraStyleForView.cpp:472
cx::CameraInfo
Definition: cxCameraStyleForView.h:61
cx::CoreServicesPtr
boost::shared_ptr< class CoreServices > CoreServicesPtr
Definition: cxCameraStyle.h:37
cx::CameraInfo::viewAngle
double viewAngle
Definition: cxCameraStyleForView.h:71
cx::JitterFilter
Definition: cxCameraStyleForView.h:51
cx::CameraStyleData
Definition: cxViewGroupData.h:41
cx::ViewportPreRenderListenerPtr
boost::shared_ptr< class ViewportPreRenderListener > ViewportPreRenderListenerPtr
Definition: cxCameraStyleForView.h:30
vtkCameraPtr
vtkSmartPointer< class vtkCamera > vtkCameraPtr
Definition: vtkForwardDeclarations.h:39
cx::CameraInfo::vup
Vector3D vup
Definition: cxCameraStyleForView.h:70
cx::ViewPtr
boost::shared_ptr< class View > ViewPtr
Definition: cxForwardDeclarations.h:110
cx::RegionOfInterest
Definition: cxRegionOfInterestMetric.h:38
cx::CameraInfo::CameraInfo
CameraInfo()
Definition: cxCameraStyleForView.h:63
cx::ToolPtr
boost::shared_ptr< class Tool > ToolPtr
Definition: cxVideoConnectionWidget.h:43
cx::CameraInfo::pos
Vector3D pos
Definition: cxCameraStyleForView.h:68
cx::DoubleRange
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
cxTransform3D.h
cx::similar
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
Definition: cxCameraStyleForView.cpp:506
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
vtkRendererPtr
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
Definition: vtkForwardDeclarations.h:122