15 #include <QVBoxLayout> 16 #include <QPushButton> 17 #include <QTableWidget> 18 #include <QTableWidgetItem> 19 #include <QHeaderView> 22 #include <vtkDoubleArray.h> 23 #include <vtkImageData.h> 38 LandmarkRegistrationWidget::LandmarkRegistrationWidget(
RegServicesPtr services, QWidget* parent,
39 QString objectName, QString windowTitle,
bool showAccuracy) :
41 mLandmarkTableWidget(new QTableWidget(this)), mAvarageAccuracyLabel(new QLabel(QString(
" "), this)),
42 mLandmarkListener(new
LandmarkListener(services)), mShowAccuracy(showAccuracy)
57 if (row < 0 || column < 0)
80 Vector3D p_pr = rMpr.inv().coord(p_r);
84 Vector3D offset = tool->get_prMt().vector(
Vector3D(0, 0, tool->getTooltipOffset()));
86 p_r = rMpr.coord(p_pr);
96 QWidget::showEvent(event);
105 mServices->registration()->setLastRegistrationTime(QDateTime::currentDateTime());
112 QWidget::hideEvent(event);
126 DataPtr fixedData = boost::dynamic_pointer_cast<
Data>(
mServices->registration()->getFixedData());
128 fixedName = fixedData->
getName();
136 QStringList headerItems(QStringList() <<
"Name" <<
"Status" <<
"Coordinates");
140 headerItems.append(
"Accuracy (mm)");
149 for (
unsigned i = 0; i < landmarks.size(); ++i)
151 std::vector<QTableWidgetItem*> items(4);
154 Vector3D coord = landmarks[i].getCoord();
155 coord = rMtarget.coord(coord);
158 items[0]->setToolTip(QString(
"Landmark name. Double-click to rename."));
160 items[1] =
new QTableWidgetItem;
163 items[1]->setCheckState(Qt::Checked);
165 items[1]->setCheckState(Qt::Unchecked);
166 items[1]->setToolTip(QString(
"Check to use landmark in current registration."));
168 QString coordText =
"Not sampled";
169 if (targetData.count(prop.
getUid()))
173 coordText = tr(
"(%1, %2, %3)").arg(coord[0], width,
'f', prec).arg(coord[1], width,
'f', prec).arg(
174 coord[2], width,
'f', prec);
177 items[2] =
new QTableWidgetItem(coordText);
178 items[2]->setToolTip(QString(
"Landmark coordinates of target [%1] in reference space.").arg(this->
getTargetName()));
180 items[3] =
new QTableWidgetItem(tr(
"%1").arg(this->
getAccuracy(landmarks[i].getUid())));
181 items[3]->setToolTip(QString(
"Distance from target [%1] to fixed [%2].").arg(this->
getTargetName()).arg(fixedName));
183 for (
unsigned j = 0; j < items.size(); ++j)
213 for (
int i=0; i<lm.size()-1; ++i)
217 return lm[i+1].getUid();
226 std::vector<Landmark> retval;
228 std::map<QString, LandmarkProperty> dataData =
mServices->patient()->getLandmarkProperties();
229 std::map<QString, LandmarkProperty>::iterator iter;
231 for (iter = dataData.begin(); iter != dataData.end(); ++iter)
233 if (targetData.count(iter->first))
234 retval.push_back(targetData[iter->first]);
236 retval.push_back(
Landmark(iter->first));
239 std::sort(retval.begin(), retval.end());
247 QString uid = item->data(Qt::UserRole).toString();
251 QString name = item->text();
252 mServices->patient()->setLandmarkName(uid, name);
256 Qt::CheckState state = item->checkState();
257 mServices->patient()->setLandmarkActive(uid, state == Qt::Checked);
262 QString val = item->text();
264 val = val.replace(
'(',
" ");
265 val = val.replace(
')',
" ");
266 val = val.replace(
',',
" ");
270 Vector3D p_r = Vector3D::fromString(val);
271 Vector3D p_target = rMtarget.inv().coord(p_r);
288 DataPtr fixedData = boost::dynamic_pointer_cast<
Data>(
mServices->registration()->getFixedData());
290 fixedName = fixedData->
getName();
304 bool LandmarkRegistrationWidget::isAverageAccuracyValid()
306 int numActiveLandmarks = 0;
308 if(numActiveLandmarks < 3)
315 int numActiveLandmarks = 0;
321 std::map<QString, LandmarkProperty> props =
mServices->patient()->getLandmarkProperties();
324 numActiveLandmarks = 0;
325 std::map<QString, LandmarkProperty>::iterator it = props.begin();
326 for (; it != props.end(); ++it)
328 if (!it->second.getActive())
330 QString uid = it->first;
335 numActiveLandmarks++;
338 if (numActiveLandmarks == 0)
340 return sum / numActiveLandmarks;
349 Landmark masterLandmark = fixedData->getLandmarks()->getLandmarks()[uid];
351 if (masterLandmark.
getUid().isEmpty() || targetLandmark.
getUid().isEmpty())
359 Vector3D p_target_r = rMtarget.coord(p_target_target);
360 Vector3D p_master_r = rMmaster.coord(p_master_master);
362 return (p_target_r - p_master_r).length();
QString qstring_cast(const T &val)
void landmarkPropertiesChanged()
emitted when global info about a landmark changed
One landmark, or fiducial, coordinate.
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void landmarkAdded(QString uid)
boost::shared_ptr< class Data > DataPtr
virtual QString getName() const
boost::shared_ptr< class RegServices > RegServicesPtr
Transform3D createTransformTranslate(const Vector3D &translation)
Vector3D getCoord() const
void activeLayoutChanged()
emitted when the active layout changes
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Superclass for all data objects.
std::map< QString, class Landmark > LandmarkMap
bool similar(const CameraInfo &lhs, const CameraInfo &rhs, double tol)
void landmarkRemoved(QString uid)
void reportDebug(QString msg)
Namespace for all CustusX production code.
boost::shared_ptr< class Tool > ToolPtr