Fraxinus  17.12
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) 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 #ifndef CXCUSTOMMETRIC_H
33 #define CXCUSTOMMETRIC_H
34 
35 #include "cxResourceExport.h"
36 #include "cxPrecompiledHeader.h"
37 
38 #include "cxDataMetric.h"
39 #include "cxPointMetric.h"
41 
42 namespace cx
43 {
50 typedef boost::shared_ptr<class CustomMetric> CustomMetricPtr;
51 
61 class cxResource_EXPORT CustomMetric: public DataMetric
62 {
63 Q_OBJECT
64 public:
65  virtual ~CustomMetric();
66  static CustomMetricPtr create(QString uid, QString name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider);
67 
68  virtual bool isValid() const;
69  virtual QIcon getIcon() {return QIcon(":/icons/metric_custom.png");}
70 
71  QString getDefineVectorUpMethod() const;
72  void setDefineVectorUpMethod(QString defineVectorUpMethod);
73  void setModelUid(QString val);
74  QString getModelUid() const;
75  DataPtr getModel() const;
76 
77  void setScaleToP1(bool val);
78  bool getScaleToP1() const;
79  void setOffsetFromP0(double val);
80  double getOffsetFromP0() const;
81  void setOffsetFromP1(double val);
82  double getOffsetFromP1() const;
83  void setRepeatDistance(double val);
84  double getRepeatDistance() const;
85  void setTranslationOnly(bool val);
86  bool getTranslationOnly() const;
87  void setTextureFollowTool(bool val);
88  bool getTextureFollowTool() const;
89 
91  virtual void addXml(QDomNode& dataNode);
92  virtual void parseXml(QDomNode& dataNode);
93  virtual DoubleBoundingBox3D boundingBox() const;
94  virtual Vector3D getRefCoord() const;
95  virtual QString getType() const
96  {
97  return getTypeName();
98  }
99  static QString getTypeName()
100  {
101  return "CustomMetric";
102  }
103  virtual QString getValueAsString() const { return ""; }
104  virtual bool showValueInGraphics() const { return false; }
105 
106 private:
107  std::vector<Vector3D> getPositions() const;
108  Vector3D getDirection() const;
109  Vector3D getVectorUp() const;
110  Vector3D getScale() const;
111 
112  struct cxResource_EXPORT DefineVectorUpMethods
113  {
114  DefineVectorUpMethods()
115  {
116  table = "tableDefinesUp";
117  connectedFrameInP1 = "connectedFrameDefinesUp";
118  tool = "toolDefinesUp";
119  }
120  QString table;
121  QString connectedFrameInP1;
122  QString tool;
123  QStringList getAvailableDefineVectorUpMethods() const;
124  std::map<QString, QString> getAvailableDefineVectorUpMethodsDisplayNames() const;
125  };
126 
127  CustomMetric(const QString& uid, const QString& name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider);
129  QString mDefineVectorUpMethod;
130  QString mModelUid;
131  DefineVectorUpMethods mDefineVectorUpMethods;
132  bool mScaleToP1;
133  double mOffsetFromP0;
134  double mOffsetFromP1;
135  double mRepeatDistance;
136  bool mShowDistanceMarkers;
137  double mDistanceMarkerVisibility;
138  bool mTranslationOnly;
139  bool mTextureFollowTool;
140  SpaceListenerPtr mToolListener;
141 
142  Transform3D calculateOrientation(Vector3D pos, Vector3D dir, Vector3D vup, Vector3D scale) const;
143  Transform3D calculateRotation(Vector3D dir, Vector3D vup) const;
144  Transform3D calculateTransformTo2DImageCenter() const;
145  void onPropertiesChanged();
146  bool needForToolListenerHasChanged() const;
147  void createOrDestroyToolListener();
148 
149 public:
150  CustomMetric::DefineVectorUpMethods getDefineVectorUpMethods() const;
151  std::vector<Transform3D> calculateOrientations() const;
152  int getRepeatCount() const;
153  std::vector<Vector3D> getPointCloud() const;
154  bool modelIsImage() const;
155  void setShowDistanceMarkers(bool show);
156  bool getShowDistanceMarkers() const;
157  Vector3D getZeroPosition() const;
158  void setDistanceMarkerVisibility(double val);
159  double getDistanceMarkerVisibility() const;
160  void updateTexture(MeshPtr model, Transform3D rMrr);
161 };
162 
166 } // namespace cx
167 
168 #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:63
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:64
boost::shared_ptr< class CustomMetric > CustomMetricPtr
Namespace for all CustusX production code.