14 #include <QInputDialog>
15 #include <QMessageBox>
34 this->setToolTip(
"Edit ultrasound probe configuration");
36 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
41 topLayout->addWidget(mActiveProbeConfigWidget);
45 "Origin of tool space in the probe image.\nUnits in pixels.",
50 connect(mOrigin.get(), SIGNAL(changed()),
this, SLOT(guiOriginSettingsChanged()));
54 mOriginWidget->
showDim(2,
false);
57 QGroupBox* cropGroupBox =
new QGroupBox(
"Crop Box",
this);
58 cropGroupBox->setToolTip(
"Define cropping box for the probe image.\nUnits in pixels.");
59 QVBoxLayout* cropLayout =
new QVBoxLayout(cropGroupBox);
60 topLayout->addWidget(cropGroupBox);
62 QStringList bbCaptions = QStringList() <<
"X (pixels)" <<
"Y (pixels)";
64 cropLayout->addWidget(mBBWidget);
68 QGroupBox* sectorGroupBox =
new QGroupBox(
"Sector");
69 sectorGroupBox->setToolTip(
"Define probe sector parameters.\nUnits in pixels and degrees.");
70 QVBoxLayout* sectorLayout =
new QVBoxLayout(sectorGroupBox);
71 topLayout->addWidget(sectorGroupBox);
73 sectorLayout->addWidget(mOriginWidget);
76 connect(mDepthWidget, SIGNAL(valueChanged(
double,
double)),
this, SLOT(guiProbeSectorChanged()));
77 sectorLayout->addWidget(mDepthWidget);
81 mWidth->setInternal2Display(180.0/
M_PI);
82 connect(mWidth.get(), SIGNAL(changed()),
this, SLOT(guiProbeSectorChanged()));
86 QHBoxLayout* buttonsLayout =
new QHBoxLayout;
87 topLayout->addLayout(buttonsLayout);
89 mSyncBoxToSector =
new QCheckBox(
"Sync Box to Sector",
this);
90 mSyncBoxToSector->setChecked(
true);
91 mSyncBoxToSector->setToolTip(
""
92 "Synchronize Crop Box to Probe Sector,\n"
93 "changes in the sector will reset the crop box.");
94 connect(mSyncBoxToSector, SIGNAL(toggled(
bool)),
this, SLOT(syncBoxToSectorChanged()));
95 buttonsLayout->addWidget(mSyncBoxToSector);
97 buttonsLayout->addStretch();
99 QIcon(
":/icons/preset_remove.png"),
100 "Delete the current probe config",
"",
101 SLOT(deletePresetSlot()),
105 QIcon(
":/icons/preset_save.png"),
106 "Add the current setting as a probe config",
"",
107 SLOT(savePresetSlot()),
110 topLayout->addStretch();
117 void ProbeConfigWidget::syncBoxToSectorChanged()
122 void ProbeConfigWidget::savePresetSlot()
124 if (!mActiveProbeConfig->getTool())
126 ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
132 QString oldname = probe->getConfigName(probe->getConfigId());
133 if (oldname.isEmpty())
134 oldname = mLastKnownProbeConfigName;
136 QString newName = QString(
"%1 (2)").arg(oldname);
139 newName = QInputDialog::getText(
this,
"Save Config",
140 "Config Name", QLineEdit::Normal,
142 if (!ok || newName.isEmpty())
145 QStringList existingConfigs = probe->getConfigIdList();
149 for (
int i=0; i<existingConfigs.size(); ++i)
151 if (newName==probe->getConfigName(existingConfigs[i]))
153 newUid = existingConfigs[i];
157 if (newUid.isEmpty())
161 newUid.remove(QRegExp(
"(:|\\s|\\(|\\)|,)"));
162 QString root = newUid;
164 while (existingConfigs.contains(newUid))
166 newUid = QString(
"%1_%2").arg(root).arg(i++);
170 probe->saveCurrentConfig(newUid, newName);
173 void ProbeConfigWidget::deletePresetSlot()
175 ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
180 QString message = QString(
"Do you really want to delete configuration\n%1?").arg(probe->getConfigName(probe->getConfigId()));
181 if (QMessageBox::warning(
this,
184 QMessageBox::No | QMessageBox::Yes) != QMessageBox::Yes)
189 probe->removeCurrentConfig();
193 void ProbeConfigWidget::activeProbeConfigurationChangedSlot()
195 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
198 ProbeDefinition data = probe->getProbeDefinition();
201 DoubleBoundingBox3D range(0, data.getSize().width(), 0, data.getSize().height());
202 mBBWidget->
setValue(data.getClipRect_p(), range);
204 mOrigin->setValue(data.getOrigin_p());
206 double sx = data.getSpacing()[0];
207 double sy = data.getSpacing()[1];
209 mDepthWidget->
setValue(data.getDepthStart()/sy, data.getDepthEnd()/sy);
210 mDepthWidget->
setRange(DoubleRange(0, range.range()[1]*1.5, 1));
212 mWidth->setValue(data.getWidth());
216 mWidth->setValueRange(DoubleRange(0, range.range()[0]*1.5*sx, 1.0*sx));
217 mWidth->setInternal2Display(1.0/sx);
221 mWidth->setValueRange(DoubleRange(0,
M_PI,
M_PI/180));
222 mWidth->setInternal2Display(180.0/
M_PI);
225 if (!probe->getConfigId().isEmpty())
227 mLastKnownProbeConfigName = probe->getConfigName(probe->getConfigId());
233 void ProbeConfigWidget::guiProbeSectorChanged()
237 if(!mActiveProbeConfig->getTool())
240 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
243 ProbeDefinition data = probe->getProbeDefinition();
246 double sy = data.getSpacing()[1];
248 data.setSector(mDepthWidget->
getValue().first*sy, mDepthWidget->
getValue().second*sy, mWidth->getValue());
250 if (mSyncBoxToSector->isChecked())
251 data.updateClipRectFromSector();
253 probe->setProbeDefinition(data);
256 void ProbeConfigWidget::guiImageSettingsChanged()
261 if (!mActiveProbeConfig->getTool())
263 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
266 ProbeDefinition data = probe->getProbeDefinition();
268 data.setClipRect_p(mBBWidget->
getValue());
270 probe->setProbeDefinition(data);
273 void ProbeConfigWidget::guiOriginSettingsChanged()
278 if (!mActiveProbeConfig->getTool())
280 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
283 ProbeDefinition data = probe->getProbeDefinition();
286 if (mSyncBoxToSector->isChecked())
289 Vector3D shift = mOrigin->getValue() - data.getOrigin_p();
293 data.setOrigin_p(mOrigin->getValue());
295 probe->setProbeDefinition(data);