13 #include <QTreeWidget>
14 #include <QTreeWidgetItem>
15 #include <QStringList>
16 #include <QVBoxLayout>
17 #include <QHeaderView>
48 void MetricBase::colorSelected()
55 QString retval = this->
getData()->getValueAsString();
64 "Set color of metric",
65 this->
getData()->getColor(), QDomNode());
66 QHBoxLayout* line =
new QHBoxLayout;
70 layout->addLayout(line);
71 connect(
mColorSelector.get(), SIGNAL(valueWasSet()),
this, SLOT(colorSelected()));
76 QWidget* widget =
new QWidget;
77 widget->setFocusPolicy(Qt::StrongFocus);
78 widget->setObjectName(objectName);
89 mInternalUpdate =
false;
94 mArguments = arguments;
95 connect(mArguments.get(), SIGNAL(argumentsChanged()),
this, SLOT(dataChangedSlot()));
102 mPSelector.resize(mArguments->getCount());
103 for (
unsigned i=0; i<mPSelector.size(); ++i)
106 QString(
"p%1").arg(i),
107 mArguments->getDescription(i),
108 mArguments->get(i) ? mArguments->get(i)->getUid() :
"",
113 connect(mPSelector[i].get(), SIGNAL(valueWasSet()),
this, SLOT(pointSelected()));
116 this->dataChangedSlot();
119 void MetricReferenceArgumentListGui::getAvailableArgumentMetrics(QStringList* uid, std::map<QString,QString>* namemap)
121 std::map<QString, DataPtr> data = mServices->patient()->getDatas();
122 for (std::map<QString, DataPtr>::iterator iter=data.begin(); iter!=data.end(); ++iter)
124 if (mArguments->validArgument(iter->second))
127 (*namemap)[iter->first] = iter->second->getName();
135 for (
unsigned i=0; i<mArguments->getCount(); ++i)
136 data << (mArguments->get(i) ? mArguments->get(i)->getName() : QString(
"*"));
137 return data.join(
"-");
140 void MetricReferenceArgumentListGui::pointSelected()
144 for (
unsigned i=0; i<mPSelector.size(); ++i)
146 DataPtr data = mServices->patient()->getData(mPSelector[i]->getValue());
147 if (mArguments->validArgument(data))
148 mArguments->set(i, data);
150 reportWarning(QString(
"Failed to set data [%1] in metric, invalid argument.").arg(data?data->getName():
"NULL"));
154 void MetricReferenceArgumentListGui::dataChangedSlot()
163 mInternalUpdate =
true;
166 std::map<QString,QString> names;
167 this->getAvailableArgumentMetrics(&range, &names);
169 for (
unsigned i=0; i<mPSelector.size(); ++i)
171 if (!mArguments->get(i))
173 mPSelector[i]->setValue(mArguments->get(i)->getUid());
174 mPSelector[i]->setDisplayNames(names);
175 mPSelector[i]->setValueRange(range);
178 mInternalUpdate =
false;
191 mInternalUpdate =
false;
203 QWidget* widget = this->
newWidget(
"point_metric");
204 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
205 QHBoxLayout* hLayout =
new QHBoxLayout;
206 hLayout->setMargin(0);
207 topLayout->setMargin(0);
208 topLayout->addLayout(hLayout);
210 mSpaceSelector = this->createSpaceSelector();
213 mCoordinate = this->createCoordinateSelector();
216 QWidget* sampleButton = this->createSampleButton(widget);
217 hLayout->addWidget(sampleButton);
220 topLayout->addStretch();
231 "Select coordinate system to store position in.");
232 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(spaceSelected()));
233 retval->setSpaceProvider(
mServices->spaceProvider());
242 "Coordinate values.",
244 DoubleRange(-1000,1000,1),
248 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(coordinateChanged()));
252 QWidget* PointMetricWrapper::createSampleButton(QWidget* parent)
const
254 QAction* sampleAction =
new QAction(
"Sample", parent);
255 QString sampleTip(
"Set the position equal to the current tool tip position.");
256 sampleAction->setStatusTip(sampleTip);
257 sampleAction->setWhatsThis(sampleTip);
258 sampleAction->setToolTip(sampleTip);
259 connect(sampleAction, SIGNAL(triggered()),
this, SLOT(moveToToolPosition()));
262 sampleButton->setDefaultAction(sampleAction);
278 Vector3D p = mData->getCoordinate();
280 if (mData->getSpace().mId==
csREF)
283 return mData->getSpace().toString() +
" " + coord;
286 void PointMetricWrapper::moveToToolPosition()
288 Vector3D p =
mServices->spaceProvider()->getActiveToolTipPoint(mData->getSpace(),
true);
289 mData->setCoordinate(p);
292 void PointMetricWrapper::spaceSelected()
296 CoordinateSystem space = mSpaceSelector->getValue();
297 if (!space.isValid())
299 mData->setSpace(space);
302 void PointMetricWrapper::coordinateChanged()
306 mData->setCoordinate(mCoordinate->getValue());
315 mInternalUpdate =
true;
316 mSpaceSelector->setValue(mData->getSpace());
317 mCoordinate->setValue(mData->getCoordinate());
318 mInternalUpdate =
false;
331 mInternalUpdate =
false;
332 connect(mData.get(), SIGNAL(transformChanged()),
this, SLOT(dataChangedSlot()));
333 connect(mData.get(), SIGNAL(propertiesChanged()),
this, SLOT(dataChangedSlot()));
334 connect(
mServices->patient().get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
339 disconnect(
mServices->patient().get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
344 QWidget* widget = this->
newWidget(
"plane_metric");
345 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
346 QHBoxLayout* hLayout =
new QHBoxLayout;
347 hLayout->setMargin(0);
348 topLayout->setMargin(0);
349 topLayout->addLayout(hLayout);
353 topLayout->addStretch();
355 this->dataChangedSlot();
375 void PlaneMetricWrapper::dataChangedSlot()
378 mInternalUpdate =
false;
396 mInternalUpdate =
false;
397 connect(mData.get(), SIGNAL(transformChanged()),
this, SLOT(dataChangedSlot()));
398 connect(
mServices->patient().get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
403 QWidget* widget = this->
newWidget(
"distance_metric");
404 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
405 QHBoxLayout* hLayout =
new QHBoxLayout;
406 hLayout->setMargin(0);
407 topLayout->setMargin(0);
408 topLayout->addLayout(hLayout);
412 topLayout->addStretch();
414 this->dataChangedSlot();
433 void DistanceMetricWrapper::dataChangedSlot()
436 mInternalUpdate =
false;
455 mInternalUpdate =
false;
456 connect(mData.get(), SIGNAL(transformChanged()),
this, SLOT(dataChangedSlot()));
457 connect(
mServices->patient().get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
462 disconnect(
mServices->patient().get(), SIGNAL(dataAddedOrRemoved()),
this, SLOT(dataChangedSlot()));
467 QWidget* widget = this->
newWidget(
"angle_metric");
468 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
469 QHBoxLayout* hLayout =
new QHBoxLayout;
470 hLayout->setMargin(0);
471 topLayout->setMargin(0);
472 topLayout->addLayout(hLayout);
476 mUseSimpleVisualization = this->createUseSimpleVisualizationSelector();
480 topLayout->addStretch();
482 this->dataChangedSlot();
500 void AngleMetricWrapper::dataChangedSlot()
502 mInternalUpdate =
true;
503 mUseSimpleVisualization->setValue(mData->getUseSimpleVisualization());
504 mInternalUpdate =
false;
507 void AngleMetricWrapper::guiChanged()
511 mData->setUseSimpleVisualization(mUseSimpleVisualization->getValue());
514 BoolPropertyPtr AngleMetricWrapper::createUseSimpleVisualizationSelector()
const
518 "Simple Visualization",
519 mData->getUseSimpleVisualization());
521 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
540 mInternalUpdate =
false;
541 connect(mData.get(), SIGNAL(propertiesChanged()),
this, SLOT(dataChangedSlot()));
546 QWidget* widget = this->
newWidget(
"donut_metric");
547 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
548 QHBoxLayout* hLayout =
new QHBoxLayout;
549 hLayout->setMargin(0);
550 topLayout->setMargin(0);
551 topLayout->addLayout(hLayout);
555 mRadius = this->createRadiusSelector();
557 mThickness = this->createThicknessSelector();
559 mFlat = this->createFlatSelector();
561 mHeight = this->createHeightSelector();
565 topLayout->addStretch();
567 this->dataChangedSlot();
591 mInternalUpdate =
true;
592 mRadius->setValue(mData->getRadius());
593 mThickness->setValue(mData->getThickness());
594 mHeight->setValue(mData->getHeight());
595 mFlat->setValue(mData->getFlat());
596 mInternalUpdate =
false;
599 void DonutMetricWrapper::dataChangedSlot()
610 void DonutMetricWrapper::guiChanged()
614 mInternalUpdate =
true;
615 mData->setRadius(mRadius->getValue());
616 mData->setThickness(mThickness->getValue());
617 mData->setHeight(mHeight->getValue());
618 mData->setFlat(mFlat->getValue());
619 mInternalUpdate =
false;
630 DoubleRange(0, 50, 1),
634 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
644 mData->getThickness(),
645 DoubleRange(0.05, 1, 0.05),
649 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
658 "Disc height, NA to torus",
660 DoubleRange(0.0, 100, 1),
664 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
673 "Flat disk or torus",
677 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
687 mScaleToP1Widget(NULL),
691 mInternalUpdate =
false;
692 connect(mData.get(), SIGNAL(propertiesChanged()),
this, SLOT(dataChangedSlot()));
697 QWidget* widget = this->
newWidget(
"custom_metric");
698 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
699 QHBoxLayout* hLayout =
new QHBoxLayout;
700 hLayout->setMargin(0);
701 topLayout->setMargin(0);
702 topLayout->addLayout(hLayout);
706 mDefineVectorUpMethod = this->createDefineVectorUpMethodSelector();
708 mModel = this->createModelSelector();
711 mOffsetFromP0 = this->createOffsetFromP0();
713 mOffsetFromP1 = this->createOffsetFromP1();
715 mRepeatDistance = this->createRepeatDistance();
718 mShowDistanceMarkers = this->createShowDistanceMarkers();
720 mDistanceMarkerVisibility = this->createDistanceMarkerVisibility();
722 topLayout->addWidget(mDistanceMarkerVisibilityWidget);
724 mScaleToP1 = this->createScaletoP1();
726 topLayout->addWidget(mScaleToP1Widget);
728 mTranslationOnly= this->createTranslationOnly();
731 mTextureFollowTool= this->createTextureFollowTool();
735 topLayout->addStretch();
737 this->dataChangedSlot();
761 mInternalUpdate =
true;
762 mDefineVectorUpMethod->setValue(mData->getDefineVectorUpMethod());
763 mModel->setValue(mData->getModelUid());
764 mInternalUpdate =
false;
768 void CustomMetricWrapper::dataChangedSlot()
779 void CustomMetricWrapper::guiChanged()
785 mScaleToP1Widget->setEnabled(
false);
787 mScaleToP1Widget->setEnabled(
true);
789 if(mShowDistanceMarkers->getValue())
790 mDistanceMarkerVisibilityWidget->setEnabled(
true);
792 mDistanceMarkerVisibilityWidget->setEnabled(
false);
794 mInternalUpdate =
true;
795 mData->setDefineVectorUpMethod(mDefineVectorUpMethod->getValue());
796 mData->setModelUid(mModel->getValue());
797 mData->setOffsetFromP0(mOffsetFromP0->getValue());
798 mData->setOffsetFromP1(mOffsetFromP1->getValue());
799 mData->setRepeatDistance(mRepeatDistance->getValue());
800 mData->setScaleToP1(mScaleToP1->getValue());
801 mData->setShowDistanceMarkers(mShowDistanceMarkers->getValue());
802 mData->setDistanceMarkerVisibility(mDistanceMarkerVisibility->getValue());
803 mData->setTranslationOnly(mTranslationOnly->getValue());
804 mData->setTextureFollowTool(mTextureFollowTool->getValue());
806 mInternalUpdate =
false;
813 "Scale model so that it fits between P0 and P1",
814 mData->getScaleToP1());
815 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
823 "Show distance to P0 for each repeated model",
824 mData->getShowDistanceMarkers());
825 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
833 "Ignore scale and rotate",
834 mData->getTranslationOnly());
835 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
843 "Any texture on the model will move with the tool",
844 mData->getTextureFollowTool());
845 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
853 "Position model an offset from P0 towards P1",
854 mData->getOffsetFromP0(), DoubleRange(-100, 100, 1), 0);
855 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
863 "When scaling to P1, scale to a point offset from P1 towards P0",
864 mData->getOffsetFromP1(), DoubleRange(-100, 100, 1), 0);
865 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
873 "Repeat model with this distance",
874 mData->getRepeatDistance(), DoubleRange(0, 100, 1), 0);
875 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
883 "Hide the markers if the distance to the camera exceeds this threshold",
884 mData->getDistanceMarkerVisibility(), DoubleRange(0, 1000, 1), 0);
885 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
889 StringPropertyPtr CustomMetricWrapper::createDefineVectorUpMethodSelector()
const
893 "Use to define the vector up",
894 "The vector up of the metric will be connected to one of:\n"
895 "- a) The static up vector of the operating table\n"
896 "- b) To a frame in p1, which might well be connected "
897 "to a tool giving a dynamic up vector.\n"
898 "- c) The tool up (tool negative x)",
899 mData->getDefineVectorUpMethod(),
900 mData->getDefineVectorUpMethods().getAvailableDefineVectorUpMethods(),
902 retval->setDisplayNames(mData->getDefineVectorUpMethods().getAvailableDefineVectorUpMethodsDisplayNames());
905 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
913 retval->setOnly2DImagesFilter(
true);
914 retval->setValueName(
"Model");
915 retval->setHelp(
"Model can be mesh or 2D image");
930 mInternalUpdate =
false;
931 connect(mData.get(), SIGNAL(propertiesChanged()),
this, SLOT(dataChangedSlot()));
936 QWidget* widget = this->
newWidget(
"sphere_metric");
937 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
938 QHBoxLayout* hLayout =
new QHBoxLayout;
939 hLayout->setMargin(0);
940 topLayout->setMargin(0);
941 topLayout->addLayout(hLayout);
945 mRadius = this->createRadiusSelector();
949 topLayout->addStretch();
951 this->dataChangedSlot();
969 void SphereMetricWrapper::dataChangedSlot()
977 mInternalUpdate =
true;
978 mRadius->setValue(mData->getRadius());
979 mInternalUpdate =
false;
982 void SphereMetricWrapper::guiChanged()
986 mData->setRadius(mRadius->getValue());
996 DoubleRange(0, 50, 0.5),
1000 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
1012 mInternalUpdate =
false;
1013 connect(mData.get(), SIGNAL(propertiesChanged()),
this, SLOT(dataChangedSlot()));
1018 QWidget* widget = this->
newWidget(
"region_of_interest_metric");
1019 QVBoxLayout* topLayout =
new QVBoxLayout(widget);
1020 QHBoxLayout* hLayout =
new QHBoxLayout;
1021 hLayout->setMargin(0);
1022 topLayout->setMargin(0);
1023 topLayout->addLayout(hLayout);
1025 mDataListProperty = this->createDataListProperty();
1027 topLayout->addWidget(datalistwidget);
1029 mUseActiveTooltipProperty = this->createUseActiveTooltipSelector();
1032 mMaxBoundsDataProperty = this->createMaxBoundsDataSelector();
1035 mMarginProperty = this->createMarginSelector();
1039 topLayout->addStretch();
1041 this->dataChangedSlot();
1059 void RegionOfInterestMetricWrapper::dataChangedSlot()
1068 "Select data to define ROI",
1071 connect(retval.get(), &
Property::changed,
this, &RegionOfInterestMetricWrapper::guiChanged);
1080 "Select data to define maximal extent of ROI",
1084 connect(retval.get(), &
Property::changed,
this, &RegionOfInterestMetricWrapper::guiChanged);
1093 "Margin added outside the data",
1095 DoubleRange(0, 100, 1),
1099 connect(retval.get(), SIGNAL(valueWasSet()),
this, SLOT(guiChanged()));
1103 BoolPropertyPtr RegionOfInterestMetricWrapper::createUseActiveTooltipSelector()
const
1107 "Include tool tip in the roi",
1110 connect(retval.get(), &
Property::changed,
this, &RegionOfInterestMetricWrapper::guiChanged);
1117 mInternalUpdate =
true;
1120 std::map<QString, QString> names;
1121 std::map<QString, DataPtr> alldata =
mServices->patient()->getDatas();
1122 for (std::map<QString, DataPtr>::iterator i=alldata.begin(); i!=alldata.end(); ++i)
1124 if (i->first == mData->getUid())
1127 names[i->first] = i->second->getName();
1130 mDataListProperty->setValue(mData->getDataList());
1131 mDataListProperty->setValueRange(data);
1132 mDataListProperty->setDisplayNames(names);
1134 mMaxBoundsDataProperty->setValue(mData->getMaxBoundsData());
1135 mMaxBoundsDataProperty->setValueRange(data);
1136 mMaxBoundsDataProperty->setDisplayNames(names);
1138 mMarginProperty->setValue(mData->getMargin());
1139 mUseActiveTooltipProperty->setValue(mData->getUseActiveTooltip());
1141 mInternalUpdate =
false;
1144 void RegionOfInterestMetricWrapper::guiChanged()
1146 if (mInternalUpdate)
1148 mData->setDataList(mDataListProperty->getValue());
1149 mData->setUseActiveTooltip(mUseActiveTooltipProperty->getValue());
1150 mData->setMargin(mMarginProperty->getValue());
1151 mData->setMaxBoundsData(mMaxBoundsDataProperty->getValue());