35 #include <QInputDialog>
36 #include <QMessageBox>
55 this->setToolTip(
"Edit ultrasound probe configuration");
57 QVBoxLayout* topLayout =
new QVBoxLayout(
this);
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",
this);
79 cropGroupBox->setToolTip(
"Define cropping box for the probe image.\nUnits in pixels.");
80 QVBoxLayout* cropLayout =
new QVBoxLayout(cropGroupBox);
81 topLayout->addWidget(cropGroupBox);
83 QStringList bbCaptions = QStringList() <<
"X (pixels)" <<
"Y (pixels)";
85 cropLayout->addWidget(mBBWidget);
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 void ProbeConfigWidget::savePresetSlot()
145 if (!mActiveProbeConfig->getTool())
147 ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
153 QString oldname = probe->getConfigName(probe->getConfigId());
154 if (oldname.isEmpty())
155 oldname = mLastKnownProbeConfigName;
157 QString newName = QString(
"%1 (2)").arg(oldname);
160 newName = QInputDialog::getText(
this,
"Save Config",
161 "Config Name", QLineEdit::Normal,
163 if (!ok || newName.isEmpty())
166 QStringList existingConfigs = probe->getConfigIdList();
170 for (
int i=0; i<existingConfigs.size(); ++i)
172 if (newName==probe->getConfigName(existingConfigs[i]))
174 newUid = existingConfigs[i];
178 if (newUid.isEmpty())
182 newUid.remove(QRegExp(
"(:|\\s|\\(|\\)|,)"));
183 QString root = newUid;
185 while (existingConfigs.contains(newUid))
187 newUid = QString(
"%1_%2").arg(root).arg(i++);
191 probe->saveCurrentConfig(newUid, newName);
194 void ProbeConfigWidget::deletePresetSlot()
196 ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
201 QString message = QString(
"Do you really want to delete configuration\n%1?").arg(probe->getConfigName(probe->getConfigId()));
202 if (QMessageBox::warning(
this,
205 QMessageBox::No | QMessageBox::Yes) != QMessageBox::Yes)
210 probe->removeCurrentConfig();
214 void ProbeConfigWidget::activeProbeConfigurationChangedSlot()
216 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
219 ProbeDefinition data = probe->getProbeDefinition();
222 DoubleBoundingBox3D range(0, data.getSize().width(), 0, data.getSize().height());
223 mBBWidget->
setValue(data.getClipRect_p(), range);
225 mOrigin->setValue(data.getOrigin_p());
227 double sx = data.getSpacing()[0];
228 double sy = data.getSpacing()[1];
230 mDepthWidget->
setValue(data.getDepthStart()/sy, data.getDepthEnd()/sy);
231 mDepthWidget->
setRange(DoubleRange(0, range.range()[1]*1.5, 1));
233 mWidth->setValue(data.getWidth());
237 mWidth->setValueRange(DoubleRange(0, range.range()[0]*1.5*sx, 1.0*sx));
238 mWidth->setInternal2Display(1.0/sx);
242 mWidth->setValueRange(DoubleRange(0,
M_PI,
M_PI/180));
243 mWidth->setInternal2Display(180.0/
M_PI);
246 if (!probe->getConfigId().isEmpty())
248 mLastKnownProbeConfigName = probe->getConfigName(probe->getConfigId());
254 void ProbeConfigWidget::guiProbeSectorChanged()
258 if(!mActiveProbeConfig->getTool())
261 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
264 ProbeDefinition data = probe->getProbeDefinition();
267 double sy = data.getSpacing()[1];
269 data.setSector(mDepthWidget->
getValue().first*sy, mDepthWidget->
getValue().second*sy, mWidth->getValue());
271 if (mSyncBoxToSector->isChecked())
272 data.updateClipRectFromSector();
274 probe->setProbeDefinition(data);
277 void ProbeConfigWidget::guiImageSettingsChanged()
282 if (!mActiveProbeConfig->getTool())
284 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
287 ProbeDefinition data = probe->getProbeDefinition();
289 data.setClipRect_p(mBBWidget->
getValue());
291 probe->setProbeDefinition(data);
294 void ProbeConfigWidget::guiOriginSettingsChanged()
299 if (!mActiveProbeConfig->getTool())
301 cx::ProbePtr probe = mActiveProbeConfig->getTool()->getProbe();
304 ProbeDefinition data = probe->getProbeDefinition();
307 if (mSyncBoxToSector->isChecked())
310 Vector3D shift = mOrigin->getValue() - data.getOrigin_p();
314 data.setOrigin_p(mOrigin->getValue());
316 probe->setProbeDefinition(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)
void changed()
emit when the underlying data value is changed: The user interface will be updated.
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())