Fraxinus  17.12
An IGT application
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  bool mTemp;
70 
72  explicit RegistrationTransform(const Transform3D& value, const QDateTime& timestamp = QDateTime(),
73  const QString& type = "", bool tempTransform = false);
74  void addXml(QDomNode& parentNode) const;
75  void parseXml(QDomNode& dataNode);
76 };
77 
78 cxResource_EXPORT bool operator<(const RegistrationTransform& lhs, const RegistrationTransform& rhs);
79 cxResource_EXPORT bool operator==(const RegistrationTransform& lhs, const RegistrationTransform& rhs);
80 
90 class cxResource_EXPORT ParentSpace
91 {
92 public:
93  QString mUid;
94  QDateTime mTimestamp;
95  QString mType;
96 
97  ParentSpace();
98  explicit
99  ParentSpace(const QString& parentFrame, const QDateTime& timestamp = QDateTime(), const QString& type = "");
100  void addXml(QDomNode& parentNode) const;
101  void parseXml(QDomNode& dataNode);
102 };
103 
104 cxResource_EXPORT bool operator<(const ParentSpace& lhs, const ParentSpace& rhs);
105 cxResource_EXPORT bool operator==(const ParentSpace& lhs, const ParentSpace& rhs);
106 
107 typedef boost::shared_ptr<class RegistrationHistory> RegistrationHistoryPtr;
108 
117 class cxResource_EXPORT RegistrationHistory: public QObject
118 {
119 Q_OBJECT
120 public:
121  virtual void addXml(QDomNode& parentNode) const;
122  virtual void parseXml(QDomNode& dataNode);
123 
124  virtual void setRegistration(const Transform3D& transform);
125  virtual void addOrUpdateRegistration(const QDateTime& oldTime, const RegistrationTransform& newTransform);
126 
127  virtual void setParentSpace(const QString& newParent);
128  virtual void addParentSpace(const QString& newParent);
129  virtual void updateParentSpace(const QDateTime& oldTime, const ParentSpace& newParent);
130 
131  virtual std::vector<RegistrationTransform> getData() const;
132  virtual std::vector<ParentSpace> getParentSpaces() const;
133  virtual void removeNewerThan(const QDateTime& timestamp);
134  virtual void setActiveTime(const QDateTime& timestamp);
135  virtual QDateTime getActiveTime() const;
136  virtual RegistrationTransform getCurrentRegistration() const;
137  virtual ParentSpace getCurrentParentSpace();
138  virtual void clear();
139 
140  virtual bool isNull() const
141  {
142  return false;
143  }
144  static RegistrationHistoryPtr getNullObject();
145 
146 signals:
147  void currentChanged();
148 private:
149  virtual void addParentSpace(const ParentSpace& newParent);
150  virtual void addRegistrationInternal(const RegistrationTransform& transform);
151  void setCache(const RegistrationTransform& val, const ParentSpace& parent, const QDateTime& timestamp);
152  static RegistrationHistoryPtr mNull;
153  std::vector<RegistrationTransform> mData;
154  std::vector<ParentSpace> mParentSpaces;
155  QDateTime mCurrentTime;
156  RegistrationTransform mTransformCache;
157  ParentSpace mParentSpaceCache;
158 };
159 
160 } // end namespace cx
161 
162 #endif /*CXREGISTRATIONTRANSFORM_H_*/
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:58
Definition of a parent space event.
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
QString mUid
parent frame uid
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.
Namespace for all CustusX production code.