00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef QMITKFUNCTIONALITY_H_ 00019 #define QMITKFUNCTIONALITY_H_ 00020 00021 #ifdef __MINGW32__ 00022 // We need to inlclude winbase.h here in order to declare 00023 // atomic intrinsics like InterlockedIncrement correctly. 00024 // Otherwhise, they would be declared wrong within qatomic_windows.h . 00025 #include <windows.h> 00026 #endif 00027 00028 //# blueberry stuff 00029 #include <berryQtViewPart.h> 00030 #include <berryIWorkbenchPartReference.h> 00031 #include <berryIPreferencesService.h> 00032 #include <berryIBerryPreferences.h> 00033 #include <berryISelectionListener.h> 00034 #include <berryISelectionProvider.h> 00035 #include <berryISelectionChangedListener.h> 00036 00037 //# mitk stuff 00038 #include "mitkQtCommonDll.h" 00039 #include "mitkDataNodeSelection.h" 00040 #include <mitkDataStorage.h> 00041 #include <mitkDataNodeSelection.h> 00042 00043 //# forward declarations 00044 class QmitkStdMultiWidget; 00045 class QScrollArea; 00046 00067 class MITK_QT_COMMON QmitkFunctionality : public berry::QtViewPart 00068 { 00069 00070 //# public virtual methods which can be overwritten 00071 public: 00075 berryObjectMacro(QmitkFunctionality) 00080 QmitkFunctionality(); 00084 virtual ~QmitkFunctionality(); 00090 virtual void ClosePart(); 00094 virtual void OnSelectionChanged(std::vector<mitk::DataNode*> /*nodes*/); 00099 virtual void OnPreferencesChanged(const berry::IBerryPreferences*); 00105 void SetHandleMultipleDataStorages(bool multiple); 00109 bool HandlesMultipleDataStorages() const; 00114 virtual void StdMultiWidgetAvailable(QmitkStdMultiWidget& stdMultiWidget); 00119 virtual void StdMultiWidgetClosed(QmitkStdMultiWidget& stdMultiWidget); 00124 virtual void StdMultiWidgetNotAvailable(); 00129 virtual void Activated(); 00133 bool IsActivated() const; 00138 virtual void Deactivated(); 00166 virtual bool IsExclusiveFunctionality() const; 00170 void FireNodeSelected(mitk::DataNode* node); 00174 void FireNodesSelected(std::vector<mitk::DataNode*> nodes); 00178 virtual void Visible(); 00182 bool IsVisible() const; 00186 virtual void Hidden(); 00187 //# protected virtual methods which can be overwritten 00188 protected: 00193 virtual void NodeAdded(const mitk::DataNode* node); 00198 virtual void NodeChanged(const mitk::DataNode* /*node*/); 00203 virtual void NodeRemoved(const mitk::DataNode* node); 00208 virtual void DataStorageChanged(); 00213 std::vector<mitk::DataNode*> GetCurrentSelection() const; 00218 std::vector<mitk::DataNode*> GetDataManagerSelection() const; 00224 berry::IPreferences::Pointer GetPreferences() const; 00231 mitk::DataStorage::Pointer GetDataStorage() const; 00235 mitk::DataStorage::Pointer GetDefaultDataStorage() const; 00240 QmitkStdMultiWidget* GetActiveStdMultiWidget(); 00248 void HandleException( std::exception& e, QWidget* parent = NULL, bool showDialog = true ) const; 00253 void HandleException( const char* str, QWidget* parent = NULL, bool showDialog = true ) const; 00257 void WaitCursorOn(); 00261 void WaitCursorOff(); 00265 void BusyCursorOn(); 00269 void BusyCursorOff(); 00273 void RestoreOverrideCursor(); 00274 00275 //# other public methods which should not be overwritten 00276 public: 00280 void CreatePartControl(void* parent); 00285 void SetFocus(); 00291 void NodeAddedProxy(const mitk::DataNode* node); 00297 void NodeRemovedProxy(const mitk::DataNode* node); 00303 void NodeChangedProxy(const mitk::DataNode* node); 00307 void SetVisible(bool visible); 00311 void SetActivated(bool activated); 00318 void ClosePartProxy(); 00319 00323 class SelectionProvider: virtual public berry::Object, virtual public berry::ISelectionProvider 00324 { 00325 public: 00329 berryObjectMacro(QmitkFunctionality::SelectionProvider) 00333 berryNewMacro1Param(QmitkFunctionality::SelectionProvider, QmitkFunctionality*) 00334 //# ISelectionProvider methods 00338 virtual void AddSelectionChangedListener(berry::ISelectionChangedListener::Pointer listener); 00342 virtual berry::ISelection::ConstPointer GetSelection() const; 00346 virtual void RemoveSelectionChangedListener(berry::ISelectionChangedListener::Pointer listener); 00350 virtual void SetSelection(berry::ISelection::Pointer selection); 00354 void FireNodesSelected( std::vector<mitk::DataNode::Pointer> nodes ); 00355 protected: 00359 SelectionProvider(QmitkFunctionality* _Functionality); 00363 virtual ~SelectionProvider(); 00367 QmitkFunctionality* m_Functionality; 00371 mitk::DataNodeSelection::Pointer m_CurrentSelection; 00375 berry::ISelectionChangedListener::Events m_SelectionEvents; 00376 }; 00377 00378 //# other protected methods which should not be overwritten (or which are deprecated) 00379 protected: 00384 void AfterCreateQtPartControl(); 00388 void ActivateLastVisibleFunctionality(); 00392 void BlueBerrySelectionChanged(berry::IWorkbenchPart::Pointer sourcepart, berry::ISelection::ConstPointer selection); 00396 std::vector<mitk::DataNode*> DataNodeSelectionToVector(mitk::DataNodeSelection::ConstPointer currentSelection) const; 00397 //# protected fields 00398 protected: 00402 friend struct berry::SelectionChangedAdapter<QmitkFunctionality>; 00407 QWidget* m_Parent; 00411 bool m_Active; 00415 bool m_Visible; 00416 00417 //# private fields: 00418 private: 00422 SelectionProvider* m_SelectionProvider; 00426 berry::ISelectionListener::Pointer m_BlueBerrySelectionListener; 00430 bool m_HandlesMultipleDataStorages; 00434 bool m_InDataStorageChanged; 00438 std::set<std::string> m_VisibleFunctionalities; 00442 berry::IPreferencesService::WeakPtr m_PreferencesService; 00443 }; 00444 00445 #endif /*QMITKFUNCTIONALITY_H_*/