Fraxinus  17.12
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) 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 CXSLICEPROXY_H_
35 #define CXSLICEPROXY_H_
36 
37 #include "cxResourceExport.h"
38 
39 #include <boost/shared_ptr.hpp>
40 #include <QObject>
41 #include "cxDefinitions.h"
42 #include "boost/scoped_ptr.hpp"
43 #include "cxTransform3D.h"
44 #include "cxIndent.h"
45 #include "cxSliceComputer.h"
46 #include "cxForwardDeclarations.h"
47 
48 namespace cx
49 {
50 class SliceComputer;
51 // forward declarations
52 typedef boost::shared_ptr<class Tool> ToolPtr;
53 typedef boost::shared_ptr<class SliceProxyInterface> SliceProxyInterfacePtr;
54 
62 class cxResource_EXPORT SliceProxyInterface : public QObject
63 {
64  Q_OBJECT
65 public:
66  virtual ~SliceProxyInterface() {}
67 
68  virtual Transform3D get_sMr() = 0;
69  void printSelf(std::ostream & os, Indent indent) {}
70 
71 #ifdef WIN32
72  typedef Transform3D Transform3D;
73 #endif
74 
75 signals:
76  void transformChanged(Transform3D sMr);
77 };
78 
79 class cxResource_EXPORT SimpleSliceProxy : public SliceProxyInterface
80 {
81  Q_OBJECT
82 public:
83  SimpleSliceProxy() : m_sMr(Transform3D::Identity()) {}
84  virtual ~SimpleSliceProxy() {}
85  void set_sMr(Transform3D sMr) { m_sMr=sMr; emit transformChanged(m_sMr); }
86  virtual Transform3D get_sMr() { return m_sMr; }
87 public:
89 };
90 
91 typedef boost::shared_ptr<class SimpleSliceProxy> SimpleSliceProxyPtr;
92 typedef boost::shared_ptr<class SliceProxy> SliceProxyPtr;
93 
103 class cxResource_EXPORT SliceProxy : public SliceProxyInterface
104 {
105  Q_OBJECT
106 public:
107  static SliceProxyPtr create(PatientModelServicePtr dataManager);
108  virtual ~SliceProxy();
109 
110  void setTool(ToolPtr tool);
111  void setOrientation(ORIENTATION_TYPE orientation );
112  void setPlane(PLANE_TYPE plane );
113  void setFollowType(FOLLOW_TYPE followType);
114  void initializeFromPlane(PLANE_TYPE plane, bool useGravity, bool useViewOffset, double viewportHeight, double toolViewOffset);
115 
116  void setGravity(bool use, const Vector3D& dir);
117  void setToolViewOffset(bool use, double viewportHeight, double toolViewOffset);
118  void setToolViewportHeight(double viewportHeight);
119  void setDefaultCenter(const Vector3D& c);
120  void setAlwaysUseDefaultCenter(bool on);
121 
122  SliceComputer getComputer() const;
123  void setComputer(const SliceComputer& val);
124 
125  ToolPtr getTool();
126  virtual Transform3D get_sMr();
127  virtual void printSelf(std::ostream & os, Indent indent);
128 
132  bool getUseTooltipOffset() { return mUseTooltipOffset; }
136  void setUseTooltipOffset(bool);
137 
138 signals:
139  void toolTransformAndTimestamp(Transform3D prMt, double timestamp);
140  void toolVisible(bool visible);
141 
142 private slots:
143  void clinicalApplicationChangedSlot();
144  void tooltipOffsetSlot(double val);
145  void toolTransformAndTimestampSlot(Transform3D prMt, double timestamp);
146  void toolVisibleSlot(bool visible);
147  void centerChangedSlot();
148  void changed();
149 
150 private:
151  SliceProxy(PatientModelServicePtr dataManager);
152  Transform3D getSyntheticToolPos(const Vector3D& center) const;
153  void initCutplane();
154 
155  ToolPtr mTool;
156  boost::scoped_ptr<SliceComputer> mCutplane;
157  Vector3D mDefaultCenter;
158  bool mAlwaysUseDefaultCenter;
159 // QString mName; ///< for debug
160  bool mUseTooltipOffset;
161  PatientModelServicePtr mDataManager;
162  SlicePlane mLastEmittedSlicePlane;
163 };
164 
169 }
170 
171 #endif /*CXSLICEPROXY_H_*/
void set_sMr(Transform3D sMr)
Definition: cxSliceProxy.h:85
Provides a slice matrix based on definition and tool.
Definition: cxSliceProxy.h:103
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:91
virtual Transform3D get_sMr()
get slice transform, i.e. the matrix sMr transforming a point p in ref to slice space.
Definition: cxSliceProxy.h:86
virtual ~SliceProxyInterface()
Definition: cxSliceProxy.h:66
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Formatting class for debug printing of the ssc library.
Definition: cxIndent.h:49
void printSelf(std::ostream &os, Indent indent)
Definition: cxSliceProxy.h:69
virtual ~SimpleSliceProxy()
Definition: cxSliceProxy.h:84
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
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:132
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr