CustusX  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
boost::shared_ptr< class ViewportListener > ViewportListenerPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Utility class for describing a bounded numeric range.
Definition: cxDoubleRange.h:32
boost::shared_ptr< class ViewportPreRenderListener > ViewportPreRenderListenerPtr
boost::shared_ptr< class View > ViewPtr
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
double newValue(double value)
boost::shared_ptr< class CameraStyleForView > CameraStyleForViewPtr
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
double distance() const
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
boost::shared_ptr< class CoreServices > CoreServicesPtr
Definition: cxCameraStyle.h:37
boost::shared_ptr< class ToolRep3D > ToolRep3DPtr
Vector3D vpn() const
vtkSmartPointer< class vtkCamera > vtkCameraPtr
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr