Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
19 #include <mapAlgorithmProfileHelper.h>
20 #include <mapConvert.h>
21 
23 {
24  this->setupUi(this);
25 }
26 
27 void QmitkAlgorithmProfileViewer::OnInfoChanged(const map::deployment::DLLInfo *newInfo)
28 {
29  updateInfo(newInfo);
30 }
31 
32 std::string AddInfoTableRow(const std::string &name,
33  const ::map::algorithm::profile::ValueListType &values,
34  const std::string &defaultStr = "")
35 {
36  std::stringstream descriptionString;
37  descriptionString << "<tr><td><b>" << name << ":</b></td><td>";
38 
39  if (!values.empty())
40  {
41  for (::map::algorithm::profile::ValueListType::const_iterator pos = values.begin(); pos != values.end(); ++pos)
42  {
43  if (pos != values.begin())
44  {
45  descriptionString << "<br/>";
46  }
47  descriptionString << *pos;
48  }
49  }
50  else
51  {
52  if (defaultStr.empty())
53  {
54  descriptionString << "<font color='gray'><i>unknown / not defined</i></font>";
55  }
56  else
57  {
58  descriptionString << defaultStr;
59  }
60  }
61 
62  descriptionString << "</td></tr>";
63 
64  return descriptionString.str();
65 }
66 
67 void QmitkAlgorithmProfileViewer::updateInfo(const map::deployment::DLLInfo *newInfo)
68 {
69  if (!newInfo)
70  {
71  this->m_teAlgorithmDetails->clear();
72  }
73  else
74  {
75  std::stringstream descriptionString;
76 
78  ::map::algorithm::profile::parseProfileString(newInfo->getAlgorithmProfileStr());
79  // create description string
80  descriptionString << "<h1>Identification</h1><p><b>Namespace:</b> " << newInfo->getAlgorithmUID().getNamespace()
81  << "<br/>"
82  << "<b>Name:</b> " << newInfo->getAlgorithmUID().getName() << "<br/>"
83  << "<b>Version:</b> " << newInfo->getAlgorithmUID().getVersion() << "<br/>"
84  << "<b>BuildTag:</b> " << newInfo->getAlgorithmUID().getBuildTag() << "<br/>"
85  << "<b>Location:</b> " << newInfo->getLibraryFilePath() << "</p>";
86 
87  descriptionString << "<h1>Description</h1><p>" << ::map::algorithm::profile::getDescription(algProfile) << "</p>";
88  descriptionString << "<h1>Keywords</h1><p>";
89  ::map::algorithm::profile::ValueListType keys = ::map::algorithm::profile::getKeywords(algProfile);
90  for (::map::algorithm::profile::ValueListType::const_iterator keyPos = keys.begin(); keyPos != keys.end(); ++keyPos)
91  {
92  if (keyPos != keys.begin())
93  {
94  descriptionString << "; ";
95  }
96  descriptionString << *keyPos;
97  }
98  descriptionString << "</p>";
99 
100  descriptionString << "<h1>Characteristics</h1><table>";
101  descriptionString << AddInfoTableRow("data type(s)", ::map::algorithm::profile::getDataType(algProfile));
102  descriptionString << AddInfoTableRow("computation style",
103  ::map::algorithm::profile::getComputationStyle(algProfile));
104  if (::map::algorithm::profile::isDeterministic(algProfile))
105  {
106  descriptionString << "<tr><td><b>deterministic:</b></td><td>yes</td></tr>";
107  }
108  else
109  {
110  descriptionString << "<tr><td><b>deterministic:</b></td><td>no</td></tr>";
111  }
112  descriptionString << AddInfoTableRow("resolution style", ::map::algorithm::profile::getResolutionStyle(algProfile));
113 
114  unsigned int dimension;
115 
116  descriptionString << "<tr><td><b>moving dim:</b></td><td>";
117  if (::map::algorithm::profile::getMovingDimensions(algProfile, dimension))
118  {
119  descriptionString << map::core::convert::toStr(dimension) << "D";
120  }
121  else
122  {
123  descriptionString << "<font color='gray'><i>unknown / not defined</i></font>";
124  }
125  descriptionString << "</td></tr>";
126  descriptionString << AddInfoTableRow("moving modality", ::map::algorithm::profile::getMovingModality(algProfile));
127 
128  descriptionString << "<tr><td><b>target dim:</b></td><td>";
129  if (::map::algorithm::profile::getTargetDimensions(algProfile, dimension))
130  {
131  descriptionString << map::core::convert::toStr(dimension) << "D";
132  }
133  else
134  {
135  descriptionString << "<font color='gray'><i>unknown / not defined</i></font>";
136  }
137  descriptionString << "</td></tr>";
138  descriptionString << AddInfoTableRow("target modality", ::map::algorithm::profile::getTargetModality(algProfile));
139 
140  descriptionString << AddInfoTableRow("subject", ::map::algorithm::profile::getSubject(algProfile));
141  descriptionString << AddInfoTableRow("object", ::map::algorithm::profile::getObject(algProfile));
142  descriptionString << AddInfoTableRow("transform model", ::map::algorithm::profile::getTransformModel(algProfile));
143  descriptionString << AddInfoTableRow("transform domain", ::map::algorithm::profile::getTransformDomain(algProfile));
144  descriptionString << AddInfoTableRow("metric", ::map::algorithm::profile::getMetric(algProfile));
145  descriptionString << AddInfoTableRow("optimization", ::map::algorithm::profile::getOptimization(algProfile));
146  descriptionString << AddInfoTableRow("interaction", ::map::algorithm::profile::getInteraction(algProfile));
147  descriptionString << "</table>";
148 
149  descriptionString << "<h1>Contact & Usage</h1><table>";
150  descriptionString << AddInfoTableRow("contact", ::map::algorithm::profile::getContact(algProfile));
151  std::string terms;
152  descriptionString << "<tr><td><b>terms:</b></td><td>";
153  if (::map::algorithm::profile::getTerms(algProfile, terms))
154  {
155  descriptionString << terms;
156  }
157  else
158  {
159  descriptionString << "<font color='gray'><i>unknown / not defined</i></font>";
160  }
161  descriptionString << "</td></tr>";
162  descriptionString << AddInfoTableRow("citation", ::map::algorithm::profile::getCitation(algProfile));
163  descriptionString << "</table>";
164 
165  // update the info label
166  this->m_teAlgorithmDetails->clear();
167  this->m_teAlgorithmDetails->insertHtml(QString::fromStdString(descriptionString.str()));
168  }
169 }
void OnInfoChanged(const map::deployment::DLLInfo *newInfo)
Slot that can be used to trigger updateInfo();.
itk::SmartPointer< Self > Pointer
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="")