diff --git a/Plugins/org.mitk.gui.qt.tofutil/plugin.xml b/Plugins/org.mitk.gui.qt.tofutil/plugin.xml index ca85e6fa7e..9590369a78 100644 --- a/Plugins/org.mitk.gui.qt.tofutil/plugin.xml +++ b/Plugins/org.mitk.gui.qt.tofutil/plugin.xml @@ -1,20 +1,20 @@ diff --git a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.cpp b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.cpp index 8917f1580d..cc849b72e4 100644 --- a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.cpp +++ b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.cpp @@ -1,163 +1,149 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ // Qmitk #include "QmitkToFScreenshotMaker.h" // Qt #include #include #include #include #include #include #include const std::string QmitkToFScreenshotMaker::VIEW_ID = "org.mitk.views.tofscreenshotmaker"; QmitkToFScreenshotMaker::QmitkToFScreenshotMaker() : QmitkAbstractView(), m_SavingCounter(0) { -// m_ToFImageGrabber = mitk::ToFImageGrabber::New(); } QmitkToFScreenshotMaker::~QmitkToFScreenshotMaker() { } void QmitkToFScreenshotMaker::SetFocus() { } void QmitkToFScreenshotMaker::CreateQtPartControl( QWidget *parent ) { // create GUI widgets from the Qt Designer's .ui file m_Controls.setupUi( parent ); connect( (QObject*)(m_Controls.m_MakeScreenshot), SIGNAL(clicked()), this, SLOT(OnMakeScreenshotClicked()) ); connect( m_Controls.m_ConnectedDeviceServiceListWidget, SIGNAL(ServiceSelectionChanged(us::ServiceReferenceU)), this, SLOT(OnSelectCamera())); std::string filter = ""; // std::string filter = "(&(IsActive=true))"; m_Controls.m_ConnectedDeviceServiceListWidget->Initialize("ToFImageSourceName", filter); std::string defaultPath = "/tmp/"; #ifdef _WIN32 - defaultPath = "C:\tmp\"; + defaultPath = "C:/tmp/"; #endif m_Controls.m_PathToSaveFiles->setText(defaultPath.c_str()); } void QmitkToFScreenshotMaker::OnSelectCamera() { - //Update gui accordingly + //Update gui according to device properties mitk::ToFImageGrabber* source = static_cast(m_Controls.m_ConnectedDeviceServiceListWidget->GetSelectedService()); mitk::ToFCameraDevice* device = source->GetCameraDevice(); -// m_Controls.m_MakeScreenshot->setEnabled(device->IsCameraActive()); - - //usually you want to save depth data - m_Controls.m_SaveDepth->setChecked(true); - m_Controls.m_SaveDepth->setEnabled(true); - - //If the device provides an amplitude (or infrared) image, we propably want to save it - bool amplitude = false; - device->GetBoolProperty("HasAmplitudeImage", amplitude); - m_Controls.m_SaveAmplitude->setChecked(amplitude); - m_Controls.m_SaveAmplitude->setEnabled(amplitude); - //If the device provides an intensity image, we propably want to save it - bool intensity = false; - device->GetBoolProperty("HasIntensityImage", intensity); - m_Controls.m_SaveIntensity->setChecked(intensity); - m_Controls.m_SaveIntensity->setEnabled(intensity); - - //If the device provides an RGB image, we propably want to save it - bool color = false; - device->GetBoolProperty("HasRGBImage", color); - m_Controls.m_SaveColor->setChecked(color); - m_Controls.m_SaveColor->setEnabled(color); - - //If the device provides Raw image, we propably want to save it - bool raw = false; - device->GetBoolProperty("HasRawImage", raw); - m_Controls.m_SaveRaw->setChecked(raw); - m_Controls.m_SaveRaw->setEnabled(raw); + m_Controls.m_MakeScreenshot->setEnabled(device->IsCameraActive()); //todo: where do i get correct file extensions? mitk::ImageWriter::Pointer imageWriter = mitk::ImageWriter::New(); std::vector fileExtensions = imageWriter->GetPossibleFileExtensions(); QStringList extensions; for( unsigned int i = 0; i < fileExtensions.size(); ++i) { extensions.append(QString(fileExtensions.at(i).c_str())); } - this->UpdateFileExtensionComboBox(true, m_Controls.m_DepthFormat, extensions, ".nrrd"); //usually you want to save depth data - this->UpdateFileExtensionComboBox(amplitude, m_Controls.m_AmplitudeFormat, extensions, ".nrrd"); - this->UpdateFileExtensionComboBox(intensity, m_Controls.m_IntensityFormat, extensions, ".nrrd"); - this->UpdateFileExtensionComboBox(color, m_Controls.m_ColorFormat, extensions, ".png"); //png is nice default for calibration - this->UpdateFileExtensionComboBox(raw, m_Controls.m_RawFormat, extensions, ".nrrd"); + this->UpdateGUIElements(device, "no depth property available", m_Controls.m_SaveDepth, m_Controls.m_DepthFormat, extensions, ".nrrd"); + //usually you want to save depth data, but there is no "HasDepthImage" property, because every depth + //camera should provide a depth iamge + m_Controls.m_SaveDepth->setChecked(true); + m_Controls.m_SaveDepth->setEnabled(true); + m_Controls.m_DepthFormat->setEnabled(true); + + this->UpdateGUIElements(device, "HasAmplitudeImage", m_Controls.m_SaveAmplitude , + m_Controls.m_AmplitudeFormat, extensions, ".nrrd"); + this->UpdateGUIElements(device, "HasIntensityImage", m_Controls.m_SaveIntensity, + m_Controls.m_IntensityFormat, extensions, ".nrrd"); + this->UpdateGUIElements(device, "HasRGBImage", m_Controls.m_SaveColor, + m_Controls.m_ColorFormat, extensions, ".png"); //png is nice default for calibration + this->UpdateGUIElements(device, "HasRawImage", m_Controls.m_SaveRaw, + m_Controls.m_RawFormat, extensions, ".nrrd"); } -void QmitkToFScreenshotMaker::UpdateFileExtensionComboBox(bool active, QComboBox* box, QStringList fileExentions, const char* preferredFormat) +void QmitkToFScreenshotMaker::UpdateGUIElements(mitk::ToFCameraDevice* device, const char* ToFImageType, + QCheckBox* saveCheckBox, QComboBox* saveTypeComboBox, + QStringList fileExentions, const char* preferredFormat) { - box->clear(); - box->setEnabled(active); - box->addItems(fileExentions); - int index = box->findText(preferredFormat); + bool isTypeProvidedByDevice = false; + device->GetBoolProperty(ToFImageType, isTypeProvidedByDevice); + saveCheckBox->setChecked(isTypeProvidedByDevice); + saveCheckBox->setEnabled(isTypeProvidedByDevice); + + saveTypeComboBox->clear(); + saveTypeComboBox->setEnabled(isTypeProvidedByDevice); + saveTypeComboBox->addItems(fileExentions); + int index = saveTypeComboBox->findText(preferredFormat); if ( index != -1 ) { // -1 for not found - box->setCurrentIndex(index); + saveTypeComboBox->setCurrentIndex(index); } } void QmitkToFScreenshotMaker::OnMakeScreenshotClicked() { mitk::ToFImageGrabber* source = static_cast(m_Controls.m_ConnectedDeviceServiceListWidget->GetSelectedService()); - source->Update(); //### Save Images this->SaveImage(source->GetOutput(0), m_Controls.m_SaveDepth->isChecked(), m_Controls.m_PathToSaveFiles->text().toStdString(), std::string("Depth_"), m_Controls.m_DepthFormat->currentText().toStdString()); this->SaveImage(source->GetOutput(1), m_Controls.m_SaveAmplitude->isChecked(), m_Controls.m_PathToSaveFiles->text().toStdString(), std::string("Amplitude_"), m_Controls.m_AmplitudeFormat->currentText().toStdString()); this->SaveImage(source->GetOutput(2), m_Controls.m_SaveIntensity->isChecked(), m_Controls.m_PathToSaveFiles->text().toStdString(), std::string("Intensity_"), m_Controls.m_IntensityFormat->currentText().toStdString()); this->SaveImage(source->GetOutput(3), m_Controls.m_SaveColor->isChecked(), m_Controls.m_PathToSaveFiles->text().toStdString(), std::string("Color_"), m_Controls.m_ColorFormat->currentText().toStdString()); //todo, where is the raw data? //todo what about the surface or pre-processed data? m_SavingCounter++; - MITK_INFO << m_SavingCounter; } void QmitkToFScreenshotMaker::SaveImage(mitk::Image::Pointer image, bool saveImage, std::string path, std::string name, std::string extension) { if(saveImage) { std::stringstream outdepthimage; outdepthimage << path << name<< m_SavingCounter << extension; - MITK_INFO << outdepthimage.str(); mitk::IOUtil::SaveImage( image, outdepthimage.str() ); } } diff --git a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.h b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.h index 330915185b..6486af9402 100644 --- a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.h +++ b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.h @@ -1,91 +1,97 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef QmitkToFScreenshotMaker_h #define QmitkToFScreenshotMaker_h #include #include - #include - #include /*! - \brief QmitkToFScreenshotMaker + \brief QmitkToFScreenshotMaker Select a ToF image source in the GUI to make a screenshot of the provided data. + If a camera is active, the Make Screenshot button will become enabled. Select the data including format you + want to save at the given path. To activate a camera, you can for example use the ToF Util view. Note you can + only select data which is provided by the device. Screenshots will be saved at the respective path with a + counter indicating the order. - \sa QmitkFunctionality - \ingroup Functionalities + \ingroup ToFUtil */ class QmitkToFScreenshotMaker : public QmitkAbstractView { // this is needed for all Qt objects that should have a Qt meta-object // (everything that derives from QObject and wants to have signal/slots) Q_OBJECT public: static const std::string VIEW_ID; QmitkToFScreenshotMaker(); ~QmitkToFScreenshotMaker(); void SetFocus(); virtual void CreateQtPartControl(QWidget *parent); protected slots: - /*! - \brief Slot called when the "Make screenshot" button is pressed. - */ + /** + * @brief OnMakeScreenshotClicked Slot called when the "Make screenshot" button is pressed. + */ void OnMakeScreenshotClicked(); + /** + * @brief OnSelectCamera Slot called to update the GUI according to the selected image source. + */ void OnSelectCamera(); protected: Ui::QmitkToFScreenshotMakerControls m_Controls; private: /** - * @brief UpdateFileExtensionComboBox - * @param active - * @param box - * @param fileExentions - * @param preferredFormat + * @brief UpdateGUIElements Internal helper method to update the GUI. + * @param device The device of the selected image source. + * @param ToFImageType Type of the image (e.g. depth, RGB, intensity, etc.) + * @param saveCheckBox Checkbox indicating whether the type should be saved. + * @param saveTypeComboBox Combobox to chose in which format the data should be saved (e.g. nrrd) + * @param fileExentions Other possible file extensions. + * @param preferredFormat Default format for this type (e.g. png for RGB). */ - void UpdateFileExtensionComboBox(bool active, QComboBox* box, QStringList fileExentions, const char *preferredFormat); + void UpdateGUIElements(mitk::ToFCameraDevice* device, const char *ToFImageType, QCheckBox *saveCheckBox, + QComboBox *saveTypeComboBox, QStringList fileExentions, const char *preferredFormat); /** - * @brief SaveImage - * @param image - * @param saveImage - * @param path - * @param name - * @param extension + * @brief SaveImage Saves a ToF image. + * @param image The image to save. + * @param saveImage Should it be saved? + * @param path Path where to save the image. + * @param name Name of the image. + * @param extension Type extension (e.g. .nrrd). */ void SaveImage(mitk::Image::Pointer image, bool saveImage, std::string path, std::string name, std::string extension); int m_SavingCounter; - mitk::ToFImageGrabber::Pointer m_ToFImageGrabber; }; #endif // _QmitkToFScreenshotMaker_H_INCLUDED diff --git a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMakerControls.ui b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMakerControls.ui index 14f22632d2..63692d0872 100644 --- a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMakerControls.ui +++ b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMakerControls.ui @@ -1,161 +1,195 @@ QmitkToFScreenshotMakerControls 0 0 466 452 0 0 QmitkTemplate - - + + + + false + + + Make Screenshot + + + + + + + + 0 + 0 + + + QFormLayout::AllNonFixedFieldsGrow + + + Path to save: + + + + + + + false Depth - + false - + false Amplidute/infra red - + + + + false + + + + false Intensity - - + + false - - Color - - - + + false - Raw + Color - - + + false - - + + false + + Raw + - - + + false - - - - false + + + + In which format? + + + + + + + Save? - - - - Which data to save in which format... - - - - - - - true - - - Make Screenshot - - - - - - - <html><head/><body><p>Usage information: </p><p><br/>Select a camera below. If the camera is active, the Make Screenshot button will become enabled. Select the data including format you want to save at the given path. Note you can only select data which is provided by the device. Screenshots will be saved at the respective path with a counter indicating the order.</p></body></html> + <html><head/><body><p>Usage information: </p><p><br/>Select a ToF image source below. If the camera is active, the Make Screenshot button will become enabled. Select the data including format you want to save at the given path. To activate a camera, you can for example use the ToF Util view. Note you can only select data which is provided by the device. Screenshots will be saved at the respective path with a counter indicating the order.</p></body></html> true + + + + Qt::Vertical + + + + 20 + 40 + + + + QmitkServiceListWidget QWidget
QmitkServiceListWidget.h
1