Fraxinus  16.5.0-fx-rc7
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 "cxForwardDeclarations.h"
46 
47 namespace cx
48 {
49 class SliceComputer;
50 // forward declarations
51 typedef boost::shared_ptr<class Tool> ToolPtr;
52 typedef boost::shared_ptr<class SliceProxyInterface> SliceProxyInterfacePtr;
53 
61 class cxResource_EXPORT SliceProxyInterface : public QObject
62 {
63  Q_OBJECT
64 public:
65  virtual ~SliceProxyInterface() {}
66 
67  virtual Transform3D get_sMr() = 0;
68  void printSelf(std::ostream & os, Indent indent) {}
69 
70 #ifdef WIN32
71  typedef Transform3D Transform3D;
72 #endif
73 
74 signals:
75  void transformChanged(Transform3D sMr);
76 };
77 
78 class cxResource_EXPORT SimpleSliceProxy : public SliceProxyInterface
79 {
80  Q_OBJECT
81 public:
82  SimpleSliceProxy() : m_sMr(Transform3D::Identity()) {}
83  virtual ~SimpleSliceProxy() {}
84  void set_sMr(Transform3D sMr) { m_sMr=sMr; emit transformChanged(m_sMr); }
85  virtual Transform3D get_sMr() { return m_sMr; }
86 public:
88 };
89 
90 typedef boost::shared_ptr<class SimpleSliceProxy> SimpleSliceProxyPtr;
91 typedef boost::shared_ptr<class SliceProxy> SliceProxyPtr;
92 
102 class cxResource_EXPORT SliceProxy : public SliceProxyInterface
103 {
104  Q_OBJECT
105 public:
106  static SliceProxyPtr create(PatientModelServicePtr dataManager);
107  virtual ~SliceProxy();
108 
109  void setTool(ToolPtr tool);
110  void setOrientation(ORIENTATION_TYPE orientation );
111  void setPlane(PLANE_TYPE plane );
112  void setFollowType(FOLLOW_TYPE followType);
113  void initializeFromPlane(PLANE_TYPE plane, bool useGravity, const Vector3D& gravityDir, bool useViewOffset, double viewportHeight, double toolViewOffset, bool useConstrainedViewOffset = false);
114 
115  void setGravity(bool use, const Vector3D& dir);
116  void setToolViewOffset(bool use, double viewportHeight, double toolViewOffset, bool useConstrainedViewOffset = false);
117  void setToolViewportHeight(double viewportHeight);
118  void setDefaultCenter(const Vector3D& c);
119  void setAlwaysUseDefaultCenter(bool on);
120 
121  SliceComputer getComputer() const;
122  void setComputer(const SliceComputer& val);
123 
124  ToolPtr getTool();
125  virtual Transform3D get_sMr();
126  virtual void printSelf(std::ostream & os, Indent indent);
127 
131  bool getUseTooltipOffset() { return mUseTooltipOffset; }
135  void setUseTooltipOffset(bool);
136 
137 signals:
138  void toolTransformAndTimestamp(Transform3D prMt, double timestamp);
139  void toolVisible(bool visible);
140 
141 private slots:
142  void clinicalApplicationChangedSlot();
143  void tooltipOffsetSlot(double val);
144  void toolTransformAndTimestampSlot(Transform3D prMt, double timestamp);
145  void toolVisibleSlot(bool visible);
146  void centerChangedSlot();
147  void changed();
148 
149 private:
150  SliceProxy(PatientModelServicePtr dataManager);
151  Transform3D getSyntheticToolPos(const Vector3D& center) const;
152  void initCutplane();
153 
154  ToolPtr mTool;
155  boost::scoped_ptr<SliceComputer> mCutplane;
156  Vector3D mDefaultCenter;
157  bool mAlwaysUseDefaultCenter;
158 // QString mName; ///< for debug
159  bool mUseTooltipOffset;
160  PatientModelServicePtr mDataManager;
161 };
162 
167 }
168 
169 #endif /*CXSLICEPROXY_H_*/
void set_sMr(Transform3D sMr)
Definition: cxSliceProxy.h:84
Provides a slice matrix based on definition and tool.
Definition: cxSliceProxy.h:102
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:90
virtual Transform3D get_sMr()
get slice transform, i.e. the matrix sMr transforming a point p in ref to slice space.
Definition: cxSliceProxy.h:85
virtual ~SliceProxyInterface()
Definition: cxSliceProxy.h:65
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:68
virtual ~SimpleSliceProxy()
Definition: cxSliceProxy.h:83
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:131
boost::shared_ptr< class Tool > ToolPtr