NorMIT-nav  18.04
An IGT application
cxMetricManager.cpp
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 
12 #include "cxMetricManager.h"
13 #include "cxManualTool.h"
14 #include "cxViewGroupData.h"
15 #include "cxTrackingService.h"
16 #include <QFile>
17 #include <QTextStream>
18 #include <QDialog>
19 #include <QVBoxLayout>
20 #include <QPushButton>
21 #include <QLabel>
22 #include <vtkMNITagPointReader.h>
23 #include <vtkStringArray.h>
24 #include "vtkForwardDeclarations.h"
25 #include "cxDataReaderWriter.h"
26 #include "cxLogger.h"
28 #include "cxPointMetric.h"
29 #include "cxDistanceMetric.h"
30 #include "cxFrameMetric.h"
31 #include "cxToolMetric.h"
32 #include "cxPlaneMetric.h"
33 #include "cxShapedMetric.h"
34 #include "cxCustomMetric.h"
35 #include "cxAngleMetric.h"
36 #include "cxSphereMetric.h"
38 #include "cxDataFactory.h"
39 #include "cxSpaceProvider.h"
40 #include "cxTypeConversions.h"
41 #include "cxPatientModelService.h"
42 #include "cxViewService.h"
43 #include "cxOrderedQDomDocument.h"
44 #include "cxXmlFileHandler.h"
45 #include "cxTime.h"
46 #include "cxErrorObserver.h"
47 #include "cxHelperWidgets.h"
48 #include "cxFileHelpers.h"
49 #include "cxSpaceProperty.h"
50 #include "cxSpaceEditWidget.h"
51 
52 namespace cx
53 {
54 
55 MetricManager::MetricManager(ViewServicePtr viewService, PatientModelServicePtr patientModelService, TrackingServicePtr trackingService, SpaceProviderPtr spaceProvider) :
56  QObject(NULL),
57  mViewService(viewService),
58  mPatientModelService(patientModelService),
59  mTrackingService(trackingService),
60  mSpaceProvider(spaceProvider)
61 {
62  connect(trackingService.get(), &TrackingService::stateChanged, this, &MetricManager::metricsChanged);
63  connect(patientModelService.get(), SIGNAL(dataAddedOrRemoved()), this, SIGNAL(metricsChanged()));
64 }
65 
67 {
68  DataPtr data = mPatientModelService->getData(uid);
69  DataMetricPtr metric = boost::dynamic_pointer_cast<DataMetric>(data);
70  return metric;
71 }
72 
74 {
75  return this->getAllMetrics().size();
76 }
77 
78 std::vector<DataMetricPtr> MetricManager::getAllMetrics() const
79 {
80  std::vector<DataMetricPtr> retval;
81  std::map<QString, DataPtr> all = mPatientModelService->getDatas();
82  for (std::map<QString, DataPtr>::iterator iter=all.begin(); iter!=all.end(); ++iter)
83  {
84  DataMetricPtr metric = boost::dynamic_pointer_cast<DataMetric>(iter->second);
85  if (metric)
86  retval.push_back(metric);
87  }
88  return retval;
89 }
90 
91 void MetricManager::setSelection(std::set<QString> selection)
92 {
93  mSelection = selection;
94 }
95 
96 void MetricManager::setActiveUid(QString uid)
97 {
98  mActiveLandmark = uid;
99  emit activeMetricChanged();
100 }
101 
103 {
104  DataMetricPtr metric = this->getMetric(uid);
105  if (!metric)
106  return;
107  Vector3D p_r = metric->getRefCoord();;
108  this->setManualToolPosition(p_r);
109 }
110 
111 void MetricManager::setManualToolPosition(Vector3D p_r)
112 {
113  Transform3D rMpr = mPatientModelService->get_rMpr();
114  Vector3D p_pr = rMpr.inv().coord(p_r);
115 
116  // set the picked point as offset tip
117  ToolPtr tool = mTrackingService->getManualTool();
118  Vector3D offset = tool->get_prMt().vector(Vector3D(0, 0, tool->getTooltipOffset()));
119  p_pr -= offset;
120  p_r = rMpr.coord(p_pr);
121 
122  // TODO set center here will not do: must handle
123  mPatientModelService->setCenter(p_r);
124  Vector3D p0_pr = tool->get_prMt().coord(Vector3D(0, 0, 0));
125  tool->set_prMt(createTransformTranslate(p_pr - p0_pr) * tool->get_prMt());
126 }
127 
128 PointMetricPtr MetricManager::addPoint(Vector3D point, CoordinateSystem space, QString uid, QColor color)
129 {
130  PointMetricPtr p1 = mPatientModelService->createSpecificData<PointMetric>(uid);
131  p1->get_rMd_History()->setParentSpace("reference");
132  p1->setSpace(space);
133  p1->setCoordinate(point);
134  p1->setColor(color);
135  mPatientModelService->insertData(p1);
136 
137  mViewService->getGroup(0)->addData(p1->getUid());
138  this->setActiveUid(p1->getUid());
139 
140  return p1;
141 }
142 
144 {
145  DistanceMetricPtr d0 = mPatientModelService->createSpecificData<DistanceMetric>(uid);
146  d0->get_rMd_History()->setParentSpace("reference");
147 
148  std::vector<DataPtr> args = this->getSpecifiedNumberOfValidArguments(d0->getArguments());
149  for (unsigned i=0; i<args.size(); ++i)
150  d0->getArguments()->set(i, args[i]);
151 
152  this->installNewMetric(d0);
153 
154  return d0;
155 }
156 
158 {
159  this->addPointInDefaultPosition();
160 }
161 
162 PointMetricPtr MetricManager::addPointInDefaultPosition()
163 {
165  QColor color = QColor(240, 170, 255, 255);
166  Vector3D p_ref = mSpaceProvider->getActiveToolTipPoint(ref, true);
167 
168  DataPtr data = mPatientModelService->getData(mActiveLandmark);
169  if(!data)
170 
171  return this->addPoint(p_ref, ref,"point%1", color);
172 
173  PointMetricPtr pointMetric = boost::dynamic_pointer_cast<PointMetric>(data);
174  if(pointMetric)
175  {
176  ref = pointMetric->getSpace();
177  p_ref = mSpaceProvider->getActiveToolTipPoint(ref, true);
178  }
179 
180  DataMetricPtr metric = boost::dynamic_pointer_cast<DataMetric>(data);
181  if(metric)
182  color = metric->getColor();
183 
184 
185 
186  return this->addPoint(p_ref, ref,"point%1", color);
187 }
188 
190 {
191  FrameMetricPtr frame = mPatientModelService->createSpecificData<FrameMetric>("frame%1");
192  frame->get_rMd_History()->setParentSpace("reference");
193 
195  Transform3D rMt = mSpaceProvider->getActiveToolTipTransform(ref, true);
196 
197  frame->setSpace(ref);
198  frame->setFrame(rMt);
199 
200  this->installNewMetric(frame);
201 }
202 
204 {
205  ToolMetricPtr frame = mPatientModelService->createSpecificData<ToolMetric>("tool%1");
206  frame->get_rMd_History()->setParentSpace("reference");
207 
209  Transform3D rMt = mSpaceProvider->getActiveToolTipTransform(ref, true);
210 
211  frame->setSpace(ref);
212  frame->setFrame(rMt);
213  frame->setToolName(mTrackingService->getActiveTool()->getName());
214  frame->setToolOffset(mTrackingService->getActiveTool()->getTooltipOffset());
215 
216  this->installNewMetric(frame);
217 }
218 
220 {
221  PlaneMetricPtr p1 = mPatientModelService->createSpecificData<PlaneMetric>("plane%1");
222  p1->get_rMd_History()->setParentSpace("reference");
223 
224  std::vector<DataPtr> args = this->getSpecifiedNumberOfValidArguments(p1->getArguments());
225  for (unsigned i=0; i<args.size(); ++i)
226  p1->getArguments()->set(i, args[i]);
227 
228  this->installNewMetric(p1);
229 }
230 
235 std::vector<DataPtr> MetricManager::refinePointArguments(std::vector<DataPtr> args, unsigned argNo)
236 {
237  // erase non-selected arguments if we have more than enough
238  //std::set<QString> selectedUids = this->getSelectedUids();
239  for (unsigned i=0; i<args.size();)
240  {
241  if (args.size() <= argNo)
242  break;
243  if (!mSelection.count(args[i]->getUid()))
244  args.erase(args.begin()+i);
245  else
246  ++i;
247  }
248 
249  while (args.size() > argNo)
250  args.erase(args.begin());
251 
252  while (args.size() < argNo)
253  {
254  PointMetricPtr p0 = this->addPointInDefaultPosition();
255  args.push_back(p0);
256  }
257 
258  return args;
259 }
260 
262 {
263  RegionOfInterestMetricPtr d0 = mPatientModelService->createSpecificData<RegionOfInterestMetric>("roi%1");
264  d0->get_rMd_History()->setParentSpace("reference");
265  this->installNewMetric(d0);
266 }
267 
269 {
270  this->addDistance();
271 }
272 
274 {
275  AngleMetricPtr d0 = mPatientModelService->createSpecificData<AngleMetric>("angle%1");
276  d0->get_rMd_History()->setParentSpace("reference");
277 
278  std::vector<DataPtr> args = this->getSpecifiedNumberOfValidArguments(d0->getArguments(), 3);
279  d0->getArguments()->set(0, args[0]);
280  d0->getArguments()->set(1, args[1]);
281  d0->getArguments()->set(2, args[1]);
282  d0->getArguments()->set(3, args[2]);
283 
284  this->installNewMetric(d0);
285 }
286 
287 std::vector<DataPtr> MetricManager::getSpecifiedNumberOfValidArguments(MetricReferenceArgumentListPtr arguments, int numberOfRequiredArguments)
288 {
289  // first try to reuse existing points as distance arguments, otherwise create new ones.
290 
291  std::vector<DataMetricPtr> metrics = this->getAllMetrics();
292 
293  std::vector<DataPtr> args;
294  for (unsigned i=0; i<metrics.size(); ++i)
295  {
296  if (arguments->validArgument(metrics[i]))
297  args.push_back(metrics[i]);
298  }
299 
300  if (numberOfRequiredArguments<0)
301  numberOfRequiredArguments = arguments->getCount();
302  args = this->refinePointArguments(args, numberOfRequiredArguments);
303 
304  return args;
305 }
306 
308 {
309  SphereMetricPtr d0 = mPatientModelService->createSpecificData<SphereMetric>("sphere%1");
310  d0->get_rMd_History()->setParentSpace("reference");
311  std::vector<DataPtr> args = this->getSpecifiedNumberOfValidArguments(d0->getArguments());
312  d0->getArguments()->set(0, args[0]);
313 
314  this->installNewMetric(d0);
315 }
316 
318 {
319  DonutMetricPtr d0 = mPatientModelService->createSpecificData<DonutMetric>("donut%1");
320  d0->get_rMd_History()->setParentSpace("reference");
321  std::vector<DataPtr> args = this->getSpecifiedNumberOfValidArguments(d0->getArguments());
322  d0->getArguments()->set(0, args[0]);
323  d0->getArguments()->set(1, args[1]);
324 
325  this->installNewMetric(d0);
326 }
327 
329 {
330  CustomMetricPtr d0 = mPatientModelService->createSpecificData<CustomMetric>("Custom%1");
331  d0->get_rMd_History()->setParentSpace("reference");
332  std::vector<DataPtr> args = this->getSpecifiedNumberOfValidArguments(d0->getArguments());
333  d0->getArguments()->set(0, args[0]);
334  d0->getArguments()->set(1, args[1]);
335 
336  this->installNewMetric(d0);
337 }
338 
339 void MetricManager::installNewMetric(DataMetricPtr metric)
340 {
341  DataMetricPtr prevMetric = this->getMetric(mActiveLandmark);
342  if(prevMetric)
343  {
344  metric->setColor(prevMetric->getColor());
345  }
346 
347  mPatientModelService->insertData(metric);
348  this->setActiveUid(metric->getUid());
349  mViewService->getGroup(0)->addData(metric->getUid());
350 }
351 
353 {
354  ToolPtr refTool = mTrackingService->getReferenceTool();
355  if(!refTool) // we only load reference points from reference tools
356  {
357  reportDebug("No reference tool, cannot load reference points into the pointsampler");
358  return;
359  }
360 
361  std::map<int, Vector3D> referencePoints_s = refTool->getReferencePoints();
362  if(referencePoints_s.empty())
363  {
364  reportWarning("No referenceppoints in reference tool "+refTool->getName());
365  return;
366  }
367 
369  CoordinateSystem sensor = mSpaceProvider->getS(refTool);
370 
371  std::map<int, Vector3D>::iterator it = referencePoints_s.begin();
372  for(; it != referencePoints_s.end(); ++it)
373  {
374  Vector3D P_ref = mSpaceProvider->get_toMfrom(sensor, ref).coord(it->second);
375  this->addPoint(P_ref, CoordinateSystem(csREF), "ref%1");
376  }
377 }
378 
380 {
381  OrderedQDomDocument orderedDoc;
382  QDomDocument& doc = orderedDoc.doc();
383  doc.appendChild(doc.createProcessingInstruction("xml version =", "'1.0'"));
384  QDomElement patientNode = doc.createElement("patient");
385  doc.appendChild(patientNode);
386  QDomElement managersNode = doc.createElement("managers");
387  patientNode.appendChild(managersNode);
388  QDomElement datamanagerNode = doc.createElement("datamanager");
389  managersNode.appendChild(datamanagerNode);
390  std::map<QString, DataPtr> dataMap = mPatientModelService->getDatas();
391 
392  std::map<QString, DataPtr>::iterator iter;
393  for (iter = dataMap.begin(); iter != dataMap.end(); ++iter)
394  {
395  DataMetricPtr metric = boost::dynamic_pointer_cast<DataMetric>(iter->second);
396  if(metric)
397  {
398  QDomElement dataNode = doc.createElement("data");
399  metric->addXml(dataNode);
400  datamanagerNode.appendChild(dataNode);
401  }
402  }
403 
404  XmlFileHandler::writeXmlFile(doc, filename);
405 }
406 
407 void MetricManager::resolveUnknownParentSpacesForPointMetrics(QDomNode dataNode, std::map<QString, QString> mapping_of_unknown_to_known_spaces, DataPtr data)
408 {
409  QString uid = data->getUid();
410  PointMetricPtr point_metric = boost::static_pointer_cast<PointMetric>(data);
411  if(!point_metric)
412  return;
413 
414  QString string_space = dataNode.toElement().attribute("space");
415  CoordinateSystem parentSpace = CoordinateSystem::fromString(string_space);
416  bool need_parent = parentSpace.isValid() && (parentSpace.mId == csDATA);
417  bool parent_found = mPatientModelService->getData(parentSpace.mRefObject) != DataPtr();
418  if(need_parent && !parent_found)
419  {
420  if(mapping_of_unknown_to_known_spaces.find(string_space) == mapping_of_unknown_to_known_spaces.end())
421  {
422  SpacePropertyPtr space_property;
423  space_property = SpaceProperty::initialize("selectSpace",
424  "Space",
425  "Select parent coordinate system of metric with uid: "+uid);
426  space_property->setSpaceProvider(mSpaceProvider);
427  QWidget* widget = new QWidget;
428  widget->setFocusPolicy(Qt::StrongFocus); // needed for help system: focus is used to display help text
429  QVBoxLayout *layout = new QVBoxLayout();
430  layout->addWidget(new QLabel("Select parent space for Point metric: "+uid+"."));
431  layout->addWidget(new SpaceEditWidget(widget, space_property));
432  QDialog dialog;
433  dialog.setWindowTitle("Space "+string_space+" does not exist.");
434  dialog.setLayout(layout);
435  QPushButton *okButton = new QPushButton(tr("Ok"));
436  layout->addWidget(okButton);
437  connect(okButton, &QAbstractButton::clicked, &dialog, &QWidget::close);
438  dialog.exec();
439  CX_LOG_DEBUG() << "New space is now: " << space_property->getValue().mId << " " << space_property->getValue().mRefObject;
440  CoordinateSystem new_parentspace = space_property->getValue();
441  mapping_of_unknown_to_known_spaces[string_space] = new_parentspace.toString();
442  }
443  parentSpace = CoordinateSystem::fromString(mapping_of_unknown_to_known_spaces[string_space]);
444  point_metric->setSpace(parentSpace);
445  point_metric->setCoordinate(Vector3D::fromString(dataNode.toElement().attribute("coord")));
446  dataNode.toElement().setAttribute("space", parentSpace.toString());
447  }
448 }
449 
451 {
452  QDomDocument xml = XmlFileHandler::readXmlFile(filename);
453  QDomElement patientNode = xml.documentElement();
454 
455  std::map<DataPtr, QDomNode> datanodes;
456 
457  QDomNode managersNode = patientNode.firstChildElement("managers");
458  QDomNode datamanagerNode = managersNode.firstChildElement("datamanager");
459  QDomNode dataNode = datamanagerNode.firstChildElement("data");
460 
461 
462  std::map<QString, QString> mapping_of_unknown_to_known_spaces;
463 
464  for (; !dataNode.isNull(); dataNode = dataNode.nextSibling())
465  {
466  QDomNamedNodeMap attributes = dataNode.attributes();
467  QDomNode typeAttribute = attributes.namedItem("type");
468  bool isMetric = false;
469  if(typeAttribute.isAttr())
470  {
471  isMetric = typeAttribute.toAttr().value().contains("Metric");
472  }
473 
474  if (dataNode.nodeName() == "data" && isMetric)
475  {
476 
477  QString uid = dataNode.toElement().attribute("uid");
478  if(mPatientModelService->getData(uid))
479  {
480  QString name = dataNode.toElement().attribute("name");
481  reportWarning("Metric: " + name + ", is already in the model with Uid: " + uid + ". Import skipped.");
482  continue;
483  }
484 
485  DataPtr data = this->loadDataFromXMLNode(dataNode.toElement());
486  if (data)
487  datanodes[data] = dataNode.toElement();
488 
489  //If point metrics space is uknown to the system, user needs to select a new parent -> POPUP DIALOG
490  this->resolveUnknownParentSpacesForPointMetrics(dataNode, mapping_of_unknown_to_known_spaces, data);
491  }
492  }
493 
494  // parse xml data separately: we want to first load all data
495  // because there might be interdependencies (cx::DistanceMetric)
496  for (std::map<DataPtr, QDomNode>::iterator iter = datanodes.begin(); iter != datanodes.end(); ++iter)
497  {
498  iter->first->parseXml(iter->second);
499  }
500 }
501 
502 QColor MetricManager::getRandomColor()
503 {
504  QStringList colorNames = QColor::colorNames();
505  int random_int = rand() % colorNames.size();
506  QColor color(colorNames[random_int]);
507  if(color == QColor("black"))
508  color = getRandomColor();
509 
510  return color;
511 }
512 
513 std::vector<QString> MetricManager::dialogForSelectingVolumesForImportedMNITagFile( int number_of_volumes, QString description)
514 {
515  std::vector<QString> data_uid;
516 
517  QDialog selectVolumeDialog;
518  selectVolumeDialog.setWindowTitle("Select volume(s) related to points in MNI Tag Point file.");
519 
520  QVBoxLayout *layout = new QVBoxLayout();
521  QLabel *description_label = new QLabel(description);
522  layout->addWidget(description_label);
523 
524  std::map<int, StringPropertySelectImagePtr> selectedImageProperties;
525  for(int i=0; i < number_of_volumes; ++i)
526  {
527  StringPropertySelectImagePtr image_property = StringPropertySelectImage::New(mPatientModelService);
528  QWidget *widget = createDataWidget(mViewService, mPatientModelService, NULL, image_property);
529  layout->addWidget(widget);
530  selectedImageProperties[i] = image_property;
531  }
532 
533  QPushButton *okButton = new QPushButton(tr("Ok"));
534  layout->addWidget(okButton);
535  connect(okButton, &QAbstractButton::clicked, &selectVolumeDialog, &QWidget::close);
536  selectVolumeDialog.setLayout(layout);
537  selectVolumeDialog.exec();
538  for(int i=0; i < number_of_volumes; ++i)
539  {
540  StringPropertySelectImagePtr image_property = selectedImageProperties[i];
541  data_uid.push_back(image_property->getValue());
542  }
543  return data_uid;
544 }
545 
546 void MetricManager::importMetricsFromMNITagFile(QString &filename, bool testmode)
547 {
548  //--- HACK to be able to read *.tag files with missing newline before eof
549  forceNewlineBeforeEof(filename);
550 
551  //--- Reader for MNI Tag Point files
552  vtkMNITagPointReaderPtr reader = vtkMNITagPointReader::New();
553  reader->SetFileName(filename.toStdString().c_str());
554  reader->Update();
555  if (!ErrorObserver::checkedRead(reader, filename))
556  CX_LOG_ERROR() << "Error reading MNI Tag Point file.";
557 
558 
559  //--- Prompt user to select the volume(s) that is(are) related to the points in the file
560  int number_of_volumes = reader->GetNumberOfVolumes();
561  QString description(reader->GetComments());
562  std::vector<QString> data_uid;
563  data_uid.push_back("");
564  data_uid.push_back("");
565  if(!testmode)
566  data_uid = dialogForSelectingVolumesForImportedMNITagFile(number_of_volumes, description);
567 
568  //--- Create the point metrics
569  QString type = "pointMetric";
570  QString uid = "";
571  QString name = "";
572  vtkStringArray *labels = reader->GetLabelText();
573 
574  for(int i=0; i< number_of_volumes; ++i)
575  {
576  QColor color = getRandomColor();
577 
578  vtkPoints *points = reader->GetPoints(i);
579  if(points != NULL)
580  {
581  unsigned int number_of_points = points->GetNumberOfPoints();
582  //CX_LOG_DEBUG() << "Number of points: " << number_of_points;
583 
584  for(int j=0; j < number_of_points; ++j)
585  {
586  vtkStdString label = labels->GetValue(j);
587  name = QString(*label); //NB: name never used, using j+1 as name to be able to correlate two sets of points from MNI import
588  uid = QDateTime::currentDateTime().toString(timestampMilliSecondsFormat()) + "_" + QString::number(i)+ QString::number(j);
589 
590  double *point = points->GetPoint(j);
591  DataPtr data = this->createData(type, uid, QString::number(j+1));
592  PointMetricPtr point_metric = boost::static_pointer_cast<PointMetric>(data);
593 
594  CoordinateSystem space(csDATA, data_uid[i]);
595  Vector3D vector_ras(point[0], point[1], point[2]);
596  //CX_LOG_DEBUG() << "POINTS: " << vector_ras;
597 
598  //Convert from RAS (MINC) to LPS (CX)
600  Vector3D vector_lps = sMr.inv() * vector_ras;
601 
602  point_metric->setCoordinate(vector_lps);
603  point_metric->setSpace(space);
604  point_metric->setColor(color);
605  }
606  }
607 
608  }
609 }
610 
611 DataPtr MetricManager::loadDataFromXMLNode(QDomElement node)
612 {
613  QString uid = node.toElement().attribute("uid");
614  QString name = node.toElement().attribute("name");
615  QString type = node.toElement().attribute("type");
616 
617  return this->createData(type, uid, name);
618 
619 }
620 
621 DataPtr MetricManager::createData(QString type, QString uid, QString name)
622 {
623  DataPtr data = mPatientModelService->createData(type, uid, name);
624  if (!data)
625  {
626  reportError(QString("Not able to create metric with name: %1, uid: %2, type: %3").arg(name).arg(uid).arg(type));
627  return DataPtr();
628  }
629 
630  if (!name.isEmpty())
631  data->setName(name);
632 
633  mPatientModelService->insertData(data);
634 
635  return data;
636 
637 }
638 
639 
640 } // namespace cx
641 
642 
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
static void writeXmlFile(QDomDocument &doc, QString &filename)
pcsRAS
Right-Anterior-Superior, used by Slicer3D, ITK-Snap, nifti, MINC.
void reportError(QString msg)
Definition: cxLogger.cpp:71
void exportMetricsToXMLFile(QString &filename)
boost::shared_ptr< class DistanceMetric > DistanceMetricPtr
void addXml(QDomNode &dataNode)
adds xml information about the data and its variabels
Composite widget for string selection.
boost::shared_ptr< class FrameMetric > FrameMetricPtr
Definition: cxFrameMetric.h:23
boost::shared_ptr< class ToolMetric > ToolMetricPtr
Definition: cxToolMetric.h:24
boost::shared_ptr< class DonutMetric > DonutMetricPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
boost::shared_ptr< DataMetric > DataMetricPtr
Definition: cxDataMetric.h:73
cxResource_EXPORT Transform3D createTransformFromReferenceToExternal(PATIENT_COORDINATE_SYSTEM external)
boost::shared_ptr< class TrackingService > TrackingServicePtr
QString timestampMilliSecondsFormat()
Definition: cxTime.cpp:22
static SpacePropertyPtr initialize(const QString &uid, QString name, QString help, Space value=Space(), std::vector< Space > range=std::vector< Space >(), QDomNode root=QDomNode())
boost::shared_ptr< class SpaceProperty > SpacePropertyPtr
csREF
the data reference space (r) using LPS (left-posterior-superior) coordinates.
Definition: cxDefinitions.h:88
boost::shared_ptr< class SphereMetric > SphereMetricPtr
DistanceMetricPtr addDistance(QString uid="distance%1")
Data class that represents a single frame (transform).
Definition: cxFrameMetric.h:33
boost::shared_ptr< class ViewService > ViewServicePtr
Data class representing a plane.
Definition: cxPlaneMetric.h:48
static CoordinateSystem reference()
MetricManager(ViewServicePtr viewService, PatientModelServicePtr patientModelService, TrackingServicePtr trackingService, SpaceProviderPtr spaceProvider)
boost::shared_ptr< class AngleMetric > AngleMetricPtr
Definition: cxAngleMetric.h:33
csDATA
a datas space (d)
Definition: cxDefinitions.h:88
QWidget * createDataWidget(ViewServicePtr viewService, PatientModelServicePtr patientModelService, QWidget *parent, PropertyPtr data, QGridLayout *gridLayout, int row)
Create a widget capable of displaying the input data.
COORDINATE_SYSTEM mId
the type of coordinate system
Data class that represents a donut.
boost::shared_ptr< class PlaneMetric > PlaneMetricPtr
Definition: cxPlaneMetric.h:34
boost::shared_ptr< class Data > DataPtr
void setSelection(std::set< QString > selection)
virtual RegistrationHistoryPtr get_rMd_History()
Definition: cxData.cpp:91
void importMetricsFromMNITagFile(QString &filename, bool testmode=false)
Note: testmode is available to skip dialog popup for running automatic tests.
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
#define CX_LOG_ERROR
Definition: cxLogger.h:99
Data class that represents a custom.
Data class that represents a donut.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
boost::shared_ptr< class MetricReferenceArgumentList > MetricReferenceArgumentListPtr
DataMetricPtr getMetric(QString uid)
Transform3D createTransformTranslate(const Vector3D &translation)
Identification of a Coordinate system.
QColor getColor()
Data class that represents a distance between two points, or a point and a plane. ...
boost::shared_ptr< class RegionOfInterestMetric > RegionOfInterestMetricPtr
QString mRefObject
for tool, sensor and data we need a object uid to define the coordinate system
boost::shared_ptr< class StringPropertySelectImage > StringPropertySelectImagePtr
Data class that represents a single point.
Definition: cxPointMetric.h:42
void importMetricsFromXMLFile(QString &filename)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Definition: cxVector3D.h:42
void forceNewlineBeforeEof(QString path)
#define CX_LOG_DEBUG
Definition: cxLogger.h:95
static QDomDocument readXmlFile(QString &filename)
static bool checkedRead(vtkSmartPointer< vtkAlgorithm > reader, QString filename)
PointMetricPtr addPoint(Vector3D point, CoordinateSystem space=CoordinateSystem(csREF), QString uid="point%1", QColor color=QColor(240, 170, 255, 255))
static StringPropertySelectImagePtr New(PatientModelServicePtr patientModelService)
void activeMetricChanged()
void addDistanceButtonClickedSlot()
int getNumberOfMetrics() const
Base class for all Data Metrics.
Definition: cxDataMetric.h:43
boost::shared_ptr< class CustomMetric > CustomMetricPtr
vtkSmartPointer< class vtkMNITagPointReader > vtkMNITagPointReaderPtr
Data class that represents an angle between two lines.
Definition: cxAngleMetric.h:46
void moveToMetric(QString uid)
static CoordinateSystem fromString(QString text)
void reportDebug(QString msg)
Definition: cxLogger.cpp:68
void setActiveUid(QString uid)
Namespace for all CustusX production code.
boost::shared_ptr< class PointMetric > PointMetricPtr
boost::shared_ptr< class Tool > ToolPtr