diff --git a/Modules/Qmitk/QmitkFileDialog.cpp b/Modules/Qmitk/QmitkFileDialog.cpp new file mode 100644 index 0000000000..9b5a9207c6 --- /dev/null +++ b/Modules/Qmitk/QmitkFileDialog.cpp @@ -0,0 +1,59 @@ +/*=================================================================== + +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. + +===================================================================*/ + +//#define _USE_MATH_DEFINES +#include + +// STL Headers +#include + +//microservices +#include +#include +#include + +#include + +const std::string QmitkFileDialog::VIEW_ID = "org.mitk.views.QmitkFileDialog"; + +QmitkFileDialog::QmitkFileDialog(QWidget* parent, Qt::WindowFlags f): QFileDialog(parent, f) +{ + //m_controls = null; + //CreateQtPartControl(this); +} + +QmitkFileDialog::~QmitkFileDialog() +{ +} + +//////////////////// INITIALIZATION ///////////////////// + +//void QmitkFileDialog::CreateQtPartControl(QWidget *parent) +//{ +// if (!m_Controls) +// { +// // create GUI widgets +// m_Controls = new Ui::QmitkFileDialogControls; +// m_Controls->setupUi(parent); +// this->CreateConnections(); +// } +// m_Context = us::GetModuleContext(); +//} + +void QmitkFileDialog::CreateConnections() +{ + //connect( m_Controls->m_ServiceList, SIGNAL(currentItemChanged( QListWidgetItem *, QListWidgetItem *)), this, SLOT(OnServiceSelectionChanged()) ); +} diff --git a/Modules/Qmitk/QmitkFileDialog.h b/Modules/Qmitk/QmitkFileDialog.h new file mode 100644 index 0000000000..a471bb0a8a --- /dev/null +++ b/Modules/Qmitk/QmitkFileDialog.h @@ -0,0 +1,77 @@ +/*=================================================================== + +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 _QmitkFileDialog_H_INCLUDED +#define _QmitkFileDialog_H_INCLUDED + +#include "QmitkExports.h" +#include + +//QT headers +#include +#include +#include + +//Microservices +#include "usServiceReference.h" +#include "usModuleContext.h" +#include "usServiceEvent.h" +#include "usServiceInterface.h" + +/** +* \ingroup QmitkModule +* +* \brief +*/ +class QMITK_EXPORT QmitkFileDialog :public QFileDialog +{ + //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) + Q_OBJECT + +private: + + //us::ModuleContext* m_Context; + ///** \brief a filter to further narrow down the list of results*/ + //std::string m_Filter; + ///** \brief The name of the ServiceInterface that this class should list */ + //std::string m_Interface; + ///** \brief The name of the ServiceProperty that will be displayed in the list to represent the service */ + //std::string m_NamingProperty; + +public: + + static const std::string VIEW_ID; + + QmitkFileDialog(QWidget* p = 0, Qt::WindowFlags f1 = 0); + virtual ~QmitkFileDialog(); + + /** \brief This method is part of the widget and needs not to be called separately. */ + //virtual void CreateQtPartControl(QWidget *parent); + /** \brief This method is part of the widget and needs not to be called separately. (Creation of the connections of main and control widget.)*/ + virtual void CreateConnections(); + +signals: + + public slots: + + protected slots: + +protected: + + //Ui::QmitkFileDialogControls* m_Controls; ///< member holding the UI elements of this widget +}; + +#endif // _QmitkFileDialog_H_INCLUDED diff --git a/Modules/Qmitk/QmitkServiceListWidget.h b/Modules/Qmitk/QmitkServiceListWidget.h index 4d65da4242..c9b3f332b4 100644 --- a/Modules/Qmitk/QmitkServiceListWidget.h +++ b/Modules/Qmitk/QmitkServiceListWidget.h @@ -1,247 +1,247 @@ /*=================================================================== 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 _QmitkServiceListWidget_H_INCLUDED #define _QmitkServiceListWidget_H_INCLUDED #include "QmitkExports.h" #include "ui_QmitkServiceListWidgetControls.h" #include //QT headers #include #include //Microservices #include "usServiceReference.h" #include "usModuleContext.h" #include "usServiceEvent.h" #include "usServiceInterface.h" /** * \ingroup QmitkModule * * \brief This widget provides abstraction for the handling of MicroServices. * * Place one in your Plugin and set it to look for a certain interface. * One can also specify a filter and / or a property to use for captioning of * the services. It also offers functionality to signal * ServiceEvents and to return the actual classes, so only a minimum of * interaction with the MicroserviceInterface is required. * To get started, just put it in your Plugin or Widget, call the Initialize * Method and optionally connect it's signals. * As QT limits templating possibilities, events only throw ServiceReferences. * You can manually dereference them using TranslateServiceReference() */ class QMITK_EXPORT QmitkServiceListWidget :public QWidget { //this is needed for all Qt objects that should have a MOC object (everything that derives from QObject) Q_OBJECT private: us::ModuleContext* m_Context; /** \brief a filter to further narrow down the list of results*/ std::string m_Filter; /** \brief The name of the ServiceInterface that this class should list */ std::string m_Interface; /** \brief The name of the ServiceProperty that will be displayed in the list to represent the service */ std::string m_NamingProperty; public: static const std::string VIEW_ID; QmitkServiceListWidget(QWidget* p = 0, Qt::WindowFlags f1 = 0); virtual ~QmitkServiceListWidget(); - /** \brief This method is part of the widget an needs not to be called separately. */ + /** \brief This method is part of the widget and needs not to be called separately. */ virtual void CreateQtPartControl(QWidget *parent); - /** \brief This method is part of the widget an needs not to be called separately. (Creation of the connections of main and control widget.)*/ + /** \brief This method is part of the widget and needs not to be called separately. (Creation of the connections of main and control widget.)*/ virtual void CreateConnections(); /** * \brief Will return true, if a service is currently selected and false otherwise. * * Call this before requesting service references to avoid invalid ServiceReferences. */ bool GetIsServiceSelected(); /** * \brief Returns the currently selected Service as a ServiceReference. * * If no Service is selected, the result will probably be a bad pointer. call GetIsServiceSelected() * beforehand to avoid this */ us::ServiceReferenceU GetSelectedServiceReference(); /** * \brief Use this function to return the currently selected service as a class directly. * * Make sure you pass the appropriate type, or else this call will fail. * Usually, you will pass the class itself, not the SmartPointer, but the function returns a pointer. Example: * \verbatim mitk::USDevice::Pointer device = GetSelectedService(); \endverbatim * @return Returns the current selected device. Returns NULL if no device is selected. */ template T* GetSelectedService() { if (this->m_Controls->m_ServiceList->currentRow()==-1) return NULL; us::ServiceReferenceU ref = GetServiceForListItem( this->m_Controls->m_ServiceList->currentItem() ); return ( m_Context->GetService(us::ServiceReference(ref)) ); } /** * \brief Initializes the Widget with essential parameters. * * The string filter is an LDAP parsable String, compare mitk::ModuleContext for examples on filtering. * Pass class T to tell the widget which class it should filter for - only services of this class will be listed. * NamingProperty is a property that will be used to caption the Items in the list. If no filter is supplied, all * matching interfaces are shown. If no namingProperty is supplied, the interfaceName will be used to caption Items in the list. * For example, this Initialization will filter for all USDevices that are set to active. The USDevice's model will be used to display it in the list: * \verbatim std::string filter = "(&(" + us::ServiceConstants::OBJECTCLASS() + "=" + "org.mitk.services.UltrasoundDevice)(IsActive=true))"; m_Controls.m_ActiveVideoDevices->Initialize(mitk::USImageMetadata::PROP_DEV_MODEL ,filter); * \endverbatim */ template void Initialize(const std::string& namingProperty = static_cast< std::string >(""),const std::string& filter = static_cast< std::string >("")) { std::string interfaceName ( us_service_interface_iid() ); m_Interface = interfaceName; InitPrivate(namingProperty, filter); } /** * \brief Translates a serviceReference to a class of the given type. * * Use this to translate the signal's parameters. To adhere to the MicroService contract, * only ServiceReferences stemming from the same widget should be used as parameters for this method. * \verbatim mitk::USDevice::Pointer device = TranslateReference(myDeviceReference); \endverbatim */ template T* TranslateReference(const us::ServiceReferenceU& reference) { return m_Context->GetService(us::ServiceReference(reference)); } /** *\brief This Function listens to ServiceRegistry changes and updates the list of services accordingly. * * The user of this widget does not need to call this method, it is instead used to recieve events from the module registry. */ void OnServiceEvent(const us::ServiceEvent event); signals: /** *\brief Emitted when a new Service matching the filter is being registered. * * Be careful if you use a filter: * If a device does not match the filter when registering, but modifies it's properties later to match the filter, * then the first signal you will see this device in will be ServiceModified. */ void ServiceRegistered(us::ServiceReferenceU); /** *\brief Emitted directly before a Service matching the filter is being unregistered. */ void ServiceUnregistering(us::ServiceReferenceU); /** *\brief Emitted when a Service matching the filter changes it's properties, or when a service that formerly not matched the filter * changed it's properties and now matches the filter. */ void ServiceModified(us::ServiceReferenceU); /** *\brief Emitted when a Service matching the filter changes it's properties, * * and the new properties make it fall trough the filter. This effectively means that * the widget will not track the service anymore. Usually, the Service should still be useable though */ void ServiceModifiedEndMatch(us::ServiceReferenceU); /** *\brief Emitted if the user selects a Service from the list. * * If no service is selected, an invalid serviceReference is returned. The user can easily check for this. * if (serviceReference) will evaluate to false, if the reference is invalid and true if valid. */ void ServiceSelectionChanged(us::ServiceReferenceU); public slots: protected slots: /** \brief Called, when the selection in the list of Services changes. */ void OnServiceSelectionChanged(); protected: Ui::QmitkServiceListWidgetControls* m_Controls; ///< member holding the UI elements of this widget /** * \brief Internal structure used to link ServiceReferences to their QListWidgetItems */ struct ServiceListLink { us::ServiceReferenceU service; QListWidgetItem* item; }; /** * \brief Finishes initialization after Initialize has been called. * * This function assumes that m_Interface is set correctly (Which Initialize does). */ void InitPrivate(const std::string& namingProperty, const std::string& filter); /** * \brief Contains a list of currently active services and their entires in the list. This is wiped with every ServiceRegistryEvent. */ std::vector m_ListContent; /** * \brief Constructs a ListItem from the given service, displays it, and locally stores the service. */ QListWidgetItem* AddServiceToList(const us::ServiceReferenceU& serviceRef); /** * \brief Removes the given service from the list and cleans up. Returns true if successful, false if service was not found. */ bool RemoveServiceFromList(const us::ServiceReferenceU& serviceRef); /** * \brief Returns the serviceReference corresponding to the given ListEntry or an invalid one if none was found (will evaluate to false in bool expressions). */ us::ServiceReferenceU GetServiceForListItem(QListWidgetItem* item); /** * \brief Returns a list of ServiceReferences matching the filter criteria by querying the service registry. */ std::vector GetAllRegisteredServices(); }; #endif // _QmitkServiceListWidget_H_INCLUDED diff --git a/Modules/Qmitk/files.cmake b/Modules/Qmitk/files.cmake index f2246f6666..98f5aa8615 100644 --- a/Modules/Qmitk/files.cmake +++ b/Modules/Qmitk/files.cmake @@ -1,66 +1,68 @@ set(CPP_FILES QmitkApplicationCursor.cpp QmitkEnums.h QmitkCustomVariants.h QmitkDataStorageComboBox.cpp QmitkDataStorageListModel.cpp QmitkDataStorageTableModel.cpp QmitkDataStorageTreeModel.cpp QmitkEventAdapter.cpp +QmitkFileDialog.cpp QmitkLevelWindowPresetDefinitionDialog.cpp QmitkLevelWindowRangeChangeDialog.cpp QmitkLevelWindowWidgetContextMenu.cpp QmitkLevelWindowWidget.cpp QmitkLineEditLevelWindowWidget.cpp QmitkMemoryUsageIndicatorView.cpp QmitkNodeDescriptor.cpp QmitkNodeDescriptorManager.cpp QmitkRenderWindowMenu.cpp QmitkProgressBar.cpp QmitkPropertiesTableEditor.cpp QmitkPropertiesTableModel.cpp QmitkPropertyDelegate.cpp QmitkRegisterClasses.cpp QmitkRenderingManager.cpp QmitkRenderingManagerFactory.cpp QmitkRenderWindow.cpp QmitkServiceListWidget.cpp QmitkSliderLevelWindowWidget.cpp QmitkStdMultiWidget.cpp QmitkMouseModeSwitcher.cpp ) set(MOC_H_FILES QmitkDataStorageComboBox.h QmitkDataStorageTableModel.h +QmitkFileDialog.h QmitkLevelWindowPresetDefinitionDialog.h QmitkLevelWindowRangeChangeDialog.h QmitkLevelWindowWidgetContextMenu.h QmitkLevelWindowWidget.h QmitkLineEditLevelWindowWidget.h QmitkMemoryUsageIndicatorView.h QmitkNodeDescriptor.h QmitkNodeDescriptorManager.h QmitkRenderWindowMenu.h QmitkProgressBar.h QmitkPropertiesTableEditor.h QmitkPropertyDelegate.h QmitkRenderingManager.h QmitkRenderWindow.h QmitkServiceListWidget.h QmitkSliderLevelWindowWidget.h QmitkStdMultiWidget.h QmitkMouseModeSwitcher.h ) set(UI_FILES QmitkLevelWindowPresetDefinition.ui QmitkLevelWindowWidget.ui QmitkLevelWindowRangeChange.ui QmitkMemoryUsageIndicator.ui QmitkServiceListWidgetControls.ui ) set(QRC_FILES Qmitk.qrc )