Fraxinus  18.10
An IGT application
cxSliceProxy.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 
12 
13 #ifndef CXSLICEPROXY_H_
14 #define CXSLICEPROXY_H_
15 
16 #include "cxResourceExport.h"
17 
18 #include <boost/shared_ptr.hpp>
19 #include <QObject>
20 #include "cxDefinitions.h"
21 #include "boost/scoped_ptr.hpp"
22 #include "cxTransform3D.h"
23 #include "cxIndent.h"
24 #include "cxSliceComputer.h"
25 #include "cxForwardDeclarations.h"
26 
27 namespace cx
28 {
29 class SliceComputer;
30 // forward declarations
31 typedef boost::shared_ptr<class Tool> ToolPtr;
32 typedef boost::shared_ptr<class SliceProxyInterface> SliceProxyInterfacePtr;
33 
41 class cxResource_EXPORT SliceProxyInterface : public QObject
42 {
43  Q_OBJECT
44 public:
45  virtual ~SliceProxyInterface() {}
46 
47  virtual Transform3D get_sMr() = 0;
48  void printSelf(std::ostream & os, Indent indent) {}
49 
50 #ifdef WIN32
51  typedef Transform3D Transform3D;
52 #endif
53 
54 signals:
55  void transformChanged(Transform3D sMr);
56 };
57 
58 class cxResource_EXPORT SimpleSliceProxy : public SliceProxyInterface
59 {
60  Q_OBJECT
61 public:
62  SimpleSliceProxy() : m_sMr(Transform3D::Identity()) {}
63  virtual ~SimpleSliceProxy() {}
64  void set_sMr(Transform3D sMr) { m_sMr=sMr; emit transformChanged(m_sMr); }
65  virtual Transform3D get_sMr() { return m_sMr; }
66 public:
68 };
69 
70 typedef boost::shared_ptr<class SimpleSliceProxy> SimpleSliceProxyPtr;
71 typedef boost::shared_ptr<class SliceProxy> SliceProxyPtr;
72 
82 class cxResource_EXPORT SliceProxy : public SliceProxyInterface
83 {
84  Q_OBJECT
85 public:
86  static SliceProxyPtr create(PatientModelServicePtr dataManager);
87  virtual ~SliceProxy();
88 
89  void setTool(ToolPtr tool);
90  void setOrientation(ORIENTATION_TYPE orientation );
91  void setPlane(PLANE_TYPE plane );
92  void setFollowType(FOLLOW_TYPE followType);
93  void initializeFromPlane(PLANE_TYPE plane, bool useGravity, bool useViewOffset, double viewportHeight, double toolViewOffset);
94 
95  void setGravity(bool use, const Vector3D& dir);
96  void setToolViewOffset(bool use, double viewportHeight, double toolViewOffset);
97  void setToolViewportHeight(double viewportHeight);
98  void setDefaultCenter(const Vector3D& c);
99  void setAlwaysUseDefaultCenter(bool on);
100 
101  SliceComputer getComputer() const;
102  void setComputer(const SliceComputer& val);
103 
104  ToolPtr getTool();
105  virtual Transform3D get_sMr();
106  virtual void printSelf(std::ostream & os, Indent indent);
107 
111  bool getUseTooltipOffset() { return mUseTooltipOffset; }
115  void setUseTooltipOffset(bool);
116 
117 signals:
118  void toolTransformAndTimestamp(Transform3D prMt, double timestamp);
119  void toolVisible(bool visible);
120 
121 private slots:
122  void clinicalApplicationChangedSlot();
123  void tooltipOffsetSlot(double val);
124  void toolTransformAndTimestampSlot(Transform3D prMt, double timestamp);
125  void toolVisibleSlot(bool visible);
126  void centerChangedSlot();
127  void changed();
128 
129 private:
130  SliceProxy(PatientModelServicePtr dataManager);
131  Transform3D getSyntheticToolPos(const Vector3D& center) const;
132  void initCutplane();
133 
134  ToolPtr mTool;
135  boost::scoped_ptr<SliceComputer> mCutplane;
136  Vector3D mDefaultCenter;
137  bool mAlwaysUseDefaultCenter;
138 // QString mName; ///< for debug
139  bool mUseTooltipOffset;
140  PatientModelServicePtr mDataManager;
141  SlicePlane mLastEmittedSlicePlane;
142 };
143 
148 }
149 
150 #endif /*CXSLICEPROXY_H_*/
void set_sMr(Transform3D sMr)
Definition: cxSliceProxy.h:64
Provides a slice matrix based on definition and tool.
Definition: cxSliceProxy.h:82
A 2D slice plane in 3D. i,j are perpendicular unit vectors.
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< class SliceProxy > SliceProxyPtr
boost::shared_ptr< class SimpleSliceProxy > SimpleSliceProxyPtr
Definition: cxSliceProxy.h:70
virtual Transform3D get_sMr()
get slice transform, i.e. the matrix sMr transforming a point p in ref to slice space.
Definition: cxSliceProxy.h:65
virtual ~SliceProxyInterface()
Definition: cxSliceProxy.h:45
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Formatting class for debug printing of the ssc library.
Definition: cxIndent.h:28
void printSelf(std::ostream &os, Indent indent)
Definition: cxSliceProxy.h:48
virtual ~SimpleSliceProxy()
Definition: cxSliceProxy.h:63
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
Calculates a slice plane given a definition.
boost::shared_ptr< class SliceProxyInterface > SliceProxyInterfacePtr
bool getUseTooltipOffset()
Return true if the active tools configured tool tip offset should be used for this slice proxy...
Definition: cxSliceProxy.h:111
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr