diff --git a/Modules/Core/include/mitkImageVtkMapper2D.h b/Modules/Core/include/mitkImageVtkMapper2D.h index f629db70c0..d4d7af9b93 100644 --- a/Modules/Core/include/mitkImageVtkMapper2D.h +++ b/Modules/Core/include/mitkImageVtkMapper2D.h @@ -1,307 +1,307 @@ /*============================================================================ 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 MITKIMAGEVTKMAPPER2D_H_HEADER_INCLUDED_C10E906E #define MITKIMAGEVTKMAPPER2D_H_HEADER_INCLUDED_C10E906E // MITK #include // MITK Rendering #include "mitkBaseRenderer.h" #include "mitkExtractSliceFilter.h" #include "mitkVtkMapper.h" // VTK #include #include class vtkActor; class vtkPolyDataMapper; class vtkPlaneSource; class vtkImageData; class vtkLookupTable; class vtkImageExtractComponents; class vtkImageReslice; class vtkImageChangeInformation; class vtkPoints; class vtkMitkThickSlicesFilter; class vtkPolyData; class vtkMitkApplyLevelWindowToRGBFilter; class vtkMitkLevelWindowFilter; namespace mitk { /** \brief Mapper to resample and display 2D slices of a 3D image. * * The following image gives a brief overview of the mapping and the involved parts. * * \image html imageVtkMapper2Darchitecture.png * * First, the image is resliced by means of vtkImageReslice. The volume image * serves as input to the mapper in addition to spatial placement of the slice and a few other * properties such as thick slices. This code was already present in the old version * (mitkImageMapperGL2D). * * Next, the obtained slice (m_ReslicedImage) is put into a vtkMitkLevelWindowFilter * and the scalar levelwindow, opacity levelwindow and optional clipping to * local image bounds are applied * * Next, the output of the vtkMitkLevelWindowFilter is used to create a texture * (m_Texture) and a plane onto which the texture is rendered (m_Plane). For * mapping purposes, a vtkPolyDataMapper (m_Mapper) is utilized. Orthographic * projection is applied to create the effect of a 2D image. The mapper and the * texture are assigned to the actor (m_Actor) which is passed to the VTK rendering * pipeline via the method GetVtkProp(). * * In order to transform the textured plane to the correct position in space, the * same transformation as used for reslicing is applied to both the camera and the * vtkActor. All important steps are explained in more detail below. The resulting * 2D image (by reslicing the underlying 3D input image appropriately) can either * be directly rendered in a 2D view or just be calculated to be used later by another * rendering entity, e.g. in texture mapping in a 3D view. * * Properties that can be set for images and influence the imageMapper2D are: * * - \b "opacity": (FloatProperty) Opacity of the image * - \b "color": (ColorProperty) Color of the image * - \b "LookupTable": (mitkLookupTableProperty) If this property is set, * the default lookuptable will be ignored and the "LookupTable" value * will be used instead. * - \b "Image Rendering.Mode": This property decides which mode is used to render images. (E.g. if a lookup table or a transferfunction is applied). Detailed documentation about the modes can be found here: \link - mitk::RenderingerModeProperty \endlink + mitk::RenderingModeProperty \endlink * - \b "Image Rendering.Transfer Function": (mitkTransferFunctionProperty) If this * property is set, a color transferfunction will be used to color the image. * - \b "binary": (BoolProperty) is the image a binary image or not * - \b "outline binary": (BoolProperty) show outline of the image or not * - \b "texture interpolation": (BoolProperty) texture interpolation of the image * - \b "reslice interpolation": (VtkResliceInterpolationProperty) reslice interpolation of the image * - \b "in plane resample extent by geometry": (BoolProperty) Do it or not * - \b "bounding box": (BoolProperty) Is the Bounding Box of the image shown or not * - \b "layer": (IntProperty) Layer of the image * - \b "volume annotation color": (ColorProperty) color of the volume annotation, TODO has to be reimplemented * - \b "volume annotation unit": (StringProperty) annotation unit as string (does not implicit convert the unit!) unit is ml or cm3, TODO has to be reimplemented * The default properties are: * - \b "opacity", mitk::FloatProperty::New(0.3f), renderer, overwrite ) * - \b "color", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ) * - \b "binary", mitk::BoolProperty::New( true ), renderer, overwrite ) * - \b "outline binary", mitk::BoolProperty::New( false ), renderer, overwrite ) * - \b "texture interpolation", mitk::BoolProperty::New( false ) ) * - \b "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() ) * - \b "in plane resample extent by geometry", mitk::BoolProperty::New( false ) ) * - \b "bounding box", mitk::BoolProperty::New( false ) ) * - \b "layer", mitk::IntProperty::New(10), renderer, overwrite) * - \b "Image Rendering.Transfer Function": Default color transfer function for CTs * - \b "LookupTable": Rainbow color. * If the modality-property is set for an image, the mapper uses modality-specific default properties, * e.g. color maps, if they are defined. * \ingroup Mapper */ class MITKCORE_EXPORT ImageVtkMapper2D : public VtkMapper { public: /** Standard class typedefs. */ mitkClassMacro(ImageVtkMapper2D, VtkMapper); /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self); itkCloneMacro(Self); /** \brief Get the Image to map */ const mitk::Image *GetInput(void); /** \brief Checks whether this mapper needs to update itself and generate * data. */ void Update(mitk::BaseRenderer *renderer) override; //### methods of MITK-VTK rendering pipeline vtkProp *GetVtkProp(mitk::BaseRenderer *renderer) override; //### end of methods of MITK-VTK rendering pipeline /** \brief Internal class holding the mapper, actor, etc. for each of the 3 2D render windows */ /** * To render transveral, coronal, and sagittal, the mapper is called three times. * For performance reasons, the corresponding data for each view is saved in the * internal helper class LocalStorage. This allows rendering n views with just * 1 mitkMapper using n vtkMapper. * */ class MITKCORE_EXPORT LocalStorage : public mitk::Mapper::BaseLocalStorage { public: /** \brief Actor of a 2D render window. */ vtkSmartPointer m_Actor; vtkSmartPointer m_Actors; /** \brief Mapper of a 2D render window. */ vtkSmartPointer m_Mapper; vtkSmartPointer m_VectorComponentExtractor; /** \brief Current slice of a 2D render window.*/ vtkSmartPointer m_ReslicedImage; /** \brief Empty vtkPolyData that is set when rendering geometry does not * intersect the image geometry. * \warning This member variable is set to nullptr, * if no image geometry is inside the plane geometry * of the respective render window. Any user of this * slice has to check whether it is set to nullptr! */ vtkSmartPointer m_EmptyPolyData; /** \brief Plane on which the slice is rendered as texture. */ vtkSmartPointer m_Plane; /** \brief The texture which is used to render the current slice. */ vtkSmartPointer m_Texture; /** \brief The lookuptables for colors and level window */ vtkSmartPointer m_DefaultLookupTable; vtkSmartPointer m_BinaryLookupTable; vtkSmartPointer m_ColorLookupTable; /** \brief The actual reslicer (one per renderer) */ mitk::ExtractSliceFilter::Pointer m_Reslicer; /** \brief Filter for thick slices */ vtkSmartPointer m_TSFilter; /** \brief PolyData object containg all lines/points needed for outlining the contour. This container is used to save a computed contour for the next rendering execution. For instance, if you zoom or pann, there is no need to recompute the contour. */ vtkSmartPointer m_OutlinePolyData; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastUpdateTime; /** \brief mmPerPixel relation between pixel and mm. (World spacing).*/ mitk::ScalarType *m_mmPerPixel; /** \brief This filter is used to apply the level window to Grayvalue and RBG(A) images. */ vtkSmartPointer m_LevelWindowFilter; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage() override; }; /** \brief The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows. */ mitk::LocalStorageHandler m_LSH; /** \brief Get the LocalStorage corresponding to the current renderer. */ LocalStorage *GetLocalStorage(mitk::BaseRenderer *renderer); /** \brief Set the default properties for general image rendering. */ static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer = nullptr, bool overwrite = false); /** \brief This method switches between different rendering modes (e.g. use a lookup table or a transfer function). - * Detailed documentation about the modes can be found here: \link mitk::RenderingerModeProperty \endlink + * Detailed documentation about the modes can be found here: \link mitk::RenderingModeProperty \endlink */ void ApplyRenderingMode(mitk::BaseRenderer *renderer); protected: /** \brief Transforms the actor to the actual position in 3D. * \param renderer The current renderer corresponding to the render window. */ void TransformActor(mitk::BaseRenderer *renderer); /** \brief Generates a plane according to the size of the resliced image in milimeters. * * \image html texturedPlane.png * * In VTK a vtkPlaneSource is defined through three points. The origin and two * points defining the axes of the plane (see VTK documentation). The origin is * set to (xMin; yMin; Z), where xMin and yMin are the minimal bounds of the * resliced image in space. Z is relevant for blending and the layer property. * The center of the plane (C) is also the center of the view plane (cf. the image above). * * \note For the standard MITK view with three 2D render windows showing three * different slices, three such planes are generated. All these planes are generated * in the XY-plane (even if they depict a YZ-slice of the volume). * */ void GeneratePlane(mitk::BaseRenderer *renderer, double planeBounds[6]); /** \brief Generates a vtkPolyData object containing the outline of a given binary slice. \param renderer: Pointer to the renderer containing the needed information \note This code is based on code from the iil library. */ template vtkSmartPointer CreateOutlinePolyData(mitk::BaseRenderer *renderer); /** Default constructor */ ImageVtkMapper2D(); /** Default deconstructor */ ~ImageVtkMapper2D() override; /** \brief Does the actual resampling, without rendering the image yet. * All the data is generated inside this method. The vtkProp (or Actor) * is filled with content (i.e. the resliced image). * * After generation, a 4x4 transformation matrix(t) of the current slice is obtained * from the vtkResliceImage object via GetReslicesAxis(). This matrix is * applied to each textured plane (actor->SetUserTransform(t)) to transform everything * to the actual 3D position (cf. the following image). * * \image html cameraPositioning3D.png * */ void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override; /** \brief This method uses the vtkCamera clipping range and the layer property * to calcualte the depth of the object (e.g. image or contour). The depth is used * to keep the correct order for the final VTK rendering.*/ float CalculateLayerDepth(mitk::BaseRenderer *renderer); /** \brief This method applies (or modifies) the lookuptable for all types of images. * \warning To use the lookup table, the property 'Lookup Table' must be set and a 'Image Rendering.Mode' * which uses the lookup table must be set. */ void ApplyLookuptable(mitk::BaseRenderer *renderer); /** \brief This method applies a color transfer function. * Internally, a vtkColorTransferFunction is used. This is usefull for coloring continous * images (e.g. float) * \warning To use the color transfer function, the property 'Image Rendering.Transfer Function' must be set and a * 'Image Rendering.Mode' which uses the color transfer function must be set. */ void ApplyColorTransferFunction(mitk::BaseRenderer *renderer); /** * @brief ApplyLevelWindow Apply the level window for the given renderer. * \warning To use the level window, the property 'LevelWindow' must be set and a 'Image Rendering.Mode' which uses * the level window must be set. * @param renderer Level window for which renderer? */ void ApplyLevelWindow(mitk::BaseRenderer *renderer); /** \brief Set the color of the image/polydata */ void ApplyColor(mitk::BaseRenderer *renderer); /** \brief Set the opacity of the actor. */ void ApplyOpacity(mitk::BaseRenderer *renderer); /** * \brief Calculates whether the given rendering geometry intersects the * given SlicedGeometry3D. * * This method checks if the given PlaneGeometry intersects the given * SlicedGeometry3D. It calculates the distance of the PlaneGeometry to all * 8 cornerpoints of the SlicedGeometry3D. If all distances have the same * sign (all positive or all negative) there is no intersection. * If the distances have different sign, there is an intersection. **/ bool RenderingGeometryIntersectsImage(const PlaneGeometry *renderingGeometry, SlicedGeometry3D *imageGeometry); }; } // namespace mitk #endif /* MITKIMAGEVTKMAPPER2D_H_HEADER_INCLUDED_C10E906E */ diff --git a/Modules/CppMicroServices/core/include/usModuleContext.h b/Modules/CppMicroServices/core/include/usModuleContext.h index dfcae418d5..358cbe4d8b 100644 --- a/Modules/CppMicroServices/core/include/usModuleContext.h +++ b/Modules/CppMicroServices/core/include/usModuleContext.h @@ -1,851 +1,851 @@ /*============================================================================ Library: CppMicroServices Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. 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. ============================================================================*/ #ifndef USMODULECONTEXT_H_ #define USMODULECONTEXT_H_ // TODO: Replace includes with forward directives! #include "usListenerFunctors_p.h" #include "usServiceInterface.h" #include "usServiceEvent.h" #include "usServiceRegistration.h" #include "usServiceException.h" #include "usModuleEvent.h" US_BEGIN_NAMESPACE typedef US_SERVICE_LISTENER_FUNCTOR ServiceListener; typedef US_MODULE_LISTENER_FUNCTOR ModuleListener; class ModuleContextPrivate; class ServiceFactory; template class ServiceObjects; /** * \ingroup MicroServices * * A module's execution context within the framework. The context is used to * grant access to other methods so that this module can interact with the * Micro Services Framework. * *

* ModuleContext methods allow a module to: *

    *
  • Subscribe to events published by the framework. *
  • Register service objects with the framework service registry. *
  • Retrieve ServiceReferences from the framework service * registry. *
  • Get and release service objects for a referenced service. *
  • Get the list of modules loaded in the framework. *
  • Get the {@link Module} object for a module. *
* *

* A ModuleContext object will be created and provided to the * module associated with this context when it is loaded using the - * {@link ModuleActivator::Load} method. The same ModuleContext + * us::ModuleActivator::Load method. The same ModuleContext * object will be passed to the module associated with this context when it is - * unloaded using the {@link ModuleActivator::Unload} method. A + * unloaded using the us::ModuleActivator::Unload method. A * ModuleContext object is generally for the private use of its * associated module and is not meant to be shared with other modules in the * module environment. * *

* The Module object associated with a ModuleContext * object is called the context module. * *

* The ModuleContext object is only valid during the execution of * its context module; that is, during the period when the context module * is loaded. If the ModuleContext * object is used subsequently, a std::logic_error is * thrown. The ModuleContext object is never reused after * its context module is unloaded. * *

* The framework is the only entity that can create ModuleContext * objects. * * @remarks This class is thread safe. */ class US_Core_EXPORT ModuleContext { public: ~ModuleContext(); /** * Returns the Module object associated with this * ModuleContext. This module is called the context module. * * @return The Module object associated with this * ModuleContext. * @throws std::logic_error If this ModuleContext is no * longer valid. */ Module* GetModule() const; /** * Returns the module with the specified identifier. * * @param id The identifier of the module to retrieve. * @return A Module object or 0 if the * identifier does not match any previously loaded module. */ Module* GetModule(long id) const; /** * Get the module that with the specified module name. * * @param name The name of the module to get. * @return The requested \c Module or \c nullptr. */ Module* GetModule(const std::string& name); /** * Returns a list of all known modules. *

* This method returns a list of all modules loaded in the module * environment at the time of the call to this method. This list will * also contain modules which might already have been unloaded. * * @return A std::vector of Module objects which * will hold one object per known module. */ std::vector GetModules() const; /** * Registers the specified service object with the specified properties * under the specified class names into the framework. A * ServiceRegistration object is returned. The * ServiceRegistration object is for the private use of the * module registering the service and should not be shared with other * modules. The registering module is defined to be the context module. * Other modules can locate the service by using either the - * {@link #GetServiceReferences} or {@link #GetServiceReference} method. + * GetServiceReferences() or GetServiceReference() method. * *

* A module can register a service object that implements the * ServiceFactory or PrototypeServiceFactory interface to have more * flexibility in providing service objects to other modules. * *

* The following steps are taken when registering a service: *

    *
  1. The framework adds the following service properties to the service * properties from the specified ServiceProperties (which may be * omitted):
    - * A property named ServiceConstants#SERVICE_ID() identifying the + * A property named us::ServiceConstants::SERVICE_ID() identifying the * registration number of the service
    - * A property named ServiceConstants#OBJECTCLASS() containing all the + * A property named us::ServiceConstants::OBJECTCLASS() containing all the * specified classes.
    - * A property named ServiceConstants#SERVICE_SCOPE() identifying the scope + * A property named us::ServiceConstants::SERVICE_SCOPE() identifying the scope * of the service.
    * Properties with these names in the specified ServiceProperties will * be ignored. *
  2. The service is added to the framework service registry and may now be * used by other modules. *
  3. A service event of type ServiceEvent#REGISTERED is fired. *
  4. A ServiceRegistration object for this registration is * returned. *
* * @note This is a low-level method and should normally not be used directly. * Use one of the templated RegisterService methods instead. * * @param service The service object, which is a map of interface identifiers * to raw service pointers. * @param properties The properties for this service. The keys in the * properties object must all be std::string objects. See - * {@link ServiceConstants} for a list of standard service property keys. + * us::ServiceConstants for a list of standard service property keys. * Changes should not be made to this object after calling this * method. To update the service's properties the - * {@link ServiceRegistration::SetProperties} method must be called. + * us::ServiceRegistration::SetProperties method must be called. * The set of properties may be omitted if the service has * no properties. * @return A ServiceRegistration object for use by the module * registering the service to update the service's properties or to * unregister the service. * * @throws std::invalid_argument If one of the following is true: *
    *
  • service is 0. *
  • properties contains case variants of the same key name. *
* @throws std::logic_error If this ModuleContext is no longer valid. * * @see ServiceRegistration * @see ServiceFactory * @see PrototypeServiceFactory */ ServiceRegistrationU RegisterService(const InterfaceMap& service, const ServiceProperties& properties = ServiceProperties()); /** * Registers the specified service object with the specified properties * using the specified template argument with the framework. * *

* This method is provided as a convenience when service will only be registered under * a single class name whose type is available to the caller. It is otherwise identical to * RegisterService(const InterfaceMap&, const ServiceProperties&) but should be preferred * since it avoids errors in the string literal identifying the class name or interface identifier. * * Example usage: * \snippet uServices-registration/main.cpp 1-1 * \snippet uServices-registration/main.cpp 1-2 * * @tparam S The type under which the service can be located. * @param service The service object or a ServiceFactory object. * @param properties The properties for this service. * @return A ServiceRegistration object for use by the module * registering the service to update the service's properties or to * unregister the service. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws ServiceException If the service type \c S is invalid or the * \c service object is nullptr. * * @see RegisterService(const InterfaceMap&, const ServiceProperties&) */ template ServiceRegistration RegisterService(S* service, const ServiceProperties& properties = ServiceProperties()) { InterfaceMap servicePointers = MakeInterfaceMap(service); return RegisterService(servicePointers, properties); } /** * Registers the specified service object with the specified properties * using the specified template argument with the framework. * *

* This method is provided as a convenience when registering a service under * two interface classes whose type is available to the caller. It is otherwise identical to * RegisterService(const InterfaceMap&, const ServiceProperties&) but should be preferred * since it avoids errors in the string literal identifying the class name or interface identifier. * * Example usage: * \snippet uServices-registration/main.cpp 2-1 * \snippet uServices-registration/main.cpp 2-2 * * @tparam I1 The first interface type under which the service can be located. * @tparam I2 The second interface type under which the service can be located. * @param impl The service object or a ServiceFactory object. * @param properties The properties for this service. * @return A ServiceRegistration object for use by the module * registering the service to update the service's properties or to * unregister the service. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws ServiceException If the service type \c S is invalid or the * \c service object is nullptr. * * @see RegisterService(const InterfaceMap&, const ServiceProperties&) */ template ServiceRegistration RegisterService(Impl* impl, const ServiceProperties& properties = ServiceProperties()) { InterfaceMap servicePointers = MakeInterfaceMap(impl); return RegisterService(servicePointers, properties); } /** * Registers the specified service object with the specified properties * using the specified template argument with the framework. * *

* This method is identical to the RegisterService(Impl*, const ServiceProperties&) * method except that it supports three service interface types. * * @tparam I1 The first interface type under which the service can be located. * @tparam I2 The second interface type under which the service can be located. * @tparam I3 The third interface type under which the service can be located. * @param impl The service object or a ServiceFactory object. * @param properties The properties for this service. * @return A ServiceRegistration object for use by the module * registering the service to update the service's properties or to * unregister the service. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws ServiceException If the service type \c S is invalid or the * \c service object is nullptr. * * @see RegisterService(const InterfaceMap&, const ServiceProperties&) */ template ServiceRegistration RegisterService(Impl* impl, const ServiceProperties& properties = ServiceProperties()) { InterfaceMap servicePointers = MakeInterfaceMap(impl); return RegisterService(servicePointers, properties); } /** * Registers the specified service factory as a service with the specified properties * using the specified template argument as service interface type with the framework. * *

* This method is provided as a convenience when factory will only be registered under * a single class name whose type is available to the caller. It is otherwise identical to * RegisterService(const InterfaceMap&, const ServiceProperties&) but should be preferred * since it avoids errors in the string literal identifying the class name or interface identifier. * * Example usage: * \snippet uServices-registration/main.cpp 1-1 * \snippet uServices-registration/main.cpp f1 * * @tparam S The type under which the service can be located. * @param factory The ServiceFactory or PrototypeServiceFactory object. * @param properties The properties for this service. * @return A ServiceRegistration object for use by the module * registering the service to update the service's properties or to * unregister the service. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws ServiceException If the service type \c S is invalid or the * \c service factory object is nullptr. * * @see RegisterService(const InterfaceMap&, const ServiceProperties&) */ template ServiceRegistration RegisterService(ServiceFactory* factory, const ServiceProperties& properties = ServiceProperties()) { InterfaceMap servicePointers = MakeInterfaceMap(factory); return RegisterService(servicePointers, properties); } /** * Registers the specified service factory as a service with the specified properties * using the specified template argument as service interface type with the framework. * *

* This method is identical to the RegisterService(ServiceFactory*, const ServiceProperties&) * method except that it supports two service interface types. * * Example usage: * \snippet uServices-registration/main.cpp 2-1 * \snippet uServices-registration/main.cpp f2 * * @tparam I1 The first interface type under which the service can be located. * @tparam I2 The second interface type under which the service can be located. * @param factory The ServiceFactory or PrototypeServiceFactory object. * @param properties The properties for this service. * @return A ServiceRegistration object for use by the module * registering the service to update the service's properties or to * unregister the service. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws ServiceException If the service type \c S is invalid or the * \c service factory object is nullptr. * * @see RegisterService(const InterfaceMap&, const ServiceProperties&) */ template ServiceRegistration RegisterService(ServiceFactory* factory, const ServiceProperties& properties = ServiceProperties()) { InterfaceMap servicePointers = MakeInterfaceMap(factory); return RegisterService(servicePointers, properties); } /** * Registers the specified service factory as a service with the specified properties * using the specified template argument as service interface type with the framework. * *

* This method is identical to the RegisterService(ServiceFactory*, const ServiceProperties&) * method except that it supports three service interface types. * * @tparam I1 The first interface type under which the service can be located. * @tparam I2 The second interface type under which the service can be located. * @tparam I3 The third interface type under which the service can be located. * @param factory The ServiceFactory or PrototypeServiceFactory object. * @param properties The properties for this service. * @return A ServiceRegistration object for use by the module * registering the service to update the service's properties or to * unregister the service. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws ServiceException If the service type \c S is invalid or the * \c service factory object is nullptr. * * @see RegisterService(const InterfaceMap&, const ServiceProperties&) */ template ServiceRegistration RegisterService(ServiceFactory* factory, const ServiceProperties& properties = ServiceProperties()) { InterfaceMap servicePointers = MakeInterfaceMap(factory); return RegisterService(servicePointers, properties); } /** * Returns a list of ServiceReference objects. The returned * list contains services that * were registered under the specified class and match the specified filter * expression. * *

* The list is valid at the time of the call to this method. However since * the Micro Services framework is a very dynamic environment, services can be modified or * unregistered at any time. * *

* The specified filter expression is used to select the * registered services whose service properties contain keys and values * which satisfy the filter expression. See LDAPFilter for a description * of the filter syntax. If the specified filter is * empty, all registered services are considered to match the * filter. If the specified filter expression cannot be parsed, * an std::invalid_argument will be thrown with a human readable * message where the filter became unparsable. * *

* The result is a list of ServiceReference objects for all * services that meet all of the following conditions: *

    *
  • If the specified class name, clazz, is not * empty, the service must have been registered with the * specified class name. The complete list of class names with which a * service was registered is available from the service's - * {@link ServiceConstants#OBJECTCLASS() objectClass} property. + * us::ServiceConstants::OBJECTCLASS() property. *
  • If the specified filter is not empty, the * filter expression must match the service. *
* * @param clazz The class name with which the service was registered or * an empty string for all services. * @param filter The filter expression or empty for all * services. * @return A list of ServiceReference objects or * an empty list if no services are registered which satisfy the * search. * @throws std::invalid_argument If the specified filter * contains an invalid filter expression that cannot be parsed. * @throws std::logic_error If this ModuleContext is no longer valid. */ std::vector GetServiceReferences(const std::string& clazz, const std::string& filter = std::string()); /** * Returns a list of ServiceReference objects. The returned * list contains services that * were registered under the interface id of the template argument S * and match the specified filter expression. * *

* This method is identical to GetServiceReferences(const std::string&, const std::string&) except that * the class name for the service object is automatically deduced from the template argument. * * @tparam S The type under which the requested service objects must have been registered. * @param filter The filter expression or empty for all * services. * @return A list of ServiceReference objects or * an empty list if no services are registered which satisfy the * search. * @throws std::invalid_argument If the specified filter * contains an invalid filter expression that cannot be parsed. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws ServiceException If the service type \c S is invalid. * * @see GetServiceReferences(const std::string&, const std::string&) */ template std::vector > GetServiceReferences(const std::string& filter = std::string()) { std::string clazz = us_service_interface_iid(); if (clazz.empty()) throw ServiceException("The service interface class has no US_DECLARE_SERVICE_INTERFACE macro"); typedef std::vector BaseVectorT; BaseVectorT serviceRefs = GetServiceReferences(clazz, filter); std::vector > result; for(BaseVectorT::const_iterator i = serviceRefs.begin(); i != serviceRefs.end(); ++i) { result.push_back(ServiceReference(*i)); } return result; } /** * Returns a ServiceReference object for a service that * implements and was registered under the specified class. * *

* The returned ServiceReference object is valid at the time of * the call to this method. However as the Micro Services framework is a very dynamic * environment, services can be modified or unregistered at any time. * *

* This method is the same as calling * {@link ModuleContext::GetServiceReferences(const std::string&, const std::string&)} with an * empty filter expression. It is provided as a convenience for * when the caller is interested in any service that implements the * specified class. *

* If multiple such services exist, the service with the highest ranking (as - * specified in its ServiceConstants::SERVICE_RANKING() property) is returned. + * specified in its us::ServiceConstants::SERVICE_RANKING() property) is returned. *

* If there is a tie in ranking, the service with the lowest service ID (as - * specified in its ServiceConstants::SERVICE_ID() property); that is, the + * specified in its us::ServiceConstants::SERVICE_ID() property); that is, the * service that was registered first is returned. * * @param clazz The class name with which the service was registered. * @return A ServiceReference object, or an invalid ServiceReference if * no services are registered which implement the named class. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws ServiceException If no service was registered under the given class name. * * @see #GetServiceReferences(const std::string&, const std::string&) */ ServiceReferenceU GetServiceReference(const std::string& clazz); /** * Returns a ServiceReference object for a service that * implements and was registered under the specified template class argument. * *

* This method is identical to GetServiceReference(const std::string&) except that * the class name for the service object is automatically deduced from the template argument. * * @tparam S The type under which the requested service must have been registered. * @return A ServiceReference object, or an invalid ServiceReference if * no services are registered which implement the type S. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws ServiceException It no service was registered under the given class name. * @see #GetServiceReference(const std::string&) * @see #GetServiceReferences(const std::string&) */ template ServiceReference GetServiceReference() { std::string clazz = us_service_interface_iid(); if (clazz.empty()) throw ServiceException("The service interface class has no US_DECLARE_SERVICE_INTERFACE macro"); return ServiceReference(GetServiceReference(clazz)); } /** * Returns the service object referenced by the specified * ServiceReferenceBase object. *

* A module's use of a service is tracked by the module's use count of that * service. Each time a service's service object is returned by * {@link #GetService(const ServiceReference&)} the context module's use count for * that service is incremented by one. Each time the service is released by * {@link #UngetService(const ServiceReferenceBase&)} the context module's use count * for that service is decremented by one. *

* When a module's use count for a service drops to zero, the module should * no longer use that service. * *

* This method will always return 0 when the service * associated with this reference has been unregistered. * *

* The following steps are taken to get the service object: *

    *
  1. If the service has been unregistered, 0 is returned. *
  2. The context module's use count for this service is incremented by * one. *
  3. If the context module's use count for the service is currently one * and the service was registered with an object implementing the * ServiceFactory interface, the - * {@link ServiceFactory::GetService} method is + * us::ServiceFactory::GetService() method is * called to create a service object for the context module. This service * object is cached by the framework. While the context module's use count * for the service is greater than zero, subsequent calls to get the * services's service object for the context module will return the cached * service object.
    * If the ServiceFactory object throws an * exception, 0 is returned and a warning is logged. *
  4. The service object for the service is returned. *
* * @param reference A reference to the service. * @return A service object for the service associated with * reference or 0 if the service is not * registered or the ServiceFactory threw * an exception. * @throws std::logic_error If this ModuleContext is no * longer valid. * @throws std::invalid_argument If the specified * ServiceReferenceBase is invalid (default constructed). * @see #UngetService(const ServiceReferenceBase&) * @see ServiceFactory */ void* GetService(const ServiceReferenceBase& reference); InterfaceMap GetService(const ServiceReferenceU& reference); /** * Returns the service object referenced by the specified * ServiceReference object. *

* This is a convenience method which is identical to void* GetService(const ServiceReferenceBase&) * except that it casts the service object to the supplied template argument type * * @tparam S The type the service object will be cast to. * @return A service object for the service associated with * reference or 0 if the service is not * registered, the ServiceFactory threw * an exception or the service could not be casted to the desired type. * @throws std::logic_error If this ModuleContext is no * longer valid. * @throws std::invalid_argument If the specified * ServiceReference is invalid (default constructed). * @see #GetService(const ServiceReferenceBase&) * @see #UngetService(const ServiceReferenceBase&) * @see ServiceFactory */ template S* GetService(const ServiceReference& reference) { const ServiceReferenceBase& baseRef = reference; return reinterpret_cast(GetService(baseRef)); } /** * Returns the ServiceObjects object for the service referenced by the specified * ServiceReference object. The ServiceObjects object can be used to obtain * multiple service objects for services with prototype scope. For services with * singleton or module scope, the ServiceObjects::GetService() method behaves * the same as the GetService(const ServiceReference&) method and the * ServiceObjects::UngetService(const ServiceReferenceBase&) method behaves the * same as the UngetService(const ServiceReferenceBase&) method. That is, only one, * use-counted service object is available from the ServiceObjects object. * * @tparam S Type of Service. * @param reference A reference to the service. * @return A ServiceObjects object for the service associated with the specified * reference or an invalid instance if the service is not registered. * @throws std::logic_error If this ModuleContext is no longer valid. * @throws std::invalid_argument If the specified ServiceReference is invalid * (default constructed or the service has been unregistered) * * @see PrototypeServiceFactory */ template ServiceObjects GetServiceObjects(const ServiceReference& reference) { return ServiceObjects(this, reference); } /** * Releases the service object referenced by the specified * ServiceReference object. If the context module's use count * for the service is zero, this method returns false. * Otherwise, the context modules's use count for the service is decremented * by one. * *

* The service's service object should no longer be used and all references * to it should be destroyed when a module's use count for the service drops * to zero. * *

* The following steps are taken to unget the service object: *

    *
  1. If the context module's use count for the service is zero or the * service has been unregistered, false is returned. *
  2. The context module's use count for this service is decremented by * one. *
  3. If the context module's use count for the service is currently zero * and the service was registered with a ServiceFactory object, * the ServiceFactory#UngetService * method is called to release the service object for the context module. *
  4. true is returned. *
* * @param reference A reference to the service to be released. * @return false if the context module's use count for the * service is zero or if the service has been unregistered; * true otherwise. * @throws std::logic_error If this ModuleContext is no * longer valid. * @see #GetService * @see ServiceFactory */ bool UngetService(const ServiceReferenceBase& reference); void AddServiceListener(const ServiceListener& delegate, const std::string& filter = std::string()); void RemoveServiceListener(const ServiceListener& delegate); void AddModuleListener(const ModuleListener& delegate); void RemoveModuleListener(const ModuleListener& delegate); /** * Adds the specified callback with the * specified filter to the context modules's list of listeners. * See LDAPFilter for a description of the filter syntax. Listeners * are notified when a service has a lifecycle state change. * *

* You must take care to remove registered listeners befor the receiver * object is destroyed. However, the Micro Services framework takes care * of removing all listeners registered by this context module's classes * after the module is unloaded. * *

* If the context module's list of listeners already contains a pair (r,c) * of receiver and callback such that * (r == receiver && c == callback), then this * method replaces that callback's filter (which may be empty) * with the specified one (which may be empty). * *

* The callback is called if the filter criteria is met. To filter based * upon the class of the service, the filter should reference the - * ServiceConstants#OBJECTCLASS() property. If filter is + * us::ServiceConstants::OBJECTCLASS() property. If filter is * empty, all services are considered to match the filter. * *

* When using a filter, it is possible that the * ServiceEvents for the complete lifecycle of a service * will not be delivered to the callback. For example, if the * filter only matches when the property x has * the value 1, the callback will not be called if the * service is registered with the property x not set to the * value 1. Subsequently, when the service is modified * setting property x to the value 1, the * filter will match and the callback will be called with a * ServiceEvent of type MODIFIED. Thus, the * callback will not be called with a ServiceEvent of type * REGISTERED. * * @tparam R The type of the receiver (containing the member function to be called) * @param receiver The object to connect to. * @param callback The member function pointer to call. * @param filter The filter criteria. * @throws std::invalid_argument If filter contains an * invalid filter string that cannot be parsed. * @throws std::logic_error If this ModuleContext is no * longer valid. * @see ServiceEvent * @see RemoveServiceListener() */ template void AddServiceListener(R* receiver, void(R::*callback)(const ServiceEvent), const std::string& filter = std::string()) { AddServiceListener(ServiceListenerMemberFunctor(receiver, callback), static_cast(receiver), filter); } /** * Removes the specified callback from the context module's * list of listeners. * *

* If the (receiver,callback) pair is not contained in this * context module's list of listeners, this method does nothing. * * @tparam R The type of the receiver (containing the member function to be removed) * @param receiver The object from which to disconnect. * @param callback The member function pointer to remove. * @throws std::logic_error If this ModuleContext is no * longer valid. * @see AddServiceListener() */ template void RemoveServiceListener(R* receiver, void(R::*callback)(const ServiceEvent)) { RemoveServiceListener(ServiceListenerMemberFunctor(receiver, callback), static_cast(receiver)); } /** * Adds the specified callback to the context modules's list * of listeners. Listeners are notified when a module has a lifecycle * state change. * *

* If the context module's list of listeners already contains a pair (r,c) * of receiver and callback such that * (r == receiver && c == callback), then this method does nothing. * * @tparam R The type of the receiver (containing the member function to be called) * @param receiver The object to connect to. * @param callback The member function pointer to call. * @throws std::logic_error If this ModuleContext is no * longer valid. * @see ModuleEvent */ template void AddModuleListener(R* receiver, void(R::*callback)(const ModuleEvent)) { AddModuleListener(ModuleListenerMemberFunctor(receiver, callback), static_cast(receiver)); } /** * Removes the specified callback from the context module's * list of listeners. * *

* If the (receiver,callback) pair is not contained in this * context module's list of listeners, this method does nothing. * * @tparam R The type of the receiver (containing the member function to be removed) * @param receiver The object from which to disconnect. * @param callback The member function pointer to remove. * @throws std::logic_error If this ModuleContext is no * longer valid. * @see AddModuleListener() */ template void RemoveModuleListener(R* receiver, void(R::*callback)(const ModuleEvent)) { RemoveModuleListener(ModuleListenerMemberFunctor(receiver, callback), static_cast(receiver)); } /** * Get the absolute path for a file or directory in the persistent * storage area provided for the module. The returned path * might be empty if no storage path has been set previously. * If the path is non-empty, it is safe to assume that the path is writable. * * @see ModuleSettings::SetStoragePath(const std::string&) * * @param filename A relative name to the file or directory to be accessed. * @return The absolute path to the persistent storage area for the given file name. */ std::string GetDataFile(const std::string& filename) const; private: friend class Module; friend class ModulePrivate; ModuleContext(ModulePrivate* module); // purposely not implemented ModuleContext(const ModuleContext&); ModuleContext& operator=(const ModuleContext&); void AddServiceListener(const ServiceListener& delegate, void* data, const std::string& filter); void RemoveServiceListener(const ServiceListener& delegate, void* data); void AddModuleListener(const ModuleListener& delegate, void* data); void RemoveModuleListener(const ModuleListener& delegate, void* data); ModuleContextPrivate * const d; }; US_END_NAMESPACE #endif /* USMODULECONTEXT_H_ */ diff --git a/Modules/DICOMReader/include/mitkDICOMFileReaderSelector.h b/Modules/DICOMReader/include/mitkDICOMFileReaderSelector.h index 832f7fd456..ff12cd7730 100644 --- a/Modules/DICOMReader/include/mitkDICOMFileReaderSelector.h +++ b/Modules/DICOMReader/include/mitkDICOMFileReaderSelector.h @@ -1,100 +1,100 @@ /*============================================================================ 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 mitkDICOMFileReaderSelector_h #define mitkDICOMFileReaderSelector_h #include "mitkDICOMFileReader.h" #include namespace mitk { /** \ingroup DICOMReaderModule \brief Simple best-reader selection. This class implements a process of comparing different DICOMFileReader%s and selecting the reader with the minimal number of mitk::Image%s in its output. The code found in this class can - just be used to select a reader using this simple strategy - be taken as an example of how to use DICOMFileReader%s To create a selection of potential readers, the class makes use of mitk::DICOMReaderConfigurator, i.e. DICOMFileReaderSelector also expects the configuration files/strings to be in the format expected by mitk::DICOMReaderConfigurator. Two convenience methods load "default" configurations from compiled-in resources: LoadBuiltIn3DConfigs() and LoadBuiltIn3DnTConfigs(). */ class MITKDICOMREADER_EXPORT DICOMFileReaderSelector : public itk::LightObject { public: typedef std::list ReaderList; mitkClassMacroItkParent( DICOMFileReaderSelector, itk::LightObject ); itkNewMacro( DICOMFileReaderSelector ); /// \brief Add a configuration as expected by DICOMReaderConfigurator. /// Configs can only be reset by instantiating a new DICOMFileReaderSelector. void AddConfig(const std::string& xmlDescription); /// \brief Add a configuration as expected by DICOMReaderConfigurator. /// Configs can only be reset by instantiating a new DICOMFileReaderSelector. void AddConfigFile(const std::string& filename); /// \brief Add a whole pre-configured reader to the selection process. void AddFileReaderCanditate(DICOMFileReader::Pointer reader); - /// \brief Load 3D image creating configurations from the MITK module system (see \ref mitk::Module::FindResources). + /// \brief Load 3D image creating configurations from the MITK module system (see us::Module::FindResources()). /// For a default set of configurations, look into the directory Resources of the DICOMReader module. void LoadBuiltIn3DConfigs(); - /// \brief Load 3D+t image creating configurations from the MITK module system (see \ref mitk::Module::FindResources). + /// \brief Load 3D+t image creating configurations from the MITK module system (see us::Module::FindResources()). /// For a default set of configurations, look into the directory Resources of the DICOMReader module. void LoadBuiltIn3DnTConfigs(); /// \brief Return all the DICOMFileReader%s that are currently used for selection by this class. /// The readers returned by this method depend on what config files have been added earlier /// (or which of the built-in readers have been loaded) ReaderList GetAllConfiguredReaders() const; /// Input files void SetInputFiles(StringList filenames); /// Input files const StringList& GetInputFiles() const; /// Execute the analysis and selection process. The first reader with a minimal number of outputs will be returned. DICOMFileReader::Pointer GetFirstReaderWithMinimumNumberOfOutputImages(); protected: DICOMFileReaderSelector(); ~DICOMFileReaderSelector() override; void AddConfigsFromResources(const std::string& path); void AddConfigFromResource(const std::string& resourcename); void AddConfigFromResource(us::ModuleResource& resource); private: StringList m_PossibleConfigurations; StringList m_InputFilenames; ReaderList m_Readers; }; } // namespace #endif // mitkDICOMFileReaderSelector_h diff --git a/Modules/DicomRT/include/mitkDoseImageVtkMapper2D.h b/Modules/DicomRT/include/mitkDoseImageVtkMapper2D.h index 9c98014252..636f1a9ffe 100644 --- a/Modules/DicomRT/include/mitkDoseImageVtkMapper2D.h +++ b/Modules/DicomRT/include/mitkDoseImageVtkMapper2D.h @@ -1,309 +1,309 @@ /*============================================================================ 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 MITKDoseImageVtkMapper2D2D_H_HEADER_INCLUDED #define MITKDoseImageVtkMapper2D2D_H_HEADER_INCLUDED //MITK #include #include //MITK Rendering #include "mitkBaseRenderer.h" #include "mitkVtkMapper.h" #include "mitkExtractSliceFilter.h" //VTK #include #include #include class vtkActor; class vtkPolyDataMapper; class vtkPlaneSource; class vtkImageData; class vtkLookupTable; class vtkImageExtractComponents; class vtkImageReslice; class vtkImageChangeInformation; class vtkPoints; class vtkMitkThickSlicesFilter; class vtkPolyData; class vtkMitkApplyLevelWindowToRGBFilter; class vtkMitkLevelWindowFilter; namespace mitk { /** \brief Mapper to resample and display 2D slices of a 3D image. * * The following image gives a brief overview of the mapping and the involved parts. * * \image html DoseImageVtkMapper2Darchitecture.png * * First, the image is resliced by means of vtkImageReslice. The volume image * serves as input to the mapper in addition to spatial placement of the slice and a few other * properties such as thick slices. This code was already present in the old version * (mitkImageMapperGL2D). * * Next, the obtained slice (m_ReslicedImage) is put into a vtkMitkLevelWindowFilter * and the scalar levelwindow, opacity levelwindow and optional clipping to * local image bounds are applied * * Next, the output of the vtkMitkLevelWindowFilter is used to create a texture * (m_Texture) and a plane onto which the texture is rendered (m_Plane). For * mapping purposes, a vtkPolyDataMapper (m_Mapper) is utilized. Orthographic * projection is applied to create the effect of a 2D image. The mapper and the * texture are assigned to the actor (m_Actor) which is passed to the VTK rendering * pipeline via the method GetVtkProp(). * * In order to transform the textured plane to the correct position in space, the * same transformation as used for reslicing is applied to both the camera and the * vtkActor. All important steps are explained in more detail below. The resulting * 2D image (by reslicing the underlying 3D input image appropriately) can either * be directly rendered in a 2D view or just be calculated to be used later by another * rendering entity, e.g. in texture mapping in a 3D view. * * Properties that can be set for images and influence the imageMapper2D are: * * - \b "opacity": (FloatProperty) Opacity of the image * - \b "color": (ColorProperty) Color of the image * - \b "LookupTable": (mitkLookupTableProperty) If this property is set, * the default lookuptable will be ignored and the "LookupTable" value * will be used instead. - * - \b "Image Rendering.Mode": This property decides which mode is used to render images. (E.g. if a lookup table or a transferfunction is applied). Detailed documentation about the modes can be found here: \link mitk::RenderingerModeProperty \endlink + * - \b "Image Rendering.Mode": This property decides which mode is used to render images. (E.g. if a lookup table or a transferfunction is applied). Detailed documentation about the modes can be found here: \link mitk::RenderingModeProperty \endlink * - \b "Image Rendering.Transfer Function": (mitkTransferFunctionProperty) If this * property is set, a color transferfunction will be used to color the image. * - \b "binary": (BoolProperty) is the image a binary image or not * - \b "outline binary": (BoolProperty) show outline of the image or not * - \b "texture interpolation": (BoolProperty) texture interpolation of the image * - \b "reslice interpolation": (VtkResliceInterpolationProperty) reslice interpolation of the image * - \b "in plane resample extent by geometry": (BoolProperty) Do it or not * - \b "bounding box": (BoolProperty) Is the Bounding Box of the image shown or not * - \b "layer": (IntProperty) Layer of the image * - \b "volume annotation color": (ColorProperty) color of the volume annotation, TODO has to be reimplemented * - \b "volume annotation unit": (StringProperty) annotation unit as string (does not implicit convert the unit!) unit is ml or cm3, TODO has to be reimplemented * The default properties are: * - \b "opacity", mitk::FloatProperty::New(0.3f), renderer, overwrite ) * - \b "color", ColorProperty::New(1.0,0.0,0.0), renderer, overwrite ) * - \b "binary", mitk::BoolProperty::New( true ), renderer, overwrite ) * - \b "outline binary", mitk::BoolProperty::New( false ), renderer, overwrite ) * - \b "texture interpolation", mitk::BoolProperty::New( false ) ) * - \b "reslice interpolation", mitk::VtkResliceInterpolationProperty::New() ) * - \b "in plane resample extent by geometry", mitk::BoolProperty::New( false ) ) * - \b "bounding box", mitk::BoolProperty::New( false ) ) * - \b "layer", mitk::IntProperty::New(10), renderer, overwrite) * - \b "Image Rendering.Transfer Function": Default color transfer function for CTs * - \b "LookupTable": Rainbow color. * If the modality-property is set for an image, the mapper uses modality-specific default properties, * e.g. color maps, if they are defined. * \ingroup Mapper */ class MITKDICOMRT_EXPORT DoseImageVtkMapper2D : public VtkMapper { public: /** Standard class typedefs. */ mitkClassMacro( DoseImageVtkMapper2D,VtkMapper ); /** Method for creation through the object factory. */ itkFactorylessNewMacro(Self); itkCloneMacro(Self); /** \brief Get the Image to map */ const mitk::Image *GetInput(void); /** \brief Checks whether this mapper needs to update itself and generate * data. */ void Update(mitk::BaseRenderer * renderer) override; //### methods of MITK-VTK rendering pipeline vtkProp* GetVtkProp(mitk::BaseRenderer* renderer) override; //### end of methods of MITK-VTK rendering pipeline /** \brief Internal class holding the mapper, actor, etc. for each of the 3 2D render windows */ /** * To render transveral, coronal, and sagittal, the mapper is called three times. * For performance reasons, the corresponding data for each view is saved in the * internal helper class LocalStorage. This allows rendering n views with just * 1 mitkMapper using n vtkMapper. * */ class MITKDICOMRT_EXPORT LocalStorage : public mitk::Mapper::BaseLocalStorage { public: /** \brief Actor of a 2D render window. */ vtkSmartPointer m_Actor; vtkSmartPointer m_Actors; /** \brief Mapper of a 2D render window. */ vtkSmartPointer m_Mapper; vtkSmartPointer m_VectorComponentExtractor; /** \brief Current slice of a 2D render window.*/ vtkSmartPointer m_ReslicedImage; /** \brief Empty vtkPolyData that is set when rendering geometry does not * intersect the image geometry. * \warning This member variable is set to nullptr, * if no image geometry is inside the plane geometry * of the respective render window. Any user of this * slice has to check whether it is set to nullptr! */ vtkSmartPointer m_EmptyPolyData; /** \brief Plane on which the slice is rendered as texture. */ vtkSmartPointer m_Plane; /** \brief The texture which is used to render the current slice. */ vtkSmartPointer m_Texture; /** \brief The lookuptables for colors and level window */ vtkSmartPointer m_DefaultLookupTable; vtkSmartPointer m_BinaryLookupTable; vtkSmartPointer m_ColorLookupTable; /** \brief The actual reslicer (one per renderer) */ mitk::ExtractSliceFilter::Pointer m_Reslicer; /** \brief Filter for thick slices */ vtkSmartPointer m_TSFilter; /** \brief PolyData object containg all lines/points needed for outlining the contour. This container is used to save a computed contour for the next rendering execution. For instance, if you zoom or pann, there is no need to recompute the contour. */ vtkSmartPointer m_OutlinePolyData; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastUpdateTime; /** \brief mmPerPixel relation between pixel and mm. (World spacing).*/ mitk::ScalarType* m_mmPerPixel; /** \brief This filter is used to apply the level window to Grayvalue and RBG(A) images. */ vtkSmartPointer m_LevelWindowFilter; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage() override; }; /** \brief The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows. */ mitk::LocalStorageHandler m_LSH; /** \brief Get the LocalStorage corresponding to the current renderer. */ LocalStorage* GetLocalStorage(mitk::BaseRenderer* renderer); /** \brief Set the default properties for general image rendering. */ static void SetDefaultProperties(mitk::DataNode* node, mitk::BaseRenderer* renderer = nullptr, bool overwrite = false); /** \brief This method switches between different rendering modes (e.g. use a lookup table or a transfer function). - * Detailed documentation about the modes can be found here: \link mitk::RenderingerModeProperty \endlink + * Detailed documentation about the modes can be found here: \link mitk::RenderingModeProperty \endlink */ void ApplyRenderingMode(mitk::BaseRenderer *renderer); protected: /** \brief Transforms the actor to the actual position in 3D. * \param renderer The current renderer corresponding to the render window. */ void TransformActor(mitk::BaseRenderer* renderer); /** \brief Generates a plane according to the size of the resliced image in milimeters. * * \image html texturedPlane.png * * In VTK a vtkPlaneSource is defined through three points. The origin and two * points defining the axes of the plane (see VTK documentation). The origin is * set to (xMin; yMin; Z), where xMin and yMin are the minimal bounds of the * resliced image in space. Z is relevant for blending and the layer property. * The center of the plane (C) is also the center of the view plane (cf. the image above). * * \note For the standard MITK view with three 2D render windows showing three * different slices, three such planes are generated. All these planes are generated * in the XY-plane (even if they depict a YZ-slice of the volume). * */ void GeneratePlane(mitk::BaseRenderer* renderer, double planeBounds[6]); /** \brief Generates a vtkPolyData object containing the outline of a given binary slice. \param renderer: Pointer to the renderer containing the needed information \note This code is based on code from the iil library. */ vtkSmartPointer CreateOutlinePolyData(mitk::BaseRenderer* renderer); /** Default constructor */ DoseImageVtkMapper2D(); /** Default deconstructor */ ~DoseImageVtkMapper2D() override; /** \brief Does the actual resampling, without rendering the image yet. * All the data is generated inside this method. The vtkProp (or Actor) * is filled with content (i.e. the resliced image). * * After generation, a 4x4 transformation matrix(t) of the current slice is obtained * from the vtkResliceImage object via GetReslicesAxis(). This matrix is * applied to each textured plane (actor->SetUserTransform(t)) to transform everything * to the actual 3D position (cf. the following image). * * \image html cameraPositioning3D.png * */ void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override; /** \brief This method uses the vtkCamera clipping range and the layer property * to calcualte the depth of the object (e.g. image or contour). The depth is used * to keep the correct order for the final VTK rendering.*/ float CalculateLayerDepth(mitk::BaseRenderer* renderer); /** \brief This method applies (or modifies) the lookuptable for all types of images. * \warning To use the lookup table, the property 'Lookup Table' must be set and a 'Image Rendering.Mode' * which uses the lookup table must be set. */ void ApplyLookuptable(mitk::BaseRenderer* renderer); /** \brief This method applies a color transfer function. * Internally, a vtkColorTransferFunction is used. This is usefull for coloring continous * images (e.g. float) * \warning To use the color transfer function, the property 'Image Rendering.Transfer Function' must be set and a 'Image Rendering.Mode' which uses the color transfer function must be set. */ void ApplyColorTransferFunction(mitk::BaseRenderer* renderer); /** * @brief ApplyLevelWindow Apply the level window for the given renderer. * \warning To use the level window, the property 'LevelWindow' must be set and a 'Image Rendering.Mode' which uses the level window must be set. * @param renderer Level window for which renderer? */ void ApplyLevelWindow(mitk::BaseRenderer* renderer); /** \brief Set the color of the image/polydata */ void ApplyColor( mitk::BaseRenderer* renderer ); /** \brief Set the opacity of the actor. */ void ApplyOpacity( mitk::BaseRenderer* renderer ); /** * \brief Calculates whether the given rendering geometry intersects the * given SlicedGeometry3D. * * This method checks if the given PlaneGeometry intersects the given * SlicedGeometry3D. It calculates the distance of the PlaneGeometry to all * 8 cornerpoints of the SlicedGeometry3D. If all distances have the same * sign (all positive or all negative) there is no intersection. * If the distances have different sign, there is an intersection. **/ bool RenderingGeometryIntersectsImage( const PlaneGeometry* renderingGeometry, SlicedGeometry3D* imageGeometry ); private: void CreateLevelOutline(mitk::BaseRenderer* renderer, const mitk::IsoDoseLevel* level, float pref, vtkSmartPointer points, vtkSmartPointer lines, vtkSmartPointer colors); }; } // namespace mitk #endif /* MITKDoseImageVtkMapper2D_H_HEADER_INCLUDED_C10E906E */ diff --git a/Modules/Multilabel/mitkLabelSetImageVtkMapper2D.h b/Modules/Multilabel/mitkLabelSetImageVtkMapper2D.h index 224ec8c912..676305caf2 100644 --- a/Modules/Multilabel/mitkLabelSetImageVtkMapper2D.h +++ b/Modules/Multilabel/mitkLabelSetImageVtkMapper2D.h @@ -1,241 +1,241 @@ /*============================================================================ 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 __mitkLabelSetImageVtkMapper2D_H_ #define __mitkLabelSetImageVtkMapper2D_H_ // MITK #include "MitkMultilabelExports.h" #include "mitkCommon.h" // MITK Rendering #include "mitkBaseRenderer.h" #include "mitkExtractSliceFilter.h" #include "mitkLabelSetImage.h" #include "mitkVtkMapper.h" // VTK #include class vtkActor; class vtkPolyDataMapper; class vtkPlaneSource; class vtkImageData; class vtkLookupTable; class vtkImageReslice; class vtkPoints; class vtkMitkThickSlicesFilter; class vtkPolyData; class vtkMitkLevelWindowFilter; class vtkNeverTranslucentTexture; namespace mitk { /** \brief Mapper to resample and display 2D slices of a 3D labelset image. * * Properties that can be set for labelset images and influence this mapper are: * * - \b "labelset.contour.active": (BoolProperty) whether to show only the active label as a contour or not * - \b "labelset.contour.width": (FloatProperty) line width of the contour * The default properties are: * - \b "labelset.contour.active", mitk::BoolProperty::New( true ), renderer, overwrite ) * - \b "labelset.contour.width", mitk::FloatProperty::New( 2.0 ), renderer, overwrite ) * \ingroup Mapper */ class MITKMULTILABEL_EXPORT LabelSetImageVtkMapper2D : public VtkMapper { public: /** Standard class typedefs. */ mitkClassMacro(LabelSetImageVtkMapper2D, VtkMapper); /** Method for creation through the object factory. */ itkNewMacro(Self); /** \brief Get the Image to map */ const mitk::Image *GetInput(void); /** \brief Checks whether this mapper needs to update itself and generate * data. */ void Update(mitk::BaseRenderer *renderer) override; //### methods of MITK-VTK rendering pipeline vtkProp *GetVtkProp(mitk::BaseRenderer *renderer) override; //### end of methods of MITK-VTK rendering pipeline /** \brief Internal class holding the mapper, actor, etc. for each of the 3 2D render windows */ /** * To render transversal, coronal, and sagittal, the mapper is called three times. * For performance reasons, the corresponding data for each view is saved in the * internal helper class LocalStorage. This allows rendering n views with just * 1 mitkMapper using n vtkMapper. * */ class MITKMULTILABEL_EXPORT LocalStorage : public mitk::Mapper::BaseLocalStorage { public: vtkSmartPointer m_Actors; std::vector> m_LayerActorVector; std::vector> m_LayerMapperVector; std::vector> m_ReslicedImageVector; std::vector> m_LayerTextureVector; vtkSmartPointer m_EmptyPolyData; vtkSmartPointer m_Plane; std::vector m_ReslicerVector; vtkSmartPointer m_OutlinePolyData; /** \brief An actor for the outline */ vtkSmartPointer m_OutlineActor; /** \brief An actor for the outline shadow*/ vtkSmartPointer m_OutlineShadowActor; /** \brief A mapper for the outline */ vtkSmartPointer m_OutlineMapper; /** \brief Timestamp of last update of stored data. */ itk::TimeStamp m_LastDataUpdateTime; /** \brief Timestamp of last update of a property. */ itk::TimeStamp m_LastPropertyUpdateTime; /** \brief mmPerPixel relation between pixel and mm. (World spacing).*/ mitk::ScalarType *m_mmPerPixel; int m_NumberOfLayers; /** \brief This filter is used to apply the level window to Grayvalue and RBG(A) images. */ // vtkSmartPointer m_LevelWindowFilter; std::vector> m_LevelWindowFilterVector; /** \brief Default constructor of the local storage. */ LocalStorage(); /** \brief Default deconstructor of the local storage. */ ~LocalStorage() override; }; /** \brief The LocalStorageHandler holds all (three) LocalStorages for the three 2D render windows. */ mitk::LocalStorageHandler m_LSH; /** \brief Get the LocalStorage corresponding to the current renderer. */ LocalStorage *GetLocalStorage(mitk::BaseRenderer *renderer); /** \brief Set the default properties for general image rendering. */ static void SetDefaultProperties(mitk::DataNode *node, mitk::BaseRenderer *renderer = nullptr, bool overwrite = false); /** \brief This method switches between different rendering modes (e.g. use a lookup table or a transfer function). - * Detailed documentation about the modes can be found here: \link mitk::RenderingerModeProperty \endlink + * Detailed documentation about the modes can be found here: \link mitk::RenderingModeProperty \endlink */ void ApplyRenderingMode(mitk::BaseRenderer *renderer); protected: /** \brief Transforms the actor to the actual position in 3D. * \param renderer The current renderer corresponding to the render window. */ void TransformActor(mitk::BaseRenderer *renderer); /** \brief Generates a plane according to the size of the resliced image in milimeters. * * \image html texturedPlane.png * * In VTK a vtkPlaneSource is defined through three points. The origin and two * points defining the axes of the plane (see VTK documentation). The origin is * set to (xMin; yMin; Z), where xMin and yMin are the minimal bounds of the * resliced image in space. Z is relevant for blending and the layer property. * The center of the plane (C) is also the center of the view plane (cf. the image above). * * \note For the standard MITK view with three 2D render windows showing three * different slices, three such planes are generated. All these planes are generated * in the XY-plane (even if they depict a YZ-slice of the volume). * */ void GeneratePlane(mitk::BaseRenderer *renderer, double planeBounds[6]); /** \brief Generates a vtkPolyData object containing the outline of a given binary slice. \param renderer: Pointer to the renderer containing the needed information \note This code is based on code from the iil library. */ vtkSmartPointer CreateOutlinePolyData(mitk::BaseRenderer *renderer, vtkImageData *image, int pixelValue = 1); /** Default constructor */ LabelSetImageVtkMapper2D(); /** Default deconstructor */ ~LabelSetImageVtkMapper2D() override; /** \brief Does the actual resampling, without rendering the image yet. * All the data is generated inside this method. The vtkProp (or Actor) * is filled with content (i.e. the resliced image). * * After generation, a 4x4 transformation matrix(t) of the current slice is obtained * from the vtkResliceImage object via GetReslicesAxis(). This matrix is * applied to each textured plane (actor->SetUserTransform(t)) to transform everything * to the actual 3D position (cf. the following image). * * \image html cameraPositioning3D.png * */ void GenerateDataForRenderer(mitk::BaseRenderer *renderer) override; /** \brief This method uses the vtkCamera clipping range and the layer property * to calcualte the depth of the object (e.g. image or contour). The depth is used * to keep the correct order for the final VTK rendering.*/ float CalculateLayerDepth(mitk::BaseRenderer *renderer); /** \brief This method applies (or modifies) the lookuptable for all types of images. * \warning To use the lookup table, the property 'Lookup Table' must be set and a 'Image Rendering.Mode' * which uses the lookup table must be set. */ void ApplyLookuptable(mitk::BaseRenderer *renderer, int layer); /** \brief This method applies a color transfer function. * Internally, a vtkColorTransferFunction is used. This is usefull for coloring continous * images (e.g. float) * \warning To use the color transfer function, the property 'Image Rendering.Transfer Function' must be set and a * 'Image Rendering.Mode' which uses the color transfer function must be set. */ void ApplyColorTransferFunction(mitk::BaseRenderer *renderer); /** * @brief ApplyLevelWindow Apply the level window for the given renderer. * \warning To use the level window, the property 'LevelWindow' must be set and a 'Image Rendering.Mode' which uses * the level window must be set. * @param renderer Level window for which renderer? */ void ApplyLevelWindow(mitk::BaseRenderer *renderer); /** \brief Set the color of the image/polydata */ void ApplyColor(mitk::BaseRenderer *renderer, const mitk::Color &color); /** \brief Set the opacity of the actor. */ void ApplyOpacity(mitk::BaseRenderer *renderer, int layer); /** * \brief Calculates whether the given rendering geometry intersects the * given SlicedGeometry3D. * * This method checks if the given Geometry2D intersects the given * SlicedGeometry3D. It calculates the distance of the Geometry2D to all * 8 cornerpoints of the SlicedGeometry3D. If all distances have the same * sign (all positive or all negative) there is no intersection. * If the distances have different sign, there is an intersection. **/ bool RenderingGeometryIntersectsImage(const PlaneGeometry *renderingGeometry, SlicedGeometry3D *imageGeometry); }; } // namespace mitk #endif // __mitkLabelSetImageVtkMapper2D_H_ diff --git a/Modules/QtWidgetsExt/include/QmitkFunctionalityComponentContainer.h b/Modules/QtWidgetsExt/include/QmitkFunctionalityComponentContainer.h deleted file mode 100644 index b2aa08832e..0000000000 --- a/Modules/QtWidgetsExt/include/QmitkFunctionalityComponentContainer.h +++ /dev/null @@ -1,180 +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 QMITK_FUNCTIONALITYCOMPONENTCONTAINER_H -#define QMITK_FUNCTIONALITYCOMPONENTCONTAINER_H - -#include "MitkQtWidgetsExtExports.h" -#include "QmitkBaseFunctionalityComponent.h" - -#include "ui_QmitkFunctionalityComponentContainerControls.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/** -* \brief ContainerClass for components -* \ingroup QmitkFunctionalityComponent -* -* -* - \ref QmitkBaseFunctionalityComponent - -* -* \section QmitkFunctionalityComponentContainer Overview -* -* The FunctionalityComponentContainer is a containerclass for several components inherit from it. -* All Components including to one FunctionalityComponentContainer can be used together as one applied -* functionality. I.e. in particular that new functionalities can be combined with different components. -* As common ground for all inherit classes the FunctionalityComponentContainer includes a selector for -* marked data like image(s), segmentation(s) or model(s). -*/ - -class MITKQTWIDGETSEXT_EXPORT QmitkFunctionalityComponentContainer : public QmitkBaseFunctionalityComponent -{ - Q_OBJECT - -public: - /** \brief Standard-Constructor. */ - QmitkFunctionalityComponentContainer(QObject *parent = 0, - const char *parentName = 0, - bool updateSelector = true, - bool showSelector = true); - - /** \brief Destructor. */ - virtual ~QmitkFunctionalityComponentContainer(); - - /*! - \brief Method to create all Signale-Slot-Connections - */ - virtual void CreateConnections(); - - /*! - \brief Method to create the GUI-Object - */ - virtual void CreateQtPartControl(QWidget *parent, mitk::DataStorage::Pointer dataStorage); - - /** \brief Method to create the forward and backward -buttons to navigate through the wizard */ - void CreateNavigationButtons(); - - /** \brief Method to create a textLabel at the Top of the wizard where a description can be created */ - void SetWizardText(const QString &text); - - /** \brief also the Graphical User Interface for the component, like m_GUI, but with its specific type */ - Ui::QmitkFunctionalityComponentContainerGUI *GetFunctionalityComponentContainerGUI(); - - /** \brief Method to set the DataStorage*/ - virtual void SetDataStorage(mitk::DataStorage::Pointer dataStorage); - - /** \brief Method to get the DataStorage*/ - virtual mitk::DataStorage::Pointer GetDataStorage(); - - /** \brief Method to set the Name of the FunctionalityComponent */ - virtual void SetComponentName(QString name); - - /** \brief Method to get the Name of the FunctionalityComponent */ - virtual QString GetComponentName(); - - /** \brief Method to get the GUI of this component.*/ - QWidget *GetGUI(); - - virtual QmitkDataStorageComboBox *GetTreeNodeSelector(); - - /** \brief Method to set the Image Selector visible or invisible */ - virtual void SetSelectorVisibility(bool visibility); - - QmitkStdMultiWidget *GetMultiWidget(); - - /** \brief Method to return the ComboBox that includes all GUI-elements instead of the outermost checkable CheckBox - * and that can be set visible or not*/ - virtual QGroupBox *GetContentContainer(); - - /** \brief Method to return the outermost checkable ComboBox that is to decide whether the content shall be shown or - * not */ - virtual QGroupBox *GetMainCheckBoxContainer(); - - /** \brief Method to set the Tree-Node-Selector visible or not as his parent group-box is set shown or not. */ - virtual void SetShowTreeNodeSelector(bool show); - - /** \brief Method to return the group-box that contains the tree-node-selector */ - virtual QGroupBox *GetImageContent(); - - /** \brief Method to return the Image Selected in the Container Combo Box */ - virtual mitk::Image *GetParentMitkImage(); - - /** \brief Method to return the NextButton to switch to the next widgetStackPage*/ - QPushButton *GetNextButton(); - - /** \brief Method to return the BackButton to switch to the last widgetStackPage*/ - QPushButton *GetBackButton(); - - /** \brief method to add components into this component. */ - virtual void AddComponent(QmitkFunctionalityComponentContainer *componentContainer); - - /** \brief method to add components into this component. */ - virtual void AddComponent(QmitkFunctionalityComponentContainer *componentContainer, QString label, int stackPage); - - virtual void TreeChanged(const itk::EventObject &treeChangedEvent); - - virtual void Activated(); - - virtual void Deactivated(); - - /** \brief Attribute to decide whether the selector shall be updated when a parent-Selector is updatet or not */ - bool m_UpdateSelector; - - /** \brief Attribute to decide whether the selector shall be shown or not */ - bool m_ShowSelector; - - /** \brief Slot method that will be called if TreeNodeSelector widget was activated. */ - void ImageSelected(const mitk::DataNode *item); - -public slots: - - /** \brief Method to set the "GetContentContainer"-visible or not, addicted to the visibility of a parent-component - * and the status of the checkable ComboBox from "GetMainCheckBoxContainer()" */ - virtual void SetContentContainerVisibility(bool); - - virtual void TreeChanged(); - - virtual void DataStorageChanged(mitk::DataStorage::Pointer ds); - -protected: - /** \brief Method to update the content of all DataTreeComboBoxes. */ - virtual void UpdateDataTreeComboBoxes(); - - unsigned long m_ObserverTag; - QWidget *m_GUI; - bool m_Active; - QmitkDataStorageComboBox *m_SelectedItem; - mitk::DataStorage::Pointer m_DataStorage; - -private: - /** \brief also the Graphical User Interface for the component, like m_GUI, but with its specific type */ - Ui::QmitkFunctionalityComponentContainerGUI *m_FunctionalityComponentContainerGUI; - - QObject *m_Parent; - QString m_ComponentName; - QSpacerItem *m_Spacer; - QmitkStdMultiWidget *m_MulitWidget; - QPushButton *m_BackButton; - QPushButton *m_NextButton; - int m_MaximumWidgedStackSize; -}; - -#endif diff --git a/Modules/QtWidgetsExt/src/QmitkFunctionalityComponentContainer.cpp b/Modules/QtWidgetsExt/src/QmitkFunctionalityComponentContainer.cpp deleted file mode 100644 index 9cf43a280b..0000000000 --- a/Modules/QtWidgetsExt/src/QmitkFunctionalityComponentContainer.cpp +++ /dev/null @@ -1,452 +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 "QmitkFunctionalityComponentContainer.h" -#include "ui_QmitkFunctionalityComponentContainerControls.h" - -#include "mitkDataTreeFilterFunctions.h" -#include "mitkProperties.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -const QSizePolicy preferred(QSizePolicy::Preferred, QSizePolicy::Preferred); - -QmitkFunctionalityComponentContainer::QmitkFunctionalityComponentContainer(QObject *parent, - const char *parentName, - bool updateSelector, - bool showSelector) - : QmitkBaseFunctionalityComponent(parent, parentName), - m_UpdateSelector(updateSelector), - m_ShowSelector(showSelector), - m_GUI(nullptr), - m_Active(false), - m_SelectedItem(nullptr), - m_FunctionalityComponentContainerGUI(nullptr), - m_Parent(parent), - m_ComponentName("ComponentContainer"), - m_Spacer(nullptr), - m_BackButton(nullptr), - m_NextButton(nullptr), - m_MaximumWidgedStackSize(-1) -{ - SetAvailability(true); -} - -QmitkFunctionalityComponentContainer::~QmitkFunctionalityComponentContainer() -{ -} - -void QmitkFunctionalityComponentContainer::SetComponentName(QString name) -{ - m_ComponentName = name; -} - -QString QmitkFunctionalityComponentContainer::GetComponentName() -{ - return m_ComponentName; -} - -void QmitkFunctionalityComponentContainer::SetShowTreeNodeSelector(bool show) -{ - GetImageContent()->setShown(show); -} - -QGroupBox *QmitkFunctionalityComponentContainer::GetImageContent() -{ - return (QGroupBox *)m_FunctionalityComponentContainerGUI->m_ImageContent; -} - -QWidget *QmitkFunctionalityComponentContainer::GetGUI() -{ - return m_GUI; -} - -mitk::Image *QmitkFunctionalityComponentContainer::GetParentMitkImage() -{ - return m_ParentMitkImage; -} - -QmitkDataStorageComboBox *QmitkFunctionalityComponentContainer::GetTreeNodeSelector() -{ - if (m_FunctionalityComponentContainerGUI) - { - return m_FunctionalityComponentContainerGUI->m_TreeNodeSelector; - } - else - return nullptr; -} - -QmitkStdMultiWidget *QmitkFunctionalityComponentContainer::GetMultiWidget() -{ - return m_MulitWidget; -} - -void QmitkFunctionalityComponentContainer::TreeChanged(const itk::EventObject &) -{ - if (IsActivated()) - { - TreeChanged(); - } - else - TreeChanged(); -} - -void QmitkFunctionalityComponentContainer::TreeChanged() -{ - UpdateDataTreeComboBoxes(); - - for (unsigned int i = 0; i < m_AddedChildList.size(); i++) - { - m_AddedChildList[i]->TreeChanged(); - } -} - -void QmitkFunctionalityComponentContainer::UpdateDataTreeComboBoxes() -{ -} - -void QmitkFunctionalityComponentContainer::CreateConnections() -{ - if (m_FunctionalityComponentContainerGUI) - { - connect((QObject *)(m_FunctionalityComponentContainerGUI->m_TreeNodeSelector), - SIGNAL(OnSelectionChanged(const mitk::DataNode *)), - (QObject *)this, - SLOT(ImageSelected(const mitk::DataNode *))); - connect((QObject *)(m_FunctionalityComponentContainerGUI->m_ContainerBorder), - SIGNAL(toggled(bool)), - (QObject *)this, - SLOT(SetContentContainerVisibility(bool))); - } -} - -void QmitkFunctionalityComponentContainer::SetDataStorage(mitk::DataStorage::Pointer dataStorage) -{ - m_DataStorage = dataStorage; -} - -mitk::DataStorage::Pointer QmitkFunctionalityComponentContainer::GetDataStorage() -{ - return m_DataStorage; -} - -void QmitkFunctionalityComponentContainer::DataStorageChanged(mitk::DataStorage::Pointer ds) -{ - if (m_FunctionalityComponentContainerGUI != nullptr) - { - for (unsigned int i = 0; i < m_AddedChildList.size(); i++) - { - QmitkBaseFunctionalityComponent *functionalityComponent = - dynamic_cast(m_AddedChildList[i]); - if (functionalityComponent != nullptr) - { - functionalityComponent->DataStorageChanged(ds); - } - } - } - - if (m_FunctionalityComponentContainerGUI) - { - if (!m_FunctionalityComponentContainerGUI->m_TreeNodeSelector) - return; - if (!m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()) - return; - if (!m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()->GetData()) - return; - m_ParentMitkImage = static_cast( - m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()->GetData()); - - if (m_FunctionalityComponentContainerGUI != nullptr) - { - for (unsigned int i = 0; i < m_AddedChildList.size(); i++) - { - QmitkBaseFunctionalityComponent *functionalityComponent = - dynamic_cast(m_AddedChildList[i]); - if (functionalityComponent != nullptr) - { - if (!m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()->GetData()) - return; - functionalityComponent->m_ParentMitkImage = static_cast( - m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->GetSelectedNode()->GetData()); - } - } - } - } -} - -void QmitkFunctionalityComponentContainer::ImageSelected(const mitk::DataNode *item) -{ - if (m_FunctionalityComponentContainerGUI != nullptr) - { - mitk::DataNode::Pointer selectedItem = const_cast(item); - GetTreeNodeSelector()->SetSelectedNode(selectedItem); - - for (unsigned int i = 0; i < m_AddedChildList.size(); i++) - { - QmitkBaseFunctionalityComponent *functionalityComponent = - dynamic_cast(m_AddedChildList[i]); - if (functionalityComponent != nullptr) - functionalityComponent->ImageSelected(item); - } - } - - if (m_FunctionalityComponentContainerGUI) - { - m_ParentMitkImage = static_cast(item->GetData()); - - if (m_FunctionalityComponentContainerGUI != nullptr) - { - for (unsigned int i = 0; i < m_AddedChildList.size(); i++) - { - QmitkBaseFunctionalityComponent *functionalityComponent = - dynamic_cast(m_AddedChildList[i]); - if (functionalityComponent != nullptr) - { - functionalityComponent->m_ParentMitkImage = static_cast(item->GetData()); - } - } - } - } - TreeChanged(); -} - -void QmitkFunctionalityComponentContainer::CreateQtPartControl(QWidget *, mitk::DataStorage::Pointer dataStorage) -{ - if (m_FunctionalityComponentContainerGUI == nullptr) - { - m_GUI = new QWidget; - m_FunctionalityComponentContainerGUI = new Ui::QmitkFunctionalityComponentContainerGUI; - m_FunctionalityComponentContainerGUI->setupUi(m_GUI); - - this->SetDataStorage(dataStorage); - - m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->SetDataStorage(dataStorage); - m_FunctionalityComponentContainerGUI->m_TreeNodeSelector->SetPredicate(mitk::NodePredicateDataType::New("Image")); - - m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(0); - } - this->CreateConnections(); -} - -QGroupBox *QmitkFunctionalityComponentContainer::GetContentContainer() -{ - return m_FunctionalityComponentContainerGUI->m_ImageContent; -} - -QGroupBox *QmitkFunctionalityComponentContainer::GetMainCheckBoxContainer() -{ - return m_FunctionalityComponentContainerGUI->m_ContainerBorder; -} - -void QmitkFunctionalityComponentContainer::SetContentContainerVisibility(bool) -{ - if (GetMainCheckBoxContainer() != nullptr) - { - if (GetMainCheckBoxContainer()->isChecked()) - { - Activated(); - } - else - { - Deactivated(); - } - } - for (unsigned int i = 0; i < m_AddedChildList.size(); i++) - { - if (m_AddedChildList[i]->GetContentContainer() != nullptr) - { - m_AddedChildList[i]->GetContentContainer()->setShown(GetMainCheckBoxContainer()->isChecked()); - } - if (m_AddedChildList[i]->GetMainCheckBoxContainer() != nullptr) - { - m_AddedChildList[i]->GetMainCheckBoxContainer()->setChecked(GetMainCheckBoxContainer()->isChecked()); - } - m_AddedChildList[i]->SetContentContainerVisibility(GetMainCheckBoxContainer()->isChecked()); - } -} - -void QmitkFunctionalityComponentContainer::SetSelectorVisibility(bool visibility) -{ - if (m_GUI) - { - m_FunctionalityComponentContainerGUI->m_ImageContent->setShown(visibility); - } - m_ShowSelector = visibility; -} - -void QmitkFunctionalityComponentContainer::Activated() -{ - TreeChanged(); - QmitkBaseFunctionalityComponent::Activated(); - m_Active = true; - for (unsigned int i = 0; i < m_AddedChildList.size(); i++) - { - m_AddedChildList[i]->Activated(); - } -} - -void QmitkFunctionalityComponentContainer::Deactivated() -{ - QmitkBaseFunctionalityComponent::Deactivated(); - m_Active = false; - for (unsigned int i = 0; i < m_AddedChildList.size(); i++) - { - m_AddedChildList[i]->Deactivated(); - } -} - -void QmitkFunctionalityComponentContainer::AddComponent(QmitkFunctionalityComponentContainer *component) -{ - if (component != nullptr) - { - QWidget *componentWidget = component->CreateControlWidget(m_GUI); - AddComponentListener(component); - m_GUI->layout()->addWidget(componentWidget); - component->CreateConnections(); - if (m_Spacer != nullptr) - { - m_GUI->layout()->removeItem(m_Spacer); - } - QSpacerItem *spacer = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); - m_Spacer = spacer; - m_GUI->layout()->addItem(m_Spacer); - m_GUI->repaint(); - } -} - -QPushButton *QmitkFunctionalityComponentContainer::GetNextButton() -{ - return m_NextButton; -} - -QPushButton *QmitkFunctionalityComponentContainer::GetBackButton() -{ - return m_BackButton; -} - -void QmitkFunctionalityComponentContainer::AddComponent(QmitkFunctionalityComponentContainer *component, - QString label, - int stackPage) -{ - if (component != nullptr) - { - QWidget *visibleWidget = m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget(); - int idVisibleWidget = m_FunctionalityComponentContainerGUI->m_WidgetStack->indexOf(visibleWidget); - if (idVisibleWidget > m_MaximumWidgedStackSize) - { - m_MaximumWidgedStackSize = idVisibleWidget; - } - if (m_MaximumWidgedStackSize < stackPage) - { - QWidget *w = new QWidget(m_FunctionalityComponentContainerGUI->m_WidgetStack); - m_FunctionalityComponentContainerGUI->m_WidgetStack->insertTab(stackPage, w, label); - m_MaximumWidgedStackSize++; - m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(stackPage); - visibleWidget = m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget(); - idVisibleWidget = m_FunctionalityComponentContainerGUI->m_WidgetStack->indexOf(visibleWidget); - new QVBoxLayout(visibleWidget); - } - - QLayout *layout; - if (m_FunctionalityComponentContainerGUI->m_WidgetStack->layout() == 0) - { - layout = new QVBoxLayout((QWidget *)(m_FunctionalityComponentContainerGUI->m_WidgetStack)); - } - else - { - layout = m_FunctionalityComponentContainerGUI->m_WidgetStack->layout(); - } - - component->CreateQtPartControl(m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget(), - this->m_DataStorage); - QWidget *componentWidget = component->GetGUI(); - AddComponentListener(component); - m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(stackPage); - QWidget *theCurrentWidget = m_FunctionalityComponentContainerGUI->m_WidgetStack->currentWidget(); - QLayout *theCurrentLayout = theCurrentWidget->layout(); - theCurrentLayout->addWidget(componentWidget); - - m_FunctionalityComponentContainerGUI->m_WidgetStack->setShown(true); - m_FunctionalityComponentContainerGUI->m_WidgetStack->updateGeometry(); - m_FunctionalityComponentContainerGUI->m_WidgetStack->layout()->activate(); - componentWidget->setShown(true); - component->CreateConnections(); - - m_GUI->repaint(); - } -} - -void QmitkFunctionalityComponentContainer::CreateNavigationButtons() -{ - QWidget *funcWidget = (QWidget *)m_FunctionalityComponentContainerGUI; - QLayout *functionalityLayout = funcWidget->layout(); - QBoxLayout *buttonLayout = new QHBoxLayout(funcWidget); - if (QBoxLayout *boxLayout = dynamic_cast(functionalityLayout)) - { - boxLayout->addLayout(buttonLayout); - } - if (m_BackButton == nullptr) - { - m_BackButton = new QPushButton("<<", (QWidget *)(m_FunctionalityComponentContainerGUI)); - } - if (m_NextButton == nullptr) - { - m_NextButton = new QPushButton(">>", (QWidget *)(m_FunctionalityComponentContainerGUI)); - } - buttonLayout->addWidget(m_BackButton); - buttonLayout->addWidget(m_NextButton); - m_BackButton->setShown(true); - m_NextButton->setShown(true); - m_GUI->layout()->activate(); - m_GUI->repaint(); - - m_FunctionalityComponentContainerGUI->m_WidgetStack->setCurrentIndex(1); - SetWizardText(""); - GetImageContent()->updateGeometry(); - if (m_Spacer != nullptr) - { - m_GUI->layout()->removeItem(m_Spacer); - } - QSpacerItem *spacer = new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding); - m_Spacer = spacer; - m_GUI->layout()->addItem(m_Spacer); - m_GUI->updateGeometry(); - m_GUI->repaint(); -} - -void QmitkFunctionalityComponentContainer::SetWizardText(const QString &) -{ - GetImageContent()->updateGeometry(); - GetImageContent()->repaint(); - m_GUI->updateGeometry(); - m_GUI->layout()->activate(); - m_GUI->repaint(); -} - -Ui::QmitkFunctionalityComponentContainerGUI * - QmitkFunctionalityComponentContainer::GetFunctionalityComponentContainerGUI() -{ - return m_FunctionalityComponentContainerGUI; -} diff --git a/Modules/Segmentation/Algorithms/mitkOverwriteDirectedPlaneImageFilter.h b/Modules/Segmentation/Algorithms/mitkOverwriteDirectedPlaneImageFilter.h index 2b112b0337..c87c74a6dd 100644 --- a/Modules/Segmentation/Algorithms/mitkOverwriteDirectedPlaneImageFilter.h +++ b/Modules/Segmentation/Algorithms/mitkOverwriteDirectedPlaneImageFilter.h @@ -1,120 +1,117 @@ /*============================================================================ 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 mitkOverwriteDirectedPlaneImageFilter_h_Included #define mitkOverwriteDirectedPlaneImageFilter_h_Included #include "mitkCommon.h" #include "mitkImageToImageFilter.h" #include #include namespace mitk { /** \deprecated This class is deprecated. Use mitkVtkImageOverwrite instead. \sa mitkVtkImageOverwrite \brief Writes a 2D slice into a 3D image. \sa SegTool2D \sa ContourTool \sa ExtractImageFilter \ingroup Process \ingroup Reliver - There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref - QmitkInteractiveSegmentationTechnicalPage - This class takes a 3D mitk::Image as input and tries to replace one slice in it with the second input image, which is specified by calling SetSliceImage with a 2D mitk::Image. Two parameters determine which slice is replaced: the "slice dimension" is that one, which is constant for all points in the plane, e.g. axial would mean 2. The "slice index" is the slice index in the image direction you specified with "affected dimension". Indices count from zero. This class works with all kind of image types, the only restrictions being that the input is 3D, and the slice image is 2D. If requested by SetCreateUndoInformation(true), this class will create instances of ApplyDiffImageOperation for the undo stack. These operations will (on user request) be executed by DiffImageApplier to perform undo. Last contributor: $Author: maleike $ */ class MITKSEGMENTATION_EXPORT OverwriteDirectedPlaneImageFilter : public ImageToImageFilter { public: mitkClassMacro(OverwriteDirectedPlaneImageFilter, ImageToImageFilter); itkFactorylessNewMacro(Self); itkCloneMacro(Self); /** \brief Which plane to overwrite */ const BaseGeometry *GetPlaneGeometry3D() const { return m_PlaneGeometry; } void SetPlaneGeometry3D(const BaseGeometry *geometry) { m_PlaneGeometry = geometry; } /** \brief Time step of the slice to overwrite */ itkSetMacro(TimeStep, unsigned int); itkGetConstMacro(TimeStep, unsigned int); /** \brief Whether to create undo operation in the MITK undo stack */ itkSetMacro(CreateUndoInformation, bool); itkGetConstMacro(CreateUndoInformation, bool); itkSetObjectMacro(SliceImage, Image); const Image *GetSliceImage() { return m_SliceImage.GetPointer(); } const Image *GetLastDifferenceImage() { return m_SliceDifferenceImage.GetPointer(); } protected: OverwriteDirectedPlaneImageFilter(); // purposely hidden ~OverwriteDirectedPlaneImageFilter() override; void GenerateData() override; template void ItkSliceOverwriting(itk::Image *input3D); template void ItkImageSwitch(itk::Image *image); template void ItkImageProcessing(itk::Image *itkImage1, itk::Image *itkImage2); // std::string EventDescription( unsigned int sliceDimension, unsigned int sliceIndex, unsigned int timeStep ); Image::ConstPointer m_SliceImage; Image::Pointer m_SliceDifferenceImage; const BaseGeometry *m_PlaneGeometry; const BaseGeometry *m_ImageGeometry3D; unsigned int m_TimeStep; unsigned int m_Dimension0; unsigned int m_Dimension1; bool m_CreateUndoInformation; }; } // namespace #endif diff --git a/Modules/Segmentation/Algorithms/mitkOverwriteSliceImageFilter.h b/Modules/Segmentation/Algorithms/mitkOverwriteSliceImageFilter.h index bbd80153ad..97db8915ef 100644 --- a/Modules/Segmentation/Algorithms/mitkOverwriteSliceImageFilter.h +++ b/Modules/Segmentation/Algorithms/mitkOverwriteSliceImageFilter.h @@ -1,124 +1,121 @@ /*============================================================================ 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 mitkOverwriteSliceImageFilter_h_Included #define mitkOverwriteSliceImageFilter_h_Included #include "mitkCommon.h" #include "mitkImageToImageFilter.h" #include #include namespace mitk { /** \deprecated This class is deprecated. Use mitkVtkImageOverwrite instead. \sa mitkVtkImageOverwrite \brief Writes a 2D slice into a 3D image. \sa SegTool2D \sa ContourTool \sa ExtractImageFilter \ingroup Process \ingroup ToolManagerEtAl - There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref - QmitkInteractiveSegmentationTechnicalPage - This class takes a 3D mitk::Image as input and tries to replace one slice in it with the second input image, which is specified by calling SetSliceImage with a 2D mitk::Image. Two parameters determine which slice is replaced: the "slice dimension" is that one, which is constant for all points in the plane, e.g. axial would mean 2. The "slice index" is the slice index in the image direction you specified with "affected dimension". Indices count from zero. This class works with all kind of image types, the only restrictions being that the input is 3D, and the slice image is 2D. If requested by SetCreateUndoInformation(true), this class will create instances of ApplyDiffImageOperation for the undo stack. These operations will (on user request) be executed by DiffImageApplier to perform undo. Last contributor: $Author$ */ class MITKSEGMENTATION_EXPORT OverwriteSliceImageFilter : public ImageToImageFilter { public: mitkClassMacro(OverwriteSliceImageFilter, ImageToImageFilter); itkFactorylessNewMacro(Self); itkCloneMacro(Self); /** \brief Which slice to overwrite (first one has index 0). */ itkSetMacro(SliceIndex, unsigned int); itkGetConstMacro(SliceIndex, unsigned int); /** \brief The orientation of the slice to overwrite. \a Parameter \a SliceDimension Number of the dimension which is constant for all pixels of the desired slices (e.g. 0 for axial) */ itkSetMacro(SliceDimension, unsigned int); itkGetConstMacro(SliceDimension, unsigned int); /** \brief Time step of the slice to overwrite */ itkSetMacro(TimeStep, unsigned int); itkGetConstMacro(TimeStep, unsigned int); /** \brief Whether to create undo operation in the MITK undo stack */ itkSetMacro(CreateUndoInformation, bool); itkGetConstMacro(CreateUndoInformation, bool); itkSetObjectMacro(SliceImage, Image); const Image *GetSliceImage() { return m_SliceImage.GetPointer(); } const Image *GetLastDifferenceImage() { return m_SliceDifferenceImage.GetPointer(); } protected: OverwriteSliceImageFilter(); // purposely hidden ~OverwriteSliceImageFilter() override; void GenerateData() override; template void ItkImageSwitch(itk::Image *image); template void ItkImageProcessing(const itk::Image *itkImage1, itk::Image *itkImage2); std::string EventDescription(unsigned int sliceDimension, unsigned int sliceIndex, unsigned int timeStep); Image::ConstPointer m_SliceImage; Image::Pointer m_SliceDifferenceImage; unsigned int m_SliceIndex; unsigned int m_SliceDimension; unsigned int m_TimeStep; unsigned int m_Dimension0; unsigned int m_Dimension1; bool m_CreateUndoInformation; }; } // namespace #endif diff --git a/Modules/Segmentation/Controllers/mitkSegmentationInterpolationController.h b/Modules/Segmentation/Controllers/mitkSegmentationInterpolationController.h index fe5c96c85f..53673f57e1 100644 --- a/Modules/Segmentation/Controllers/mitkSegmentationInterpolationController.h +++ b/Modules/Segmentation/Controllers/mitkSegmentationInterpolationController.h @@ -1,223 +1,220 @@ /*============================================================================ 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 mitkSegmentationInterpolationController_h_Included #define mitkSegmentationInterpolationController_h_Included #include "mitkCommon.h" #include "mitkImage.h" #include #include #include #include #include namespace mitk { class Image; /** \brief Generates interpolations of 2D slices. \sa QmitkSlicesInterpolator \sa QmitkInteractiveSegmentation \ingroup ToolManagerEtAl - There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref - QmitkInteractiveSegmentationTechnicalPage - This class keeps track of the contents of a 3D segmentation image. \attention mitk::SegmentationInterpolationController assumes that the image contains pixel values of 0 and 1. After you set the segmentation image using SetSegmentationVolume(), the whole image is scanned for pixels other than 0. SegmentationInterpolationController registers as an observer to the segmentation image, and repeats the scan whenvever the image is modified. You can prevent this (time consuming) scan if you do the changes slice-wise and send difference images to SegmentationInterpolationController. For this purpose SetChangedSlice() should be used. mitk::OverwriteImageFilter already does this every time it changes a slice of an image. There is a static method InterpolatorForImage(), which can be used to find out if there already is an interpolator instance for a specified image. OverwriteImageFilter uses this to get to know its interpolator. SegmentationInterpolationController needs to maintain some information about the image slices (in every dimension). This information is stored internally in m_SegmentationCountInSlice, which is basically three std::vectors (one for each dimension). Each item describes one image dimension, each vector item holds the count of pixels in "its" slice. This is perhaps better to understand from the following picture (where red items just mean to symbolize "there is some segmentation" - in reality there is an integer count). \image html slice_based_segmentation_interpolator.png $Author$ */ class MITKSEGMENTATION_EXPORT SegmentationInterpolationController : public itk::Object { public: mitkClassMacroItkParent(SegmentationInterpolationController, itk::Object); itkFactorylessNewMacro(Self); itkCloneMacro(Self); /** \brief Find interpolator for a given image. \return nullptr if there is no interpolator yet. This method is useful if several "clients" modify the same image and want to access the interpolations. Then they can share the same object. */ static SegmentationInterpolationController *InterpolatorForImage(const Image *); /** \brief Block reaction to an images Modified() events. Blocking the scan of the whole image is especially useful when you are about to change a single slice of the image. Then you would send a difference image of this single slice to SegmentationInterpolationController but call image->Modified() anyway. Before calling image->Modified() you should block SegmentationInterpolationController's reactions to this modified by using this method. */ void BlockModified(bool); /** \brief Initialize with a whole volume. Will scan the volume for segmentation pixels (values other than 0) and fill some internal data structures. You don't have to call this method every time something changes, but only when several slices at once change. When you change a single slice, call SetChangedSlice() instead. */ void SetSegmentationVolume(const Image *segmentation); /** \brief Set a reference image (original patient image) - optional. If this volume is set (must exactly match the dimensions of the segmentation), the interpolation algorithm may consider image content to improve the interpolated (estimated) segmentation. */ void SetReferenceVolume(const Image *segmentation); /** \brief Update after changing a single slice. \param sliceDiff is a 2D image with the difference image of the slice determined by sliceDimension and sliceIndex. The difference is (pixel value in the new slice minus pixel value in the old slice). \param sliceDimension Number of the dimension which is constant for all pixels of the meant slice. \param sliceIndex Which slice to take, in the direction specified by sliceDimension. Count starts from 0. \param timeStep Which time step is changed */ void SetChangedSlice(const Image *sliceDiff, unsigned int sliceDimension, unsigned int sliceIndex, unsigned int timeStep); void SetChangedVolume(const Image *sliceDiff, unsigned int timeStep); /** \brief Generates an interpolated image for the given slice. \param sliceDimension Number of the dimension which is constant for all pixels of the meant slice. \param sliceIndex Which slice to take, in the direction specified by sliceDimension. Count starts from 0. \param timeStep Which time step to use */ Image::Pointer Interpolate(unsigned int sliceDimension, unsigned int sliceIndex, const mitk::PlaneGeometry *currentPlane, unsigned int timeStep); void OnImageModified(const itk::EventObject &); /** * Activate/Deactivate the 2D interpolation. */ void Activate2DInterpolation(bool); /** \brief Get existing instance or create a new one */ static SegmentationInterpolationController *GetInstance(); protected: /** \brief Protected class of mitk::SegmentationInterpolationController. Don't use (you shouldn't be able to do so)! */ class MITKSEGMENTATION_EXPORT SetChangedSliceOptions { public: SetChangedSliceOptions( unsigned int sd, unsigned int si, unsigned int d0, unsigned int d1, unsigned int t, const void *pixels) : sliceDimension(sd), sliceIndex(si), dim0(d0), dim1(d1), timeStep(t), pixelData(pixels) { } unsigned int sliceDimension; unsigned int sliceIndex; unsigned int dim0; unsigned int dim1; unsigned int timeStep; const void *pixelData; }; typedef std::vector DirtyVectorType; // typedef std::vector< DirtyVectorType[3] > TimeResolvedDirtyVectorType; // cannot work with C++, so next line is // used for implementation typedef std::vector> TimeResolvedDirtyVectorType; typedef std::map InterpolatorMapType; SegmentationInterpolationController(); // purposely hidden ~SegmentationInterpolationController() override; /// internal scan of a single slice template void ScanChangedSlice(const itk::Image *, const SetChangedSliceOptions &options); template void ScanChangedVolume(const itk::Image *, unsigned int timeStep); template void ScanWholeVolume(const itk::Image *, const Image *volume, unsigned int timeStep); void PrintStatus(); /** An array of flags. One for each dimension of the image. A flag is set, when a slice in a certain dimension has at least one pixel that is not 0 (which would mean that it has to be considered by the interpolation algorithm). E.g. flags for axial slices are stored in m_SegmentationCountInSlice[0][index]. Enhanced with time steps it is now m_SegmentationCountInSlice[timeStep][0][index] */ TimeResolvedDirtyVectorType m_SegmentationCountInSlice; static InterpolatorMapType s_InterpolatorForImage; Image::ConstPointer m_Segmentation; Image::ConstPointer m_ReferenceImage; bool m_BlockModified; bool m_2DInterpolationActivated; }; } // namespace #endif diff --git a/Modules/Segmentation/Controllers/mitkSliceBasedInterpolationController.h b/Modules/Segmentation/Controllers/mitkSliceBasedInterpolationController.h index ba89047e97..4f8996d593 100644 --- a/Modules/Segmentation/Controllers/mitkSliceBasedInterpolationController.h +++ b/Modules/Segmentation/Controllers/mitkSliceBasedInterpolationController.h @@ -1,203 +1,200 @@ /*============================================================================ 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 mitkSliceBasedInterpolationController_h_Included #define mitkSliceBasedInterpolationController_h_Included #include "mitkLabelSetImage.h" #include #include #include #include #include namespace mitk { class Image; /** \brief Generates interpolations of 2D slices. \sa QmitkSlicesInterpolator \sa QmitkInteractiveSegmentation \ingroup ToolManagerEtAl - There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref - QmitkInteractiveSegmentationTechnicalPage - This class keeps track of the contents of a 3D segmentation image. \attention mitk::SliceBasedInterpolationController assumes that the image contains pixel values of 0 and 1. After you set the segmentation image using SetSegmentationVolume(), the whole image is scanned for pixels other than 0. SliceBasedInterpolationController registers as an observer to the segmentation image, and repeats the scan whenvever the image is modified. You can prevent this (time consuming) scan if you do the changes slice-wise and send difference images to SliceBasedInterpolationController. For this purpose SetChangedSlice() should be used. mitk::OverwriteImageFilter already does this every time it changes a slice of an image. There is a static method InterpolatorForImage(), which can be used to find out if there already is an interpolator instance for a specified image. OverwriteImageFilter uses this to get to know its interpolator. SliceBasedInterpolationController needs to maintain some information about the image slices (in every dimension). This information is stored internally in m_SegmentationCountInSlice, which is basically three std::vectors (one for each dimension). Each item describes one image dimension, each vector item holds the count of pixels in "its" slice. This is perhaps better to understand from the following picture (where red items just mean to symbolize "there is some segmentation" - in reality there is an integer count). \image html slice_based_segmentation_interpolator.png $Author$ */ class MITKSEGMENTATION_EXPORT SliceBasedInterpolationController : public itk::Object { public: mitkClassMacroItkParent(SliceBasedInterpolationController, itk::Object); itkFactorylessNewMacro(Self); itkCloneMacro(Self); /** \brief Find interpolator for a given image. \return nullptr if there is no interpolator yet. This method is useful if several "clients" modify the same image and want to access the interpolations. Then they can share the same object. */ static SliceBasedInterpolationController *InterpolatorForImage(const Image *); /** \brief Initialize with a whole volume. Will scan the volume for segmentation pixels (values other than 0) and fill some internal data structures. You don't have to call this method every time something changes, but only when several slices at once change. When you change a single slice, call SetChangedSlice() instead. */ void SetWorkingImage(LabelSetImage *image); /** \brief Set a reference image (original patient image) - optional. If this image is set (must exactly match the dimensions of the segmentation), the interpolation algorithm may consider image content to improve the interpolated (estimated) segmentation. */ void SetReferenceImage(Image *image); /** \brief Update after changing a single slice in the working image. \param image is a 2D image with the difference image of the slice determined by sliceDimension and sliceIndex. The difference is (pixel value in the new slice minus pixel value in the old slice). \param sliceDimension Number of the dimension which is constant for all pixels of the meant slice. \param sliceIndex Which slice to take, in the direction specified by sliceDimension. Count starts from 0. \param timeStep Which time step is changed */ void SetChangedSlice(const Image *image, unsigned int sliceDimension, unsigned int sliceIndex, unsigned int timeStep); /** \brief Update after changing the whole working image. \param image is a 3D image with the difference image of the slice determined by sliceDimension and sliceIndex. The difference is (pixel value in the new slice minus pixel value in the old slice). \param timeStep Which time step is changed */ // void SetChangedImage( const Image* image, unsigned int timeStep ); /** \brief Generates an interpolated image for the given slice. \param sliceDimension Number of the dimension which is constant for all pixels of the meant slice. \param sliceIndex Which slice to take, in the direction specified by sliceDimension. Count starts from 0. \param timeStep Which time step to use */ Image::Pointer Interpolate(unsigned int sliceDimension, unsigned int sliceIndex, const mitk::PlaneGeometry *currentPlane, unsigned int timeStep); /** \brief Initializes the internal container with the number of voxels per label. */ void ResetLabelCount(); protected: /** \brief Protected class of mitk::SliceBasedInterpolationController. Don't use (you shouldn't be able to do so)! */ class MITKSEGMENTATION_EXPORT SetChangedSliceOptions { public: SetChangedSliceOptions(unsigned int sd, unsigned int si, unsigned int d0, unsigned int d1, unsigned int t) : sliceDimension(sd), sliceIndex(si), dim0(d0), dim1(d1), timeStep(t) { } unsigned int sliceDimension; unsigned int sliceIndex; unsigned int dim0; unsigned int dim1; unsigned int timeStep; // void* pixelData; }; typedef std::vector LabelCounterVectorType; typedef std::vector LabelCounterSliceVectorType; typedef std::vector> LabelCounterSliceTimeVectorType; typedef std::map InterpolatorMapType; SliceBasedInterpolationController(); // purposely hidden ~SliceBasedInterpolationController() override; /// internal scan of a single slice template void ScanSliceITKProcessing(const itk::Image *, const SetChangedSliceOptions &options); /// internal scan of the whole image template void ScanImageITKProcessing(itk::Image *, unsigned int timeStep); /** An array that of flags. One for each dimension of the image. A flag is set, when a slice in a certain dimension has at least one pixel that is not 0 (which would mean that it has to be considered by the interpolation algorithm). E.g. flags for axial slices are stored in m_SegmentationCountInSlice[0][index]. Enhanced with time steps it is now m_SegmentationCountInSlice[timeStep][0][index] */ LabelCounterSliceTimeVectorType m_LabelCountInSlice; static InterpolatorMapType s_InterpolatorForImage; LabelSetImage::Pointer m_WorkingImage; Image::Pointer m_ReferenceImage; }; } // namespace #endif diff --git a/Modules/Segmentation/Interactions/mitkTool.h b/Modules/Segmentation/Interactions/mitkTool.h index 9313eb1c7e..e9110e2a7a 100644 --- a/Modules/Segmentation/Interactions/mitkTool.h +++ b/Modules/Segmentation/Interactions/mitkTool.h @@ -1,267 +1,265 @@ /*============================================================================ 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 mitkTool_h_Included #define mitkTool_h_Included #include "itkObjectFactoryBase.h" #include "itkVersion.h" #include "mitkCommon.h" #include "mitkDataNode.h" #include "mitkEventStateMachine.h" #include "mitkInteractionEventObserver.h" #include "mitkLabelSetImage.h" #include "mitkMessage.h" #include "mitkNodePredicateAnd.h" #include "mitkNodePredicateDataType.h" #include "mitkNodePredicateDimension.h" #include "mitkNodePredicateNot.h" #include "mitkNodePredicateOr.h" #include "mitkNodePredicateProperty.h" #include "mitkToolEvents.h" #include "mitkToolFactoryMacro.h" #include #include #include #include #include #include #include "usServiceRegistration.h" namespace us { class ModuleResource; } namespace mitk { class ToolManager; /** \brief Base class of all tools used by mitk::ToolManager. \sa ToolManager \sa SegTool2D \ingroup Interaction \ingroup ToolManagerEtAl - There is a separate page describing the \ref QmitkInteractiveSegmentationTechnicalPage. - Every tool is a mitk::StateMachine, which can follow any transition pattern that it likes. One important thing to know is, that every derived tool should always call SuperClass::Deactivated() at the end of its own implementation of Deactivated, because mitk::Tool resets the StateMachine in this method. Only if you are very sure that you covered all possible things that might happen to your own tool, you should consider not to reset the StateMachine from time to time. To learn about the MITK implementation of state machines in general, have a look at \ref InteractionPage. To derive a non-abstract tool, you inherit from mitk::Tool (or some other base class further down the inheritance tree), and in your own parameterless constructor (that is called from the itkFactorylessNewMacro that you use) you pass a StateMachine pattern name to the superclass. Names for valid patterns can be found in StateMachine.xml (which might be enhanced by you). You have to implement at least GetXPM() and GetName() to provide some identification. Each Tool knows its ToolManager, which can provide the data that the tool should work on. \warning Only to be instantiated by mitk::ToolManager (because SetToolManager has to be called). All other uses are unsupported. $Author$ */ class MITKSEGMENTATION_EXPORT Tool : public EventStateMachine, public InteractionEventObserver { public: typedef mitk::Label::PixelType DefaultSegmentationDataType; /** * \brief To let GUI process new events (e.g. qApp->processEvents() ) */ Message<> GUIProcessEventsMessage; /** * \brief To send error messages (to be shown by some GUI) */ Message1 ErrorMessage; /** * \brief To send whether the tool is busy (to be shown by some GUI) */ Message1 CurrentlyBusy; /** * \brief To send general messages (to be shown by some GUI) */ Message1 GeneralMessage; mitkClassMacro(Tool, EventStateMachine); // no New(), there should only be subclasses /** \brief Returns an icon in the XPM format. This icon has to fit into some kind of button in most applications, so make it smaller than 25x25 pixels. XPM is e.g. supported by The Gimp. But if you open any XPM file in your text editor, you will see that you could also "draw" it with an editor. */ virtual const char **GetXPM() const = 0; /** * \brief Returns the path of an icon. * * This icon is preferred to the XPM icon. */ virtual std::string GetIconPath() const { return ""; } /** * \brief Returns the path of a cursor icon. * */ virtual us::ModuleResource GetCursorIconResource() const; /** * @brief Returns the tool button icon of the tool wrapped by a usModuleResource * @return a valid ModuleResource or an invalid if this function * is not reimplemented */ virtual us::ModuleResource GetIconResource() const; /** \brief Returns the name of this tool. Make it short! This name has to fit into some kind of button in most applications, so take some time to think of a good name! */ virtual const char *GetName() const = 0; /** \brief Name of a group. You can group several tools by assigning a group name. Graphical tool selectors might use this information to group tools. (What other reason could there be?) */ virtual const char *GetGroup() const; virtual void InitializeStateMachine(); /** * \brief Interface for GUI creation. * * This is the basic interface for creation of a GUI object belonging to one tool. * * Tools that support a GUI (e.g. for display/editing of parameters) should follow some rules: * * - A Tool and its GUI are two separate classes * - There may be several instances of a GUI at the same time. * - mitk::Tool is toolkit (Qt, wxWidgets, etc.) independent, the GUI part is of course dependent * - The GUI part inherits both from itk::Object and some GUI toolkit class * - The GUI class name HAS to be constructed like "toolkitPrefix" tool->GetClassName() + "toolkitPostfix", e.g. * MyTool -> wxMyToolGUI * - For each supported toolkit there is a base class for tool GUIs, which contains some convenience methods * - Tools notify the GUI about changes using ITK events. The GUI must observe interesting events. * - The GUI base class may convert all ITK events to the GUI toolkit's favoured messaging system (Qt -> signals) * - Calling methods of a tool by its GUI is done directly. * In some cases GUIs don't want to be notified by the tool when they cause a change in a tool. * There is a macro CALL_WITHOUT_NOTICE(method()), which will temporarily disable all notifications during a * method call. */ virtual itk::Object::Pointer GetGUI(const std::string &toolkitPrefix, const std::string &toolkitPostfix); virtual NodePredicateBase::ConstPointer GetReferenceDataPreference() const; virtual NodePredicateBase::ConstPointer GetWorkingDataPreference() const; DataNode::Pointer CreateEmptySegmentationNode(const Image *original, const std::string &organName, const mitk::Color &color); DataNode::Pointer CreateSegmentationNode(Image *image, const std::string &organName, const mitk::Color &color); virtual bool CanHandle(BaseData *referenceData) const; protected: friend class ToolManager; virtual void SetToolManager(ToolManager *); void ConnectActionsAndFunctions() override; /** \brief Called when the tool gets activated. Derived tools should call their parents implementation at the beginning of the overriding function. */ virtual void Activated(); /** \brief Called when the tool gets deactivated. Derived tools should call their parents implementation at the end of the overriding function. */ virtual void Deactivated(); /** \brief Let subclasses change their event configuration. */ std::string m_EventConfig; Tool(); // purposely hidden Tool(const char *, const us::Module *interactorModule = nullptr); // purposely hidden ~Tool() override; void Notify(InteractionEvent *interactionEvent, bool isHandled) override; bool FilterEvents(InteractionEvent *, DataNode *) override; ToolManager *m_ToolManager; private: // for reference data NodePredicateDataType::Pointer m_PredicateImages; NodePredicateDimension::Pointer m_PredicateDim3; NodePredicateDimension::Pointer m_PredicateDim4; NodePredicateOr::Pointer m_PredicateDimension; NodePredicateAnd::Pointer m_PredicateImage3D; NodePredicateProperty::Pointer m_PredicateBinary; NodePredicateNot::Pointer m_PredicateNotBinary; NodePredicateProperty::Pointer m_PredicateSegmentation; NodePredicateNot::Pointer m_PredicateNotSegmentation; NodePredicateProperty::Pointer m_PredicateHelper; NodePredicateNot::Pointer m_PredicateNotHelper; NodePredicateAnd::Pointer m_PredicateImageColorful; NodePredicateAnd::Pointer m_PredicateImageColorfulNotHelper; NodePredicateAnd::Pointer m_PredicateReference; // for working data NodePredicateAnd::Pointer m_IsSegmentationPredicate; std::string m_InteractorType; std::map m_DisplayInteractorConfigs; const us::Module *m_InteractorModule; }; } // namespace #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkSliceBasedInterpolatorWidget.h b/Modules/SegmentationUI/Qmitk/QmitkSliceBasedInterpolatorWidget.h index e0716789e1..af03e3829e 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkSliceBasedInterpolatorWidget.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSliceBasedInterpolatorWidget.h @@ -1,198 +1,195 @@ /*============================================================================ 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 QmitkSliceBasedInterpolatorWidget_h_Included #define QmitkSliceBasedInterpolatorWidget_h_Included #include "MitkSegmentationUIExports.h" #include "mitkDataStorage.h" #include "mitkSliceBasedInterpolationController.h" #include #include #include "ui_QmitkSliceBasedInterpolatorWidgetGUIControls.h" namespace mitk { class PlaneGeometry; class SliceNavigationController; class LabelSetImage; class ToolManager; class DiffSliceOperation; } /** \brief GUI for slices interpolation. \ingroup ToolManagerEtAl \ingroup Widgets \sa QmitkInteractiveSegmentation \sa mitk::SegmentationInterpolation - There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref - QmitkInteractiveSegmentationTechnicalPage - While mitk::SegmentationInterpolation does the bookkeeping of interpolation (keeping track of which slices contain how much segmentation) and the algorithmic work, QmitkSliceBasedInterpolatorWidget is responsible to watch the GUI, to notice, which slice is currently visible. It triggers generation of interpolation suggestions and also triggers acception of suggestions. \todo show/hide feedback on demand Last contributor: $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkSliceBasedInterpolatorWidget : public QWidget { Q_OBJECT public: QmitkSliceBasedInterpolatorWidget(QWidget *parent = nullptr, const char *name = nullptr); ~QmitkSliceBasedInterpolatorWidget() override; void SetDataStorage(mitk::DataStorage &storage); /** Sets the slice navigation controllers for getting slice changed events from the views. */ void SetSliceNavigationControllers(const QList &controllers); void OnToolManagerWorkingDataModified(); void OnTimeChanged(itk::Object *sender, const itk::EventObject &); void OnSliceChanged(itk::Object *sender, const itk::EventObject &); void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSliceInterpolationInfoChanged(const itk::EventObject &); Ui::QmitkSliceBasedInterpolatorWidgetGUIControls m_Controls; signals: void signalSliceBasedInterpolationEnabled(bool); public slots: /** \brief Reaction to "Start/Stop" button click */ void OnToggleWidgetActivation(bool); protected slots: /** \brief Reaction to "Accept Current Slice" button click. */ void OnAcceptInterpolationClicked(); /* \brief Reaction to "Accept All Slices" button click. Opens popup to ask about which orientation should be interpolated */ void OnAcceptAllInterpolationsClicked(); /* \brief Called from popup menu of OnAcceptAllInterpolationsClicked() Will trigger interpolation for all slices in given orientation */ void OnAcceptAllPopupActivated(QAction *action); protected: typedef std::map ActionToSliceDimensionMapType; const ActionToSliceDimensionMapType CreateActionToSliceDimension(); ActionToSliceDimensionMapType m_ActionToSliceDimensionMap; void AcceptAllInterpolations(mitk::SliceNavigationController *slicer); void WaitCursorOn(); void WaitCursorOff(); void RestoreOverrideCursor(); /** Gets the working slice based on the given plane geometry and last saved interaction \param planeGeometry a plane geometry */ mitk::Image::Pointer GetWorkingSlice(const mitk::PlaneGeometry *planeGeometry); /** Retrieves the currently selected PlaneGeometry from a SlicedGeometry3D that is generated by a SliceNavigationController and calls Interpolate to further process this PlaneGeometry into an interpolation. \param e is a actually a mitk::SliceNavigationController::GeometrySliceEvent, sent by a SliceNavigationController \param slice the SliceNavigationController */ void TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *slicer); /** Given a PlaneGeometry, this method figures out which slice of the first working image (of the associated ToolManager) should be interpolated. The actual work is then done by our SegmentationInterpolation object. */ void Interpolate(mitk::PlaneGeometry *plane, unsigned int timeStep, mitk::SliceNavigationController *slicer); /** Called internally to update the interpolation suggestion. Finds out about the focused render window and requests an interpolation. */ void UpdateVisibleSuggestion(); private: mitk::SliceBasedInterpolationController::Pointer m_SliceInterpolatorController; mitk::ToolManager *m_ToolManager; bool m_Activated; template void WritePreviewOnWorkingImage(itk::Image *target, const mitk::Image *source, int overwritevalue); QHash m_ControllerToTimeObserverTag; QHash m_ControllerToSliceObserverTag; QHash m_ControllerToDeleteObserverTag; unsigned int m_InterpolationInfoChangedObserverTag; mitk::DiffSliceOperation *m_doOperation; mitk::DiffSliceOperation *m_undoOperation; mitk::DataNode::Pointer m_PreviewNode; mitk::Image::Pointer m_PreviewImage; mitk::LabelSetImage::Pointer m_WorkingImage; QHash m_TimeStep; mitk::DataStorage::Pointer m_DataStorage; mitk::SliceNavigationController *m_LastSNC; unsigned int m_LastSliceIndex; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h b/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h index 9e66e70157..ce6c55bae2 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h @@ -1,294 +1,291 @@ /*============================================================================ 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 QmitkSlicesInterpolator_h_Included #define QmitkSlicesInterpolator_h_Included #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkSegmentationInterpolationController.h" #include "mitkSliceNavigationController.h" #include "mitkSurfaceInterpolationController.h" #include "mitkToolManager.h" #include #include "mitkFeatureBasedEdgeDetectionFilter.h" #include "mitkPointCloudScoringFilter.h" #include #include #include #include #include #include #include #include "mitkVtkRepresentationProperty.h" #include "vtkProperty.h" // For running 3D interpolation in background #include #include #include #include namespace mitk { class PlaneGeometry; class SliceNavigationController; } class QPushButton; /** \brief GUI for slices interpolation. \ingroup ToolManagerEtAl \ingroup Widgets \sa QmitkInteractiveSegmentation \sa mitk::SegmentationInterpolation - There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref - QmitkInteractiveSegmentationTechnicalPage - While mitk::SegmentationInterpolation does the bookkeeping of interpolation (keeping track of which slices contain how much segmentation) and the algorithmic work, QmitkSlicesInterpolator is responsible to watch the GUI, to notice, which slice is currently visible. It triggers generation of interpolation suggestions and also triggers acception of suggestions. \todo show/hide feedback on demand Last contributor: $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkSlicesInterpolator : public QWidget { Q_OBJECT public: QmitkSlicesInterpolator(QWidget *parent = nullptr, const char *name = nullptr); /** To be called once before real use. */ void Initialize(mitk::ToolManager *toolManager, const QList &controllers); void Uninitialize(); ~QmitkSlicesInterpolator() override; void SetDataStorage(mitk::DataStorage::Pointer storage); mitk::DataStorage *GetDataStorage(); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnToolManagerWorkingDataModified(); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnToolManagerReferenceDataModified(); void OnTimeChanged(itk::Object *sender, const itk::EventObject &); void OnSliceChanged(itk::Object *sender, const itk::EventObject &); void OnSliceNavigationControllerDeleted(const itk::Object *sender, const itk::EventObject &); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnInterpolationInfoChanged(const itk::EventObject &); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSurfaceInterpolationInfoChanged(const itk::EventObject &); /** * @brief Set the visibility of the 3d interpolation */ void Show3DInterpolationResult(bool); signals: void SignalRememberContourPositions(bool); void SignalShowMarkerNodes(bool); public slots: virtual void setEnabled(bool); /** Call this from the outside to enable/disable interpolation */ void EnableInterpolation(bool); void Enable3DInterpolation(bool); /** Call this from the outside to accept all interpolations */ void FinishInterpolation(mitk::SliceNavigationController *slicer = nullptr); protected slots: /** Reaction to button clicks. */ void OnAcceptInterpolationClicked(); /* Opens popup to ask about which orientation should be interpolated */ void OnAcceptAllInterpolationsClicked(); /* Reaction to button clicks */ void OnAccept3DInterpolationClicked(); void OnReinit3DInterpolation(); void OnSuggestPlaneClicked(); /* * Will trigger interpolation for all slices in given orientation (called from popup menu of * OnAcceptAllInterpolationsClicked) */ void OnAcceptAllPopupActivated(QAction *action); /** Called on activation/deactivation */ void OnInterpolationActivated(bool); void On3DInterpolationActivated(bool); void OnInterpolationMethodChanged(int index); // Enhancement for 3D interpolation void On2DInterpolationEnabled(bool); void On3DInterpolationEnabled(bool); void OnInterpolationDisabled(bool); void OnShowMarkers(bool); void Run3DInterpolation(); void RunPlaneSuggestion(); void OnSurfaceInterpolationFinished(); void StartUpdateInterpolationTimer(); void StopUpdateInterpolationTimer(); void ChangeSurfaceColor(); protected: const std::map createActionToSliceDimension(); std::map ACTION_TO_SLICEDIMENSION; void AcceptAllInterpolations(mitk::SliceNavigationController *slicer); /** Retrieves the currently selected PlaneGeometry from a SlicedGeometry3D that is generated by a SliceNavigationController and calls Interpolate to further process this PlaneGeometry into an interpolation. \param e is a actually a mitk::SliceNavigationController::GeometrySliceEvent, sent by a SliceNavigationController \param slice the SliceNavigationController */ bool TranslateAndInterpolateChangedSlice(const itk::EventObject &e, mitk::SliceNavigationController *slicer); /** Given a PlaneGeometry, this method figures out which slice of the first working image (of the associated ToolManager) should be interpolated. The actual work is then done by our SegmentationInterpolation object. */ void Interpolate(mitk::PlaneGeometry *plane, unsigned int timeStep, mitk::SliceNavigationController *slicer); // void InterpolateSurface(); /** Called internally to update the interpolation suggestion. Finds out about the focused render window and requests an interpolation. */ void UpdateVisibleSuggestion(); void SetCurrentContourListID(); private: void HideAllInterpolationControls(); void Show2DInterpolationControls(bool show); void Show3DInterpolationControls(bool show); void CheckSupportedImageDimension(); void WaitForFutures(); void NodeRemoved(const mitk::DataNode* node); mitk::SegmentationInterpolationController::Pointer m_Interpolator; mitk::SurfaceInterpolationController::Pointer m_SurfaceInterpolator; mitk::FeatureBasedEdgeDetectionFilter::Pointer m_EdgeDetector; mitk::PointCloudScoringFilter::Pointer m_PointScorer; mitk::ToolManager::Pointer m_ToolManager; bool m_Initialized; QHash m_ControllerToTimeObserverTag; QHash m_ControllerToSliceObserverTag; QHash m_ControllerToDeleteObserverTag; unsigned int InterpolationInfoChangedObserverTag; unsigned int SurfaceInterpolationInfoChangedObserverTag; QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode; QComboBox *m_CmbInterpolation; QPushButton *m_BtnApply2D; QPushButton *m_BtnApplyForAllSlices2D; QPushButton *m_BtnApply3D; QPushButton *m_BtnSuggestPlane; QCheckBox *m_ChkShowPositionNodes; QPushButton *m_BtnReinit3DInterpolation; mitk::DataNode::Pointer m_FeedbackNode; mitk::DataNode::Pointer m_InterpolatedSurfaceNode; mitk::DataNode::Pointer m_3DContourNode; mitk::Image *m_Segmentation; mitk::SliceNavigationController *m_LastSNC; unsigned int m_LastSliceIndex; QHash m_TimeStep; bool m_2DInterpolationEnabled; bool m_3DInterpolationEnabled; // unsigned int m_CurrentListID; mitk::DataStorage::Pointer m_DataStorage; QFuture m_Future; QFutureWatcher m_Watcher; QTimer *m_Timer; QFuture m_PlaneFuture; QFutureWatcher m_PlaneWatcher; bool m_FirstRun; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkSurfaceBasedInterpolatorWidget.h b/Modules/SegmentationUI/Qmitk/QmitkSurfaceBasedInterpolatorWidget.h index 6561c4c3b4..a4582310dc 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkSurfaceBasedInterpolatorWidget.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSurfaceBasedInterpolatorWidget.h @@ -1,122 +1,119 @@ /*============================================================================ 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 QmitkSurfaceBasedInterpolatorWidgetWidget_h_Included #define QmitkSurfaceBasedInterpolatorWidgetWidget_h_Included #include "MitkSegmentationUIExports.h" #include "mitkDataNode.h" #include "mitkDataStorage.h" #include "mitkLabelSetImage.h" #include "mitkSurfaceBasedInterpolationController.h" #include #include // For running 3D interpolation in background #include #include #include #include #include "ui_QmitkSurfaceBasedInterpolatorWidgetGUIControls.h" namespace mitk { class ToolManager; } /** \brief GUI for surface-based interpolation. \ingroup ToolManagerEtAl \ingroup Widgets \sa QmitkInteractiveSegmentation \sa mitk::SurfaceBasedInterpolationController - There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref - QmitkInteractiveSegmentationTechnicalPage - QmitkSurfaceBasedInterpolatorWidgetController is responsible to watch the GUI, to notice, which slice is currently visible. It triggers generation of interpolation suggestions and also triggers acception of suggestions. */ class MITKSEGMENTATIONUI_EXPORT QmitkSurfaceBasedInterpolatorWidget : public QWidget { Q_OBJECT public: QmitkSurfaceBasedInterpolatorWidget(QWidget *parent = nullptr, const char *name = nullptr); ~QmitkSurfaceBasedInterpolatorWidget() override; void SetDataStorage(mitk::DataStorage &storage); void OnToolManagerWorkingDataModified(); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSurfaceInterpolationInfoChanged(const itk::EventObject &); /** * @brief Set the visibility of the interpolation */ void ShowInterpolationResult(bool); Ui::QmitkSurfaceBasedInterpolatorWidgetGUIControls m_Controls; public slots: /** \brief Reaction to "Start/Stop" button click */ void OnToggleWidgetActivation(bool); protected slots: void OnAcceptInterpolationClicked(); void OnSurfaceInterpolationFinished(); void OnRunInterpolation(); void OnShowMarkers(bool); void StartUpdateInterpolationTimer(); void StopUpdateInterpolationTimer(); void ChangeSurfaceColor(); private: mitk::SurfaceBasedInterpolationController::Pointer m_SurfaceBasedInterpolatorController; mitk::ToolManager *m_ToolManager; bool m_Activated; unsigned int m_SurfaceInterpolationInfoChangedObserverTag; mitk::DataNode::Pointer m_InterpolatedSurfaceNode; mitk::DataNode::Pointer m_3DContourNode; mitk::DataStorage::Pointer m_DataStorage; mitk::LabelSetImage::Pointer m_WorkingImage; QFuture m_Future; QFutureWatcher m_Watcher; QTimer *m_Timer; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h index b2901eb6b0..90097a1074 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolReferenceDataSelectionBox.h @@ -1,126 +1,123 @@ /*============================================================================ 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 QmitkToolReferenceDataSelectionBox_h_Included #define QmitkToolReferenceDataSelectionBox_h_Included #include "mitkDataStorage.h" #include "mitkToolManager.h" #include #include #include class QmitkDataStorageComboBox; /** \brief Display the data selection of a ToolManager. \sa mitk::ToolManager \sa mitk::DataStorage \ingroup ToolManagerEtAl \ingroup Widgets -There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref -QmitkInteractiveSegmentationTechnicalPage - Shows the reference data of a ToolManager in a segmentation setting. The reference image can be selected from a combobox, where all images of the scene are listed. $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkToolReferenceDataSelectionBox : public QWidget { Q_OBJECT public: /** * \brief What kind of items should be displayed. * * Every mitk::Tool holds a NodePredicateBase object, telling the kind of data that this * tool will successfully work with. There are two ways that this list box deals with * these predicates. * * DEFAULT is: list data if ANY one of the displayed tools' predicate matches. * Other option: list data if ALL one of the displayed tools' predicate matches */ enum DisplayMode { ListDataIfAllToolsMatch, ListDataIfAnyToolMatches }; QmitkToolReferenceDataSelectionBox(QWidget *parent = nullptr); ~QmitkToolReferenceDataSelectionBox() override; mitk::DataStorage *GetDataStorage(); void SetDataStorage(mitk::DataStorage &storage); /// initialization with a data storage object void Initialize(mitk::DataStorage *); void UpdateDataDisplay(); mitk::ToolManager *GetToolManager(); void SetToolManager(mitk::ToolManager &); // no nullptr pointer allowed here, a manager is required void OnToolManagerReferenceDataModified(); /** * \brief No brief description. * * Should be called to restrict the number of tools that are * evaluated to build up the list. Default is to ask all tools for their predicate, by * setting the 'groups' string this can be restricted to certain groups of tools * or single tools. */ void SetToolGroupsForFiltering(const std::string &groups); /** * \brief How the list contents is determined. * * See also documentation of DisplayMode. * * \sa DisplayMode */ void SetDisplayMode(DisplayMode mode); signals: void ReferenceNodeSelected(const mitk::DataNode *); protected slots: void OnReferenceDataSelected(const mitk::DataNode *node); void EnsureOnlyReferenceImageIsVisibile(); protected: mitk::DataStorage::SetOfObjects::ConstPointer GetAllPossibleReferenceImages(); mitk::NodePredicateBase::ConstPointer GetAllPossibleReferenceImagesPredicate(); mitk::ToolManager::Pointer m_ToolManager; QmitkDataStorageComboBox *m_ReferenceDataSelectionBox; bool m_SelfCall; DisplayMode m_DisplayMode; std::string m_ToolGroupsForFiltering; QVBoxLayout *m_Layout; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h index ea8970ba74..643e32bd71 100755 --- a/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolSelectionBox.h @@ -1,150 +1,147 @@ /*============================================================================ 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 QmitkToolSelectionBox_h_Included #define QmitkToolSelectionBox_h_Included #include "QmitkToolGUIArea.h" #include #include "mitkToolManager.h" #include #include #include #include class QmitkToolGUI; /** \brief Display the tool selection state of a mitk::ToolManager \sa mitk::ToolManager \ingroup org_mitk_gui_qt_interactivesegmentation \ingroup ToolManagerEtAl - There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref - QmitkInteractiveSegmentationTechnicalPage - This widget graphically displays the active tool of a mitk::ToolManager as a set of toggle buttons. Each button show the identification of a Tool (icon and name). When a button's toggle state is "down", the tool is activated. When a different button is clicked, the active tool is switched. When you click an already active button, the associated tool is deactivated with no replacement, which means that no tool is active then. When this widget is enabled/disabled it (normally) also enables/disables the tools. There could be cases where two QmitkToolSelectionBox widgets are associated to the same ToolManager, but if this happens, please look deeply into the code. Last contributor: $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkToolSelectionBox : public QWidget //! { Q_OBJECT public: enum EnabledMode { EnabledWithReferenceAndWorkingDataVisible, EnabledWithReferenceData, EnabledWithWorkingData, AlwaysEnabled }; QmitkToolSelectionBox(QWidget *parent = nullptr, mitk::DataStorage *storage = nullptr); ~QmitkToolSelectionBox() override; mitk::ToolManager *GetToolManager(); void SetToolManager(mitk::ToolManager &); // no nullptr pointer allowed here, a manager is required void setTitle(const QString &title); /** You may specify a list of tool "groups" that should be displayed in this widget. Every Tool can report its group as a string. This method will try to find the tool's group inside the supplied string \param toolGroups. If there is a match, the tool is displayed. Effectively, you can provide a human readable list like "default, lymphnodevolumetry, oldERISstuff". */ void SetDisplayedToolGroups(const std::string &toolGroups = nullptr); void OnToolManagerToolModified(); void OnToolManagerReferenceDataModified(); void OnToolManagerWorkingDataModified(); void OnToolGUIProcessEventsMessage(); void OnToolErrorMessage(std::string s); void OnGeneralToolMessage(std::string s); void RecreateButtons(); signals: /// Whenever a tool is activated. id is the index of the active tool. Counting starts at 0, -1 indicates "no tool /// selected" /// This signal is also emitted, when the whole QmitkToolSelectionBox get disabled. Then it will claim /// ToolSelected(-1) /// When it is enabled again, there will be another ToolSelected event with the tool that is currently selected void ToolSelected(int id); public slots: virtual void setEnabled(bool); virtual void SetEnabledMode(EnabledMode mode); virtual void SetLayoutColumns(int); virtual void SetShowNames(bool); virtual void SetGenerateAccelerators(bool); virtual void SetToolGUIArea(QWidget *parentWidget); protected slots: void toolButtonClicked(int id); void SetGUIEnabledAccordingToToolManagerState(); protected: void showEvent(QShowEvent *) override; void hideEvent(QHideEvent *) override; void SetOrUnsetButtonForActiveTool(); mitk::ToolManager::Pointer m_ToolManager; bool m_SelfCall; std::string m_DisplayedGroups; /// stores relationship between button IDs of the Qt widget and tool IDs of ToolManager std::map m_ButtonIDForToolID; /// stores relationship between button IDs of the Qt widget and tool IDs of ToolManager std::map m_ToolIDForButtonID; int m_LayoutColumns; bool m_ShowNames; bool m_GenerateAccelerators; QWidget *m_ToolGUIWidget; QmitkToolGUI *m_LastToolGUI; // store buttons in this group QButtonGroup *m_ToolButtonGroup; QGridLayout *m_ButtonLayout; EnabledMode m_EnabledMode; }; #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h b/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h index 0ab821f534..0275f2a869 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h +++ b/Modules/SegmentationUI/Qmitk/QmitkToolWorkingDataSelectionBox.h @@ -1,141 +1,138 @@ /*============================================================================ 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 QmitkToolWorkingDataSelectionListBox_h_Included #define QmitkToolWorkingDataSelectionListBox_h_Included // mmueller #include #include #include "mitkProperties.h" #include "mitkToolManager.h" /** \brief Display the data selection of a ToolManager. \sa mitk::ToolManager \sa mitk::DataStorage \ingroup Widgets -There is a separate page describing the general design of QmitkInteractiveSegmentation: \ref -QmitkInteractiveSegmentationTechnicalPage - Shows the working data of a ToolManager in a segmentation setting. By default only the segmentation name is shown. The working images (segmentations) are listed in a QListView, each row telling the color and name of a single segmentation. One or several segmentations can be selected to be the "active" segmentations. $Author: maleike $ */ class MITKSEGMENTATIONUI_EXPORT QmitkToolWorkingDataSelectionBox : public QListWidget { Q_OBJECT public: /** * \brief What kind of items should be displayed. * * Every mitk::Tool holds a NodePredicateBase object, telling the kind of data that this * tool will successfully work with. There are two ways that this list box deals with * these predicates. * * DEFAULT is: list data if ANY one of the displayed tools' predicate matches. * Other option: list data if ALL one of the displayed tools' predicate matches */ enum DisplayMode { ListDataIfAllToolsMatch, ListDataIfAnyToolMatches }; QmitkToolWorkingDataSelectionBox(QWidget *parent = nullptr); ~QmitkToolWorkingDataSelectionBox() override; mitk::DataStorage *GetDataStorage(); void SetDataStorage(mitk::DataStorage &storage); /** \brief Can be called to trigger an update of the list contents. */ void UpdateDataDisplay(); /** \brief Returns the associated mitk::ToolManager. */ mitk::ToolManager *GetToolManager(); /** \brief Tell this object to listen to another ToolManager. */ void SetToolManager(mitk::ToolManager &); // no nullptr pointer allowed here, a manager is required /** * \brief A list of all displayed DataNode objects. * This method might be convenient for program modules that want to display * additional information about these nodes, like a total volume of all segmentations, etc. */ mitk::ToolManager::DataVectorType GetAllNodes(bool onlyDerivedFromOriginal = true); /** * \brief A list of all selected DataNode objects. * This method might be convenient for program modules that want to display * additional information about these nodes, like a total volume of all segmentations, etc. */ mitk::ToolManager::DataVectorType GetSelectedNodes(); /** * \brief Like GetSelectedNodes(), but will only return one object. * Will only return what QListView gives as selected object (documentation says nothing is returned if list is in * Single selection mode). */ mitk::DataNode *GetSelectedNode(); /** * \brief Callback function, no need to call it. * This is used to observe and react to changes in the mitk::ToolManager object. */ void OnToolManagerWorkingDataModified(); /** * \brief Callback function, no need to call it. * This is used to observe and react to changes in the mitk::ToolManager object. */ void OnToolManagerReferenceDataModified(); signals: void WorkingNodeSelected(const mitk::DataNode *); protected slots: void OnWorkingDataSelectionChanged(); protected: typedef std::map ItemNodeMapType; mitk::ToolManager::Pointer m_ToolManager; ItemNodeMapType m_Node; bool m_SelfCall; mitk::DataNode *m_LastSelectedReferenceData; std::string m_ToolGroupsForFiltering; bool m_DisplayOnlyDerivedNodes; }; #endif diff --git a/Plugins/org.blueberry.ui.qt/src/actions/berryAbstractContributionFactory.h b/Plugins/org.blueberry.ui.qt/src/actions/berryAbstractContributionFactory.h index cdff48a34d..c22feb26b7 100644 --- a/Plugins/org.blueberry.ui.qt/src/actions/berryAbstractContributionFactory.h +++ b/Plugins/org.blueberry.ui.qt/src/actions/berryAbstractContributionFactory.h @@ -1,135 +1,135 @@ /*============================================================================ 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 BERRYABSTRACTCONTRIBUTIONFACTORY_H_ #define BERRYABSTRACTCONTRIBUTIONFACTORY_H_ #include #include namespace berry { struct IServiceLocator; struct IContributionRoot; /** * ContributionFactories are used by the IMenuService to populate - * ContributionManagers. In {@link #createContributionItems(IServiceLocator, IContributionRoot)} + * ContributionManagers. In CreateContributionItems() * you fill in the additions List with {@link IContributionItem} to be inserted at this * factory's location. For example: *

* *

  * AbstractContributionFactory contributions = new AbstractContributionFactory(
  *    "menu:org.eclipse.ui.tests.api.MenuTestHarness?after=additions") {
- *  public void createContributionItems(IMenuService menuService, List additions) {
+ *  public void CreateContributionItems(IMenuService menuService, List additions) {
  *    CommandContributionItem item = new CommandContributionItem(
  *        "org.eclipse.ui.tests.menus.helloWorld",
  *        "org.eclipse.ui.tests.commands.enabledHelloWorld", null, null,
  *        "Say Hello", null);
  *    additions.add(item);
  *    item = new CommandContributionItem(
  *        "org.eclipse.ui.tests.menus.refresh",
  *        "org.eclipse.ui.tests.commands.refreshView", null, null,
  *        "Refresh", null);
  *    menuService.registerVisibleWhen(item, new MyActiveContextExpression(
  *        "org.eclipse.ui.tests.myview.context"));
  *    additions.add(item);
  *  }
  *
  *  public void releaseContributionItems(IMenuService menuService, List items) {
  *    // we have nothing to do
  *  }
  * };
  * IMenuService service = (IMenuService) PlatformUI.getWorkbench().getService(
  *    IMenuService.class);
  * service.addContributionFactory(contributions);
  * 
* *

*

* Only the abstract methods may be implemented. *

* * @see IMenuService * @see MenuManager * @see ToolBarManager */ class BERRY_UI_QT AbstractContributionFactory: public Object { private: QString location; QString namespaze; public: berryObjectMacro(berry::AbstractContributionFactory); /** * The contribution factories must be instantiated with their location, * which which specifies the contributions insertion location. * * @param location * the addition location in Menu API URI format. It must not be * null. * @param namespace * the namespace for this contribution. May be null. * @see #getNamespace() */ AbstractContributionFactory(const QString& location, const QString& namespaze); /** * Return the location as a String. * * @return the location - never null. */ QString GetLocation() const; /** * This factory should create the IContributionItems that it wants to * contribute, and add them to the additions list. The menu service will * call this method at the appropriate time. It should always return new * instances of its contributions in the additions list. *

* This method is not meant to be called by clients. It will be called by * the menu service at the appropriate time. *

* * @param serviceLocator * a service locator that may be used in the construction of * items created by this factory * @param additions * A {@link IContributionRoot} supplied by the framework. It will * never be null. * @see org.eclipse.ui.menus.CommandContributionItem * @see org.eclipse.jface.action.MenuManager */ virtual void CreateContributionItems(IServiceLocator* serviceLocator, const SmartPointer& additions) = 0; /** * Return the namespace for this cache. This corresponds to the plug-in that * is contributing this factory. * * @return the namespace the namespace of this factory */ QString GetNamespace() const; }; } #endif /* BERRYABSTRACTCONTRIBUTIONFACTORY_H_ */ diff --git a/Plugins/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.h b/Plugins/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.h index 6680aed849..d3f8a174c4 100644 --- a/Plugins/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.h +++ b/Plugins/org.blueberry.ui.qt/src/actions/berryCommandContributionItem.h @@ -1,212 +1,211 @@ /*============================================================================ 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 BERRYCOMMANDCONTRIBUTIONITEM_H_ #define BERRYCOMMANDCONTRIBUTIONITEM_H_ #include "berryContributionItem.h" #include #include namespace berry { struct IMenuService; struct ICommandService; struct ICommandListener; struct IHandlerService; struct IHandler; struct IElementReference; struct IServiceLocator; class CommandEvent; class ParameterizedCommand; class CommandContributionItemParameter; class UIElement; /** - * A contribution item which delegates to a command. It can be used in {@link - * AbstractContributionFactory#CreateContributionItems(IServiceLocator, - * IContributionRoot)}. + * A contribution item which delegates to a command. It can be used in + * berry::AbstractContributionFactory::CreateContributionItems(). *

* It currently supports placement in menus and toolbars. *

*

* This class may be instantiated; it is not intended to be subclassed. *

*/ class BERRY_UI_QT CommandContributionItem : public QObject, public ContributionItem { Q_OBJECT public: /** * Mode bit: Show text on tool items or buttons, even if an image is * present. If this mode bit is not set, text is only shown on tool items if * there is no image present. */ static Modes modes; private: //LocalResourceManager localResourceManager; //Listener menuItemListener; QAction* action; IMenuService* menuService; ICommandService* commandService; IHandlerService* handlerService; //IBindingService bindingService; SmartPointer command; QIcon icon; QString label; QString tooltip; QChar mnemonic; // This is a workaround until key bindings are fully implemented QKeySequence shortcut; SmartPointer elementRef; bool checkedState; Style style; QScopedPointer commandListener; QString dropDownMenuOverride; //IWorkbenchHelpSystem workbenchHelpSystem; QString helpContextId; Modes mode; /** * This is true when the menu contribution's visibleWhen * checkEnabled attribute is true. */ bool visibleEnabled; // items contributed QString contributedLabel; QIcon contributedIcon; SmartPointer serviceLocator; public: /** * Create a CommandContributionItem to place in a ContributionManager. * * @param contributionParameters * parameters necessary to render this contribution item. */ CommandContributionItem( const SmartPointer& contributionParameters); ~CommandContributionItem() override; using ContributionItem::Fill; void Fill(QMenu* parent, QAction* before) override; void Fill(QToolBar* parent, QAction* before) override; void Update() override; void Update(const QString& id) override; bool IsEnabled() const override; bool IsVisible() const override; void UpdateCommandPropertiesInUI(const SmartPointer& commandEvent); private: void SetImages(IServiceLocator* locator, const QString &iconStyle); ICommandListener *GetCommandListener(); void UpdateMenuItem(); void UpdateToolItem(); void UpdateCommandProperties(const SmartPointer commandEvent); bool ShouldRestoreAppearance(const SmartPointer& handler); SmartPointer GetCommand() const; void CreateCommand(const QString& commandId, const QHash& parameters); QString GetToolTipText(const QString& text) const; QString UpdateMnemonic(const QString& s); // void disposeOldImages() { // if (localResourceManager != null) { // localResourceManager.dispose(); // localResourceManager = null; // } // } //SmartPointer GetItemListener(); /** * Determines if the selection was on the dropdown affordance and, if so, * opens the drop down menu (populated using the same id as this item... * * @param event * The SWT.Selection event to be tested * * @return true iff a drop down menu was opened */ //TODO Tool item drop down menu contributions //bool OpenDropDownMenu(SmartPointer event); void SetIcon(const QIcon& icon); void UpdateIcons(); void SetText(const QString& text); void SetChecked(bool checked); void SetToolTip(const QString& text); private slots: void HandleActionDestroyed(); void HandleWidgetSelection(); }; } #endif /* BERRYCOMMANDCONTRIBUTIONITEM_H_ */ diff --git a/Plugins/org.blueberry.ui.qt/src/application/berryActionBarAdvisor.h b/Plugins/org.blueberry.ui.qt/src/application/berryActionBarAdvisor.h index d71f7b8f7c..4ce6da062c 100644 --- a/Plugins/org.blueberry.ui.qt/src/application/berryActionBarAdvisor.h +++ b/Plugins/org.blueberry.ui.qt/src/application/berryActionBarAdvisor.h @@ -1,248 +1,248 @@ /*============================================================================ 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 BERRYACTIONBARADVISOR_H_ #define BERRYACTIONBARADVISOR_H_ #include #include class QAction; namespace berry { struct IMenuManager; struct IToolBarManager; struct IStatusLineManager; struct IActionBarConfigurer; struct IMemento; struct IWorkbenchWindow; /** * Public base class for configuring the action bars of a workbench window. *

* An application should declare a subclass of ActionBarAdvisor * and override methods to configure a window's action bars to suit the needs of the * particular application. *

*

* The following advisor methods are called at strategic points in the * workbench's lifecycle (all occur within the dynamic scope of the call - * to {@link PlatformUI#createAndRunWorkbench PlatformUI.createAndRunWorkbench}): + * to berry::PlatformUI::CreateAndRunWorkbench()): *

    - *
  • fillActionBars - called after WorkbenchWindowAdvisor.preWindowOpen + *
  • FillActionBars() - called after berry::WorkbenchWindowAdvisor::PreWindowOpen() * to configure a window's action bars
  • *
*

* - * @see WorkbenchWindowAdvisor#createActionBarAdvisor(IActionBarConfigurer) + * @see berry::WorkbenchWindowAdvisor::CreateActionBarAdvisor() */ class BERRY_UI_QT ActionBarAdvisor : public Object { public: berryObjectMacro(berry::ActionBarAdvisor); enum FillType { /** - * Bit flag for {@link #fillActionBars fillActionBars} indicating that the + * Bit flag for FillActionBars() indicating that the * operation is not filling the action bars of an actual workbench window, * but rather a proxy (used for perspective customization). */ FILL_PROXY = 0x01, /** - * Bit flag for {@link #fillActionBars fillActionBars} indicating that the + * Bit flag for FillActionBars() indicating that the * operation is supposed to fill (or describe) the workbench window's menu * bar. */ FILL_MENU_BAR = 0x02, /** - * Bit flag for {@link #fillActionBars fillActionBars} indicating that the + * Bit flag for FillActionBars() indicating that the * operation is supposed to fill (or describe) the workbench window's cool * bar. */ FILL_TOOL_BAR = 0x04, /** - * Bit flag for {@link #fillActionBars fillActionBars} indicating that the + * Bit flag for FillActionBars() indicating that the * operation is supposed to fill (or describe) the workbench window's status * line. */ FILL_STATUS_LINE = 0x08 }; Q_DECLARE_FLAGS(FillFlags, FillType) public: ~ActionBarAdvisor() override; /** * Creates a new action bar advisor to configure a workbench * window's action bars via the given action bar configurer. * * @param configurer the action bar configurer */ ActionBarAdvisor(const SmartPointer& configurer); /** * Configures the action bars using the given action bar configurer. * Under normal circumstances, flags does not include - * FILL_PROXY, meaning this is a request to fill the action + * #FILL_PROXY, meaning this is a request to fill the action * bars of the corresponding workbench window; the * remaining flags indicate which combination of - * the menu bar (FILL_MENU_BAR), - * the tool bar (FILL_TOOL_BAR), - * and the status line (FILL_STATUS_LINE) are to be filled. + * the menu bar (#FILL_MENU_BAR), + * the tool bar (#FILL_TOOL_BAR), + * and the status line (#FILL_STATUS_LINE) are to be filled. *

- * If flags does include FILL_PROXY, then this + * If flags does include #FILL_PROXY, then this * is a request to describe the actions bars of the given workbench window * (which will already have been filled); * again, the remaining flags indicate which combination of the menu bar, * the tool bar, and the status line are to be described. * The actions included in the proxy action bars can be the same instances * as in the actual window's action bars. *

*

- * This method is called just after {@link WorkbenchWindowAdvisor#PreWindowOpen()}. + * This method is called just after berry::WorkbenchWindowAdvisor::PreWindowOpen(). * Clients must not call this method directly (although super calls are okay). - * The default implementation calls MakeActions if - * FILL_PROXY is specified, then calls FillMenuBar, - * FillToolBar, and FillStatusLine + * The default implementation calls MakeActions() if + * #FILL_PROXY is specified, then calls FillMenuBar(), + * FillToolBar(), and FillStatusLine() * if the corresponding flags are specified. *

*

* Subclasses may override, but it is recommended that they override the * methods mentioned above instead. *

* * @param flags bit mask composed from the constants - * {@link #FILL_MENU_BAR FILL_MENU_BAR}, - * {@link #FILL_TOOL_BAR FILL_TOOL_BAR}, - * {@link #FILL_STATUS_LINE FILL_STATUS_LINE}, - * and {@link #FILL_PROXY FILL_PROXY} + * #FILL_MENU_BAR, + * #FILL_TOOL_BAR, + * #FILL_STATUS_LINE, + * and #FILL_PROXY */ virtual void FillActionBars(FillFlags flags); /** * Saves arbitrary application-specific state information * for this action bar advisor. *

* The default implementation simply returns an OK status. * Subclasses may extend or override. *

* * @param memento the memento in which to save the advisor's state * @return a status object indicating whether the save was successful */ virtual bool SaveState(SmartPointer memento); /** * Restores arbitrary application-specific state information * for this action bar advisor. *

* The default implementation simply returns an OK status. * Subclasses may extend or override. *

* * @param memento the memento from which to restore the advisor's state * @return a status object indicating whether the restore was successful */ public: virtual bool RestoreState(SmartPointer memento); using Object::Register; protected: /** * Returns the action bar configurer. * * @return the action bar configurer */ virtual SmartPointer GetActionBarConfigurer() const; /** * Instantiates the actions used in the fill methods. - * Use {@link #Register(QAction*)} to add it to the list of actions to + * Use Register() to add it to the list of actions to * be disposed when the window is closed. * * @param window the window containing the action bars */ virtual void MakeActions(IWorkbenchWindow* window); /** * Adds the given action to the list of actions to be disposed when the window is closed. * * @param action the action to register, this cannot be null * @param id the unique action id */ virtual void Register(QAction* action, const QString& id); /** * Returns the action with the given id, or null if not found. * * @param id the action id * @return the action with the given id, or null if not found */ virtual QAction* GetAction(const QString& id) const; /** * Fills the menu bar with the main menus for the window. *

* The default implementation does nothing. * Subclasses may override. *

* * @param menuBar the menu manager for the menu bar */ virtual void FillMenuBar(IMenuManager* menuBar); /** * Fills the tool bar with the main toolbars for the window. *

* The default implementation does nothing. * Subclasses may override. *

* * @param toolBar the bar manager */ virtual void FillToolBar(IToolBarManager* toolBar); /** * Fills the status line with the main status line contributions * for the window. *

* The default implementation does nothing. * Subclasses may override. *

* * @param statusLine the status line manager */ virtual void FillStatusLine(IStatusLineManager* statusLine); private: SmartPointer actionBarConfigurer; QHash actions; }; } Q_DECLARE_OPERATORS_FOR_FLAGS(berry::ActionBarAdvisor::FillFlags) #endif /*BERRYACTIONBARADVISOR_H_*/ diff --git a/Plugins/org.blueberry.ui.qt/src/berryIContributionRoot.h b/Plugins/org.blueberry.ui.qt/src/berryIContributionRoot.h index c0834293a7..5b3074227d 100644 --- a/Plugins/org.blueberry.ui.qt/src/berryIContributionRoot.h +++ b/Plugins/org.blueberry.ui.qt/src/berryIContributionRoot.h @@ -1,67 +1,67 @@ /*============================================================================ 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 BERRYICONTRIBUTIONROOT_H #define BERRYICONTRIBUTIONROOT_H #include namespace berry { struct IContributionItem; class Expression; /** * Instances of this interface represent a position in the contribution * hierarchy into which {@link AbstractContributionFactory} instances may insert * elements. Instances of this interface are provided by the platform and this * interface should NOT be implemented by clients. */ struct IContributionRoot : public Object { berryObjectMacro(berry::IContributionRoot); /** * Adds a given contribution item with provided visibility expression and * kill-switch filtering as a direct child of this container. This should be * called for all top-level elements created in - * {@link AbstractContributionFactory#createContributionItems(org.eclipse.ui.services.IServiceLocator, IContributionRoot)} + * berry::AbstractContributionFactory::CreateContributionItems(). * * @param item * the item to add * @param visibleWhen * the visibility expression. May be null. */ virtual void AddContributionItem(const SmartPointer& item, const SmartPointer& visibleWhen) = 0; /** * Registers visibilty for arbitrary {@link IContributionItem} instances * that are NOT direct children of this container. Ie: children of a * {@link IContributionManager} that has been previously registered with a - * call to {{@link #AddContributionItem(IContributionItem, Expression)}. + * call to AddContributionItem(). * * @param item * the item for which to register a visibility clause * @param visibleWhen * the visibility expression. May be null in which * case this method is a no-op. */ virtual void RegisterVisibilityForChild(const SmartPointer& item, const SmartPointer& visibleWhen) = 0; }; } #endif // BERRYICONTRIBUTIONROOT_H diff --git a/Plugins/org.blueberry.ui.qt/src/berryPlatformUI.h b/Plugins/org.blueberry.ui.qt/src/berryPlatformUI.h index 4d19c9355d..ab60ec62dd 100644 --- a/Plugins/org.blueberry.ui.qt/src/berryPlatformUI.h +++ b/Plugins/org.blueberry.ui.qt/src/berryPlatformUI.h @@ -1,170 +1,170 @@ /*============================================================================ 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 BERRYPLATFORMUI_H_ #define BERRYPLATFORMUI_H_ #include #include "berryDisplay.h" #include "application/berryWorkbenchAdvisor.h" #include "testing/berryTestableObject.h" namespace berry { /** * \ingroup org_blueberry_ui_qt * * The central class for access to the BlueBerry Platform User Interface. * This class cannot be instantiated; all functionality is provided by * static methods. * * Features provided: *
    *
  • creation of the workbench.
  • *
  • access to the workbench.
  • *
*

* * @see IWorkbench */ class BERRY_UI_QT PlatformUI { public: static QString PLUGIN_ID(); static const QString XP_WORKBENCH; static const QString XP_VIEWS; /** * Return code (value 0) indicating that the workbench terminated normally. * - * @see #CreateAndRunWorkbench + * @see CreateAndRunWorkbench() * @since 3.0 */ static const int RETURN_OK; /** * Return code (value 1) indicating that the workbench was terminated with * a call to IWorkbench.restart. * - * @see #CreateAndRunWorkbench + * @see CreateAndRunWorkbench() * @see IWorkbench#Restart * @since 3.0 */ static const int RETURN_RESTART; /** * Return code (value 2) indicating that the workbench failed to start. * - * @see #CreateAndRunWorkbench + * @see CreateAndRunWorkbench() * @see IWorkbench#Restart * @since 3.0 */ static const int RETURN_UNSTARTABLE; /** * Return code (value 3) indicating that the workbench was terminated with * a call to IWorkbenchConfigurer#emergencyClose. * - * @see #CreateAndRunWorkbench + * @see CreateAndRunWorkbench() * @since 3.0 */ static const int RETURN_EMERGENCY_CLOSE; /** * Creates the workbench and associates it with the given display and workbench * advisor, and runs the workbench UI. This entails processing and dispatching * events until the workbench is closed or restarted. *

* This method is intended to be called by the main class (the "application"). * Fails if the workbench UI has already been created. *

*

* Use {@link #createDisplay createDisplay} to create the display to pass in. *

*

* Note that this method is intended to be called by the application * (org.blueberry.core.boot.IPlatformRunnable). It must be * called exactly once, and early on before anyone else asks * getWorkbench() for the workbench. *

* * @param display the display to be used for all UI interactions with the workbench * @param advisor the application-specific advisor that configures and * specializes the workbench * @return return code {@link #RETURN_OK RETURN_OK} for normal exit; * {@link #RETURN_RESTART RETURN_RESTART} if the workbench was terminated * with a call to {@link IWorkbench#restart IWorkbench.restart}; * {@link #RETURN_UNSTARTABLE RETURN_UNSTARTABLE} if the workbench could * not be started; * {@link #RETURN_EMERGENCY_CLOSE RETURN_EMERGENCY_CLOSE} if the UI quit * because of an emergency; other values reserved for future use */ static int CreateAndRunWorkbench(Display* display, WorkbenchAdvisor* advisor); /** * Creates the Display to be used by the workbench. * It is the caller's responsibility to dispose the resulting Display, * not the workbench's. * * @return the display */ static Display* CreateDisplay(); /** * Returns the workbench. Fails if the workbench has not been created yet. * * @return the workbench. A raw pointer is returned because you normally * should not hold a smart pointer to it (and possibly create reference * cycles) */ static IWorkbench* GetWorkbench(); /** - * Returns whether {@link #createAndRunWorkbench createAndRunWorkbench} has + * Returns whether CreateAndRunWorkbench() has * been called to create the workbench, and the workbench has yet to * terminate. *

* Note that this method may return true while the workbench * is still being initialized, so it may not be safe to call workbench API * methods even if this method returns true. See bug 49316 for details. *

* * @return true if the workbench has been created and is * still running, and false if the workbench has not * yet been created or has completed * @since 3.0 */ static bool IsWorkbenchRunning(); /** * Returns the testable object facade, for use by the test harness. *

* IMPORTANT: This method is only for use by the test harness. * Applications and regular plug-ins should not call this method. *

* * @return the testable object facade * @since 3.0 */ static TestableObject::Pointer GetTestableObject(); private: PlatformUI(); }; } #endif /*BERRYPLATFORMUI_H_*/ diff --git a/Plugins/org.blueberry.ui.qt/src/handlers/berryIHandlerActivation.h b/Plugins/org.blueberry.ui.qt/src/handlers/berryIHandlerActivation.h index d9579d2f46..ee99ce3b1f 100755 --- a/Plugins/org.blueberry.ui.qt/src/handlers/berryIHandlerActivation.h +++ b/Plugins/org.blueberry.ui.qt/src/handlers/berryIHandlerActivation.h @@ -1,100 +1,100 @@ /*============================================================================ 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 BERRYIHANDLERACTIVATION_H_ #define BERRYIHANDLERACTIVATION_H_ #include "internal/berryIEvaluationResultCache.h" #include namespace berry { struct IHandler; struct IHandlerService; /** *

* A token representing the activation of a handler. This token can later be * used to cancel that activation. Without this token, then handler will only * become inactive if the component in which the handler was activated is * destroyed. *

*

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

* * @see org.eclipse.ui.ISources * @see org.eclipse.ui.ISourceProvider */ struct BERRY_UI_QT IHandlerActivation : public virtual IEvaluationResultCache { berryObjectMacro(berry::IHandlerActivation); ~IHandlerActivation() override; /** * The depth at which the root exists. */ static const int ROOT_DEPTH; // = 1; /** * Clears the cached computation of the isActive method, if * any. This method is only intended for internal use. It provides a * mechanism by which ISourceProvider events can invalidate * state on a IHandlerActivation instance. * - * @deprecated Use {@link IEvaluationResultCache#clearResult()} instead. + * @deprecated Use berry::IEvaluationResultCache::clearResult() instead. */ virtual void ClearActive() = 0; /** * Returns the identifier of the command whose handler is being activated. * * @return The command identifier; never null. */ virtual QString GetCommandId() const = 0; /** * Returns the depth at which this activation was created within the * services hierarchy. The root of the hierarchy is at a depth of * 1. This is used as the final tie-breaker in the event * that no other method can be used to determine a winner. * * @return The depth at which the handler was inserted into the services * hierarchy; should be a positive integer. */ virtual int GetDepth() const = 0; /** * Returns the handler that should be activated. * * @return The handler; may be null. */ virtual SmartPointer GetHandler() const = 0; /** * Returns the handler service from which this activation was requested. * This is used to ensure that an activation can only be retracted from the * same service which issued it. * * @return The handler service; never null. */ virtual IHandlerService* GetHandlerService() const = 0; }; } #endif /* BERRYIHANDLERACTIVATION_H_ */