diff --git a/Examples/FirstSteps/NewModule/include/mitkExampleDataStructure.h b/Examples/FirstSteps/NewModule/include/mitkExampleDataStructure.h index 4906fb2e0b..6d968daeba 100644 --- a/Examples/FirstSteps/NewModule/include/mitkExampleDataStructure.h +++ b/Examples/FirstSteps/NewModule/include/mitkExampleDataStructure.h @@ -1,84 +1,83 @@ - /*============================================================================ 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 _MITK_ExampleDataStructure_H #define _MITK_ExampleDataStructure_H #include #include "mitkBaseData.h" namespace mitk { /** * \brief Example Data Structure * * This class is an example of deriving your own data structure based on mitk::BaseData . */ class MITKNEWMODULE_EXPORT ExampleDataStructure : public BaseData { public: // virtual methods that need to be implemented void UpdateOutputInformation() override; void SetRequestedRegionToLargestPossibleRegion() override; bool RequestedRegionIsOutsideOfTheBufferedRegion() override; bool VerifyRequestedRegion() override; void SetRequestedRegion(const itk::DataObject *) override; // Macros mitkClassMacro(ExampleDataStructure, BaseData); itkFactorylessNewMacro(Self); itkCloneMacro(Self); ////////////////// Interface /////////////////// // Get macros itkGetMacro(Data, std::string); itkGetConstMacro(Data, std::string); // Set macros itkSetMacro(Data, std::string); /** * \brief Append a string to the data string * * Takes a string that is appended to the data string. * * \param input string to be appended */ void AppendAString(const std::string input); protected: ExampleDataStructure(); ~ExampleDataStructure() override; // this string is the data stored in this example data structure std::string m_Data; private: }; /** * \brief Returns true if the example data structures are considered equal. * * They are considered equal if their string is equal */ MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose); } // namespace mitk #endif /* _MITK_ExampleDataStructure_H */ diff --git a/Modules/CommandLine/include/mitkCommandLineParser.h b/Modules/CommandLine/include/mitkCommandLineParser.h index c83544cad7..8aaaf6e297 100644 --- a/Modules/CommandLine/include/mitkCommandLineParser.h +++ b/Modules/CommandLine/include/mitkCommandLineParser.h @@ -1,391 +1,372 @@ /*============================================================================ 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. ============================================================================*/ -/*========================================================================= - - Library: CTK - - Copyright (c) Kitware Inc. - - 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 - - https://www.apache.org/licenses/LICENSE-2.0.txt - - 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 __mitkCommandLineParser_h #define __mitkCommandLineParser_h #include #include #include #include /** * * The MITK command line parser, based on the CTK command line parser. * * Use this class to add information about the command line arguments * your program understands and to easily parse them from a given list * of strings. * * This parser provides the following features: * *
    *
  • Add arguments by supplying a long name and/or a short name. * Arguments are validated using a regular expression. They can have * a default value and a help string.
  • *
  • Deprecated arguments.
  • *
  • Custom regular expressions for argument validation.
  • *
  • Set different argument name prefixes for native platform look and feel.
  • *
  • Create a help text for the command line arguments with support for * grouping arguments.
  • *
* * The main difference between the MITK command line parser and the CTK command line * parser is that the former does not depend on Qt. Apart from that an image type was * added and XML output improved for automatic GUI generation. * * std::out is used for output to keep dependencies to a minimum. */ class MITKCOMMANDLINE_EXPORT mitkCommandLineParser { public: enum Type { String = 0, Bool = 1, StringList = 2, Int = 3, Float = 4, Directory = 5, File = 6, Image = 7 }; enum Channel { None = 0, Input = 1, Output = 2 }; typedef std::vector StringContainerType; mitkCommandLineParser(); ~mitkCommandLineParser(); /** * Parse a given list of command line arguments. * * This method parses a list of string elements considering the known arguments * added by calls to addArgument(). If any one of the argument * values does not match the corresponding regular expression, * ok is set to false and an empty map object is returned. * * The keys in the returned map object correspond to the long argument string, * if it is not empty. Otherwise, the short argument string is used as key. The * us::Any values can safely be converted to the type specified in the * addArgument() method call. * * @param arguments A StringContainerType containing command line arguments. * @param ok A pointer to a boolean variable. Will be set to true * if all regular expressions matched, false otherwise. * @return A map object mapping the long argument (if empty, the short one) * to a us::Any containing the value. */ std::map parseArguments(const StringContainerType &arguments, bool *ok = nullptr); /** * Convenient method allowing to parse a given list of command line arguments. * @see parseArguments(const StringContainerType &, bool*) */ std::map parseArguments(int argc, char **argv, bool *ok = nullptr); /** * Returns a detailed error description if a call to parseArguments() * failed. * * @return The error description, empty if no error occured. * @see parseArguments(const StringContainerType&, bool*) */ std::string errorString() const; /** * This method returns all unparsed arguments, i.e. all arguments * for which no long or short name has been registered via a call * to addArgument(). * * @see addArgument() * * @return A list containing unparsed arguments. */ const StringContainerType &unparsedArguments() const; /** * Checks if the given argument has been added via a call * to addArgument(). * * @see addArgument() * * @param argument The argument to be checked. * @return true if the argument was added, false * otherwise. */ bool argumentAdded(const std::string &argument) const; /** * Checks if the given argument has been parsed successfully by a previous * call to parseArguments(). * * @param argument The argument to be checked. * @return true if the argument was parsed, false * otherwise. */ bool argumentParsed(const std::string &argument) const; /** * Adds a command line argument. An argument can have a long name * (like --long-argument-name), a short name (like -l), or both. The type * of the argument can be specified by using the type parameter. * The following types are supported: * * * * * * * * *
Type# of parametersDefault regular exprExample
us::Any::String1.*--test-string StringParameter
us::Any::Bool0does not apply--enable-something
us::Any::StringList-1.*--test-list string1 string2
us::Any::Int1-?[0-9]+--test-int -5
* * The regular expressions are used to validate the parameters of command line * arguments. You can restrict the valid set of parameters by calling * setExactMatchRegularExpression() for your argument. * * Optionally, a help string and a default value can be provided for the argument. If * the us::Any type of the default value does not match type, an * exception is thrown. Arguments with default values are always returned by * parseArguments(). * * You can also declare an argument deprecated, by setting deprecated * to true. Alternatively you can add a deprecated argument by calling * addDeprecatedArgument(). * * If the long or short argument has already been added, or if both are empty strings, * the method call has no effect. * * @param longarg The long argument name. * @param shortarg The short argument name. * @param type The argument type (see the list above for supported types). * @param argLabel The label of this argument, when auto generated interface is used. * @param argHelp A help string describing the argument. * @param defaultValue A default value for the argument. * @param optional * @param ignoreRest All arguments after the current one will be ignored. * @param deprecated Declares the argument deprecated. * @param channel * * @see setExactMatchRegularExpression() * @see addDeprecatedArgument() * @throws std::logic_error If the us::Any type of defaultValue * does not match type, a std::logic_error is thrown. */ void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp = std::string(), const us::Any &defaultValue = us::Any(), bool optional = true, bool ignoreRest = false, bool deprecated = false, mitkCommandLineParser::Channel channel = mitkCommandLineParser::Channel::None); /** * Adds a deprecated command line argument. If a deprecated argument is provided * on the command line, argHelp is displayed in the console and * processing continues with the next argument. * * Deprecated arguments are grouped separately at the end of the help text * returned by helpText(). * * @param longarg The long argument name. * @param shortarg The short argument name. * @param argLabel * @param argHelp A help string describing alternatives to the deprecated argument. */ void addDeprecatedArgument(const std::string &longarg, const std::string &shortarg, const std::string &argLabel, const std::string &argHelp); /** * Returns the vector of current Command line Parameter * */ std::vector < std::map > getArgumentList(); /** * Sets a custom regular expression for validating argument parameters. The method * errorString() can be used the get the last error description. * * @param argument The previously added long or short argument name. * @param expression A regular expression which the arugment parameters must match. * @param exactMatchFailedMessage An error message explaining why the parameter did * not match. * * @return true if the argument was found and the regular expression was set, * false otherwise. * * @see errorString() */ bool setExactMatchRegularExpression(const std::string &argument, const std::string &expression, const std::string &exactMatchFailedMessage); /** * The field width for the argument names without the help text. * * @return The argument names field width in the help text. */ std::string::size_type fieldWidth() const; /** * Creates a help text containing properly formatted argument names and help strings * provided by calls to addArgument(). The arguments can be grouped by * using beginGroup() and endGroup(). * * @return The formatted help text. */ std::string helpText() const; /** * Sets the argument prefix for long and short argument names. This can be used * to create native command line arguments without changing the calls to * addArgument(). For example on Unix-based systems, long argument * names start with "--" and short names with "-", while on Windows argument names * always start with "/". * * Note that all methods in mitkCommandLineParser which take an argument name * expect the name as it was supplied to addArgument. * * Example usage: * * \code * ctkCommandLineParser parser; * parser.setArgumentPrefix("--", "-"); * parser.addArgument("long-argument", "l", us::Any::String); * StringContainerType args; * args << "program name" << "--long-argument Hi"; * parser.parseArguments(args); * \endcode * * @param longPrefix The prefix for long argument names. * @param shortPrefix The prefix for short argument names. */ void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix); /** * Begins a new group for documenting arguments. All newly added arguments via * addArgument() will be put in the new group. You can close the * current group by calling endGroup() or be opening a new group. * * Note that groups cannot be nested and all arguments which do not belong to * a group will be listed at the top of the text created by helpText(). * * @param description The description of the group */ void beginGroup(const std::string &description); /** * Ends the current group. * * @see beginGroup(const std::string&) */ void endGroup(); /** * Can be used to teach the parser to stop parsing the arguments and return False when * an unknown argument is encountered. By default StrictMode is disabled. * * @see parseArguments(const StringContainerType &, bool*) */ void setStrictModeEnabled(bool strictMode); /** * Is used to generate an XML output for any commandline program. */ void generateXmlOutput(); /** * Is used to set the title of the auto generated interface. * * @param title The title of the app. */ void setTitle(std::string title); /** * Is used to set the contributor for the help view in the auto generated interface. * * @param contributor Contributor of the app. */ void setContributor(std::string contributor); /** * Is used to categorize the apps in the commandline module. * * @param category The category of the app. */ void setCategory(std::string category); /** * Is used as the help text in the auto generated interface. * * @param description A short description for the app. */ void setDescription(std::string description); /** * Is used to group several Parameters in one groupbox in the auto generated interface. * Default name is "Parameters", with the tooltip: "Groupbox containing parameters." * * To change the group of several arguments, call this method before the arguments are added. * * @param name The name of the groupbox. * @param tooltip The tooltip of the groupbox. */ void changeParameterGroup(std::string name, std::string tooltip); protected: class ctkInternal; ctkInternal *Internal; std::string Title; std::string Contributor; std::string Category; std::string Description; std::string ParameterGroupName; std::string ParameterGroupDescription; }; #endif diff --git a/Modules/ImageStatistics/mitkitkMaskImageFilter.h b/Modules/ImageStatistics/mitkitkMaskImageFilter.h index e649aaf951..2cdeda3782 100644 --- a/Modules/ImageStatistics/mitkitkMaskImageFilter.h +++ b/Modules/ImageStatistics/mitkitkMaskImageFilter.h @@ -1,285 +1,282 @@ -/*========================================================================= - * - * Copyright Insight Software Consortium - * - * 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 - * - * https://www.apache.org/licenses/LICENSE-2.0.txt - * - * 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 __itkMaskImageFilter2_h -#define __itkMaskImageFilter2_h +/*============================================================================ + +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 mitkitkMaskImageFilter_h +#define mitkitkMaskImageFilter_h + +// This file is based on ITK's itkMaskImageFilter.h #include "itkBinaryFunctorImageFilter.h" #include "itkNumericTraits.h" #include "itkVariableLengthVector.h" #include namespace itk { namespace Functor { /** * \class MaskInput2 * \brief * \ingroup ITKImageIntensity */ template< typename TInput, typename TMask, typename TOutput = TInput > class MaskInput2 { public: typedef typename NumericTraits< TInput >::AccumulateType AccumulatorType; MaskInput2() { m_MaskingValue = NumericTraits< TMask >::ZeroValue(); InitializeOutsideValue( static_cast( nullptr ) ); } ~MaskInput2() {} bool operator!=(const MaskInput2 &) const { return false; } bool operator==(const MaskInput2 & other) const { return !( *this != other ); } inline TOutput operator()(const TInput & A, const TMask & B) const { if ( B == m_MaskingValue ) { return static_cast< TOutput >( A ); } else { return m_OutsideValue; } } /** Method to explicitly set the outside value of the mask */ void SetOutsideValue(const TOutput & outsideValue) { m_OutsideValue = outsideValue; } /** Method to get the outside value of the mask */ const TOutput & GetOutsideValue() const { return m_OutsideValue; } /** Method to explicitly set the masking value */ void SetMaskingValue(const TMask & maskingValue) { m_MaskingValue = maskingValue; } /** Method to get the masking value */ const TMask & GetMaskingValue() const { return m_MaskingValue; } private: template < typename TPixelType > void InitializeOutsideValue( TPixelType * ) { this->m_OutsideValue = NumericTraits< TPixelType >::ZeroValue(); } template < typename TValue > void InitializeOutsideValue( VariableLengthVector * ) { // set the outside value to be of zero length this->m_OutsideValue = VariableLengthVector< TValue >(0); } TOutput m_OutsideValue; TMask m_MaskingValue; }; } /** \class MaskImageFilter * \brief Mask an image with a mask. * * This class is templated over the types of the * input image type, the mask image type and the type of the output image. * Numeric conversions (castings) are done by the C++ defaults. * * The pixel type of the input 2 image must have a valid definition of the * operator != with zero. This condition is required because internally this * filter will perform the operation * * \code{.unparsed} * if pixel_from_mask_image == masking_value * pixel_output_image = pixel_input_image * else * pixel_output_image = outside_value * \endcode * * The pixel from the input 1 is cast to the pixel type of the output image. * * Note that the input and the mask images must be of the same size. * * * \sa MaskNegatedImageFilter * \ingroup IntensityImageFilters * \ingroup MultiThreaded * \ingroup ITKImageIntensity */ template< typename TInputImage, typename TMaskImage, typename TOutputImage = TInputImage > class MITKIMAGESTATISTICS_EXPORT MaskImageFilter2: public BinaryFunctorImageFilter< TInputImage, TMaskImage, TOutputImage, Functor::MaskInput2< typename TInputImage::PixelType, typename TMaskImage::PixelType, typename TOutputImage::PixelType > > { public: /** Standard class typedefs. */ typedef MaskImageFilter2 Self; typedef BinaryFunctorImageFilter< TInputImage, TMaskImage, TOutputImage, Functor::MaskInput2< typename TInputImage::PixelType, typename TMaskImage::PixelType, typename TOutputImage::PixelType > > Superclass; typedef SmartPointer< Self > Pointer; typedef SmartPointer< const Self > ConstPointer; /** Method for creation through the object factory. */ itkNewMacro(Self); /** Runtime information support. */ itkTypeMacro(MaskImageFilter2, BinaryFunctorImageFilter); /** Typedefs **/ typedef TMaskImage MaskImageType; /** Set/Get the mask image. Pixels set in the mask image will retain * the original value of the input image while pixels not set in * the mask will be set to the "OutsideValue". */ void SetMaskImage(const MaskImageType *maskImage) { // Process object is not const-correct so the const casting is required. this->SetNthInput( 1, const_cast< MaskImageType * >( maskImage ) ); } const MaskImageType * GetMaskImage() { return static_cast(this->ProcessObject::GetInput(1)); } /** Method to explicitly set the outside value of the mask. Defaults to 0 */ void SetOutsideValue(const typename TOutputImage::PixelType & outsideValue) { if ( this->GetOutsideValue() != outsideValue ) { this->Modified(); this->GetFunctor().SetOutsideValue(outsideValue); } } const typename TOutputImage::PixelType & GetOutsideValue() const { return this->GetFunctor().GetOutsideValue(); } /** Method to explicitly set the masking value of the mask. Defaults to 0 */ void SetMaskingValue(const typename TMaskImage::PixelType & maskingValue) { if ( this->GetMaskingValue() != maskingValue ) { this->Modified(); this->GetFunctor().SetMaskingValue(maskingValue); } } /** Method to get the masking value of the mask. */ const typename TMaskImage::PixelType & GetMaskingValue() const { return this->GetFunctor().GetMaskingValue(); } void BeforeThreadedGenerateData() override { typedef typename TOutputImage::PixelType PixelType; this->CheckOutsideValue( static_cast(nullptr) ); } #ifdef ITK_USE_CONCEPT_CHECKING // Begin concept checking itkConceptMacro( MaskEqualityComparableCheck, ( Concept::EqualityComparable< typename TMaskImage::PixelType > ) ); itkConceptMacro( InputConvertibleToOutputCheck, ( Concept::Convertible< typename TInputImage::PixelType, typename TOutputImage::PixelType > ) ); // End concept checking #endif protected: MaskImageFilter2() {} ~MaskImageFilter2() override {} void PrintSelf(std::ostream & os, Indent indent) const override { Superclass::PrintSelf(os, indent); os << indent << "OutsideValue: " << this->GetOutsideValue() << std::endl; } private: MaskImageFilter2(const Self &); //purposely not implemented void operator=(const Self &); //purposely not implemented template < typename TPixelType > void CheckOutsideValue( const TPixelType * ) {} template < typename TValue > void CheckOutsideValue( const VariableLengthVector< TValue > * ) { // Check to see if the outside value contains only zeros. If so, // resize it to have the same number of zeros as the output // image. Otherwise, check that the number of components in the // outside value is the same as the number of components in the // output image. If not, throw an exception. VariableLengthVector< TValue > currentValue = this->GetFunctor().GetOutsideValue(); VariableLengthVector< TValue > zeroVector( currentValue.GetSize() ); zeroVector.Fill( NumericTraits< TValue >::ZeroValue() ); if ( currentValue == zeroVector ) { zeroVector.SetSize( this->GetOutput()->GetVectorLength() ); zeroVector.Fill( NumericTraits< TValue >::ZeroValue() ); this->GetFunctor().SetOutsideValue( zeroVector ); } else if ( this->GetFunctor().GetOutsideValue().GetSize() != this->GetOutput()->GetVectorLength() ) { itkExceptionMacro( << "Number of components in OutsideValue: " << this->GetFunctor().GetOutsideValue().GetSize() << " is not the same as the " << "number of components in the image: " << this->GetOutput()->GetVectorLength()); } } }; } // end namespace itk #endif diff --git a/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h b/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h index 20b772841d..dab97605a1 100644 --- a/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h +++ b/Modules/SegmentationUI/Qmitk/QmitkSlicesInterpolator.h @@ -1,423 +1,423 @@ - /*============================================================================ +/*============================================================================ 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; enum ModifyLabelActionTrigerred { Null, Erase, Merge }; /** \brief GUI for slices interpolation. \ingroup ToolManagerEtAl \ingroup Widgets \sa QmitkInteractiveSegmentation \sa mitk::SegmentationInterpolation 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); /** * @brief * */ void Uninitialize(); ~QmitkSlicesInterpolator() override; /** * @brief Set the Data Storage object * * @param storage */ void SetDataStorage(mitk::DataStorage::Pointer storage); /** * @brief Get the Data Storage object * * @return mitk::DataStorage* */ 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(); /** * @brief Reacts to the time changed event. * * @param sender */ void OnTimeChanged(itk::Object *sender, const itk::EventObject &); /** * @brief Reacts to the slice changed event * * @param sender */ 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 OnInterpolationAborted(const itk::EventObject &); /** Just public because it is called by itk::Commands. You should not need to call this. */ void OnSurfaceInterpolationInfoChanged(const itk::EventObject &); private: /** * @brief Set the visibility of the 3d interpolation */ void Show3DInterpolationResult(bool); /** * @brief Function that reacts to a change in the activeLabel of the working segmentation image. * */ void OnActiveLabelChanged(mitk::Label::PixelType); /** * @brief Function that reacts to a change in the layer. * */ void OnLayerChanged(); /** * @brief Function that handles label removal from the segmentation image. * */ void OnRemoveLabel(); /** * @brief Function that to changes in the segmentation image. It handles the layer removal, addition, label erasure, * */ void OnModifyLabelChanged(const itk::Object *caller, const itk::EventObject & /*event*/); /** * @brief Add the necessary subscribers to the label set image, for UI responsiveness. * It deals with remove label, change active label, layer changes and change in the label. * */ void OnAddLabelSetConnection(); /** * @brief Add the necessary subscribers to the current LabelSetImage at the layer input, for UI responsiveness. * It deals with remove label, change active label, layer changes and change in the label. * * @param layerID */ void OnAddLabelSetConnection(unsigned int layerID); /** * @brief Remove the subscribers for the different events to the segmentation image. * */ void OnRemoveLabelSetConnection(); /** * @brief Merge contours for the current layerID and current timeStep. * * @param timeStep * @param layerID */ void MergeContours(unsigned int timeStep, unsigned int layerID); /** * @brief Prepare Inputs for 3D Interpolation. * */ void PrepareInputsFor3DInterpolation(); 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(); /** * @brief Reaction to reinit 3D Interpolation. Re-reads the plane geometries of the image * that should have generated the * */ void OnReinit3DInterpolation(); /* * 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(); /** * @brief Function triggers when the surface interpolation thread completes running. * It is responsible for retrieving the data, rendering it in the active color label, * storing the surface information in the feedback node. * */ void OnSurfaceInterpolationFinished(); void StartUpdateInterpolationTimer(); void StopUpdateInterpolationTimer(); void ChangeSurfaceColor(); /** * @brief Removes all observers to the labelSetImage at the layerID specified. * Is used when changing the segmentation image. * * @param labelSetImage * @param layerID */ void OnRemoveLabelSetConnection(mitk::LabelSetImage* labelSetImage, unsigned int layerID); 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 slicer 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, mitk::TimePointType timePoint, 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; std::map m_SegmentationObserverTags; unsigned int InterpolationInfoChangedObserverTag; unsigned int SurfaceInterpolationInfoChangedObserverTag; unsigned int InterpolationAbortedObserverTag; QGroupBox *m_GroupBoxEnableExclusiveInterpolationMode; QComboBox *m_CmbInterpolation; QPushButton *m_BtnApply2D; QPushButton *m_BtnApplyForAllSlices2D; QPushButton *m_BtnApply3D; // T28261 // 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_TimePoints; bool m_2DInterpolationEnabled; bool m_3DInterpolationEnabled; unsigned int m_numTimesLabelSetConnectionAdded; mitk::DataStorage::Pointer m_DataStorage; QFuture m_Future; QFutureWatcher m_Watcher; QFuture m_ModifyFuture; QFutureWatcher m_ModifyWatcher; QTimer *m_Timer; QFuture m_PlaneFuture; QFutureWatcher m_PlaneWatcher; mitk::Label::PixelType m_PreviousActiveLabelValue; mitk::Label::PixelType m_CurrentActiveLabelValue; unsigned int m_PreviousLayerIndex; unsigned int m_CurrentLayerIndex; bool m_FirstRun; }; #endif