13 template<
class T,
class SUPER>
14 boost::shared_ptr<T> castTo(boost::shared_ptr<SUPER> data)
16 return boost::dynamic_pointer_cast<T>(data);
19 template<
class T,
class SUPER>
20 bool isType(boost::shared_ptr<SUPER> data)
22 return (castTo<T>(data) ?
true :
false);
24 template<
class WRAPPER,
class METRIC,
class SUPER>
25 boost::shared_ptr<WRAPPER> createMetricWrapperOfType(
cx::VisServicesPtr services, boost::shared_ptr<SUPER> data)
27 return boost::shared_ptr<WRAPPER>(
new WRAPPER(services, castTo<METRIC>(data)));
34 BaseWidget(parent, wrapper->getType()+
"_single_metric_widget", wrapper->getType()+
" Metric Widget"),
36 mValueLabel(valueLabel)
48 QString value =
mWrapper->getValue();
61 if (isType<PointMetric>(data))
62 return createMetricWrapperOfType<PointMetricWrapper, PointMetric>(mServices, data);
63 if (isType<DistanceMetric>(data))
64 return createMetricWrapperOfType<DistanceMetricWrapper, DistanceMetric>(mServices, data);
65 if (isType<AngleMetric>(data))
66 return createMetricWrapperOfType<AngleMetricWrapper, AngleMetric>(mServices, data);
67 if (isType<FrameMetric>(data))
68 return createMetricWrapperOfType<FrameMetricWrapper, FrameMetric>(mServices, data);
69 if (isType<ToolMetric>(data))
70 return createMetricWrapperOfType<ToolMetricWrapper, ToolMetric>(mServices, data);
71 if (isType<PlaneMetric>(data))
72 return createMetricWrapperOfType<PlaneMetricWrapper, PlaneMetric>(mServices, data);
73 if (isType<DonutMetric>(data))
74 return createMetricWrapperOfType<DonutMetricWrapper, DonutMetric>(mServices, data);
75 if (isType<CustomMetric>(data))
76 return createMetricWrapperOfType<CustomMetricWrapper, CustomMetric>(mServices, data);
77 if (isType<SphereMetric>(data))
78 return createMetricWrapperOfType<SphereMetricWrapper, SphereMetric>(mServices, data);
79 if (isType<RegionOfInterestMetric>(data))
80 return createMetricWrapperOfType<RegionOfInterestMetricWrapper, RegionOfInterestMetric>(mServices, data);
90 std::vector<MetricBasePtr> retval;
91 std::map<QString, DataPtr> all = mServices->patient()->getDatas();
92 for (std::map<QString, DataPtr>::iterator iter=all.begin(); iter!=all.end(); ++iter)
97 retval.push_back(wrapper);
107 QWidget* widget = wrapper->createWidget();
110 QString value = wrapper->getValue();
111 QString type = wrapper->getType();
113 QLabel* valueLabel =
new QLabel(value);
116 nameAdapter->setData(data);
121 QGroupBox* groupBox =
new QGroupBox(
"Metric type: "+ type, topWidget);
122 groupBox->setFlat(
true);
123 QVBoxLayout* verticalLayout =
new QVBoxLayout(groupBox);
124 verticalLayout->setMargin(4);
126 QHBoxLayout* valueLayout =
new QHBoxLayout();
127 valueLayout->addWidget(
new QLabel(
"Value: "));
128 valueLayout->addWidget(valueLabel);
131 verticalLayout->addLayout(valueLayout);
132 verticalLayout->addWidget(widget, 1);
134 QHBoxLayout* topLayout =
new QHBoxLayout(topWidget);
135 topLayout->addWidget(groupBox);