Fraxinus  18.10
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 "cxEnumConverter.h"
19 #include "cxViewService.h"
20 #include "cxViewGroupData.h"
22 #include "cxDoubleRange.h"
23 class QIcon;
24 class QWidget;
25 class QMenu;
26 class QActionGroup;
27 class vtkInteractorStyle;
28 
29 namespace cx
30 {
31 typedef boost::shared_ptr<class ViewportPreRenderListener> ViewportPreRenderListenerPtr;
32 typedef boost::shared_ptr<class CoreServices> CoreServicesPtr;
33 
34 typedef boost::shared_ptr<class CameraStyleForView> CameraStyleForViewPtr;
35 using cx::Transform3D;
36 
53 {
54 public:
55  JitterFilter();
56  double newValue(double value);
57 private:
58  DoubleRange range;
59  double currentValue;
60 };
61 
62 struct CameraInfo
63 {
65  explicit CameraInfo(vtkCameraPtr camera);
66  double distance() const { return (pos-focus).length(); }
67  Vector3D vpn() const { return (pos-focus).normal(); }
68 
72  double viewAngle; // vtk View angle in DEGREES
73 };
74 
75 bool similar(const CameraInfo& lhs, const CameraInfo& rhs, double tol=1.0E-6);
76 
88 class org_custusx_core_view_EXPORT CameraStyleForView: public QObject
89 {
90 Q_OBJECT
91 public:
92  explicit CameraStyleForView(CoreServicesPtr backend);
93  void setView(ViewPtr widget);
94 
97  void setCameraStyle(CameraStyleData style);
98  CameraStyleData getCameraStyle();
99 
100 private slots:
101  void setModified();
102  void activeToolChangedSlot();
103 
104 private:
105  ViewPtr getView() const;
106  vtkRendererPtr getRenderer() const;
107  vtkCameraPtr getCamera() const;
108  ToolRep3DPtr getToolRep() const;
109  bool isToolFollowingStyle() const;
110  void onPreRender();
111  void applyCameraStyle();
112 
113  void connectTool();
114  void disconnectTool();
115  void viewportChangedSlot();
116  RegionOfInterest getROI(QString uid) const;
117  void setInteractor(vtkSmartPointer<vtkInteractorStyle> style);
118 
119  CameraStyleData mStyle;
120  ToolPtr mFollowingTool;
121  ViewportListenerPtr mViewportListener;
122  ViewportPreRenderListenerPtr mPreRenderListener;
123  bool mBlockCameraUpdate;
124  ViewPtr mView;
125  CoreServicesPtr mBackend;
126 
127 // Vector3D mPreviousZoomCameraPos;
128  JitterFilter mZoomJitterFilter;
129 
130  Vector3D smoothZoomedCameraPosition(Vector3D pos);
131  void handleLights();
132  CameraInfo viewEntireAutoZoomROI(CameraInfo info);
133  void updateCamera(CameraInfo info);
134  Vector3D getToolTip_r();
135  Transform3D get_rMto();
136 };
137 
141 } //namespace cx
142 
143 #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:38
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