diff --git a/Plugins/org.mitk.gui.qt.common.legacy/files.cmake b/Plugins/org.mitk.gui.qt.common.legacy/files.cmake index 331c6b063f..8a9f981fd2 100755 --- a/Plugins/org.mitk.gui.qt.common.legacy/files.cmake +++ b/Plugins/org.mitk.gui.qt.common.legacy/files.cmake @@ -1,33 +1,29 @@ set(SRC_CPP_FILES - QmitkFunctionality.cpp - QmitkFunctionality2.cpp - QmitkFunctionalityCoordinator.cpp ) set(INTERNAL_CPP_FILES QmitkCommonLegacyActivator.cpp - QmitkFunctionalityUtil.cpp ) set(MOC_H_FILES src/internal/QmitkCommonLegacyActivator.h ) set(UI_FILES ) set(CACHED_RESOURCE_FILES ) set(QRC_FILES ) set(CPP_FILES ) foreach(file ${SRC_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/${file}) endforeach(file ${SRC_CPP_FILES}) foreach(file ${INTERNAL_CPP_FILES}) set(CPP_FILES ${CPP_FILES} src/internal/${file}) endforeach(file ${INTERNAL_CPP_FILES}) diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.cpp deleted file mode 100644 index a18f8f3b53..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.cpp +++ /dev/null @@ -1,373 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkFunctionality.h" -#include "internal/QmitkFunctionalityUtil.h" -#include "internal/QmitkCommonLegacyActivator.h" - -// other includes -#include - -// mitk Includes -#include -#include - -// berry Includes -#include -#include -#include -#include - -// Qmitk Includes -#include - -// Qt Includes -#include -#include -#include -#include - -QmitkFunctionality::QmitkFunctionality() - : m_Parent(nullptr) - , m_Active(false) - , m_Visible(false) - , m_SelectionProvider(nullptr) - , m_DataStorageServiceTracker(QmitkCommonLegacyActivator::GetContext()) - , m_HandlesMultipleDataStorages(false) - , m_InDataStorageChanged(false) -{ - m_DataStorageServiceTracker.open(); -} - -void QmitkFunctionality::SetHandleMultipleDataStorages(bool multiple) -{ - m_HandlesMultipleDataStorages = multiple; -} - -bool QmitkFunctionality::HandlesMultipleDataStorages() const -{ - return m_HandlesMultipleDataStorages; -} - -mitk::DataStorage::Pointer -QmitkFunctionality::GetDataStorage() const -{ - mitk::IDataStorageService* service = m_DataStorageServiceTracker.getService(); - - if (service != nullptr) - { - if(m_HandlesMultipleDataStorages) - return service->GetActiveDataStorage()->GetDataStorage(); - else - return service->GetDefaultDataStorage()->GetDataStorage(); - } - - return nullptr; -} - -mitk::DataStorage::Pointer QmitkFunctionality::GetDefaultDataStorage() const -{ - mitk::IDataStorageService* service = m_DataStorageServiceTracker.getService(); - - if (service != nullptr) - { - return service->GetDefaultDataStorage()->GetDataStorage(); - } - - return nullptr; -} - -mitk::IDataStorageReference::Pointer QmitkFunctionality::GetDataStorageReference() const -{ - mitk::IDataStorageService* dsService = m_DataStorageServiceTracker.getService(); - - if (dsService != nullptr) - { - return dsService->GetDataStorage(); - } - - return mitk::IDataStorageReference::Pointer(nullptr); -} - -void QmitkFunctionality::CreatePartControl(QWidget* parent) -{ - - // scrollArea - QScrollArea* scrollArea = new QScrollArea; - //QVBoxLayout* scrollAreaLayout = new QVBoxLayout(scrollArea); - scrollArea->setFrameShadow(QFrame::Plain); - scrollArea->setFrameShape(QFrame::NoFrame); - scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - - // m_Parent - m_Parent = new QWidget; - //m_Parent->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); - this->CreateQtPartControl(m_Parent); - - //scrollAreaLayout->addWidget(m_Parent); - //scrollArea->setLayout(scrollAreaLayout); - - // set the widget now - scrollArea->setWidgetResizable(true); - scrollArea->setWidget(m_Parent); - - // add the scroll area to the real parent (the view tabbar) - QWidget* parentQWidget = static_cast(parent); - QVBoxLayout* parentLayout = new QVBoxLayout(parentQWidget); - parentLayout->setMargin(0); - parentLayout->setSpacing(0); - parentLayout->addWidget(scrollArea); - - // finally set the layout containing the scroll area to the parent widget (= show it) - parentQWidget->setLayout(parentLayout); - - this->AfterCreateQtPartControl(); -} - -void QmitkFunctionality::AfterCreateQtPartControl() -{ - // REGISTER DATASTORAGE LISTENER - this->GetDefaultDataStorage()->AddNodeEvent.AddListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeAddedProxy ) ); - this->GetDefaultDataStorage()->ChangedNodeEvent.AddListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeChangedProxy ) ); - this->GetDefaultDataStorage()->RemoveNodeEvent.AddListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeRemovedProxy ) ); - - // REGISTER PREFERENCES LISTENER - berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); - if(prefs.IsNotNull()) - prefs->OnChanged.AddListener(berry::MessageDelegate1(this, &QmitkFunctionality::OnPreferencesChanged)); - - // REGISTER FOR WORKBENCH SELECTION EVENTS - m_BlueBerrySelectionListener.reset(new berry::SelectionChangedAdapter( - this, - &QmitkFunctionality::BlueBerrySelectionChanged) - ); - this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->AddPostSelectionListener( - /*"org.mitk.views.datamanager",*/ m_BlueBerrySelectionListener.data()); - - // REGISTER A SELECTION PROVIDER - QmitkFunctionalitySelectionProvider::Pointer _SelectionProvider( - new QmitkFunctionalitySelectionProvider(this)); - m_SelectionProvider = _SelectionProvider.GetPointer(); - this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(m_SelectionProvider)); - - // EMULATE INITIAL SELECTION EVENTS - - // by default a multi widget is always available - this->MultiWidgetAvailable(*this->GetActiveMultiWidget()); - - // send datamanager selection - this->OnSelectionChanged(this->GetDataManagerSelection()); - - // send preferences changed event - this->OnPreferencesChanged(this->GetPreferences().Cast().GetPointer()); -} - -void QmitkFunctionality::ClosePart() -{ - -} - -void QmitkFunctionality::ClosePartProxy() -{ - this->GetDefaultDataStorage()->AddNodeEvent.RemoveListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeAddedProxy ) ); - this->GetDefaultDataStorage()->RemoveNodeEvent.RemoveListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeRemovedProxy) ); - this->GetDefaultDataStorage()->ChangedNodeEvent.RemoveListener( mitk::MessageDelegate1 - ( this, &QmitkFunctionality::NodeChangedProxy ) ); - - berry::IBerryPreferences::Pointer prefs = this->GetPreferences().Cast(); - if(prefs.IsNotNull()) - { - prefs->OnChanged.RemoveListener(berry::MessageDelegate1(this, &QmitkFunctionality::OnPreferencesChanged)); - // flush the preferences here (disabled, everyone should flush them by themselves at the right moment) - // prefs->Flush(); - } - - // REMOVE SELECTION PROVIDER - this->GetSite()->SetSelectionProvider(berry::ISelectionProvider::Pointer(nullptr)); - - berry::ISelectionService* s = GetSite()->GetWorkbenchWindow()->GetSelectionService(); - if(s) - { - s->RemovePostSelectionListener(m_BlueBerrySelectionListener.data()); - } - - this->ClosePart(); -} - -QmitkFunctionality::~QmitkFunctionality() -{ - this->Register(); - this->ClosePartProxy(); - - this->UnRegister(false); - - m_DataStorageServiceTracker.close(); -} - -void QmitkFunctionality::OnPreferencesChanged( const berry::IBerryPreferences* ) -{ -} - -void QmitkFunctionality::BlueBerrySelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart, - const berry::ISelection::ConstPointer& selection) -{ - if(sourcepart.IsNull() || sourcepart->GetSite()->GetId() != "org.mitk.views.datamanager") - return; - - mitk::DataNodeSelection::ConstPointer _DataNodeSelection - = selection.Cast(); - this->OnSelectionChanged(this->DataNodeSelectionToVector(_DataNodeSelection)); -} - -bool QmitkFunctionality::IsVisible() const -{ - return m_Visible; -} - -void QmitkFunctionality::SetFocus() -{ -} - -void QmitkFunctionality::Activated() -{ -} - -void QmitkFunctionality::Deactivated() -{ -} - -void QmitkFunctionality::MultiWidgetAvailable( QmitkAbstractMultiWidget& /*multiWidget*/ ) -{ -} -void QmitkFunctionality::MultiWidgetNotAvailable() -{ -} - -void QmitkFunctionality::DataStorageChanged() -{ - -} - -QmitkAbstractMultiWidget* QmitkFunctionality::GetActiveMultiWidget( bool reCreateWidget ) -{ - QmitkAbstractMultiWidget* activeMultiWidget = nullptr; - - berry::IEditorPart::Pointer editor = - this->GetSite()->GetPage()->GetActiveEditor(); - - if (reCreateWidget || editor.Cast().IsNull()) - { - mitk::DataStorageEditorInput::Pointer editorInput( - new mitk::DataStorageEditorInput( this->GetDataStorageReference() )); - // open a new multi-widget editor, but do not give it the focus - berry::IEditorPart::Pointer editor = this->GetSite()->GetPage()->OpenEditor(editorInput, QmitkStdMultiWidgetEditor::EDITOR_ID, false, berry::IWorkbenchPage::MATCH_ID); - activeMultiWidget = editor.Cast()->GetMultiWidget(); - } - else if (editor.Cast().IsNotNull()) - { - activeMultiWidget = editor.Cast()->GetMultiWidget(); - } - - return activeMultiWidget; -} - -void QmitkFunctionality::HandleException( const char* str, QWidget* parent, bool showDialog ) const -{ - //itkGenericOutputMacro( << "Exception caught: " << str ); - MITK_ERROR << str; - if ( showDialog ) - { - QMessageBox::critical ( parent, "Exception caught!", str ); - } -} - -void QmitkFunctionality::HandleException( std::exception& e, QWidget* parent, bool showDialog ) const -{ - HandleException( e.what(), parent, showDialog ); -} - -void QmitkFunctionality::MultiWidgetClosed( QmitkAbstractMultiWidget& /*multiWidget*/ ) -{ - -} - -void QmitkFunctionality::WaitCursorOn() -{ - QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); -} - -void QmitkFunctionality::BusyCursorOn() -{ - QApplication::setOverrideCursor( QCursor(Qt::BusyCursor) ); -} - -void QmitkFunctionality::WaitCursorOff() -{ - this->RestoreOverrideCursor(); -} - -void QmitkFunctionality::BusyCursorOff() -{ - this->RestoreOverrideCursor(); -} - -void QmitkFunctionality::RestoreOverrideCursor() -{ - QApplication::restoreOverrideCursor(); -} - -berry::IPreferences::Pointer QmitkFunctionality::GetPreferences() const -{ - berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService(); - // const_cast workaround for bad programming: const uncorrectness this->GetViewSite() should be const - QString id = "/" + (const_cast(this))->GetViewSite()->GetId(); - return prefService != nullptr ? prefService->GetSystemPreferences()->Node(id): berry::IPreferences::Pointer(nullptr); -} - -void QmitkFunctionality::Visible() -{ - -} - -void QmitkFunctionality::Hidden() -{ - -} - -bool QmitkFunctionality::IsExclusiveFunctionality() const -{ - return true; -} - -void QmitkFunctionality::SetVisible( bool visible ) -{ - m_Visible = visible; -} - -void QmitkFunctionality::SetActivated( bool activated ) -{ - m_Active = activated; -} - -bool QmitkFunctionality::IsActivated() const -{ - return m_Active; -} - diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.h b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.h deleted file mode 100755 index fae0b394ce..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality.h +++ /dev/null @@ -1,397 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#ifndef QMITKFUNCTIONALITY_H_ -#define QMITKFUNCTIONALITY_H_ - -//# blueberry stuff -#include -#include -#include - -#include - -//# mitk stuff -#include -#include "mitkDataNodeSelection.h" -#include -#include -#include -#include - -// CTK Includes -#include - - -//# forward declarations - -namespace mitk { - class DataNode; - struct IDataStorageService; -} - -namespace berry { - struct IBerryPreferences; -} - -class QmitkFunctionalitySelectionProvider; - -/// -/// \ingroup org_mitk_gui_qt_common_legacy -/// -/// \class QmitkFunctionality -/// -/// \brief The base class of all MITK related blueberry views (~ in the old version of MITK, this was called "Functionality") -/// -/// QmitkFunctionality provides several convenience methods that eases the introduction of a new view: -/// -///
    -///
  1. Access to the DataStorage (~ the shared data repository) -///
  2. Access to the MultiWidget -///
  3. Access to and update notification for the functionality/view preferences -///
  4. Access to and update notification for the current DataNode selection / to DataNode selection events send through the SelectionService -///
  5. Methods to send DataNode selections through the SelectionService -///
  6. Some events for unproblematic inter-View communication (e.g. when to add/remove interactors) -///
  7. Some minor important convenience methods (like changing the mouse cursor/exception handling) -///
-/// -/// Please use the Activated/Deactivated method to add/remove interactors, disabling multiwidget crosshair or anything which may -/// "affect" other functionalities. For further reading please have a look at QmitkFunctionality::IsExclusiveFunctionality(). -/// -class MITK_QT_COMMON_LEGACY QmitkFunctionality : public berry::QtViewPart -{ - -//# public virtual methods which can be overwritten -public: - /// - /// Creates smartpointer typedefs - /// - berryObjectMacro(QmitkFunctionality); - /// - /// Nothing to do in the standard ctor. Initiliaze your GUI in CreateQtPartControl(QWidget*) - /// \see berry::QtViewPart::CreateQtPartControl(QWidget*) - /// - QmitkFunctionality(); - /// - /// Disconnects all standard event listeners - /// - ~QmitkFunctionality() override; - /// - /// Called, when the WorkbenchPart gets closed - /// by the user directly or by closing the whole - /// app (e.g. for removing event listeners) - /// - virtual void ClosePart(); - /// - /// Called when the selection in the workbench changed - /// - virtual void OnSelectionChanged(std::vector /*nodes*/); - /// - /// Called when the preferences object of this view changed. - /// \see GetPreferences() - /// - virtual void OnPreferencesChanged(const berry::IBerryPreferences*); - /// - /// Make this view manage multiple DataStorage. If set to true GetDataStorage() - /// will return the currently active DataStorage (and not the default one). - /// \see GetDataStorage() - /// - void SetHandleMultipleDataStorages(bool multiple); - /// - /// \return true if this view handles multiple DataStorages, false otherwise - /// - bool HandlesMultipleDataStorages() const; - /// - /// Called when a MultiWidget is available. Should not be used anymore, see GetActiveMultiWidget() - /// \see GetActiveMultiWidget() - /// - virtual void MultiWidgetAvailable(QmitkAbstractMultiWidget& multiWidget); - /// - /// Called when a MultiWidget is available. Should not be used anymore, see GetActiveMultiWidget() - /// \see GetActiveMultiWidget() - /// - virtual void MultiWidgetClosed(QmitkAbstractMultiWidget& multiWidget); - /// - /// Called when no MultiWidget is available anymore. Should not be used anymore, see GetActiveMultiWidget() - /// \see GetActiveMultiWidget() - /// - virtual void MultiWidgetNotAvailable(); - /// - /// Only called when IsExclusiveFunctionality() returns true. - /// \see IsExclusiveFunctionality() - /// - virtual void Activated(); - /// - /// \return true if this view is currently activated, false otherwise - /// - bool IsActivated() const; - /// - /// Only called when IsExclusiveFunctionality() returns true. - /// \see IsExclusiveFunctionality() - /// - virtual void Deactivated(); - /// - /// Some functionalities need to add special interactors, removes the crosshair from the multiwidget, etc. - /// In this case the functionality has to tidy up when changing to another functionality - /// which also wants to change the "default configuration". In the old Qt3-based - /// version of MITK, two functionalities could never be opened at the same time so that the - /// methods Activated() and Deactivated() were the right place for the functionalitites to - /// add/remove their interactors, etc. This is still true for the new MITK Workbench, - /// but as there can be several functionalities visible at the same time, the behaviour concerning - /// when Activated() and Deactivated() are called has changed: - /// - /// 1. Activated() and Deactivated() are only called if IsExclusiveFunctionality() returns true - /// - /// 2. If only one standalone functionality is or becomes visible, Activated() will be called on that functionality - /// - /// 3. If two or more standalone functionalities are visible, - /// Activated() will be called on the functionality that receives focus, Deactivated() will be called - /// on the one that looses focus, gets hidden or closed - /// - /// - /// As a consequence of 1. if you overwrite IsExclusiveFunctionality() and let it return false, you - /// signalize the MITK Workbench that this functionality does nothing to the "default configuration" - /// and can easily be visible while other functionalities are also visible. - /// - /// By default the method returns true. - /// - /// \return true if this functionality is meant to work as a standalone view, false otherwise - /// - virtual bool IsExclusiveFunctionality() const; - /// - /// Informs other parts of the workbench that node is selected via the blueberry selection service. - /// - void FireNodeSelected(mitk::DataNode* node); - /// - /// Informs other parts of the workbench that the nodes are selected via the blueberry selection service. - /// - void FireNodesSelected(std::vector nodes); - /// - /// Called when this functionality becomes visible ( no matter what IsExclusiveFunctionality() returns ) - /// - virtual void Visible(); - /// - /// \return true if this view is currently visible, false otherwise - /// - bool IsVisible() const; - /// - /// Called when this functionality is hidden ( no matter what IsExclusiveFunctionality() returns ) - /// - virtual void Hidden(); -//# protected virtual methods which can be overwritten -protected: - /// - /// Called when a DataStorage Add event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void NodeAdded(const mitk::DataNode* node); - /// - /// Called when a DataStorage Changed event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void NodeChanged(const mitk::DataNode* /*node*/); - /// - /// Called when a DataStorage Remove event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void NodeRemoved(const mitk::DataNode* node); - /// - /// Called when a DataStorage add *or* remove *or* change event was thrown. May be reimplemented - /// by deriving classes. - /// - virtual void DataStorageChanged(); - /// - /// \return the selection of the currently active part of the workbench or an empty vector - /// if nothing is selected - /// - std::vector GetCurrentSelection() const; - /// - /// Returns the current selection made in the datamanager bundle or an empty vector - /// if nothing`s selected or if the bundle does not exist - /// - std::vector GetDataManagerSelection() const; - /// - /// Returns the Preferences object for this Functionality. - /// Important: When refering to this preferences, e.g. in a PreferencePage: The ID - /// for this preferences object is "/", e.g. "/org.mitk.views.datamanager" - /// - berry::IPreferences::Pointer GetPreferences() const; - /// - /// Returns the default or the currently active DataStorage if m_HandlesMultipleDataStorages - /// is set to true - /// \see SetHandleMultipleDataStorages(bool) - /// \see HandlesMultipleDataStorages() - /// - mitk::DataStorage::Pointer GetDataStorage() const; - /// - /// \return always returns the default DataStorage - /// - mitk::DataStorage::Pointer GetDefaultDataStorage() const; - - mitk::IDataStorageReference::Pointer GetDataStorageReference() const; - - /// - /// Returns the default and active MultiWidget. - /// \param reCreateWidget a boolean flag to en-/disable the attempt to re-create the StdWidget - /// If there is not MultiWidget yet a new one is - /// created in this method when called with default parameter! - /// - QmitkAbstractMultiWidget* GetActiveMultiWidget( bool reCreateWidget = true); - /// - /// Outputs an error message to the console and displays a message box containing - /// the exception description. - /// \param e the exception which should be handled - /// \param parent - /// \param showDialog controls, whether additionally a message box should be - /// displayed to inform the user that something went wrong - /// - void HandleException( std::exception& e, QWidget* parent = nullptr, bool showDialog = true ) const; - /// - /// Calls HandleException ( std::exception&, QWidget*, bool ) internally - /// \see HandleException ( std::exception&, QWidget*, bool ) - /// - void HandleException( const char* str, QWidget* parent = nullptr, bool showDialog = true ) const; - /// - /// Convenient method to set and reset a wait cursor ("hourglass") - /// - void WaitCursorOn(); - /// - /// Convenient method to restore the standard cursor - /// - void WaitCursorOff(); - /// - /// Convenient method to set and reset a busy cursor - /// - void BusyCursorOn(); - /// - /// Convenient method to restore the standard cursor - /// - void BusyCursorOff(); - /// - /// Convenient method to restore the standard cursor - /// - void RestoreOverrideCursor(); - -//# other public methods which should not be overwritten -public: - /// - /// Creates a scroll area for this view and calls CreateQtPartControl then - /// - void CreatePartControl(QWidget* parent) override; - /// - /// Called when this view receives the focus. Same as Activated() - /// \see Activated() - /// - void SetFocus() override; - /// - /// Called when a DataStorage Add Event was thrown. Sets - /// m_InDataStorageChanged to true and calls NodeAdded afterwards. - /// \see m_InDataStorageChanged - /// - void NodeAddedProxy(const mitk::DataNode* node); - /// - /// Called when a DataStorage remove event was thrown. Sets - /// m_InDataStorageChanged to true and calls NodeRemoved afterwards. - /// \see m_InDataStorageChanged - /// - void NodeRemovedProxy(const mitk::DataNode* node); - /// - /// Called when a DataStorage changed event was thrown. Sets - /// m_InDataStorageChanged to true and calls NodeChanged afterwards. - /// \see m_InDataStorageChanged - /// - void NodeChangedProxy(const mitk::DataNode* node); - /// - /// Toggles the visible flag m_Visible - /// - void SetVisible(bool visible); - /// - /// Toggles the activated flag m_Activated - /// - void SetActivated(bool activated); - /// - /// Called, when the WorkbenchPart gets closed for removing event listeners - /// Internally this method calls ClosePart after it removed the listeners registered - /// by QmitkFunctionality. By having this proxy method the user does not have to - /// call QmitkFunctionality::ClosePart() when overwriting ClosePart() - /// - void ClosePartProxy(); - -//# other protected methods which should not be overwritten (or which are deprecated) -protected: - /// - /// Called immediately after CreateQtPartControl(). - /// Here standard event listeners for a QmitkFunctionality are registered - /// - void AfterCreateQtPartControl(); - /// - /// code to activate the last visible functionality - /// - void ActivateLastVisibleFunctionality(); - /// - /// reactions to selection events from data manager (and potential other senders) - /// - void BlueBerrySelectionChanged(const berry::IWorkbenchPart::Pointer& sourcepart, const berry::ISelection::ConstPointer& selection); - /// - /// Converts a mitk::DataNodeSelection to a std::vector (possibly empty - /// - std::vector DataNodeSelectionToVector(mitk::DataNodeSelection::ConstPointer currentSelection) const; - //# protected fields -protected: - /// - /// helper stuff to observe BlueBerry selections - /// - friend struct berry::SelectionChangedAdapter; - /// - /// Saves the parent of this view (this is the scrollarea created in CreatePartControl(QWidget*) - /// \see CreatePartControl(QWidget*) - /// - QWidget* m_Parent; - /// - /// Saves if this view is the currently active one. - /// - bool m_Active; - /// - /// Saves if this view is visible - /// - bool m_Visible; - - //# private fields: - -private: - /// - /// Holds the current selection (selection made by this Functionality !!!) - /// - QmitkFunctionalitySelectionProvider* m_SelectionProvider; - /// - /// object to observe BlueBerry selections - /// - QScopedPointer m_BlueBerrySelectionListener; - - ctkServiceTracker m_DataStorageServiceTracker; - - - /// - /// Saves if this view handles multiple datastorages - /// - bool m_HandlesMultipleDataStorages; - /// - /// Saves if this class is currently working on DataStorage changes. - /// This is a protector variable to avoid recursive calls on event listener functions. - bool m_InDataStorageChanged; - /// - /// saves all visible functionalities - /// - std::set m_VisibleFunctionalities; -}; - -#endif /*QMITKFUNCTIONALITY_H_*/ diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality2.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality2.cpp deleted file mode 100644 index cc16019d2f..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionality2.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkFunctionality.h" -#include "internal/QmitkFunctionalityUtil.h" - -#include -#include - -#include - -std::vector QmitkFunctionality::GetCurrentSelection() const -{ - berry::ISelection::ConstPointer selection( this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection()); - // buffer for the data manager selection - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - return this->DataNodeSelectionToVector(currentSelection); -} - -std::vector QmitkFunctionality::GetDataManagerSelection() const -{ - berry::ISelection::ConstPointer selection( this->GetSite()->GetWorkbenchWindow()->GetSelectionService()->GetSelection("org.mitk.views.datamanager")); - // buffer for the data manager selection - mitk::DataNodeSelection::ConstPointer currentSelection = selection.Cast(); - return this->DataNodeSelectionToVector(currentSelection); -} - -void QmitkFunctionality::OnSelectionChanged(std::vector /*nodes*/) -{ -} - -std::vector QmitkFunctionality::DataNodeSelectionToVector(mitk::DataNodeSelection::ConstPointer currentSelection) const -{ - - std::vector selectedNodes; - if(currentSelection.IsNull()) - return selectedNodes; - - mitk::DataNodeObject* _DataNodeObject = nullptr; - mitk::DataNode* _DataNode = nullptr; - - for(mitk::DataNodeSelection::iterator it = currentSelection->Begin(); - it != currentSelection->End(); ++it) - { - _DataNodeObject = dynamic_cast((*it).GetPointer()); - if(_DataNodeObject) - { - _DataNode = _DataNodeObject->GetDataNode(); - if(_DataNode) - selectedNodes.push_back(_DataNode); - } - } - - return selectedNodes; -} - -void QmitkFunctionality::NodeAddedProxy( const mitk::DataNode* node ) -{ - // garantuee no recursions when a new node event is thrown in NodeAdded() - if(!m_InDataStorageChanged) - { - m_InDataStorageChanged = true; - this->NodeAdded(node); - this->DataStorageChanged(); - m_InDataStorageChanged = false; - } - -} - -void QmitkFunctionality::NodeAdded( const mitk::DataNode* /*node*/ ) -{ - -} - -void QmitkFunctionality::NodeRemovedProxy( const mitk::DataNode* node ) -{ - // garantuee no recursions when a new node event is thrown in NodeAdded() - if(!m_InDataStorageChanged) - { - m_InDataStorageChanged = true; - this->NodeRemoved(node); - this->DataStorageChanged(); - m_InDataStorageChanged = false; - } -} - -void QmitkFunctionality::NodeRemoved( const mitk::DataNode* /*node*/ ) -{ - -} - -void QmitkFunctionality::NodeChanged( const mitk::DataNode* /*node*/ ) -{ - -} - -void QmitkFunctionality::NodeChangedProxy( const mitk::DataNode* node ) -{ - // garantuee no recursions when a new node event is thrown in NodeAdded() - if(!m_InDataStorageChanged) - { - m_InDataStorageChanged = true; - this->NodeChanged(node); - this->DataStorageChanged(); - m_InDataStorageChanged = false; - } -} - -void QmitkFunctionality::FireNodeSelected( mitk::DataNode* node ) -{ - std::vector nodes; - nodes.push_back(node); - this->FireNodesSelected(nodes); -} - -void QmitkFunctionality::FireNodesSelected( std::vector nodes ) -{ - if( !m_SelectionProvider ) - return; - - std::vector nodesSmartPointers; - for (std::vector::iterator it = nodes.begin() - ; it != nodes.end(); it++) - { - nodesSmartPointers.push_back( *it ); - } - m_SelectionProvider->FireNodesSelected(nodesSmartPointers); - -} diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.cpp deleted file mode 100644 index 8caec50f33..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.cpp +++ /dev/null @@ -1,216 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - -#include "QmitkFunctionalityCoordinator.h" -#include "QmitkFunctionality.h" -#include -#include -#include - -#include - -QmitkFunctionalityCoordinator::QmitkFunctionalityCoordinator() - : m_StandaloneFuntionality(nullptr) -{ -} - -void QmitkFunctionalityCoordinator::Start() -{ - berry::PlatformUI::GetWorkbench()->AddWindowListener(this); - QList wnds(berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows()); - for (auto i = wnds.begin(); i != wnds.end(); ++i) - { - (*i)->GetPartService()->AddPartListener(this); - } -} - -void QmitkFunctionalityCoordinator::Stop() -{ - if (!berry::PlatformUI::IsWorkbenchRunning()) return; - - berry::PlatformUI::GetWorkbench()->RemoveWindowListener(this); - QList wnds(berry::PlatformUI::GetWorkbench()->GetWorkbenchWindows()); - for (auto i = wnds.begin(); i != wnds.end(); ++i) - { - (*i)->GetPartService()->RemovePartListener(this); - } -} - -QmitkFunctionalityCoordinator::~QmitkFunctionalityCoordinator() -{ -} - -berry::IPartListener::Events::Types QmitkFunctionalityCoordinator::GetPartEventTypes() const -{ - return berry::IPartListener::Events::ACTIVATED | berry::IPartListener::Events::DEACTIVATED - | berry::IPartListener::Events::CLOSED | berry::IPartListener::Events::HIDDEN - | berry::IPartListener::Events::VISIBLE | berry::IPartListener::Events::OPENED; -} - -void QmitkFunctionalityCoordinator::PartActivated( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // change the active standalone functionality - this->ActivateStandaloneFunctionality(partRef.GetPointer()); -} - -void QmitkFunctionalityCoordinator::PartDeactivated( const berry::IWorkbenchPartReference::Pointer& /*partRef*/ ) -{ - // nothing to do here: see PartActivated() -} - -void QmitkFunctionalityCoordinator::PartOpened( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // check for multiwidget and inform views that it is available now - if ( partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID ) - { - for (std::set::iterator it = m_Functionalities.begin() - ; it != m_Functionalities.end(); it++) - { - (*it)->MultiWidgetAvailable(*(partRef - ->GetPart(false).Cast()->GetMultiWidget())); - } - } - else - { - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality.IsNotNull()) - { - m_Functionalities.insert(_QmitkFunctionality.GetPointer()); // save as opened functionality - } - } -} - -void QmitkFunctionalityCoordinator::PartClosed( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // check for multiwidget and inform views that it not available any more - if ( partRef->GetId() == QmitkStdMultiWidgetEditor::EDITOR_ID ) - { - - QmitkStdMultiWidgetEditor::Pointer stdMultiWidgetEditor = partRef->GetPart(false).Cast(); - for (std::set::iterator it = m_Functionalities.begin() - ; it != m_Functionalities.end(); it++) - { - (*it)->MultiWidgetClosed(*(stdMultiWidgetEditor->GetMultiWidget())); - (*it)->MultiWidgetNotAvailable(); // deprecated call, provided for consistence - } - } - else - { - // check for functionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality.IsNotNull()) - { - // deactivate on close ( the standalone functionality may still be activated ) - this->DeactivateStandaloneFunctionality(partRef.GetPointer(), nullptr); - - // and set pointer to 0 - if(m_StandaloneFuntionality == partRef.GetPointer()) - m_StandaloneFuntionality = nullptr; - - m_Functionalities.erase(_QmitkFunctionality.GetPointer()); // remove as opened functionality - - // call PartClosed on the QmitkFunctionality - _QmitkFunctionality->ClosePartProxy(); - //m_VisibleStandaloneFunctionalities.erase(_QmitkFunctionality.GetPointer()); // remove if necessary (should be done before in PartHidden() - } - } -} - -void QmitkFunctionalityCoordinator::PartHidden( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality != 0) - { - _QmitkFunctionality->SetVisible(false); - _QmitkFunctionality->Hidden(); - - // tracking of Visible Standalone Functionalities - m_VisibleStandaloneFunctionalities.erase(partRef.GetPointer()); - - // activate Functionality if just one Standalone Functionality is visible - if( m_VisibleStandaloneFunctionalities.size() == 1 ) - this->ActivateStandaloneFunctionality( *m_VisibleStandaloneFunctionalities.begin() ); - } -} - -void QmitkFunctionalityCoordinator::PartVisible( const berry::IWorkbenchPartReference::Pointer& partRef ) -{ - // Check for QmitkFunctionality - QmitkFunctionality::Pointer _QmitkFunctionality = partRef->GetPart(false).Cast(); - if(_QmitkFunctionality.IsNotNull()) - { - _QmitkFunctionality->SetVisible(true); - _QmitkFunctionality->Visible(); - - // tracking of Visible Standalone Functionalities - if( _QmitkFunctionality->IsExclusiveFunctionality() ) - { - m_VisibleStandaloneFunctionalities.insert(partRef.GetPointer()); - - // activate Functionality if just one Standalone Functionality is visible - if( m_VisibleStandaloneFunctionalities.size() == 1 ) - this->ActivateStandaloneFunctionality( *m_VisibleStandaloneFunctionalities.begin() ); - } - } -} - -void QmitkFunctionalityCoordinator::ActivateStandaloneFunctionality( berry::IWorkbenchPartReference* partRef ) -{ - QmitkFunctionality* functionality = dynamic_cast(partRef->GetPart(false).GetPointer()); - if( functionality && !functionality->IsActivated() && functionality->IsExclusiveFunctionality() ) - { - MITK_INFO << "**** Activating legacy standalone functionality"; - // deactivate old one if necessary - this->DeactivateStandaloneFunctionality(m_StandaloneFuntionality, partRef); - m_StandaloneFuntionality = partRef; - - MITK_INFO << "setting active flag"; - // call activated on this functionality - functionality->SetActivated(true); - functionality->Activated(); - } - else if (dynamic_cast(partRef->GetPart(false).GetPointer()) && - m_StandaloneFuntionality != partRef) - { - this->DeactivateStandaloneFunctionality(m_StandaloneFuntionality, partRef); - m_StandaloneFuntionality = partRef; - } -} - -void QmitkFunctionalityCoordinator::DeactivateStandaloneFunctionality(berry::IWorkbenchPartReference* partRef, - berry::IWorkbenchPartReference* newRef) -{ - if (partRef == nullptr) return; - - QmitkFunctionality* functionality = dynamic_cast(partRef->GetPart(false).GetPointer()); - if(functionality && functionality->IsActivated()) - { - functionality->SetActivated(false); - functionality->Deactivated(); - } - else if (mitk::IZombieViewPart* zombie = dynamic_cast(partRef->GetPart(false).GetPointer())) - { - zombie->ActivatedZombieView(berry::IWorkbenchPartReference::Pointer(newRef)); - } -} - -void QmitkFunctionalityCoordinator::WindowClosed(const berry::IWorkbenchWindow::Pointer& /*window*/ ) -{ - -} - -void QmitkFunctionalityCoordinator::WindowOpened(const berry::IWorkbenchWindow::Pointer& window ) -{ - window->GetPartService()->AddPartListener(this); -} diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.h b/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.h deleted file mode 100644 index c8b1075222..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/QmitkFunctionalityCoordinator.h +++ /dev/null @@ -1,117 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef QmitkFunctionalityCoordinator_h -#define QmitkFunctionalityCoordinator_h - -#include -#include -#include - -#include -#include - -class QmitkFunctionality; - -/// -/// \ingroup org_mitk_gui_qt_common_legacy -/// -/// A class which coordinates active QmitkFunctionalities, e.g. calling activated and hidden on them. -/// -class MITK_QT_COMMON_LEGACY QmitkFunctionalityCoordinator : virtual public berry::IPartListener, virtual public berry::IWindowListener -{ -public: - - QmitkFunctionalityCoordinator(); - - ~QmitkFunctionalityCoordinator() override; - - /// - /// Add listener - /// - void Start(); - - /// - /// Remove listener - /// - void Stop(); - - //#IPartListener methods (these methods internally call Activated() or other similar methods) - /// - /// \see IPartListener::GetPartEventTypes() - /// - berry::IPartListener::Events::Types GetPartEventTypes() const override; - /// - /// \see IPartListener::PartActivated() - /// - void PartActivated (const berry::IWorkbenchPartReference::Pointer& partRef) override; - /// - /// \see IPartListener::PartDeactivated() - /// - void PartDeactivated(const berry::IWorkbenchPartReference::Pointer& /*partRef*/) override; - /// - /// \see IPartListener::PartOpened() - /// - void PartOpened(const berry::IWorkbenchPartReference::Pointer& partRef) override; - /// - /// \see IPartListener::PartClosed() - /// - void PartClosed (const berry::IWorkbenchPartReference::Pointer& partRef) override; - /// - /// \see IPartListener::PartHidden() - /// - void PartHidden (const berry::IWorkbenchPartReference::Pointer& partRef) override; - /// - /// \see IPartListener::PartVisible() - /// - void PartVisible (const berry::IWorkbenchPartReference::Pointer& partRef) override; - - /** - * Notifies this listener that the given window has been closed. - */ - void WindowClosed(const berry::IWorkbenchWindow::Pointer& window) override; - - /** - * Notifies this listener that the given window has been opened. - */ - void WindowOpened(const berry::IWorkbenchWindow::Pointer& /*window*/) override; - -protected: - /// - /// Activates the standalone functionality - /// - void ActivateStandaloneFunctionality(berry::IWorkbenchPartReference *partRef); - /// - /// Deactivates the standalone functionality - /// - void DeactivateStandaloneFunctionality(berry::IWorkbenchPartReference *functionality, berry::IWorkbenchPartReference *newRef); - /// - /// Saves the workbench window - /// - berry::IWorkbenchWindow::WeakPtr m_Window; - /// - /// Saves the last part that added interactors - /// - berry::IWorkbenchPartReference* m_StandaloneFuntionality; - - /// - /// Saves all opened QmitkFclassunctionalities - /// - std::set m_Functionalities; - /// - /// Saves all visible QmitkFunctionalities - /// - std::set m_VisibleStandaloneFunctionalities; -}; - -#endif // QmitkFunctionalityCoordinator_h diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp index 38dd4642cd..21ae105377 100644 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp +++ b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.cpp @@ -1,47 +1,45 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #include "QmitkCommonLegacyActivator.h" #include #include ctkPluginContext* QmitkCommonLegacyActivator::m_Context = nullptr; void QmitkCommonLegacyActivator::start(ctkPluginContext* context) { Q_UNUSED(context) if(berry::PlatformUI::IsWorkbenchRunning()) { - m_FunctionalityCoordinator.Start(); m_Context = context; } else { MITK_ERROR << "BlueBerry Workbench not running!"; } } void QmitkCommonLegacyActivator::stop(ctkPluginContext* context) { Q_UNUSED(context) - m_FunctionalityCoordinator.Stop(); m_Context = nullptr; } ctkPluginContext*QmitkCommonLegacyActivator::GetContext() { return m_Context; } diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h index 49407c0bc3..6fc454d68b 100644 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h +++ b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkCommonLegacyActivator.h @@ -1,49 +1,45 @@ /*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef QMITKCOMMONLEGACYACTIVATOR_H_ #define QMITKCOMMONLEGACYACTIVATOR_H_ #include -#include "QmitkFunctionalityCoordinator.h" - /** * \ingroup org_mitk_gui_qt_common_legacy_internal */ class QmitkCommonLegacyActivator : public QObject, public ctkPluginActivator { Q_OBJECT Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_common_legacy") Q_INTERFACES(ctkPluginActivator) public: /** * Sets default StateMachine to EventMapper. */ void start(ctkPluginContext* context) override; void stop(ctkPluginContext* context) override; static ctkPluginContext* GetContext(); private: - QmitkFunctionalityCoordinator m_FunctionalityCoordinator; - static ctkPluginContext* m_Context; }; #endif /* QMITKCOMMONLEGACYACTIVATOR_H_ */ diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.cpp b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.cpp deleted file mode 100644 index dcff198c77..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#include "QmitkFunctionalityUtil.h" - -#include "../QmitkFunctionality.h" - -QmitkFunctionalitySelectionProvider::QmitkFunctionalitySelectionProvider( QmitkFunctionality* _Functionality ) -: m_Functionality(_Functionality) -{ - -} - -QmitkFunctionalitySelectionProvider::~QmitkFunctionalitySelectionProvider() -{ - m_Functionality = nullptr; -} - -void QmitkFunctionalitySelectionProvider::AddSelectionChangedListener( berry::ISelectionChangedListener* listener ) -{ - m_SelectionEvents.AddListener(listener); -} - - -berry::ISelection::ConstPointer QmitkFunctionalitySelectionProvider::GetSelection() const -{ - return m_CurrentSelection; -} - -void QmitkFunctionalitySelectionProvider::RemoveSelectionChangedListener( berry::ISelectionChangedListener* listener ) -{ - m_SelectionEvents.RemoveListener(listener); -} - -void QmitkFunctionalitySelectionProvider::SetSelection(const berry::ISelection::ConstPointer& selection ) -{ - m_CurrentSelection = selection.Cast(); -} - -void QmitkFunctionalitySelectionProvider::FireNodesSelected(const std::vector& nodes ) -{ - mitk::DataNodeSelection::Pointer sel(new mitk::DataNodeSelection(nodes)); - m_CurrentSelection = sel; - berry::SelectionChangedEvent::Pointer event(new berry::SelectionChangedEvent(berry::ISelectionProvider::Pointer(this) - , m_CurrentSelection)); - m_SelectionEvents.selectionChanged(event); - -} diff --git a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.h b/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.h deleted file mode 100644 index 14c7521f6f..0000000000 --- a/Plugins/org.mitk.gui.qt.common.legacy/src/internal/QmitkFunctionalityUtil.h +++ /dev/null @@ -1,79 +0,0 @@ -/*============================================================================ - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center (DKFZ) -All rights reserved. - -Use of this source code is governed by a 3-clause BSD license that can be -found in the LICENSE file. - -============================================================================*/ - - -#ifndef QMITKFUNCTIONALITYUTIL_H -#define QMITKFUNCTIONALITYUTIL_H - -#include - -class QmitkFunctionality; - -#include -#include - -/// -/// Internal class for selection providing -/// -class QmitkFunctionalitySelectionProvider: public berry::ISelectionProvider -{ - -public: - - /// - /// Creates smartpointer typedefs - /// - berryObjectMacro(QmitkFunctionalitySelectionProvider); - - QmitkFunctionalitySelectionProvider(QmitkFunctionality* _Functionality); - - ~QmitkFunctionalitySelectionProvider() override; - - //# ISelectionProvider methods - /// - /// \see ISelectionProvider::AddSelectionChangedListener() - /// - void AddSelectionChangedListener(berry::ISelectionChangedListener* listener) override; - /// - /// \see ISelectionProvider::GetSelection() - /// - berry::ISelection::ConstPointer GetSelection() const override; - /// - /// \see ISelectionProvider::RemoveSelectionChangedListener() - /// - void RemoveSelectionChangedListener(berry::ISelectionChangedListener* listener) override; - /// - /// \see ISelectionProvider::SetSelection() - /// - void SetSelection(const berry::ISelection::ConstPointer& selection) override; - /// - /// Sends the nodes as selected to the workbench - /// - void FireNodesSelected(const std::vector& nodes ); - -protected: - - /// - /// the functionality parent - /// - QmitkFunctionality* m_Functionality; - /// - /// Holds the current selection (selection made by m_Functionality !!!) - /// - mitk::DataNodeSelection::ConstPointer m_CurrentSelection; - /// - /// The selection events other parts can listen too - /// - berry::ISelectionChangedListener::Events m_SelectionEvents; -}; - -#endif // QMITKFUNCTIONALITYUTIL_H