35 #include <QInputDialog>
36 #include <QMessageBox>
55 this->setToolTip(this->defaultWhatsThis());
57 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
60 connect(mActiveProbeConfig.get(), SIGNAL(changed()),
this, SLOT(activeProbeConfigurationChangedSlot()));
62 topLayout->addWidget(mActiveProbeConfigWidget);
66 "Origin of tool space in the probe image.\nUnits in pixels.",
71 connect(mOrigin.get(), SIGNAL(changed()),
this, SLOT(guiOriginSettingsChanged()));
75 mOriginWidget->showDim(2,
false);
78 QGroupBox* cropGroupBox =
new QGroupBox(
"Crop Box");
79 cropGroupBox->setToolTip(
"Define cropping box for the probe image.\nUnits in pixels.");
80 QVBoxLayout* cropLayout =
new QVBoxLayout(cropGroupBox);
81 topLayout->addWidget(cropGroupBox);
85 cropLayout->addWidget(mBBWidget);
86 connect(mBBWidget, SIGNAL(changed()),
this, SLOT(guiImageSettingsChanged()));
89 QGroupBox* sectorGroupBox =
new QGroupBox(
"Sector");
90 sectorGroupBox->setToolTip(
"Define probe sector parameters.\nUnits in pixels and degrees.");
91 QVBoxLayout* sectorLayout =
new QVBoxLayout(sectorGroupBox);
92 topLayout->addWidget(sectorGroupBox);
94 sectorLayout->addWidget(mOriginWidget);
97 connect(mDepthWidget, SIGNAL(valueChanged(
double,
double)),
this, SLOT(guiProbeSectorChanged()));
98 sectorLayout->addWidget(mDepthWidget);
102 mWidth->setInternal2Display(180.0/
M_PI);
103 connect(mWidth.get(), SIGNAL(changed()),
this, SLOT(guiProbeSectorChanged()));
107 QHBoxLayout* buttonsLayout =
new QHBoxLayout;
108 topLayout->addLayout(buttonsLayout);
110 mSyncBoxToSector =
new QCheckBox(
"Sync Box to Sector",
this);
111 mSyncBoxToSector->setChecked(
true);
112 mSyncBoxToSector->setToolTip(
""
113 "Synchronize Crop Box to Probe Sector,\n"
114 "changes in the sector will reset the crop box.");
115 connect(mSyncBoxToSector, SIGNAL(toggled(
bool)),
this, SLOT(syncBoxToSectorChanged()));
116 buttonsLayout->addWidget(mSyncBoxToSector);
118 buttonsLayout->addStretch();
120 QIcon(
":/icons/preset_remove.png"),
121 "Delete the current probe config",
"",
122 SLOT(deletePresetSlot()),
126 QIcon(
":/icons/preset_save.png"),
127 "Add the current setting as a probe config",
"",
128 SLOT(savePresetSlot()),
131 topLayout->addStretch();
138 void ProbeConfigWidget::syncBoxToSectorChanged()
143 QString ProbeConfigWidget::defaultWhatsThis()
const
146 "<h3>Probe Configuration</h3>"
148 "View and edit the probe configuration. "
149 "Use the origin to define the position of the probe image in relation "
150 "to the tool t space. Set the cropping box and the probe sector parameters "
151 "(depth and width). All can be written back to the ProbeCalibConfigs.xml file."
156 void ProbeConfigWidget::savePresetSlot()
158 if (!mActiveProbeConfig->getTool())
160 ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
166 QString oldname = probe->getConfigName(probe->getConfigId());
167 if (oldname.isEmpty())
168 oldname = mLastKnownProbeConfigName;
170 QString newName = QString(
"%1 (2)").arg(oldname);
173 newName = QInputDialog::getText(
this,
"Save Config",
174 "Config Name", QLineEdit::Normal,
176 if (!ok || newName.isEmpty())
179 QStringList existingConfigs = probe->getConfigIdList();
183 for (
int i=0; i<existingConfigs.size(); ++i)
185 if (newName==probe->getConfigName(existingConfigs[i]))
187 newUid = existingConfigs[i];
191 if (newUid.isEmpty())
195 newUid.remove(QRegExp(
"(:|\\s|\\(|\\)|,)"));
196 QString root = newUid;
198 while (existingConfigs.contains(newUid))
200 newUid = QString(
"%1_%2").arg(root).arg(i++);
204 probe->saveCurrentConfig(newUid, newName);
207 void ProbeConfigWidget::deletePresetSlot()
209 ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
214 QString message = QString(
"Do you really want to delete configuration\n%1?").arg(probe->getConfigName(probe->getConfigId()));
215 if (QMessageBox::warning(
this,
218 QMessageBox::No | QMessageBox::Yes) != QMessageBox::Yes)
223 probe->removeCurrentConfig();
227 void ProbeConfigWidget::activeProbeConfigurationChangedSlot()
229 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
232 ProbeDefinition data = probe->getProbeData();
235 DoubleBoundingBox3D range(0, data.getSize().width(), 0, data.getSize().height());
236 mBBWidget->
setValue(data.getClipRect_p(), range);
238 mOrigin->setValue(data.getOrigin_p());
240 double sx = data.getSpacing()[0];
241 double sy = data.getSpacing()[1];
243 mDepthWidget->
setValue(data.getDepthStart()/sy, data.getDepthEnd()/sy);
244 mDepthWidget->
setRange(DoubleRange(0, range.range()[1]*1.5, 1));
246 mWidth->setValue(data.getWidth());
250 mWidth->setValueRange(DoubleRange(0, range.range()[0]*1.5*sx, 1.0*sx));
251 mWidth->setInternal2Display(1.0/sx);
255 mWidth->setValueRange(DoubleRange(0,
M_PI,
M_PI/180));
256 mWidth->setInternal2Display(180.0/
M_PI);
259 if (!probe->getConfigId().isEmpty())
261 mLastKnownProbeConfigName = probe->getConfigName(probe->getConfigId());
267 void ProbeConfigWidget::guiProbeSectorChanged()
271 if(!mActiveProbeConfig->getTool())
274 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
277 ProbeDefinition data = probe->getProbeData();
280 double sy = data.getSpacing()[1];
282 data.setSector(mDepthWidget->
getValue().first*sy, mDepthWidget->
getValue().second*sy, mWidth->getValue());
284 if (mSyncBoxToSector->isChecked())
285 data.updateClipRectFromSector();
287 probe->setProbeSector(data);
290 void ProbeConfigWidget::guiImageSettingsChanged()
295 if (!mActiveProbeConfig->getTool())
297 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
300 ProbeDefinition data = probe->getProbeData();
302 data.setClipRect_p(mBBWidget->
getValue());
304 probe->setProbeSector(data);
307 void ProbeConfigWidget::guiOriginSettingsChanged()
312 if (!mActiveProbeConfig->getTool())
314 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
317 ProbeDefinition data = probe->getProbeData();
320 if (mSyncBoxToSector->isChecked())
323 Vector3D shift = mOrigin->getValue() - data.getOrigin_p();
327 data.setOrigin_p(mOrigin->getValue());
329 probe->setProbeSector(data);
DoubleBoundingBox3D transform(const Transform3D &m, const DoubleBoundingBox3D &bb)
boost::shared_ptr< class VisServices > VisServicesPtr
boost::shared_ptr< class TrackingService > TrackingServicePtr
US beam is emitted straight forward.
Utility class for describing a bounded numeric range.
static StringPropertyActiveProbeConfigurationPtr New(TrackingServicePtr trackingService)
boost::shared_ptr< Probe > ProbePtr
US beam is emitted radially in a flat cone.
static Vector3DPropertyPtr initialize(const QString &uid, QString name, QString help, Vector3D value, DoubleRange range, int decimals, QDomNode root=QDomNode())
Transform3D createTransformTranslate(const Vector3D &translation)
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
boost::shared_ptr< class DoublePairProperty > DoublePairPropertyPtr
static DoublePropertyPtr initialize(const QString &uid, QString name, QString help, double value, DoubleRange range, int decimals, QDomNode root=QDomNode())
static DoublePairPropertyPtr initialize(const QString &uid, QString name, QString help, DoubleRange range, int decimals, QDomNode root=QDomNode())