Fraxinus  17.12-rc2
An IGT application
cxMetricManager.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 #ifndef CXMETRICMANAGER_H
34 #define CXMETRICMANAGER_H
35 
36 #include "cxGuiExport.h"
37 
38 #include "cxForwardDeclarations.h"
39 #include "cxDataMetric.h"
40 #include "cxDefinitions.h"
42 
43 class QDomElement;
44 
45 namespace cx
46 {
47 typedef boost::shared_ptr<class MetricReferenceArgumentList> MetricReferenceArgumentListPtr;
48 typedef boost::shared_ptr<class MetricManager> MetricManagerPtr;
49 
57 class cxGui_EXPORT MetricManager : public QObject
58 {
59  Q_OBJECT
60 public:
61  MetricManager(ViewServicePtr viewService, PatientModelServicePtr patientModelService, TrackingServicePtr trackingService, SpaceProviderPtr spaceProvider);
62 
63  DataMetricPtr getMetric(QString uid);
64  int getNumberOfMetrics() const;
65  void moveToMetric(QString uid);
66  void setSelection(std::set<QString> selection);
67  void setActiveUid(QString uid);
68  QString getActiveUid() const { return mActiveLandmark; }
69  void exportMetricsToXMLFile(QString& filename);
70  void importMetricsFromXMLFile(QString& filename);
71  void importMetricsFromMNITagFile(QString& filename, bool testmode=false);
72  PointMetricPtr addPoint(Vector3D point, CoordinateSystem space=CoordinateSystem(csREF), QString uid="point%1", QColor color = QColor(240, 170, 255, 255));
73  DistanceMetricPtr addDistance(QString uid = "distance%1");
74 
75 signals:
76  void activeMetricChanged();
77  void metricsChanged();
78 
79 public slots:
80  void loadReferencePointsSlot();
81  void addPointButtonClickedSlot();
82  void addFrameButtonClickedSlot();
83  void addToolButtonClickedSlot();
84  void addPlaneButtonClickedSlot();
85  void addAngleButtonClickedSlot();
86  void addDistanceButtonClickedSlot();
87  void addSphereButtonClickedSlot();
88  void addDonutButtonClickedSlot();
89  void addCustomButtonClickedSlot();
90  void addROIButtonClickedSlot();
91 
92 private:
93  void setManualToolPosition(Vector3D p_r);
94  std::vector<DataPtr> refinePointArguments(std::vector<DataPtr> args, unsigned argNo);
95  std::vector<DataPtr> getSpecifiedNumberOfValidArguments(MetricReferenceArgumentListPtr arguments, int numberOfRequiredArguments=-1);
96  void installNewMetric(DataMetricPtr metric);
97  PointMetricPtr addPointInDefaultPosition();
98  std::vector<DataMetricPtr> getAllMetrics() const;
99  DataPtr loadDataFromXMLNode(QDomElement node);
100  DataPtr createData(QString type, QString uid, QString name);
101 
102  QString mActiveLandmark;
103  std::set<QString> mSelection;
104  PatientModelServicePtr mPatientModelService;
105  ViewServicePtr mViewService;
106  TrackingServicePtr mTrackingService;
107  SpaceProviderPtr mSpaceProvider;
108  QColor getRandomColor();
109  std::vector<QString> dialogForSelectingVolumesForImportedMNITagFile(int number_of_volumes, QString description);
110  void resolveUnknownParentSpacesForPointMetrics(QDomNode dataNode, std::map<QString, QString> mapping_of_unknown_to_known_spaces, DataPtr data);
111 };
112 
113 
114 } // namespace cx
115 
116 #endif // CXMETRICMANAGER_H
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
boost::shared_ptr< class DistanceMetric > DistanceMetricPtr
boost::shared_ptr< DataMetric > DataMetricPtr
Definition: cxDataMetric.h:94
boost::shared_ptr< class TrackingService > TrackingServicePtr
csREF
the data reference space (r) using LPS (left-posterior-superior) coordinates.
boost::shared_ptr< class ViewService > ViewServicePtr
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class MetricManager > MetricManagerPtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class MetricReferenceArgumentList > MetricReferenceArgumentListPtr
Identification of a Coordinate system.
QString getActiveUid() const
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:63
Namespace for all CustusX production code.
boost::shared_ptr< class PointMetric > PointMetricPtr