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 cc849b72e4..7b035a88eb 100644 --- a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.cpp +++ b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.cpp @@ -1,149 +1,147 @@ /*=================================================================== 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" +#include + +// Mitk +#include +#include +#include // Qt #include #include #include -#include -#include - -#include -#include - const std::string QmitkToFScreenshotMaker::VIEW_ID = "org.mitk.views.tofscreenshotmaker"; QmitkToFScreenshotMaker::QmitkToFScreenshotMaker() : QmitkAbstractView(), m_SavingCounter(0) { } 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/"; #endif m_Controls.m_PathToSaveFiles->setText(defaultPath.c_str()); } void QmitkToFScreenshotMaker::OnSelectCamera() { //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()); //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->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::UpdateGUIElements(mitk::ToFCameraDevice* device, const char* ToFImageType, QCheckBox* saveCheckBox, QComboBox* saveTypeComboBox, QStringList fileExentions, const char* 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 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++; } 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::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 6486af9402..1048fffc05 100644 --- a/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.h +++ b/Plugins/org.mitk.gui.qt.tofutil/src/internal/QmitkToFScreenshotMaker.h @@ -1,97 +1,100 @@ /*=================================================================== 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 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. \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: +public: - static const std::string VIEW_ID; + static const std::string VIEW_ID; - QmitkToFScreenshotMaker(); - ~QmitkToFScreenshotMaker(); + QmitkToFScreenshotMaker(); + ~QmitkToFScreenshotMaker(); - void SetFocus(); + void SetFocus(); - virtual void CreateQtPartControl(QWidget *parent); + virtual void CreateQtPartControl(QWidget *parent); protected slots: - /** - * @brief OnMakeScreenshotClicked Slot called when the "Make screenshot" button is pressed. - */ - void OnMakeScreenshotClicked(); + /** + * @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(); + /** + * @brief OnSelectCamera Slot called to update the GUI according to the selected image source. + */ + void OnSelectCamera(); - protected: +protected: - Ui::QmitkToFScreenshotMakerControls m_Controls; + Ui::QmitkToFScreenshotMakerControls m_Controls; - private: +private: - /** + /** * @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 UpdateGUIElements(mitk::ToFCameraDevice* device, const char *ToFImageType, QCheckBox *saveCheckBox, - QComboBox *saveTypeComboBox, QStringList fileExentions, const char *preferredFormat); + void UpdateGUIElements(mitk::ToFCameraDevice* device, const char *ToFImageType, QCheckBox *saveCheckBox, + QComboBox *saveTypeComboBox, QStringList fileExentions, const char *preferredFormat); - /** + /** * @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); + void SaveImage(mitk::Image::Pointer image, bool saveImage, std::string path, std::string name, std::string extension); - int m_SavingCounter; + /** + * @brief m_SavingCounter Internal counter for saving images with higher number. + */ + int m_SavingCounter; }; -#endif // _QmitkToFScreenshotMaker_H_INCLUDED +#endif // QmitkToFScreenshotMaker_h