17 #define _USE_MATH_DEFINES
21 #include <QMessageBox>
25 #include <QGridLayout>
27 #include <QFileDialog>
33 #pragma GCC visibility push(default)
34 #include <itkEventObject.h>
35 #pragma GCC visibility pop
36 #include <itksys/SystemTools.hxx>
38 struct QFileDialogArgs;
39 class QFileDialogPrivate;
62 this->
m_Controls =
new Ui::QmitkToFRecorderWidgetControls;
72 connect( (QObject*)(
m_Controls->m_PlayButton), SIGNAL(clicked()),(QObject*)
this, SLOT(
OnPlay()) );
73 connect( (QObject*)(
m_Controls->m_StopButton), SIGNAL(clicked()),(QObject*)
this, SLOT(
OnStop()) );
94 m_Controls->m_StartRecordingButton->setChecked(
false);
95 m_Controls->m_RecorderGroupBox->setEnabled(
true);
107 m_Controls->m_RecorderGroupBox->setEnabled(
false);
112 m_Controls->m_StartRecordingButton->setChecked(
false);
113 m_Controls->m_RecorderGroupBox->setEnabled(
true);
130 m_Controls->m_RecorderGroupBox->setEnabled(
true);
162 m_Controls->m_StartRecordingButton->setChecked(
true);
163 m_Controls->m_RecorderGroupBox->setEnabled(
false);
166 int numOfFrames =
m_Controls->m_NumOfFramesSpinBox->value();
170 bool distanceImageSelected =
true;
171 bool amplitudeImageSelected =
false;
172 bool intensityImageSelected =
false;
173 bool rgbImageSelected =
false;
174 bool rawDataSelected =
false;
177 m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty(
"HasAmplitudeImage",amplitudeImageSelected);
178 m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty(
"HasIntensityImage",intensityImageSelected);
179 m_ToFImageGrabber->GetCameraDevice()->GetBoolProperty(
"HasRGBImage",rgbImageSelected);
181 QString tmpFileName(
"");
182 QString selectedFilter(
"");
183 QString imageFileName(
"");
186 distanceImageSelected, amplitudeImageSelected, intensityImageSelected, rgbImageSelected, rawDataSelected,
187 NULL,
"Save Image To...", imageFileName,
"NRRD Images (*.nrrd);;PIC Images - deprecated (*.pic);;Text (*.csv)", &selectedFilter);
189 if (tmpFileName.isEmpty())
195 imageFileName = tmpFileName;
200 std::string dir = itksys::SystemTools::GetFilenamePath( imageFileName.toStdString() );
201 std::string baseFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( imageFileName.toStdString() );
202 std::string extension = itksys::SystemTools::GetFilenameLastExtension( imageFileName.toStdString() );
207 QString integrationTimeStr;
208 integrationTimeStr.setNum(integrationTime);
209 QString modulationFreqStr;
210 modulationFreqStr.setNum(modulationFreq);
211 QString numOfFramesStr(
"");
214 numOfFramesStr.setNum(numOfFrames);
217 std::string distImageFileName =
prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
218 integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension,
"_DistanceImage");
219 MITK_INFO <<
"Save distance data to: " << distImageFileName;
221 std::string amplImageFileName =
prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
222 integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension,
"_AmplitudeImage");
223 MITK_INFO <<
"Save amplitude data to: " << amplImageFileName;
225 std::string intenImageFileName =
prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
226 integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension,
"_IntensityImage");
227 MITK_INFO <<
"Save intensity data to: " << intenImageFileName;
229 std::string rgbImageFileName =
prepareFilename(dir, baseFilename, modulationFreqStr.toStdString(),
230 integrationTimeStr.toStdString(), numOfFramesStr.toStdString(), extension,
"_RGBImage");
231 MITK_INFO <<
"Save intensity data to: " << rgbImageFileName;
233 if (selectedFilter.compare(
"Text (*.csv)") == 0)
237 else if (selectedFilter.compare(
"PIC Images - deprecated (*.pic)") == 0)
242 QMessageBox::warning(NULL,
"Deprecated File Format!",
243 "Please note that *.pic file format is deprecated and not longer supported! The suggested file format for images is *.nrrd!");
245 else if (selectedFilter.compare(
"NRRD Images (*.nrrd)") == 0)
251 QMessageBox::warning(NULL,
"Unsupported file format!",
"Please specify one of the supported file formats *.nrrd, *.csv!");
255 numOfFrames =
m_Controls->m_NumOfFramesSpinBox->value();
276 catch(std::exception& e)
278 QMessageBox::critical(NULL,
"Error", QString(e.what()));
284 bool& distanceImageSelected,
285 bool& amplitudeImageSelected,
286 bool& intensityImageSelected,
287 bool& rgbImageSelected,
288 bool& rawDataSelected,
290 const QString &caption,
292 const QString &filter,
293 QString *selectedFilter,
294 QFileDialog::Options options
297 QString selectedFileName =
"";
298 QComboBox* combo =
new QComboBox;
299 combo->addItem(
"3D");
300 combo->addItem(
"2D + t");
302 QHBoxLayout* checkBoxGroup =
new QHBoxLayout();
304 QCheckBox* distanceImageCheckBox =
new QCheckBox;
305 distanceImageCheckBox->setText(
"Distance image");
306 distanceImageCheckBox->setChecked(distanceImageSelected);
308 QCheckBox* amplitudeImageCheckBox =
new QCheckBox;
309 amplitudeImageCheckBox->setText(
"Amplitude image");
310 amplitudeImageCheckBox->setChecked(amplitudeImageSelected);
311 amplitudeImageCheckBox->setEnabled(amplitudeImageSelected);
312 if(!amplitudeImageSelected)
313 amplitudeImageCheckBox->setToolTip(QString(
"This device does not provide amplitude data."));
315 QCheckBox* intensityImageCheckBox =
new QCheckBox;
316 intensityImageCheckBox->setText(
"Intensity image");
317 intensityImageCheckBox->setChecked(intensityImageSelected);
318 intensityImageCheckBox->setEnabled(intensityImageSelected);
319 if(!intensityImageSelected)
320 intensityImageCheckBox->setToolTip(QString(
"This device does not provide intensity data."));
322 QCheckBox* rgbImageCheckBox =
new QCheckBox;
323 rgbImageCheckBox->setText(
"RGB image");
324 rgbImageCheckBox->setChecked(rgbImageSelected);
325 rgbImageCheckBox->setEnabled(rgbImageSelected);
326 if(!rgbImageSelected)
327 rgbImageCheckBox->setToolTip(QString(
"This device does not provide RGB data."));
329 QCheckBox* rawDataCheckBox =
new QCheckBox;
330 rawDataCheckBox->setText(
"Raw data");
331 rawDataCheckBox->setChecked(
false);
332 rawDataCheckBox->setEnabled(
false);
334 checkBoxGroup->addWidget(distanceImageCheckBox);
335 checkBoxGroup->addWidget(amplitudeImageCheckBox);
336 checkBoxGroup->addWidget(intensityImageCheckBox);
337 checkBoxGroup->addWidget(rgbImageCheckBox);
338 checkBoxGroup->addWidget(rawDataCheckBox);
340 QFileDialog* fileDialog =
new QFileDialog(parent, caption, dir, filter);
342 QLayout* layout = fileDialog->layout();
343 QGridLayout* gridbox = qobject_cast<QGridLayout*>(layout);
347 gridbox->addWidget(
new QLabel(
"ToF-Image type:"));
348 gridbox->addWidget(combo);
349 int lastRow = gridbox->rowCount();
350 gridbox->addLayout(checkBoxGroup, lastRow, 0, 1, -1);
353 fileDialog->setLayout(gridbox);
354 fileDialog->setAcceptMode(QFileDialog::AcceptSave);
358 fileDialog->selectNameFilter(*selectedFilter);
361 if (fileDialog->exec() == QDialog::Accepted)
365 *selectedFilter = fileDialog->selectedNameFilter();
368 if (combo->currentIndex() == 0)
378 distanceImageSelected = distanceImageCheckBox->isChecked();
379 amplitudeImageSelected = amplitudeImageCheckBox->isChecked();
380 intensityImageSelected = intensityImageCheckBox->isChecked();
381 rgbImageSelected = rgbImageCheckBox->isChecked();
382 rawDataSelected = rawDataCheckBox->isChecked();
384 selectedFileName = fileDialog->selectedFiles().value(0);
388 return selectedFileName;
392 std::string baseFilename,
393 std::string modulationFreq,
394 std::string integrationTime,
395 std::string numOfFrames,
396 std::string extension,
397 std::string imageType)
399 std::string filenName(
"");
400 filenName.append(dir);
401 filenName.append(
"/");
402 filenName.append(baseFilename);
403 filenName.append(
"_MF");
404 filenName.append(modulationFreq);
405 filenName.append(
"_IT");
406 filenName.append(integrationTime);
407 filenName.append(
"_");
408 filenName.append(numOfFrames);
409 filenName.append(
"Images");
410 filenName.append(imageType);
411 filenName.append(extension);
420 m_Controls->m_NumOfFramesSpinBox->setEnabled(
true);
425 m_Controls->m_NumOfFramesSpinBox->setEnabled(
false);
Recorder class for ToF images.
Image source providing ToF images. Interface for filters provided in ToFProcessing module...
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.