13 #include <QPushButton> 14 #include <QTextStream> 15 #include <QFileDialog> 16 #include <QMessageBox> 35 BaseWidget(parent,
"tool_tip_sample_widget",
"ToolTip Sample"),
37 mSampleButton(new QPushButton(
"Sample")),
38 mSaveToFileNameLabel(new QLabel(
"<font color=red> No file selected </font>")),
39 mSaveFileButton(new QPushButton(
"Save to...")),
42 QVBoxLayout* toplayout =
new QVBoxLayout(
this);
44 this->setToolTip(
"Sample the tool tip position");
53 toplayout->addWidget(
new QLabel(
"<b>Select coordinate system to sample in: </b>"));
54 toplayout->addWidget(mCoordinateSystemComboBox);
55 toplayout->addWidget(mToolComboBox);
56 toplayout->addWidget(mDataComboBox);
58 toplayout->addWidget(mSampleButton);
60 toplayout->addWidget(mSaveFileButton);
61 toplayout->addWidget(mSaveToFileNameLabel);
62 toplayout->addStretch();
64 connect(mSaveFileButton, SIGNAL(clicked()),
this, SLOT(saveFileSlot()));
65 connect(mSampleButton, SIGNAL(clicked()),
this, SLOT(sampleSlot()));
66 connect(mCoordinateSystems.get(), SIGNAL(changed()),
this, SLOT(coordinateSystemChanged()));
69 this->coordinateSystemChanged();
75 void ToolTipSampleWidget::saveFileSlot()
77 QString configPath =
profile()->getPath();
78 if(mServices->patient()->isPatientValid())
79 configPath = mServices->patient()->getActivePatientFolder();
81 QString fileName = QFileDialog::getSaveFileName(
this, tr(
"Save File"),
82 configPath+
"/SampledPoints.txt",
84 if(fileName.isEmpty())
86 else if(QFile::exists(fileName))
89 mSaveToFileNameLabel->setText(fileName);
92 void ToolTipSampleWidget::sampleSlot()
94 QFile samplingFile(mSaveToFileNameLabel->text());
97 Vector3D toolPoint = mServices->spaceProvider()->getActiveToolTipPoint(to,
false);
99 if(!samplingFile.open(QIODevice::WriteOnly | (mTruncateFile ? QIODevice::Truncate : QIODevice::Append)))
108 mTruncateFile =
false;
113 QTextStream streamer(&samplingFile);
114 streamer << sampledPoint;
118 report(
"Sampled point in "+
qstring_cast(to.mId)+
" ("+to.mRefObject+
") space, result: "+sampledPoint);
121 void ToolTipSampleWidget::coordinateSystemChanged()
123 switch (string2enum<COORDINATE_SYSTEM>(mCoordinateSystems->getValue()))
126 mDataComboBox->show();
127 mToolComboBox->hide();
130 mToolComboBox->show();
131 mDataComboBox->hide();
134 mToolComboBox->show();
135 mDataComboBox->hide();
138 mDataComboBox->hide();
139 mToolComboBox->hide();
148 retval.
mId = string2enum<COORDINATE_SYSTEM>(mCoordinateSystems->getValue());
153 retval = mServices->spaceProvider()->getD(mData->getData());
156 retval = mServices->spaceProvider()->getT(mTools->getTool());
159 retval = mServices->spaceProvider()->getT(mTools->getTool());
QString qstring_cast(const T &val)
cxResource_EXPORT ProfilePtr profile()
boost::shared_ptr< class VisServices > VisServicesPtr
csSENSOR
a tools sensor space (s)
static StringPropertySelectDataPtr New(PatientModelServicePtr patientModelService, QString typeRegexp=".*")
static StringPropertySelectCoordinateSystemPtr New(TrackingServicePtr trackingService)
COORDINATE_SYSTEM mId
the type of coordinate system
void reportWarning(QString msg)
Identification of a Coordinate system.
QString mRefObject
for tool, sensor and data we need a object uid to define the coordinate system
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
Namespace for all CustusX production code.