Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkAlgorithmProfileViewer.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 #include <mapAlgorithmProfileHelper.h>
16 #include <mapConvert.h>
17 
19 {
20  this->setupUi(this);
21 }
22 
23 void QmitkAlgorithmProfileViewer::OnInfoChanged(const map::deployment::DLLInfo *newInfo)
24 {
25  updateInfo(newInfo);
26 }
27 
28 std::string AddInfoTableRow(const std::string &name,
29  const ::map::algorithm::profile::ValueListType &values,
30  const std::string &defaultStr = "")
31 {
32  std::stringstream descriptionString;
33  descriptionString << "<tr><td><b>" << name << ":</b></td><td>";
34 
35  if (!values.empty())
36  {
37  for (::map::algorithm::profile::ValueListType::const_iterator pos = values.begin(); pos != values.end(); ++pos)
38  {
39  if (pos != values.begin())
40  {
41  descriptionString << "<br/>";
42  }
43  descriptionString << *pos;
44  }
45  }
46  else
47  {
48  if (defaultStr.empty())
49  {
50  descriptionString << "<font color='gray'><i>unknown / not defined</i></font>";
51  }
52  else
53  {
54  descriptionString << defaultStr;
55  }
56  }
57 
58  descriptionString << "</td></tr>";
59 
60  return descriptionString.str();
61 }
62 
63 void QmitkAlgorithmProfileViewer::updateInfo(const map::deployment::DLLInfo *newInfo)
64 {
65  if (!newInfo)
66  {
67  this->m_teAlgorithmDetails->clear();
68  }
69  else
70  {
71  std::stringstream descriptionString;
72 
73  ::map::structuredData::Element::Pointer algProfile =
74  ::map::algorithm::profile::parseProfileString(newInfo->getAlgorithmProfileStr());
75  // create description string
76  descriptionString << "<h1>Identification</h1><p><b>Namespace:</b> " << newInfo->getAlgorithmUID().getNamespace()
77  << "<br/>"
78  << "<b>Name:</b> " << newInfo->getAlgorithmUID().getName() << "<br/>"
79  << "<b>Version:</b> " << newInfo->getAlgorithmUID().getVersion() << "<br/>"
80  << "<b>BuildTag:</b> " << newInfo->getAlgorithmUID().getBuildTag() << "<br/>"
81  << "<b>Location:</b> " << newInfo->getLibraryFilePath() << "</p>";
82 
83  descriptionString << "<h1>Description</h1><p>" << ::map::algorithm::profile::getDescription(algProfile) << "</p>";
84  descriptionString << "<h1>Keywords</h1><p>";
85  ::map::algorithm::profile::ValueListType keys = ::map::algorithm::profile::getKeywords(algProfile);
86  for (::map::algorithm::profile::ValueListType::const_iterator keyPos = keys.begin(); keyPos != keys.end(); ++keyPos)
87  {
88  if (keyPos != keys.begin())
89  {
90  descriptionString << "; ";
91  }
92  descriptionString << *keyPos;
93  }
94  descriptionString << "</p>";
95 
96  descriptionString << "<h1>Characteristics</h1><table>";
97  descriptionString << AddInfoTableRow("data type(s)", ::map::algorithm::profile::getDataType(algProfile));
98  descriptionString << AddInfoTableRow("computation style",
99  ::map::algorithm::profile::getComputationStyle(algProfile));
100  if (::map::algorithm::profile::isDeterministic(algProfile))
101  {
102  descriptionString << "<tr><td><b>deterministic:</b></td><td>yes</td></tr>";
103  }
104  else
105  {
106  descriptionString << "<tr><td><b>deterministic:</b></td><td>no</td></tr>";
107  }
108  descriptionString << AddInfoTableRow("resolution style", ::map::algorithm::profile::getResolutionStyle(algProfile));
109 
110  unsigned int dimension;
111 
112  descriptionString << "<tr><td><b>moving dim:</b></td><td>";
113  if (::map::algorithm::profile::getMovingDimensions(algProfile, dimension))
114  {
115  descriptionString << map::core::convert::toStr(dimension) << "D";
116  }
117  else
118  {
119  descriptionString << "<font color='gray'><i>unknown / not defined</i></font>";
120  }
121  descriptionString << "</td></tr>";
122  descriptionString << AddInfoTableRow("moving modality", ::map::algorithm::profile::getMovingModality(algProfile));
123 
124  descriptionString << "<tr><td><b>target dim:</b></td><td>";
125  if (::map::algorithm::profile::getTargetDimensions(algProfile, dimension))
126  {
127  descriptionString << map::core::convert::toStr(dimension) << "D";
128  }
129  else
130  {
131  descriptionString << "<font color='gray'><i>unknown / not defined</i></font>";
132  }
133  descriptionString << "</td></tr>";
134  descriptionString << AddInfoTableRow("target modality", ::map::algorithm::profile::getTargetModality(algProfile));
135 
136  descriptionString << AddInfoTableRow("subject", ::map::algorithm::profile::getSubject(algProfile));
137  descriptionString << AddInfoTableRow("object", ::map::algorithm::profile::getObject(algProfile));
138  descriptionString << AddInfoTableRow("transform model", ::map::algorithm::profile::getTransformModel(algProfile));
139  descriptionString << AddInfoTableRow("transform domain", ::map::algorithm::profile::getTransformDomain(algProfile));
140  descriptionString << AddInfoTableRow("metric", ::map::algorithm::profile::getMetric(algProfile));
141  descriptionString << AddInfoTableRow("optimization", ::map::algorithm::profile::getOptimization(algProfile));
142  descriptionString << AddInfoTableRow("interaction", ::map::algorithm::profile::getInteraction(algProfile));
143  descriptionString << "</table>";
144 
145  descriptionString << "<h1>Contact & Usage</h1><table>";
146  descriptionString << AddInfoTableRow("contact", ::map::algorithm::profile::getContact(algProfile));
147  std::string terms;
148  descriptionString << "<tr><td><b>terms:</b></td><td>";
149  if (::map::algorithm::profile::getTerms(algProfile, terms))
150  {
151  descriptionString << terms;
152  }
153  else
154  {
155  descriptionString << "<font color='gray'><i>unknown / not defined</i></font>";
156  }
157  descriptionString << "</td></tr>";
158  descriptionString << AddInfoTableRow("citation", ::map::algorithm::profile::getCitation(algProfile));
159  descriptionString << "</table>";
160 
161  // update the info label
162  this->m_teAlgorithmDetails->clear();
163  this->m_teAlgorithmDetails->insertHtml(QString::fromStdString(descriptionString.str()));
164  }
165 }
void OnInfoChanged(const map::deployment::DLLInfo *newInfo)
Slot that can be used to trigger updateInfo();.
QmitkAlgorithmProfileViewer(QWidget *parent=nullptr)
void updateInfo(const map::deployment::DLLInfo *newInfo)
Updates the widget according to the new info.
std::string AddInfoTableRow(const std::string &name, const ::map::algorithm::profile::ValueListType &values, const std::string &defaultStr="")