36 #include <QVBoxLayout>
37 #include <QPushButton>
38 #include <QTableWidget>
39 #include <QTableWidgetItem>
40 #include <QHeaderView>
43 #include <vtkDoubleArray.h>
44 #include <vtkImageData.h>
57 LandmarkRegistrationWidget::LandmarkRegistrationWidget(
RegServices services, QWidget* parent,
58 QString objectName, QString windowTitle) :
60 mLandmarkTableWidget(new QTableWidget(this)), mAvarageAccuracyLabel(new QLabel(QString(
" "), this))
76 "<h3>Registration.</h3>"
77 "<p>Interface for registrating.</p>"
84 if (row < 0 || column < 0)
107 Vector3D p_pr = rMpr.inv().coord(p_r);
111 Vector3D offset = tool->get_prMt().vector(
Vector3D(0, 0, tool->getTooltipOffset()));
113 p_r = rMpr.coord(p_pr);
123 QWidget::showEvent(event);
134 QWidget::hideEvent(event);
147 fixedName = fixedData->
getName();
156 QStringList headerItems(QStringList() <<
"Name" <<
"Status" <<
"Coordinates" <<
"Accuracy (mm)");
161 for (
unsigned i = 0; i < landmarks.size(); ++i)
163 std::vector<QTableWidgetItem*> items(4);
167 coord = rMtarget.coord(coord);
170 items[0]->setToolTip(QString(
"Landmark name. Double-click to rename."));
172 items[1] =
new QTableWidgetItem;
175 items[1]->setCheckState(Qt::Checked);
177 items[1]->setCheckState(Qt::Unchecked);
178 items[1]->setToolTip(QString(
"Check to use landmark in current registration."));
180 QString coordText =
"Not sampled";
181 if (targetData.count(prop.
getUid()))
185 coordText = tr(
"(%1, %2, %3)").arg(coord[0], width,
'f', prec).arg(coord[1], width,
'f', prec).arg(
186 coord[2], width,
'f', prec);
189 items[2] =
new QTableWidgetItem(coordText);
190 items[2]->setToolTip(QString(
"Landmark coordinates of target [%1] in reference space.").arg(this->
getTargetName()));
192 items[3] =
new QTableWidgetItem(tr(
"%1").arg(this->
getAccuracy(landmarks[i].getUid())));
193 items[3]->setToolTip(QString(
"Distance from target [%1] to fixed [%2].").arg(this->
getTargetName()).arg(fixedName));
195 for (
unsigned j = 0; j < items.size(); ++j)
225 for (
int i=0; i<lm.size()-1; ++i)
229 return lm[i+1].getUid();
238 std::vector<Landmark> retval;
241 std::map<QString, LandmarkProperty>::iterator iter;
243 for (iter = dataData.begin(); iter != dataData.end(); ++iter)
245 if (targetData.count(iter->first))
246 retval.push_back(targetData[iter->first]);
248 retval.push_back(
Landmark(iter->first));
251 std::sort(retval.begin(), retval.end());
259 QString uid = item->data(Qt::UserRole).toString();
263 QString name = item->text();
268 Qt::CheckState state = item->checkState();
274 QString val = item->text();
276 val = val.replace(
'(',
" ");
277 val = val.replace(
')',
" ");
278 val = val.replace(
',',
" ");
282 Vector3D p_r = Vector3D::fromString(val);
283 Vector3D p_target = rMtarget.inv().coord(p_r);
302 fixedName = fixedData->
getName();
304 if(this->isAverageAccuracyValid())
316 bool LandmarkRegistrationWidget::isAverageAccuracyValid()
318 int numActiveLandmarks = 0;
320 if(numActiveLandmarks < 3)
327 int numActiveLandmarks = 0;
336 numActiveLandmarks = 0;
337 std::map<QString, LandmarkProperty>::iterator it = props.begin();
338 for (; it != props.end(); ++it)
340 if (!it->second.getActive())
342 QString uid = it->first;
347 numActiveLandmarks++;
350 if (numActiveLandmarks == 0)
352 return sum / numActiveLandmarks;
361 Landmark masterLandmark = fixedData->getLandmarks()->getLandmarks()[uid];
363 if (masterLandmark.
getUid().isEmpty() || targetLandmark.
getUid().isEmpty())
371 Vector3D p_target_r = rMtarget.coord(p_target_target);
372 Vector3D p_master_r = rMmaster.coord(p_master_master);
374 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.
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
boost::shared_ptr< class Data > DataPtr
virtual QString getName() const
Transform3D createTransformTranslate(const Vector3D &translation)
Vector3D getCoord() const
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
TrackingServicePtr trackingService
PatientModelServicePtr patientModelService
void reportDebug(QString msg)
RegistrationServicePtr registrationService
boost::shared_ptr< class Tool > ToolPtr