14 #include <vtkImageData.h>
30 BaseWidget(parent,
"sampler_widget",
"Point Sampler"),
31 mPatientModelService(patientModelService),
32 mSpaceProvider(spaceProvider)
34 this->setToolTip(
"Display current tool tip position");
35 mListener = spaceProvider->createListener();
38 connect(mListener.get(), SIGNAL(changed()),
this, SLOT(
setModified()));
41 connect(mActiveTool.get(), SIGNAL(activeToolChanged(
const QString&)),
this, SLOT(
setModified()));
45 mLayout =
new QHBoxLayout(
this);
46 mLayout->setMargin(4);
47 mLayout->setSpacing(4);
50 QIcon(
":/icons/open_icon_library/system-run-5.png"),
52 "Show Advanced options",
53 SLOT(toggleAdvancedSlot()),
57 mAdvancedWidget =
new QWidget(
this);
58 mAdvancedLayout =
new QHBoxLayout(mAdvancedWidget);
59 mAdvancedLayout->setMargin(0);
60 mLayout->addWidget(mAdvancedWidget);
64 "Select coordinate system to store position in.");
65 mSpaceSelector->setSpaceProvider(spaceProvider);
70 mSpaceSelector->setValue(space);
73 mAdvancedLayout->addWidget(spaceSelectorWidget);
74 this->spacesChangedSlot();
76 mCoordLineEdit =
new QLineEdit(
this);
77 mCoordLineEdit->setStyleSheet(
"QLineEdit { width : 30ex; }");
78 mCoordLineEdit->setSizePolicy(QSizePolicy::Fixed,
79 mCoordLineEdit->sizePolicy().verticalPolicy());
80 mCoordLineEdit->setReadOnly(
true);
81 mLayout->addWidget(mCoordLineEdit);
90 void SamplerWidget::toggleAdvancedSlot()
93 mAdvancedWidget->setVisible(!mAdvancedWidget->isVisible());
97 void SamplerWidget::showAdvanced()
100 mAdvancedWidget->setVisible(on);
103 void SamplerWidget::spacesChangedSlot()
105 CoordinateSystem space = mSpaceSelector->getValue();
110 mListener->setSpace(space);
116 Vector3D p = mSpaceProvider->getActiveToolTipPoint(space,
true);
118 QString coord = QString(
"%1, %2, %3").arg(p[0], w,
'f', 1).arg(p[1], w,
'f', 1).arg(p[2], w,
'f', 1);
120 ActiveDataPtr activeData = mPatientModelService->getActiveData();
127 Eigen::Vector3i(image->getBaseVtkImageData()->GetDimensions())-Eigen::Vector3i(1,1,1));
130 double val = image->getBaseVtkImageData()->GetScalarComponentAsFloat(p[0], p[1], p[2], 0);
132 coord += QString(
" I=%1").arg(intVal);
136 mCoordLineEdit->setText(coord);
137 mCoordLineEdit->setStatusTip(QString(
"Position of active tool tip in %1 space\n"
138 "and the intensity of the active volume in that position").arg(space.
toString()));
139 mCoordLineEdit->setToolTip(mCoordLineEdit->statusTip());