ToolManualCalibrationWidget::ToolManualCalibrationWidget(VisServicesPtr services, QWidget* parent) :
	BaseWidget(parent, "ToolManualCalibrationWidget", "Tool Manual Calibrate"),
	mServices(services)
{
  //layout
  QVBoxLayout* mToptopLayout = new QVBoxLayout(this);
  //toptopLayout->setMargin(0);

  this->setToolTip("Edit tool calibration matrix sMt");
  mTool = StringPropertySelectTool::New(mServices->tracking());
  mToptopLayout->addWidget(sscCreateDataWidget(this, mTool));

  mToptopLayout->addWidget(new QLabel("<font color=red>Caution: sMt is changed directly by this control.</font>"));
  mGroup = new QGroupBox(this);
  mGroup->setTitle("Calibration matrix sMt");
  mToptopLayout->addWidget(mGroup);
  QVBoxLayout* groupLayout = new QVBoxLayout;
  mGroup->setLayout(groupLayout);
  groupLayout->setMargin(0);
  mMatrixWidget = new Transform3DWidget(mGroup);
  groupLayout->addWidget(mMatrixWidget);
  connect(mMatrixWidget, SIGNAL(changed()), this, SLOT(matrixWidgetChanged()));
  connect(mTool.get(), SIGNAL(changed()), this, SLOT(toolCalibrationChanged()));

  this->toolCalibrationChanged();
  mMatrixWidget->setEditable(true);

  mToptopLayout->addStretch();

  connect(mServices->tracking().get(), &TrackingService::stateChanged, this, &ToolManualCalibrationWidget::toolCalibrationChanged);
}
ManualPatientRegistrationWidget::ManualPatientRegistrationWidget(RegServicesPtr services, QWidget* parent, QString objectName) :
				BaseWidget(parent, objectName, "Manual Patient Registration"),
				mVerticalLayout(new QVBoxLayout(this)),
				mServices(services)
{
	this->setToolTip("Set patient registration directly");
	mVerticalLayout->setMargin(0);
	mLabel = new QLabel("Patient Registration matrix rMpr");
	mVerticalLayout->addWidget(mLabel);
	mMatrixWidget = new Transform3DWidget(this);
	mVerticalLayout->addWidget(mMatrixWidget);
	connect(mMatrixWidget, SIGNAL(changed()), this, SLOT(matrixWidgetChanged()));
	connect(services->patient().get(), SIGNAL(rMprChanged()), this, SLOT(patientMatrixChanged()));
	mMatrixWidget->setEditable(true);

	mVerticalLayout->addStretch();

}
ManualImageRegistrationWidget::ManualImageRegistrationWidget(RegServicesPtr services, QWidget* parent, QString objectName, QString windowTitle) :
	BaseWidget(parent, objectName, windowTitle),
	mVerticalLayout(new QVBoxLayout(this)),
	mServices(services)
{
	this->setToolTip("Set image position directly");
	mVerticalLayout->setMargin(0);
	mLabel = new QLabel("Data matrix rMd");
	mVerticalLayout->addWidget(mLabel);
	mMatrixWidget = new Transform3DWidget(this);
	mVerticalLayout->addWidget(mMatrixWidget);
	connect(mMatrixWidget, SIGNAL(changed()), this, SLOT(matrixWidgetChanged()));
	mMatrixWidget->setEditable(true);

	mVerticalLayout->addStretch();

	connect(mServices->registration().get(), SIGNAL(movingDataChanged(QString)), this, SLOT(movingDataChanged()));
}