CustusX  22.04-rc2
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
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
virtual bool showValueInGraphics() const
virtual QString getType() const
boost::shared_ptr< class Data > DataPtr
static QString getTypeName()
Data class that represents a custom.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class MetricReferenceArgumentList > MetricReferenceArgumentListPtr
Representation of a floating-point bounding box in 3D. The data are stored as {xmin,xmax,ymin,ymax,zmin,zmax}, in order to simplify communication with vtk.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
MetricReferenceArgumentListPtr getArguments()
virtual QString getValueAsString() const
virtual QIcon getIcon()
boost::shared_ptr< class SpaceListener > SpaceListenerPtr
boost::shared_ptr< class Mesh > MeshPtr
Base class for all Data Metrics.
Definition: cxDataMetric.h:43
boost::shared_ptr< class CustomMetric > CustomMetricPtr
Namespace for all CustusX production code.