15 #include <QVBoxLayout> 16 #include <QPushButton> 17 #include <QTableWidget> 18 #include <QTableWidgetItem> 19 #include <QHeaderView> 22 #include <vtkDoubleArray.h> 23 #include <vtkImageData.h> 44 ImageLandmarksWidget::ImageLandmarksWidget(
RegServicesPtr services, QWidget* parent,
45 QString objectName, QString windowTitle,
bool useRegistrationFixedPropertyInsteadOfActiveImage) :
47 mUseRegistrationFixedPropertyInsteadOfActiveImage(useRegistrationFixedPropertyInsteadOfActiveImage),
48 mLandmarksShowAdvancedSettingsString(
"Landmarks/ShowAdvanced")
50 if(mUseRegistrationFixedPropertyInsteadOfActiveImage)
64 mAddLandmarkButton->setToolTip(
"Add landmark");
65 mAddLandmarkButton->setDisabled(
true);
91 QHBoxLayout* landmarkButtonsLayout =
new QHBoxLayout;
92 landmarkButtonsLayout->addWidget(mAddLandmarkButton);
97 QIcon(
":/icons/open_icon_library/system-run-5.png"),
98 "Advanced",
"Toggle advanced options",
100 landmarkButtonsLayout);
103 QHBoxLayout* landmarkAdvancedButtonsLayout =
new QHBoxLayout;
104 landmarkAdvancedButtonsLayout =
new QHBoxLayout;
108 this->showOrHideDetails();
122 if (data && !
mServices->registration()->getFixedData())
123 mServices->registration()->setFixedData(data);
130 bool newShowAdvancedValue = !
settings()->
value(mLandmarksShowAdvancedSettingsString,
"true").toBool();
131 settings()->
setValue(mLandmarksShowAdvancedSettingsString, newShowAdvancedValue);
132 this->showOrHideDetails();
135 void ImageLandmarksWidget::showOrHideDetails()
137 bool showAdvanced =
settings()->
value(mLandmarksShowAdvancedSettingsString).toBool();
146 DataPtr ImageLandmarksWidget::getCurrentData()
const 160 DataPtr image = this->getCurrentData();
164 QString uid =
mServices->patient()->addLandmark();
165 Vector3D pos_r = PickerRep->getPosition();
166 Vector3D pos_d = image->get_rMd().inv().coord(pos_r);
167 image->getLandmarks()->setLandmark(
Landmark(uid, pos_d));
182 DataPtr image = this->getCurrentData();
187 Vector3D pos_r = PickerRep->getPosition();
188 Vector3D pos_d = image->get_rMd().inv().coord(pos_r);
189 image->getLandmarks()->setLandmark(
Landmark(uid, pos_d));
196 DataPtr image = this->getCurrentData();
207 DataPtr image = this->getCurrentData();
211 image->getLandmarks()->clear();
218 DataPtr image = this->getCurrentData();
222 std::map<QString, DataPtr> point_metrics =
mServices->patient()->getChildren(image->getUid(),
"pointMetric");
223 std::map<QString, DataPtr>::iterator it = point_metrics.begin();
226 int number_of_landmarks =
mServices->patient()->getLandmarkProperties().size();
227 int number_of_metrics = point_metrics.size();
228 for(
int i=number_of_landmarks; i<number_of_metrics; ++i)
230 QString uid =
mServices->patient()->addLandmark();
233 for(; it != point_metrics.end(); ++it)
242 QString point_metric_name = point_metric->getName();
243 image->getLandmarks()->setLandmark(
Landmark(point_metric_name, pos_x));
257 bool loaded = this->getCurrentData() != 0;
265 DataPtr image = this->getCurrentData();
268 mAddLandmarkButton->setToolTip(QString(
"Add landmark to image %1").arg(image->getName()));
269 mEditLandmarkButton->setToolTip(QString(
"Resample landmark in image %1").arg(image->getName()));
278 if(!mUseRegistrationFixedPropertyInsteadOfActiveImage)
303 this->showOrHideDetails();
308 DataPtr image = this->getCurrentData();
312 return image->getLandmarks()->getLandmarks();
320 DataPtr image = this->getCurrentData();
322 return Transform3D::Identity();
323 return image->get_rMd();
328 DataPtr image = this->getCurrentData();
331 image->getLandmarks()->setLandmark(
Landmark(uid, p_target));
336 DataPtr image = this->getCurrentData();
339 return image->getName();
void reportError(QString msg)
One landmark, or fiducial, coordinate.
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
static StringPropertySelectDataPtr New(PatientModelServicePtr patientModelService, QString typeRegexp=".*")
boost::shared_ptr< class Image > ImagePtr
boost::shared_ptr< class ActiveData > ActiveDataPtr
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
void setValue(const QString &key, const QVariant &value)
boost::shared_ptr< class Data > DataPtr
boost::shared_ptr< class PickerRep > PickerRepPtr
Picking of points in an image.
Vector3D getCoordinate() const
boost::shared_ptr< class RegServices > RegServicesPtr
Settings * settings()
Shortcut for accessing the settings instance.
void changed()
emit when the underlying data value is changed: The user interface will be updated.
Data class that represents a single point.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
std::map< QString, class Landmark > LandmarkMap
Namespace for all CustusX production code.
boost::shared_ptr< class PointMetric > PointMetricPtr