CustusX  16.12
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 QString getAsSingleLineString() const;
70  virtual QIcon getIcon() {return QIcon(":/icons/metric_custom.png");}
71 
72  QString getDefineVectorUpMethod() const;
73  void setDefineVectorUpMethod(QString defineVectorUpMethod);
74  void setModelUid(QString val);
75  QString getModelUid() const;
76  DataPtr getModel() const;
77 
78  void setScaleToP1(bool val);
79  bool getScaleToP1() const;
80  void setOffsetFromP0(double val);
81  double getOffsetFromP0() const;
82  void setOffsetFromP1(double val);
83  double getOffsetFromP1() const;
84  void setRepeatDistance(double val);
85  double getRepeatDistance() const;
86  void setTranslationOnly(bool val);
87  bool getTranslationOnly() const;
88  void setTextureFollowTool(bool val);
89  bool getTextureFollowTool() const;
90 
92  virtual void addXml(QDomNode& dataNode);
93  virtual void parseXml(QDomNode& dataNode);
94  virtual DoubleBoundingBox3D boundingBox() const;
95  virtual Vector3D getRefCoord() const;
96  virtual QString getType() const
97  {
98  return getTypeName();
99  }
100  static QString getTypeName()
101  {
102  return "CustomMetric";
103  }
104  virtual QString getValueAsString() const { return ""; }
105  virtual bool showValueInGraphics() const { return false; }
106 
107 private:
108  std::vector<Vector3D> getPositions() const;
109  Vector3D getDirection() const;
110  Vector3D getVectorUp() const;
111  Vector3D getScale() const;
112 
113  struct cxResource_EXPORT DefineVectorUpMethods
114  {
115  DefineVectorUpMethods()
116  {
117  table = "tableDefinesUp";
118  connectedFrameInP1 = "connectedFrameDefinesUp";
119  tool = "toolDefinesUp";
120  }
121  QString table;
122  QString connectedFrameInP1;
123  QString tool;
124  QStringList getAvailableDefineVectorUpMethods() const;
125  std::map<QString, QString> getAvailableDefineVectorUpMethodsDisplayNames() const;
126  };
127 
128  CustomMetric(const QString& uid, const QString& name, PatientModelServicePtr dataManager, SpaceProviderPtr spaceProvider);
130  QString mDefineVectorUpMethod;
131  QString mModelUid;
132  DefineVectorUpMethods mDefineVectorUpMethods;
133  bool mScaleToP1;
134  double mOffsetFromP0;
135  double mOffsetFromP1;
136  double mRepeatDistance;
137  bool mShowDistanceMarkers;
138  double mDistanceMarkerVisibility;
139  bool mTranslationOnly;
140  bool mTextureFollowTool;
141  SpaceListenerPtr mToolListener;
142 
143  Transform3D calculateOrientation(Vector3D pos, Vector3D dir, Vector3D vup, Vector3D scale) const;
144  Transform3D calculateRotation(Vector3D dir, Vector3D vup) const;
145  Transform3D calculateTransformTo2DImageCenter() const;
146  void onPropertiesChanged();
147  bool needForToolListenerHasChanged() const;
148  void createOrDestroyToolListener();
149 
150 public:
151  CustomMetric::DefineVectorUpMethods getDefineVectorUpMethods() const;
152  std::vector<Transform3D> calculateOrientations() const;
153  int getRepeatCount() const;
154  std::vector<Vector3D> getPointCloud() const;
155  bool modelIsImage() const;
156  void setShowDistanceMarkers(bool show);
157  bool getShowDistanceMarkers() const;
158  Vector3D getZeroPosition() const;
159  void setDistanceMarkerVisibility(double val);
160  double getDistanceMarkerVisibility() const;
161  void updateTexture(MeshPtr model, Transform3D rMrr);
162 };
163 
167 } // namespace cx
168 
169 #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.
cxLogicManager_EXPORT SpaceProviderPtr spaceProvider()
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