diff --git a/CMake/mitkModuleInit.cpp b/CMake/mitkModuleInit.cpp index 90c174b18f..c83234403b 100644 --- a/CMake/mitkModuleInit.cpp +++ b/CMake/mitkModuleInit.cpp @@ -1,84 +1,80 @@ -/*============================================================================= +/*========================================================================= - Library: CTK +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ - Copyright (c) German Cancer Research Center, - Division of Medical and Biological Informatics +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ +=========================================================================*/ #include "mitkStaticInit.h" #include "mitkModuleRegistry.h" #include "mitkModuleContext.h" #include "mitkModule.h" #include "mitkModuleInfo.h" #include "mitkModuleUtils.h" namespace mitk { MITK_GLOBAL_STATIC_WITH_ARGS(ModuleInfo, moduleInfo, ("@MODULE_NAME@", "@MODULE_LIBNAME@", "@MODULE_DEPENDS_STR@", "@MODULE_PACKAGE_DEPENDS_STR@", "@MODULE_VERSION@", @MODULE_QT_BOOL@)) class MITK_LOCAL ModuleInitializer { public: ModuleInitializer() { std::string location = ModuleUtils::GetLibraryPath(moduleInfo()->libName, (void*)moduleInfo); std::string activator_func = "_mitk_module_activator_instance_"; activator_func.append(moduleInfo()->name); moduleInfo()->location = location; if (moduleInfo()->libName.empty()) { // make sure we retrieve symbols from the executable, if "libName" is empty location.clear(); } moduleInfo()->activatorHook = (ModuleInfo::ModuleActivatorHook)ModuleUtils::GetSymbol(location, activator_func.c_str()); Register(); } static void Register() { ModuleRegistry::Register(moduleInfo()); } ~ModuleInitializer() { ModuleRegistry::UnRegister(moduleInfo()); } }; ModuleContext* GetModuleContext() { // make sure the module is registered if (moduleInfo()->id == 0) { ModuleInitializer::Register(); } return ModuleRegistry::GetModule(moduleInfo()->id)->GetModuleContext(); } } static mitk::ModuleInitializer coreModule; diff --git a/Core/Code/Service/mitkServiceInterface.h b/Core/Code/Service/mitkServiceInterface.h index 725c61495e..80a059a657 100644 --- a/Core/Code/Service/mitkServiceInterface.h +++ b/Core/Code/Service/mitkServiceInterface.h @@ -1,50 +1,46 @@ -/*============================================================================= +/*========================================================================= - Library: CTK +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ - Copyright (c) German Cancer Research Center, - Division of Medical and Biological Informatics +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ +=========================================================================*/ #ifndef MITKSERVICEINTERFACE_H #define MITKSERVICEINTERFACE_H template inline const char* mitk_service_interface_iid() { return 0; } #if defined(QT_DEBUG) || defined(QT_NODEBUG) #include #define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId) \ template <> inline const char* qobject_interface_iid() \ { return IId; } \ template <> inline const char* mitk_service_interface_iid() \ { return IId; } \ template <> inline IFace *qobject_cast(QObject *object) \ { return reinterpret_cast((object ? object->qt_metacast(IId) : 0)); } \ template <> inline IFace *qobject_cast(const QObject *object) \ { return reinterpret_cast((object ? const_cast(object)->qt_metacast(IId) : 0)); } #else #define MITK_DECLARE_SERVICE_INTERFACE(IFace, IId) \ template <> inline const char* mitk_service_interface_iid() \ { return IId; } \ #endif #endif // MITKSERVICEINTERFACE_H diff --git a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.cpp b/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.cpp index d0def44ac3..afe696f36f 100644 --- a/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.cpp +++ b/CoreUI/Bundles/org.mitk.gui.common/src/mitkDataNodeSelection.cpp @@ -1,91 +1,91 @@ /*========================================================================= - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. - =========================================================================*/ +=========================================================================*/ #include "mitkDataNodeSelection.h" #include "mitkDataNodeObject.h" namespace mitk { DataNodeSelection::DataNodeSelection() : m_Selection(new ContainerType()) { } DataNodeSelection::DataNodeSelection(DataNode::Pointer node) : m_Selection(new ContainerType()) { DataNodeObject::Pointer obj(new DataNodeObject(node)); m_Selection->push_back(obj); } DataNodeSelection::DataNodeSelection(const std::vector& nodes) : m_Selection(new ContainerType()) { for (std::vector::const_iterator i = nodes.begin(); i != nodes.end(); ++i) { DataNodeObject::Pointer obj(new DataNodeObject(*i)); m_Selection->push_back(obj); } } berry::Object::Pointer DataNodeSelection::GetFirstElement() const { if (m_Selection->empty()) return berry::Object::Pointer(); return *(m_Selection->begin()); } berry::IStructuredSelection::iterator DataNodeSelection::Begin() const { return m_Selection->begin(); } berry::IStructuredSelection::iterator DataNodeSelection::End() const { return m_Selection->end(); } int DataNodeSelection::Size() const { return m_Selection->size(); } berry::IStructuredSelection::ContainerType::Pointer DataNodeSelection::ToVector() const { return m_Selection; } bool DataNodeSelection::IsEmpty() const { return m_Selection->empty(); } bool DataNodeSelection::operator==(const berry::Object* obj) const { if (const berry::IStructuredSelection* other = dynamic_cast(obj)) { return m_Selection == other->ToVector(); } return false; } } diff --git a/CoreUI/Qmitk/QmitkCustomVariants.h b/CoreUI/Qmitk/QmitkCustomVariants.h index 3aca1aa8a8..fdbbd0628e 100755 --- a/CoreUI/Qmitk/QmitkCustomVariants.h +++ b/CoreUI/Qmitk/QmitkCustomVariants.h @@ -1,27 +1,27 @@ /*========================================================================= - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. - =========================================================================*/ +=========================================================================*/ #ifndef QMITKCUSTOMVARIANTS_H_ #define QMITKCUSTOMVARIANTS_H_ #include Q_DECLARE_METATYPE(mitk::DataNode::Pointer) Q_DECLARE_METATYPE(mitk::DataNode*) #endif /* QMITKCUSTOMVARIANTS_H_ */ diff --git a/CoreUI/Qmitk/QmitkEnums.h b/CoreUI/Qmitk/QmitkEnums.h index 892ea88158..641138711b 100755 --- a/CoreUI/Qmitk/QmitkEnums.h +++ b/CoreUI/Qmitk/QmitkEnums.h @@ -1,27 +1,27 @@ /*========================================================================= - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. - =========================================================================*/ +=========================================================================*/ #ifndef QMITKENUMS_H_ #define QMITKENUMS_H_ enum QmitkItemModelRole { QmitkDataNodeRole = 64 }; #endif /* QMITKENUMS_H_ */ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.cpp b/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.cpp index 86e4e3e7e7..f492b8291f 100644 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.cpp +++ b/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.cpp @@ -1,31 +1,31 @@ /*========================================================================= -Program: BlueBerry Platform +Program: Medical Imaging & Interaction Toolkit Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ +Date: $Date$ +Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include "mitkIInputDeviceRegistry.h" const std::string mitk::CoreExtConstants::INPUTDEVICE_SERVICE = "org.mitk.core.ext.services.inputdeviceregistry"; const std::string mitk::CoreExtConstants::INPUTDEVICE_PREFERENCES = "org.mitk.core.ext.preferences.inputdevices"; const std::string mitk::CoreExtConstants::INPUTDEVICE_EXTENSION_NAME = "org.mitk.core.ext.inputdevices"; const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS = "class"; const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION = "description"; const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_NAME = "name"; const std::string mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_ID = "id"; const std::string mitk::CoreExtConstants::WIIMOTE_SURFACEINTERACTION = "Surface Interaction"; const std::string mitk::CoreExtConstants::WIIMOTE_HEADTRACKING = "Headtracking"; const std::string mitk::CoreExtConstants::WIIMOTE_XMLATTRIBUTE_NAME = "org.mitk.inputdevices.wiimote"; diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.h b/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.h index ef6526b139..4b7cae4abd 100644 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.h +++ b/Modules/Bundles/org.mitk.core.ext/src/mitkCoreExtConstants.h @@ -1,54 +1,54 @@ /*========================================================================= -Program: BlueBerry Platform +Program: Medical Imaging & Interaction Toolkit Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ +Date: $Date$ +Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKCOREEXTCONSTANTS_H_ #define MITKCOREEXTCONSTANTS_H_ #include #include namespace mitk { /** * The CoreExt Constants contains a list of unique ids in the following form:
* "org.mitk.mybundle.mytype.propername"
* * This ids have the purpose of connecting the plugin.xml of each bundle to the * appropriate classes. * * Additionally it includes names of tags, which are used in XML files
* regarding any input device. * * @ingroup org_mitk_core_ext */ struct MITKCOREEXT_EXPORT CoreExtConstants { static const std::string INPUTDEVICE_SERVICE; static const std::string INPUTDEVICE_PREFERENCES; static const std::string INPUTDEVICE_EXTENSION_NAME; static const std::string INPUTDEVICE_XMLATTRIBUTE_CLASS; static const std::string INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION; static const std::string INPUTDEVICE_XMLATTRIBUTE_NAME; static const std::string INPUTDEVICE_XMLATTRIBUTE_ID; static const std::string WIIMOTE_SURFACEINTERACTION; static const std::string WIIMOTE_HEADTRACKING; static const std::string WIIMOTE_XMLATTRIBUTE_NAME; }; } #endif /*MITKCOREEXTCONSTANTS_H_*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDevice.h b/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDevice.h index f89e3901e3..ca8ae7603a 100644 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDevice.h +++ b/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDevice.h @@ -1,57 +1,57 @@ /*========================================================================= -Program: BlueBerry Platform +Program: Medical Imaging & Interaction Toolkit Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ +Date: $Date$ +Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKIINPUTDEVICE_H_ #define MITKIINPUTDEVICE_H_ #include #include #include namespace mitk { /** * An input device provides a method to register and unregister itself. Meaning
* for example adding listeners and instianciate classes necessary to use the input device. * * @noimplement This interface is not intended to be implemented by clients. * @ingroup org_mitk_core_ext */ struct IInputDevice : public berry::Object { berryInterfaceMacro(IInputDevice, mitk) /** * Register the input device at one or more instances. */ virtual bool RegisterInputDevice() = 0; /** * Unregister the input device at one or more instances. */ virtual bool UnRegisterInputDevice() = 0; virtual ~IInputDevice() {} }; // end struct IInputDevice } // end namespace mitk Q_DECLARE_INTERFACE(mitk::IInputDevice, "org.mitk.IInputDevice") #endif /*MITKIINPUTDEVICE_H_*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h b/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h index 71dc02fe16..2c02905d65 100644 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h +++ b/Modules/Bundles/org.mitk.core.ext/src/mitkIInputDeviceRegistry.h @@ -1,77 +1,77 @@ /*========================================================================= - -Program: BlueBerry Platform + +Program: Medical Imaging & Interaction Toolkit Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ - +Date: $Date$ +Version: $Revision$ + Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - + This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. - + =========================================================================*/ #ifndef MITKIINPUTDEVICEREGISTRY_H_ #define MITKIINPUTDEVICEREGISTRY_H_ #include #include #include #include #include #include "mitkIInputDeviceDescriptor.h" namespace mitk { /** * * The input device registry maintains a list of input devices explicitly registered * against the view extension point. *

* The description of a given input device is kept in a IInputDeviceDescriptor. *

*

* This interface is not intended to be implemented by clients. *

* * @see mitk::IInputDeviceDescriptor * @noimplement This interface is not intended to be implemented by clients. * @ingroup org_mitk_core_ext */ struct MITKCOREEXT_EXPORT IInputDeviceRegistry: public berry::Service { berryInterfaceMacro(IInputDeviceRegistry, mitk) /** * Return an input device descriptor with the given extension id. If no input device exists, * with the id return null. * * @param id * the id to search for * @return the descriptor or null */ virtual IInputDeviceDescriptor::Pointer Find(const std::string& id) const = 0; /** * Return a list of input devices defined in the registry. * * @return the input devices. */ virtual std::vector GetInputDevices() const = 0; virtual ~IInputDeviceRegistry() {} }; // end struct IInputDeviceRegistry } // end namespace mitk Q_DECLARE_INTERFACE(mitk::IInputDeviceRegistry, "org.mitk.service.IInputDeviceRegistry") #endif /*MITKIINPUTDEVICEREGISTRY_H_*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp index 170a44c470..d98d818f4b 100644 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp +++ b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.cpp @@ -1,84 +1,84 @@ /*========================================================================= -Program: BlueBerry Platform +Program: Medical Imaging & Interaction Toolkit Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ +Date: $Date$ +Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include "mitkInputDeviceDescriptor.h" #include "mitkCoreExtConstants.h" mitk::InputDeviceDescriptor::InputDeviceDescriptor(berry::IConfigurationElement::Pointer inputDeviceExtensionPoint) : IInputDeviceDescriptor(), m_InputDeviceExtensionPoint(inputDeviceExtensionPoint) { } mitk::InputDeviceDescriptor::~InputDeviceDescriptor() { } mitk::IInputDevice::Pointer mitk::InputDeviceDescriptor::CreateInputDevice() { if(this->m_InputDevice == 0) { // "class" refers to xml attribute in a xml tag this->m_InputDevice = this->m_InputDeviceExtensionPoint ->CreateExecutableExtension(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS); if (this->m_InputDevice == 0) { // support legacy BlueBerry extensions this->m_InputDevice = this->m_InputDeviceExtensionPoint ->CreateExecutableExtension( mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_CLASS, IInputDevice::GetManifestName()); } } return this->m_InputDevice; } std::string mitk::InputDeviceDescriptor::GetID() const { std::string idOfExtensionPoint; this->m_InputDeviceExtensionPoint->GetAttribute(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_ID,idOfExtensionPoint); return idOfExtensionPoint; } std::string mitk::InputDeviceDescriptor::GetDescription() const { std::vector descriptions(this->m_InputDeviceExtensionPoint->GetChildren(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_DESCRIPTION)); if(!descriptions.empty()) { return descriptions[0]->GetValue(); } return ""; } std::string mitk::InputDeviceDescriptor::GetName() const { std::string name; this->m_InputDeviceExtensionPoint->GetAttribute(mitk::CoreExtConstants::INPUTDEVICE_XMLATTRIBUTE_NAME,name); return name; } bool mitk::InputDeviceDescriptor::operator==(const Object* object) const { if (const InputDeviceDescriptor* other = dynamic_cast(object)) { return this->GetID() == other->GetID(); } return false; } diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h index d91fe09689..ca40817db1 100644 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h +++ b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceDescriptor.h @@ -1,88 +1,88 @@ /*========================================================================= -Program: BlueBerry Platform +Program: Medical Imaging & Interaction Toolkit Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sat, 16 Jan 2010) $ -Version: $Revision: 21070 $ +Date: $Date$ +Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKINPUTDEVICEDESCRIPTOR_H_ #define MITKINPUTDEVICEDESCRIPTOR_H_ #include #include #include "mitkIInputDeviceDescriptor.h" #include "mitkIInputDevice.h" namespace mitk { /** * Documentation in the interface. * * @see mitk::IInputDeviceDescriptor * @ingroup org_mitk_core_ext */ class InputDeviceDescriptor : public IInputDeviceDescriptor { public: /** * Initialize the Input Device Descriptor with the given extension point. * * @param inputDeviceExtensionPoint * element, that refers to a extension point (type, id, name, class) */ InputDeviceDescriptor(berry::IConfigurationElement::Pointer inputDeviceExtensionPoint); /** * Default destructor */ ~InputDeviceDescriptor(); /** * @see mitk::IInputDeviceDescriptor::CreateInputDevice() */ mitk::IInputDevice::Pointer CreateInputDevice(); /** * @see mitk::IInputDeviceDescriptor::GetDescription() */ std::string GetDescription() const; /** * @see mitk::IInputDeviceDescriptor::GetID() */ std::string GetID() const; /** * @see mitk::IInputDeviceDescriptor::GetName() */ std::string GetName() const; /** * @see mitk::IInputDeviceDescriptor::operator==(const Object* object) */ bool operator==(const Object* object) const; private: // IConfigurationElements are used to access xml files (here: plugin.xml) berry::IConfigurationElement::Pointer m_InputDeviceExtensionPoint; mitk::IInputDevice::Pointer m_InputDevice; }; // end class } // end namespace #endif /*MITKINPUTDEVICEDESCRIPTOR_H_*/ diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp index a129200f32..28966b038e 100644 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp +++ b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.cpp @@ -1,86 +1,86 @@ /*========================================================================= -Program: BlueBerry Platform +Program: Medical Imaging & Interaction Toolkit Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ -Version: $Revision: 21070 $ +Date: $Date$ +Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include #include #include #include #include "mitkCoreExtConstants.h" mitk::InputDeviceRegistry::InputDeviceRegistry() { //initialize the registry by copying all available extension points into a local variable berry::IExtensionPointService::Pointer extensionPointService = berry::Platform::GetExtensionPointService(); std::vector allExtensionsInputDevices = extensionPointService->GetConfigurationElementsFor(mitk::CoreExtConstants::INPUTDEVICE_EXTENSION_NAME); for(std::vector::const_iterator it = allExtensionsInputDevices.begin(); it != allExtensionsInputDevices.end();++it) { InputDeviceDescriptorPtr temp(new mitk::InputDeviceDescriptor(*it)); // The equation with the end means, that if there is no such element and // the pointer will be at end (not the last element, actually after it) if(this->m_ListRegisteredDevices.find(temp->GetID()) == this->m_ListRegisteredDevices.end()) { m_ListRegisteredDevices.insert(std::make_pair(temp->GetID(),temp)); } else { throw std::runtime_error("The Input Device ID: "+temp->GetID()+" is already registered."); } } } mitk::InputDeviceRegistry::~InputDeviceRegistry() { } mitk::InputDeviceRegistry::InputDeviceDescriptorPtr mitk::InputDeviceRegistry::Find(const std::string &id) const { Poco::HashMap::ConstIterator result = this->m_ListRegisteredDevices.find(id); // first = key, second = element or vice versa, if inserted different in the hash map if(result != this->m_ListRegisteredDevices.end()) return result->second; return InputDeviceDescriptorPtr(0); } std::vector mitk::InputDeviceRegistry::GetInputDevices() const { std::vector temp; for(Poco::HashMap::ConstIterator it = m_ListRegisteredDevices.begin(); it != m_ListRegisteredDevices.end();++it) { // first = key, second = element or vice versa, if inserted different in the hash map temp.push_back(it->second); } return temp; } bool mitk::InputDeviceRegistry::IsA(const std::type_info& type) const { std::string name(GetType().name()); return name == type.name() || berry::Service::IsA(type); } const std::type_info& mitk::InputDeviceRegistry::GetType() const { return typeid(IInputDeviceRegistry); } diff --git a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.h b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.h index a758dd010d..3e990240fd 100644 --- a/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.h +++ b/Modules/Bundles/org.mitk.core.ext/src/mitkInputDeviceRegistry.h @@ -1,67 +1,67 @@ /*========================================================================= -Program: BlueBerry Platform +Program: Medical Imaging & Interaction Toolkit Language: C++ -Date: $Date: 2010-01-16 19:57:43 +0100 (Sa, 16 Jan 2010) $ -Version: $Revision: 21070 $ +Date: $Date$ +Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKSPACENAVIGATORREGISTRY_H_ #define MITKSPACENAVIGATORREGISTRY_H_ #include #include #include #include #include namespace mitk { /** * Documentation in the interface. * * @see mitk::IInputDeviceRegistry * @ingroup org_mitk_core_ext */ class InputDeviceRegistry : public IInputDeviceRegistry { public: bool IsA(const std::type_info& type) const; const std::type_info& GetType() const; // easier maintenance typedef IInputDeviceDescriptor::Pointer InputDeviceDescriptorPtr; InputDeviceRegistry(); ~InputDeviceRegistry(); /** * @see mitk::IInputDeviceRegistry::Find(const std::string& id) */ InputDeviceDescriptorPtr Find(const std::string& id) const; /** * @see mitk::IInputDeviceRegistry´::GetInputDevices() */ std::vector GetInputDevices() const; protected: private: Poco::HashMap m_ListRegisteredDevices; }; // end class InputDeviceRegistry } // end namespace mitk #endif /*MITKSPACENAVIGATORREGISTRY_H_*/ diff --git a/Modules/Bundles/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h b/Modules/Bundles/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h index 61fff1824c..124bf2ee61 100644 --- a/Modules/Bundles/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h +++ b/Modules/Bundles/org.mitk.core.jobs/src/mitkDataStorageAccessRule.h @@ -1,159 +1,159 @@ /*========================================================================= - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision: 15350 $ +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. - =========================================================================*/ +=========================================================================*/ #ifndef MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ #define MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ #include #include "berryISchedulingRule.h" #include "berryObject.h" #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkStandaloneDataStorage.h" namespace mitk { /** *@class DataStorageAccessRule * *@brief The DataStorageAccessRule inherits from the ISchedulingRule class. DataStorageAccessRule are used to restrict the adding and * removing of DataStorage nodes in multi-threaded scenarios. Only DataStorageNodes within different branches can be modified * concurrently. The idea and its restrictions is explained in the sections and diagrams below. * *

the IsScheduling(...) method :

* returns true or false depending if conflictions with another rule are found * *

* *

*

the rule behavior if jobs holing add rules of an DataTree node

* * two add rules are always allowed since there are no conflictions when adding nodes concurrently. The final order the nodes are finally added has * to be checked by the programmer of the particular job * * *

the rule behavior when two jobs holding remove rules of a DataNode

* * two jobs holding remove rules can be executed concurrently since all removing scenarios do not cause conflictions. If two jobs are * trying to remove the same DataTree node the job by itself needs to check if the node is still available before executing the removing * command * * *

the rule behavior of a jobs that is holding an add rule compared with a job that is holding a remove rule on a * DataNode

* * adding and removing of DataTree nodes concurrently can cause serious errors and needs to be restricted. Performing add and remove * operations on different DataStorage branches can be done concurrently since no conflictions are expected. * the performing of add and remove operation on the same DataNode, its parent nodes or child nodes of the same branch * by different jobs is not allowed. Jobs holding rules that are trying to perform such operations are blocked until the running job is done. * *

* *

*

the Contains method (...) method :

* only necessary for a specific type of scheduling rules. Has to be used if IScheduling rules are composed into hierarchies. * In such scenarios the contains(...) method specifies the hierarchical relationships among the locks. For example if a method tries to acquire a specific * rule to lock a specific directory it needs to check if no job is holding a rule for one or more subdirectories. For all cases in which no composing of * IScheduling rules is needed the Contains(...) method only needs to check if two jobs are holding exactly the same IScheduling rule on the same object. * Normally this can be achieved by just calling the IsConflicting(...) method. *

* *@author Jan Woerner */ class MITK_JOBS_EXPORT DataStorageAccessRule : public berry::ISchedulingRule { public: enum RuleType {ADD_RULE = 0, REMOVE_RULE} ; RuleType m_Rule; berryObjectMacro(DataStorageAccessRule) DataStorageAccessRule (mitk::DataStorage::Pointer myDataStorage, mitk::DataNode::Pointer myDataNode, DataStorageAccessRule::RuleType myRule) ; bool Contains (berry::ISchedulingRule::Pointer otherISchedulingRule) ; bool IsConflicting (berry::ISchedulingRule::Pointer otherISchedulingRule) ; private: /** * Returns false, identifying no conflictions between two DataStorageAccessRules. * Two add and remove rules do work together. From importance is that jobs using this rule need to check if the * node operating on is still available or already deleted by another job. The DataStorageAccessRule only checks if conflictions could * occur if the removing or adding of nodes is performed currently. */ bool CompareTwoAddorRemoveRules() const ; /** * searches for conflictions of an add DataStorageAccessRule with a remove DataStorageAccess rule * if the add and remove rule do operate in different branches, no conflictions are expected and false is returned */ bool CompareAddandRemoveRules(mitk::DataStorageAccessRule::Pointer sptr_otherDataStorageAccessRule) const; /** * for internal use only, * checks if the jobs that are to be compared do hold DataStorageAccessRule on the same * DataStorage. Jobs that do operate on different DataStorage do not conflict and false is returned */ bool CompareDataStorages(mitk::DataStorage::Pointer otherDataStorage) const; /** * for internal use only * validates if the DataTree node of a particular DataStorageAccess rule belongs to the DataStorage specified within the particular rule. * if not the rule is invalid and false is returned. No conflictions can be expected */ bool TestDataNode(mitk::DataNode::Pointer dataTreeToBeStored) const; /** * returns a pointer to the specified DataStorage node */ mitk::DataNode::Pointer GetDataNode() const; /** * returns a pointer to the specified DataStorage */ mitk::DataStorage::Pointer GetDataStorage() const; mitk::DataStorageAccessRule::RuleType GetRuleType() const; DataStorage::Pointer m_sptrMyDataStorage ; DataNode::Pointer m_sptrMyDataNode ; }; } #endif /*MITKDATASTORAGEACCESSRULE_H_HEADER_INCLUDED_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp index 5a9ff7813b..1109246ed4 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.cpp @@ -1,253 +1,253 @@ /*========================================================================= - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. - =========================================================================*/ +=========================================================================*/ #include "QmitkCommonExtPlugin.h" #include #include "QmitkAppInstancesPreferencePage.h" #include "QmitkInputDevicesPrefPage.h" #include "QmitkModuleView.h" #include #include #include #include #include #include #include #include #include #include #include ctkPluginContext* QmitkCommonExtPlugin::_context = 0; void QmitkCommonExtPlugin::start(ctkPluginContext* context) { this->_context = context; QmitkExtRegisterClasses(); BERRY_REGISTER_EXTENSION_CLASS(QmitkAppInstancesPreferencePage, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkInputDevicesPrefPage, context) BERRY_REGISTER_EXTENSION_CLASS(QmitkModuleView, context) if (qApp->metaObject()->indexOfSignal("messageReceived(QByteArray)") > -1) { connect(qApp, SIGNAL(messageReceived(QByteArray)), this, SLOT(handleIPCMessage(QByteArray))); } std::vector args = berry::Platform::GetApplicationArgs(); QStringList qargs; for (std::vector::const_iterator it = args.begin(); it != args.end(); ++it) { qargs << QString::fromStdString(*it); } // This is a potentially long running operation. loadDataFromDisk(qargs, true); } void QmitkCommonExtPlugin::stop(ctkPluginContext* context) { Q_UNUSED(context) this->_context = 0; } ctkPluginContext* QmitkCommonExtPlugin::getContext() { return _context; } void QmitkCommonExtPlugin::loadDataFromDisk(const QStringList &arguments, bool globalReinit) { if (!arguments.empty()) { ctkServiceReference serviceRef = _context->getServiceReference(); if (serviceRef) { mitk::IDataStorageService* dataStorageService = _context->getService(serviceRef); mitk::DataStorage::Pointer dataStorage = dataStorageService->GetDefaultDataStorage()->GetDataStorage(); int argumentsAdded = 0; for (int i = 0; i < arguments.size(); ++i) { if (arguments[i].right(5) == ".mitk") { mitk::SceneIO::Pointer sceneIO = mitk::SceneIO::New(); bool clearDataStorageFirst(false); mitk::ProgressBar::GetInstance()->AddStepsToDo(2); dataStorage = sceneIO->LoadScene( arguments[i].toLocal8Bit().constData(), dataStorage, clearDataStorageFirst ); mitk::ProgressBar::GetInstance()->Progress(2); argumentsAdded++; } else { mitk::DataNodeFactory::Pointer nodeReader = mitk::DataNodeFactory::New(); try { nodeReader->SetFileName(arguments[i].toStdString()); nodeReader->Update(); for (unsigned int j = 0 ; j < nodeReader->GetNumberOfOutputs( ); ++j) { mitk::DataNode::Pointer node = nodeReader->GetOutput(j); if (node->GetData() != 0) { dataStorage->Add(node); argumentsAdded++; } } } catch(...) { MITK_WARN << "Failed to load command line argument: " << arguments[i].toStdString(); } } } // end for each command line argument if (argumentsAdded > 0 && globalReinit) { // calculate bounding geometry mitk::RenderingManager::GetInstance()->InitializeViews(dataStorage->ComputeBoundingGeometry3D()); } } else { MITK_ERROR << "A service reference for mitk::IDataStorageService does not exist"; } } } void QmitkCommonExtPlugin::startNewInstance(const QStringList &args, const QStringList& files) { QStringList newArgs(args); #ifdef Q_OS_UNIX newArgs << QString("--") + QString::fromStdString(berry::Platform::ARG_NEWINSTANCE); #else newArgs << QString("/") + QString::fromStdString(berry::Platform::ARG_NEWINSTANCE); #endif newArgs << files; QProcess::startDetached(qApp->applicationFilePath(), newArgs); } void QmitkCommonExtPlugin::handleIPCMessage(const QByteArray& msg) { QDataStream ds(msg); QString msgType; ds >> msgType; // we only handle messages containing command line arguments if (msgType != "$cmdLineArgs") return; // activate the current workbench window berry::IWorkbenchWindow::Pointer window = berry::PlatformUI::GetWorkbench()->GetActiveWorkbenchWindow(); QMainWindow* mainWindow = static_cast (window->GetShell()->GetControl()); mainWindow->setWindowState(mainWindow->windowState() & ~Qt::WindowMinimized); mainWindow->raise(); mainWindow->activateWindow(); // Get the preferences for the instantiation behavior berry::IPreferencesService::Pointer prefService = berry::Platform::GetServiceRegistry() .GetServiceById(berry::IPreferencesService::ID); berry::IPreferences::Pointer prefs = prefService->GetSystemPreferences()->Node("/General"); bool newInstanceAlways = prefs->GetBool("newInstance.always", false); bool newInstanceScene = prefs->GetBool("newInstance.scene", true); QStringList args; ds >> args; QStringList fileArgs; QStringList sceneArgs; Poco::Util::OptionSet os; berry::Platform::GetOptionSet(os); Poco::Util::OptionProcessor processor(os); #if !defined(POCO_OS_FAMILY_UNIX) processor.setUnixStyle(false); #endif args.pop_front(); QStringList::Iterator it = args.begin(); while (it != args.end()) { std::string name; std::string value; if (processor.process(it->toStdString(), name, value)) { ++it; } else { if (it->endsWith(".mitk")) { sceneArgs << *it; } else { fileArgs << *it; } it = args.erase(it); } } if (newInstanceAlways) { if (newInstanceScene) { startNewInstance(args, fileArgs); foreach(QString sceneFile, sceneArgs) { startNewInstance(args, QStringList(sceneFile)); } } else { fileArgs.append(sceneArgs); startNewInstance(args, fileArgs); } } else { loadDataFromDisk(fileArgs, false); if (newInstanceScene) { foreach(QString sceneFile, sceneArgs) { startNewInstance(args, QStringList(sceneFile)); } } else { loadDataFromDisk(sceneArgs, false); } } } Q_EXPORT_PLUGIN2(org_mitk_gui_qt_ext, QmitkCommonExtPlugin) diff --git a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h index 2e7ccab06f..8e10046865 100644 --- a/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h +++ b/Modules/Bundles/org.mitk.gui.qt.ext/src/internal/QmitkCommonExtPlugin.h @@ -1,51 +1,51 @@ /*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #ifndef QMITKCOMMONEXTPLUGIN_H_ #define QMITKCOMMONEXTPLUGIN_H_ #include class QmitkCommonExtPlugin : public QObject, public ctkPluginActivator { Q_OBJECT Q_INTERFACES(ctkPluginActivator) public: void start(ctkPluginContext* context); void stop(ctkPluginContext* context); static ctkPluginContext* getContext(); private: void loadDataFromDisk(const QStringList& args, bool globalReinit); void startNewInstance(const QStringList& args, const QStringList &files); private Q_SLOTS: void handleIPCMessage(const QByteArray &msg); private: static ctkPluginContext* _context; }; #endif /* QMITKCOMMONEXTPLUGIN_H_ */ diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp index 235e635ba4..650148db7c 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.cpp @@ -1,85 +1,85 @@ /*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #include "QmitkExtApplicationPlugin.h" #include "QmitkExtDefaultPerspective.h" #include "../QmitkExtApplication.h" #include #include #include #include #include #include #include QmitkExtApplicationPlugin* QmitkExtApplicationPlugin::inst = 0; QmitkExtApplicationPlugin::QmitkExtApplicationPlugin() { inst = this; } QmitkExtApplicationPlugin::~QmitkExtApplicationPlugin() { } QmitkExtApplicationPlugin* QmitkExtApplicationPlugin::GetDefault() { return inst; } void QmitkExtApplicationPlugin::start(ctkPluginContext* context) { berry::AbstractUICTKPlugin::start(context); this->context = context; BERRY_REGISTER_EXTENSION_CLASS(QmitkExtDefaultPerspective, context); BERRY_REGISTER_EXTENSION_CLASS(QmitkExtApplication, context); ctkServiceReference cmRef = context->getServiceReference(); ctkConfigurationAdmin* configAdmin = 0; if (cmRef) { configAdmin = context->getService(cmRef); } // Use the CTK Configuration Admin service to configure the BlueBerry help system if (configAdmin) { ctkConfigurationPtr conf = configAdmin->getConfiguration("org.blueberry.services.help", QString()); ctkDictionary helpProps; helpProps.insert("homePage", "qthelp://org.mitk.gui.qt.extapplication/bundle/index.html"); conf->update(helpProps); context->ungetService(cmRef); } else { MITK_WARN << "Configuration Admin service unavailable, cannot set home page url."; } } ctkPluginContext* QmitkExtApplicationPlugin::GetPluginContext() const { return context; } Q_EXPORT_PLUGIN2(org_mitk_gui_qt_extapplication, QmitkExtApplicationPlugin) diff --git a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h index 657d450496..bf9076659c 100644 --- a/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h +++ b/Modules/Bundles/org.mitk.gui.qt.extapplication/src/internal/QmitkExtApplicationPlugin.h @@ -1,53 +1,53 @@ /*========================================================================= - - Program: BlueBerry Platform - Language: C++ - Date: $Date$ - Version: $Revision$ - - Copyright (c) German Cancer Research Center, Division of Medical and - Biological Informatics. All rights reserved. - See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - =========================================================================*/ + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #ifndef QMITKEXTAPPLICATIONPLUGIN_H_ #define QMITKEXTAPPLICATIONPLUGIN_H_ #include #include #include class QmitkExtApplicationPlugin : public QObject, public berry::AbstractUICTKPlugin { Q_OBJECT Q_INTERFACES(ctkPluginActivator) public: QmitkExtApplicationPlugin(); ~QmitkExtApplicationPlugin(); static QmitkExtApplicationPlugin* GetDefault(); ctkPluginContext* GetPluginContext() const; void start(ctkPluginContext*); QString GetQtHelpCollectionFile() const; private: static QmitkExtApplicationPlugin* inst; ctkPluginContext* context; }; #endif /* QMITKEXTAPPLICATIONPLUGIN_H_ */ diff --git a/Utilities/qtsingleapplication/qthandlenewappinstance.cpp b/Utilities/qtsingleapplication/qthandlenewappinstance.cpp index 00f6692a9a..8b1da575d3 100644 --- a/Utilities/qtsingleapplication/qthandlenewappinstance.cpp +++ b/Utilities/qtsingleapplication/qthandlenewappinstance.cpp @@ -1,120 +1,116 @@ -/*============================================================================= - - Library: CTK - - Copyright (c) German Cancer Research Center, - Division of Medical and Biological Informatics - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #include "qthandlenewappinstance.h" #include "qtsingleapplication.h" #include #include // mkdtemp #ifdef Q_OS_WIN #include //#include #endif bool createTemporaryDir(QString& path) { QString baseName = QCoreApplication::applicationName(); if (baseName.isEmpty()) { baseName = QLatin1String("mitk_temp"); } QString templateName = QDir::tempPath() + QLatin1Char('/') + baseName + QLatin1String("-XXXXXX"); bool success = false; #ifdef Q_OS_WIN QString buffer = templateName; // Windows' mktemp believes 26 temp files per process ought to be enough for everyone (!) // Let's add a few random chars then, before the XXXXXX template. for (int i = 0 ; i < 4 ; ++i) buffer += QChar((qrand() & 0xffff) % (26) + 'A'); if (!buffer.endsWith(QLatin1String("XXXXXX"))) buffer += QLatin1String("XXXXXX"); //QFileSystemEntry baseEntry(buffer); //QFileSystemEntry::NativePath basePath = baseEntry.nativeFilePath(); QString basePath = QDir::toNativeSeparators(buffer); wchar_t* array = (wchar_t*)basePath.utf16(); if (_wmktemp(array) && ::CreateDirectoryW(array, 0)) { success = true; //QFileSystemEntry entry(QString::fromWCharArray(array), QFileSystemEntry::FromNativePath()); //path = entry.filePath(); path = QDir::fromNativeSeparators(QString::fromUtf16((const ushort*)array)); } #else QByteArray buffer = QFile::encodeName(templateName); if (!buffer.endsWith("XXXXXX")) buffer += "XXXXXX"; if (mkdtemp(buffer.data())) { // modifies buffer success = true; path = QFile::decodeName(buffer.constData()); } #endif return success; } QString handleNewAppInstance(QtSingleApplication* singleApp, int argc, char** argv, const QString& newInstanceArg) { if (singleApp->isRunning()) { QStringList args; bool newInstance = false; for (int i = 0; i < argc; ++i) { args << argv[i]; if (args.back().endsWith(newInstanceArg)) { newInstance = true; } } if (newInstance) { QString path; if (!createTemporaryDir(path)) { qCritical("Could not create temporary storage path for new application instance."); exit(EXIT_FAILURE); } qWarning("Forcing new application instance. The application data will be written to a temporary directory."); return path; } else { QByteArray ba; QDataStream msg(&ba, QIODevice::WriteOnly); msg << QString("$cmdLineArgs"); // This message contains command line arguments msg << args; if(singleApp->sendMessage(ba)) { exit(EXIT_SUCCESS); } else { qCritical("The running application seems to be frozen."); exit(EXIT_FAILURE); } } } return QString(); } diff --git a/Utilities/qtsingleapplication/qthandlenewappinstance.h b/Utilities/qtsingleapplication/qthandlenewappinstance.h index e901c956c6..11743f08cc 100644 --- a/Utilities/qtsingleapplication/qthandlenewappinstance.h +++ b/Utilities/qtsingleapplication/qthandlenewappinstance.h @@ -1,34 +1,30 @@ -/*============================================================================= - - Library: CTK - - Copyright (c) German Cancer Research Center, - Division of Medical and Biological Informatics - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - -=============================================================================*/ +/*========================================================================= + +Program: Medical Imaging & Interaction Toolkit +Language: C++ +Date: $Date$ +Version: $Revision$ + +Copyright (c) German Cancer Research Center, Division of Medical and +Biological Informatics. All rights reserved. +See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. + +This software is distributed WITHOUT ANY WARRANTY; without even +the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ #ifndef QTHANDLENEWAPPINSTANCE_H #define QTHANDLENEWAPPINSTANCE_H #include class QtSingleApplication; bool createTemporaryDir(QString& path); QString handleNewAppInstance(QtSingleApplication* singleApp, int argc, char** argv, const QString& newInstanceArg); #endif // QTHANDLENEWAPPINSTANCE_H