NorMIT-nav  22.09
An IGT application
cxCustomMetric.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 #ifndef CXCUSTOMMETRIC_H
12 #define CXCUSTOMMETRIC_H
13 
14 #include "cxResourceExport.h"
15 #include "cxPrecompiledHeader.h"
16 
17 #include "cxDataMetric.h"
18 #include "cxPointMetric.h"
20 
21 namespace cx
22 {
29 typedef boost::shared_ptr<class CustomMetric> CustomMetricPtr;
30 
40 class cxResource_EXPORT CustomMetric: public DataMetric
41 {
42 Q_OBJECT
43 public:
44  virtual ~CustomMetric();
45  static CustomMetricPtr create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider);
46 
47  virtual bool isValid() const;
48  virtual QIcon getIcon() {return QIcon(":/icons/metric_custom.png");}
49 
50  QString getDefineVectorUpMethod() const;
51  void setDefineVectorUpMethod(QString defineVectorUpMethod);
52  void setModelUid(QString val);
53  QString getModelUid() const;
54  DataPtr getModel() const;
55 
56  void setScaleToP1(bool val);
57  bool getScaleToP1() const;
58  void setOffsetFromP0(double val);
59  double getOffsetFromP0() const;
60  void setOffsetFromP1(double val);
61  double getOffsetFromP1() const;
62  void setRepeatDistance(double val);
63  double getRepeatDistance() const;
64  void setTranslationOnly(bool val);
65  bool getTranslationOnly() const;
66  void setTextureFollowTool(bool val);
67  bool getTextureFollowTool() const;
68 
70  virtual void addXml(QDomNode& dataNode);
71  virtual void parseXml(QDomNode& dataNode);
72  virtual DoubleBoundingBox3D boundingBox() const;
73  virtual Vector3D getRefCoord() const;
74  virtual QString getType() const
75  {
76  return getTypeName();
77  }
78  static QString getTypeName()
79  {
80  return "CustomMetric";
81  }
82  virtual QString getValueAsString() const { return ""; }
83  virtual bool showValueInGraphics() const { return false; }
84 
85 private:
86  std::vector<Vector3D> getPositions() const;
87  Vector3D getDirection() const;
88  Vector3D getVectorUp() const;
89  Vector3D getScale() const;
90 
91  struct cxResource_EXPORT DefineVectorUpMethods
92  {
93  DefineVectorUpMethods()
94  {
95  table = "tableDefinesUp";
96  connectedFrameInP1 = "connectedFrameDefinesUp";
97  tool = "toolDefinesUp";
98  }
99  QString table;
100  QString connectedFrameInP1;
101  QString tool;
102  QStringList getAvailableDefineVectorUpMethods() const;
103  std::map<QString, QString> getAvailableDefineVectorUpMethodsDisplayNames() const;
104  };
105 
106  CustomMetric(const QString& uid, const QString& name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider);
108  QString mDefineVectorUpMethod;
109  QString mModelUid;
110  DefineVectorUpMethods mDefineVectorUpMethods;
111  bool mScaleToP1;
112  double mOffsetFromP0;
113  double mOffsetFromP1;
114  double mRepeatDistance;
115  bool mShowDistanceMarkers;
116  double mDistanceMarkerVisibility;
117  bool mTranslationOnly;
118  bool mTextureFollowTool;
119  SpaceListenerPtr mToolListener;
120 
121  Transform3D calculateOrientation(Vector3D pos, Vector3D dir, Vector3D vup, Vector3D scale) const;
122  Transform3D calculateRotation(Vector3D dir, Vector3D vup) const;
123  Transform3D calculateTransformTo2DImageCenter() const;
124  void onPropertiesChanged();
125  bool needForToolListenerHasChanged() const;
126  void createOrDestroyToolListener();
127 
128 public:
129  CustomMetric::DefineVectorUpMethods getDefineVectorUpMethods() const;
130  std::vector<Transform3D> calculateOrientations() const;
131  int getRepeatCount() const;
132  std::vector<Vector3D> getPointCloud() const;
133  bool modelIsImage() const;
134  void setShowDistanceMarkers(bool show);
135  bool getShowDistanceMarkers() const;
136  Vector3D getZeroPosition() const;
137  void setDistanceMarkerVisibility(double val);
138  double getDistanceMarkerVisibility() const;
139  void updateTexture(MeshPtr model, Transform3D rMrr);
140 };
141 
145 } // namespace cx
146 
147 #endif // CXSHAPEDMETRIC_H
cx::SpaceListenerPtr
boost::shared_ptr< class SpaceListener > SpaceListenerPtr
Definition: cxAxisConnector.h:23
cx::MetricReferenceArgumentListPtr
boost::shared_ptr< class MetricReferenceArgumentList > MetricReferenceArgumentListPtr
Definition: cxMetricManager.h:26
cx::DoubleBoundingBox3D
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,...
Definition: cxBoundingBox3D.h:63
cx::CustomMetric
Data class that represents a custom.
Definition: cxCustomMetric.h:40
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cxPrecompiledHeader.h
cx::CustomMetric::getType
virtual QString getType() const
Definition: cxCustomMetric.h:74
cx::CustomMetric::getValueAsString
virtual QString getValueAsString() const
Definition: cxCustomMetric.h:82
cxDataMetric.h
cx::CustomMetric::showValueInGraphics
virtual bool showValueInGraphics() const
Definition: cxCustomMetric.h:83
cx::MeshPtr
boost::shared_ptr< class Mesh > MeshPtr
Definition: cxForwardDeclarations.h:48
cx::Transform3D
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
Definition: cxLandmarkPatientRegistrationWidget.h:33
cxMetricReferenceArgumentList.h
cx::CustomMetricPtr
boost::shared_ptr< class CustomMetric > CustomMetricPtr
Definition: cxCustomMetric.h:29
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::DataPtr
boost::shared_ptr< class Data > DataPtr
Definition: cxRegistrationApplicator.h:22
cx::CustomMetric::getIcon
virtual QIcon getIcon()
Definition: cxCustomMetric.h:48
cx::CustomMetric::getTypeName
static QString getTypeName()
Definition: cxCustomMetric.h:78
cx::DataMetric
Base class for all Data Metrics.
Definition: cxDataMetric.h:43
cxPointMetric.h
cx::CustomMetric::getArguments
MetricReferenceArgumentListPtr getArguments()
Definition: cxCustomMetric.h:69
cx::Vector3D
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
cx::SpaceProviderPtr
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
Definition: cxLogicManager.h:23