CustusX  16.5.0-rc9
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxRegistrationTransform.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 CXREGISTRATIONTRANSFORM_H_
35 #define CXREGISTRATIONTRANSFORM_H_
36 
37 #include "cxResourceExport.h"
38 #include "cxPrecompiledHeader.h"
39 
40 #include <string>
41 #include <vector>
42 #include <boost/shared_ptr.hpp>
43 #include <QObject>
44 #include <QDateTime>
45 
46 #include "cxTransform3D.h"
47 
48 class QDomNode;
49 
50 namespace cx
51 {
52 
60 class cxResource_EXPORT RegistrationTransform
61 {
62 public:
64  QDateTime mTimestamp;
65  QString mType;
66 
67  QString mFixed;
68  QString mMoving;
69 
71  explicit RegistrationTransform(const Transform3D& value, const QDateTime& timestamp = QDateTime(),
72  const QString& type = "");
73  void addXml(QDomNode& parentNode) const;
74  void parseXml(QDomNode& dataNode);
75 };
76 
77 cxResource_EXPORT bool operator<(const RegistrationTransform& lhs, const RegistrationTransform& rhs);
78 cxResource_EXPORT bool operator==(const RegistrationTransform& lhs, const RegistrationTransform& rhs);
79 
89 class cxResource_EXPORT ParentSpace
90 {
91 public:
92  QString mValue;
93  QDateTime mTimestamp;
94  QString mType;
95 
96  ParentSpace();
97  explicit
98  ParentSpace(const QString& parentFrame, const QDateTime& timestamp = QDateTime(), const QString& type = "");
99  void addXml(QDomNode& parentNode) const;
100  void parseXml(QDomNode& dataNode);
101 };
102 
103 cxResource_EXPORT bool operator<(const ParentSpace& lhs, const ParentSpace& rhs);
104 cxResource_EXPORT bool operator==(const ParentSpace& lhs, const ParentSpace& rhs);
105 
106 typedef boost::shared_ptr<class RegistrationHistory> RegistrationHistoryPtr;
107 
116 class cxResource_EXPORT RegistrationHistory: public QObject
117 {
118 Q_OBJECT
119 public:
120  virtual void addXml(QDomNode& parentNode) const;
121  virtual void parseXml(QDomNode& dataNode);
122 
123  virtual void addRegistration(const RegistrationTransform& transform);
124  virtual void setRegistration(const Transform3D& transform);
125  virtual void updateRegistration(const QDateTime& oldTime, const RegistrationTransform& newTransform);
126 
127  virtual void setParentSpace(const QString& newParent);
128  virtual void addParentSpace(const QString& newParent);
129  virtual void addParentSpace(const ParentSpace& newParent);
130  virtual void updateParentSpace(const QDateTime& oldTime, const ParentSpace& newParent);
131 
132  virtual std::vector<RegistrationTransform> getData() const;
133  virtual std::vector<ParentSpace> getParentSpaces() const;
134  virtual void removeNewerThan(const QDateTime& timestamp);
135  virtual void setActiveTime(const QDateTime& timestamp);
136  virtual QDateTime getActiveTime() const;
137  virtual RegistrationTransform getCurrentRegistration() const;
138  virtual ParentSpace getCurrentParentSpace();
139  virtual void clear();
140 
141  virtual bool isNull() const
142  {
143  return false;
144  }
145  static RegistrationHistoryPtr getNullObject();
146 
147 signals:
148  void currentChanged();
149 private:
150  void setCache(const RegistrationTransform& val, const ParentSpace& parent, const QDateTime& timestamp);
151  static RegistrationHistoryPtr mNull;
152  std::vector<RegistrationTransform> mData;
153  std::vector<ParentSpace> mParentSpaces;
154  QDateTime mCurrentTime;
155  RegistrationTransform mTransformCache;
156  ParentSpace mParentSpaceCache;
157 };
158 
159 } // end namespace cx
160 
161 #endif /*CXREGISTRATIONTRANSFORM_H_*/
QString mValue
parent frame uid
bool operator<(const Landmark &lhs, const Landmark &rhs)
Definition: cxLandmark.cpp:94
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
boost::shared_ptr< class RegistrationHistory > RegistrationHistoryPtr
Definition: cxDataManager.h:57
Definition of a parent space event.
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
QDateTime mTimestamp
time the transform was registrated.
QDateTime mTimestamp
time the transform was registrated.
Transform3D mValue
value of transform
virtual bool isNull() const
QString mType
description of the kind if registration (manual, patient, landmark, coregistration etc) ...
QString mType
description of the kind if registration (manual, patient, landmark, coregistration etc) ...
A registration event and its transform.
bool operator==(const RegistrationTransform &lhs, const RegistrationTransform &rhs)
A history of registration events.