diff --git a/Modules/Classification/CLCore/include/mitkAbstractGlobalImageFeature.h b/Modules/Classification/CLCore/include/mitkAbstractGlobalImageFeature.h index b72e15a9f5..ddbce9819e 100644 --- a/Modules/Classification/CLCore/include/mitkAbstractGlobalImageFeature.h +++ b/Modules/Classification/CLCore/include/mitkAbstractGlobalImageFeature.h @@ -1,342 +1,342 @@ /*============================================================================ 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 mitkAbstractGlobalImageFeature_h #define mitkAbstractGlobalImageFeature_h #include #include #include #include #include // STD Includes // Eigen #include // MITK includes #include namespace mitk { /**Used as ID for features calculated by feature classes*/ struct MITKCLCORE_EXPORT FeatureID { /**Name of the feature*/ std::string name; /**Name of the feature class*/ std::string featureClass; /**ID for the setting that is represented by parameters and is specified by the feature class while calculating the features. It must be as unique as the parameters themself.*/ std::string settingID; /**Alternative name that containes the legacy naming of the feature that encodes the parametersetting directly in the string.*/ std::string legacyName; /**Version of the feature definition*/ std::string version = "1"; using ParametersType = std::map; ParametersType parameters; bool operator < (const FeatureID& rh) const; bool operator ==(const FeatureID& rh) const; }; /**Helper that takes a pass templateID clones it and populates it with the also passed informations befor returning it. * @param templateID reference ID that should be cloned. * @param name Name of the feature.*/ MITKCLCORE_EXPORT FeatureID CreateFeatureID(FeatureID templateID, std::string name); /** * * * ## Histogram Configuration ## * Most Feature Generation Classes that use histograms use the same parameters and * initialization logic. In general, all information can be passed either by the corresponding * Setter (which does not differenciate between global setting and feature specific setting) and * a parameter object which can be obtained from the command line arguments, for example. * * If the image values are used for the initializiation of the histogram, it can be defined * whether the whole image is used or only the masked areas to find minima and maxima. This is * done by the option SetIgnoreMask or the corrsponding options - * -NAME::ignore-mask-for-histogram and -ignore-mask-for-histogram. If these are + * %-NAME::ignore-mask-for-histogram and -ignore-mask-for-histogram. If these are * true, the whole image is used for the calculation. * * Depending on the passed arguments, different initialization methods are used. The initialization * is in the following order: * - If Minimum Intensity, Maximum Intensity, and Binsize: The histogram is * initialized between the minimum and maximum intensity. the number of bins is determined by the * binsize. If the distance between minimum and maximum is not a multiple of the binsize, the maximum * is increase so that it is. * - Minimum Intensity, Bins, and Binsize: The histogram is initialized with the * given binsize, and the intensity range from the minimum to \f$maximum = minimum + binsize*bins\f$. * - Minimum Intensity, Maximum Intensity, and Bins: The histogram is initialized * between the given minimum and maximum intensity. The binsize is calculated so that the number * of bins is equal to the given number of bins. * - Binsize, and Minimum Intensity: The maximum is set to the maximum that * occur in the given image. Depending if the mask is considered or not, either only masked voxels or * the whole image is used for the calculation. The initialization is then equal as if the minimum * and maximum would have been given right from the beginning. * - Binsize, and Maximum Intensity: The minimum intensity is set to the minimum that * occur in the given image. Depending if the mask is considered or not, either only masked voxels or * the whole image is used for the calculation. The initialization is then equal as if the minimum * and maximum would have been given right from the beginning. * - Binsize: The maximum and the minimum intensity is set to the minimum and maximum that * occur in the given image. Depending if the mask is considered or not, either only masked voxels or * the whole image is used for the calculation. The initialization is then equal as if the minimum * and maximum would have been given right from the beginning. * - Bins, and Minimum Intensity: The maximum is calculated from the image. Depending * if the mask is considered or not, either only masked voxels or the whole image is used for the calculation. The histogram is * then initialized as if these values would have been given as minimum and maximum intensity. * - Bins, and Maximum Intensity: The minimum is calculated from the image. Depending * if the mask is considered or not, either only masked voxels or the whole image is used for the calculation. The histogram is * then initialized as if these values would have been given as minimum and maximum intensity. * - Bins: The minimum and the maximum is calculated from the image. Depending * if the mask is considered or not, either only masked voxels or * the whole image is used for the calculation. The histogram is * then initialized as if these values would have been given as minimum and maximum intensity. * - No Parameter given:The minimum and maximum intensity from the whole image or masked image is calculated and * the histogram then initialized to this with a standard number of bins (Is set by each filter on its own.) * * ### Remark about command line parameter#### * There are generally two options to set a parameter via the command line. A global one that works for * all filters that use histograms and a local one that set this parameter specific for this filter. The * local parameters start with the filter name (Indiciated by NAME) followed by two colons, for example * vol::min to set the minimum intensity for the volume filter. The global parameter is overwritten * by the local parameter, if it is specified. Otherwise, it is still valid. If this prevents the specification * of an histogram initialization method (for example, because the binsize is globally specified but the histogram * should be initialized using a fixed numbe of bins), the parameter NAME::ignore-global-histogram can be passed. * Then, all global histogram parameters are ignored and only local ones are used. * * The maximum intensity can be set by different command line parameters: global for all filters that use histograms * by -minimum-intensity and -minimum. Alternative it can be set only for this filter by - * -NAME::minimum and -NAME::min. + * %-NAME::minimum and %-NAME::min. * * The minimum intensity can be set by different command line parameters: global for all filters that use histograms * by -maximum-intensity and -maximum. Alternative it can be set only for this filter by - * -NAME::maximum and -NAME::max. + * %-NAME::maximum and %-NAME::max. * * The binsize can be set by different command line parameters: global for all filters that use histograms * by -binsize. Alternative it can be set only for this filter by - * -NAME::binsize. + * %-NAME::binsize. * * The number of bins can be set by different command line parameters: global for all filters that use histograms * by -bins. Alternative it can be set only for this filter by - * -NAME::bins. + * %-NAME::bins. * ### Note to the developers ### * All features are supposed to work the same way if a histogram is used somewhere in * the code. For this, each derived class that makes use of a histogram should use * the Quantifier object. In order to use this object correctly, the AddArguments-Function should * contain the line AddQuantifierArguments(parser);, the CalculateFeaturesUsingParameters function * should contain the line InitializeQuantifierFromParameters(feature, mask); and the CalculateFeatures function * sould contain the line InitializeQuantifier(image, mask);. These function * calls ensure that the necessary options are given to the configuration file, and that the initialization * of the quantifier is done correctly. This ensures an consistend behavior over all FeatureGeneration Classes. * */ class MITKCLCORE_EXPORT AbstractGlobalImageFeature : public BaseData { public: mitkClassMacro(AbstractGlobalImageFeature, BaseData); typedef std::vector< std::pair > FeatureListType; using ParametersType = FeatureID::ParametersType; /** * \brief Calculates the feature of this abstact interface. Does not necessarily considers the parameter settings. */ FeatureListType CalculateFeatures(const Image* image, const Image* mask); virtual FeatureListType CalculateFeatures(const Image* image, const Image* mask, const Image* maskNoNAN) = 0; /** * \brief Calculates the given feature Slice-wise. Might not be availble for an individual filter! */ FeatureListType CalculateFeaturesSlicewise(const Image::Pointer & image, const Image::Pointer &mask, int sliceID); /** * \brief Calculates the feature of this abstact interface. Does not necessarily considers the parameter settings. */ virtual void CalculateAndAppendFeaturesSliceWise(const Image::Pointer & image, const Image::Pointer &mask, int sliceID, FeatureListType &featureList, bool checkParameterActivation = true); /** * \brief Calculates the feature of this abstact interface. Does not necessarily considers the parameter settings. * @param image * @param mask * @param maskNoNaN * @param featureList * @param checkParameterActivation Indicates if the features should only be calculated and added if the FeatureClass is activated in the parameters. * True: only append if activated in the parametes. False: always and append it. */ void CalculateAndAppendFeatures(const Image* image, const Image* mask, const Image* maskNoNaN, FeatureListType &featureList, bool checkParameterActivation = true); itkSetMacro(Prefix, std::string); itkSetMacro(ShortName, std::string); itkSetMacro(LongName, std::string); itkSetMacro(FeatureClassName, std::string); itkSetMacro(Direction, int); void SetParameters(ParametersType param) { m_Parameters = param; this->ConfigureQuantifierSettingsByParameters(); this->ConfigureSettingsByParameters(param); this->Modified(); }; itkGetConstMacro(Prefix, std::string); itkGetConstMacro(ShortName, std::string); itkGetConstMacro(LongName, std::string); itkGetConstMacro(FeatureClassName, std::string); itkGetConstMacro(Parameters, ParametersType); itkGetMacro(Quantifier, IntensityQuantifier::Pointer); itkGetConstMacro(Direction, int); itkSetMacro(MinimumIntensity, double); itkSetMacro(UseMinimumIntensity, bool); itkSetMacro(MaximumIntensity, double); itkSetMacro(UseMaximumIntensity, bool); itkGetConstMacro(MinimumIntensity, double); itkGetConstMacro(UseMinimumIntensity, bool); itkGetConstMacro(MaximumIntensity, double); itkGetConstMacro(UseMaximumIntensity, bool); itkSetMacro(Binsize, double); itkSetMacro(UseBinsize, bool); itkGetConstMacro(Binsize, double); itkGetConstMacro(UseBinsize, bool); itkSetMacro(MorphMask, mitk::Image::Pointer); itkGetConstMacro(MorphMask, mitk::Image::Pointer); itkSetMacro(Bins, int); itkSetMacro(UseBins, bool); itkGetConstMacro(UseBins, bool); itkGetConstMacro(Bins, int); itkSetMacro(IgnoreMask, bool); itkGetConstMacro(IgnoreMask, bool); itkSetMacro(EncodeParametersInFeaturePrefix, bool); itkGetConstMacro(EncodeParametersInFeaturePrefix, bool); itkBooleanMacro(EncodeParametersInFeaturePrefix); std::string GetOptionPrefix() const { if (!m_Prefix.empty()) return m_Prefix + "::" + m_ShortName; return m_ShortName; } /** Can be called to add all relevant argument for configuring the feature instance to the passed parser instance. Must be implemented be derived classes. For adding the quantifier arguments use AddQuantifierArguments(...) as helper function.*/ virtual void AddArguments(mitkCommandLineParser &parser) const = 0; /** Helper function that generates the legacy feature name without encoding of parameters; as it is used e.g. in the unit tests.*/ static std::string GenerateLegacyFeatureNameWOEncoding(const FeatureID& id); protected: std::vector SplitDouble(std::string str, char delimiter); virtual FeatureListType DoCalculateFeatures(const Image* image, const Image* mask) = 0; void AddQuantifierArguments(mitkCommandLineParser& parser) const; /** Ensures that all quantifier relevant variables of the instance are set correctly given the information in m_Parameters.*/ void ConfigureQuantifierSettingsByParameters(); /** Ensures that the instance is configured according to the information given in the passed parameters. * This method will be called by SetParameters(...) after ConfigureQuantifierSettingsByParameters() was called.*/ virtual void ConfigureSettingsByParameters(const ParametersType& parameters); /**Initializes the quantifier gigen the quantifier relevant variables and the passed arguments.*/ void InitializeQuantifier(const Image* image, const Image* mask, unsigned int defaultBins = 256); /** Helper that encodes the quantifier parameters in a string (e.g. used for the legacy feature name)*/ std::string QuantifierParameterString() const; /* Creates a template feature id. * it will set the featureClass, the settingID (assuming that it is the featureClass with the passed suffix * and all parameters that are global or have the option prefix of the instance.*/ FeatureID CreateTemplateFeatureID(std::string settingsSuffix = "", FeatureID::ParametersType additionalParams = {}); /** Helper that generates the legacy feature names for a passed FeatureID. * Format of the legacy feature name is: \::[\::]\ * Overwrite GenerateLegacyFeatureNamePart and GenerateLegacyFeatureEncoding to change behavior in * derived classes. */ virtual std::string GenerateLegacyFeatureName(const FeatureID& id) const; virtual std::string GenerateLegacyFeatureNamePart(const FeatureID& id) const; virtual std::string GenerateLegacyFeatureEncoding(const FeatureID& id) const; public: //#ifndef DOXYGEN_SKIP void SetRequestedRegionToLargestPossibleRegion() override {}; bool RequestedRegionIsOutsideOfTheBufferedRegion() override { return true; }; bool VerifyRequestedRegion() override { return false; }; void SetRequestedRegion (const itk::DataObject * /*data*/) override {}; // Override bool IsEmpty() const override { if(IsInitialized() == false) return true; const TimeGeometry* timeGeometry = const_cast(this)->GetUpdatedTimeGeometry(); if(timeGeometry == nullptr) return true; return false; } private: std::string m_Prefix; // Prefix before all input parameters std::string m_ShortName; // Name of all variables std::string m_LongName; // Long version of the name (For turning on) std::string m_FeatureClassName; ParametersType m_Parameters; // Parameter setting mitk::Image::Pointer m_MorphMask = nullptr; IntensityQuantifier::Pointer m_Quantifier; //Quantifier relevant variables double m_MinimumIntensity = 0; bool m_UseMinimumIntensity = false; double m_MaximumIntensity = 100; bool m_UseMaximumIntensity = false; bool m_EncodeParametersInFeaturePrefix = false; double m_Binsize = 1; bool m_UseBinsize = false; int m_Bins = 256; bool m_UseBins = true; int m_Direction = 0; bool m_IgnoreMask = false; //#endif // Skip Doxygen }; } #endif //mitkAbstractGlobalImageFeature_h diff --git a/Modules/CommandLine/include/mitkCommandLineParser.h b/Modules/CommandLine/include/mitkCommandLineParser.h index ddba149101..24cd81b25a 100644 --- a/Modules/CommandLine/include/mitkCommandLineParser.h +++ b/Modules/CommandLine/include/mitkCommandLineParser.h @@ -1,392 +1,391 @@ /*============================================================================ 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 http://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(). * - * @param charPad The padding character. * @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/ContourModel/DataManagement/mitkContourElement.h b/Modules/ContourModel/DataManagement/mitkContourElement.h index 9191b72409..ea18abc41d 100644 --- a/Modules/ContourModel/DataManagement/mitkContourElement.h +++ b/Modules/ContourModel/DataManagement/mitkContourElement.h @@ -1,237 +1,231 @@ /*============================================================================ 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 _mitkContourElement_H_ #define _mitkContourElement_H_ #include "mitkCommon.h" #include #include //#include #include namespace mitk { /** \brief Represents a contour in 3D space. A ContourElement is consisting of linked vertices implicitely defining the contour. They are stored in a double ended queue making it possible to add vertices at front and end of the contour and to iterate in both directions. To mark a vertex as a special one it can be set as a control point. \note It is highly not recommend to use this class directly as no secure mechanism is used here. Use mitk::ContourModel instead providing some additional features. */ class MITKCONTOURMODEL_EXPORT ContourElement : public itk::LightObject { public: mitkClassMacroItkParent(ContourElement, itk::LightObject); itkFactorylessNewMacro(Self); itkCloneMacro(Self); // Data container representing vertices /** \brief Represents a single vertex of contour. */ struct ContourModelVertex { ContourModelVertex(mitk::Point3D &point, bool active = false) : IsControlPoint(active), Coordinates(point) {} ContourModelVertex(const ContourModelVertex &other) : IsControlPoint(other.IsControlPoint), Coordinates(other.Coordinates) { } /** \brief Treat point special. */ bool IsControlPoint; /** \brief Coordinates in 3D space. */ mitk::Point3D Coordinates; }; // END Data container representing vertices typedef ContourModelVertex VertexType; typedef std::deque VertexListType; typedef VertexListType::iterator VertexIterator; typedef VertexListType::const_iterator ConstVertexIterator; // start of inline methods /** \brief Return a const iterator a the front. */ virtual ConstVertexIterator ConstIteratorBegin() { return this->m_Vertices->begin(); } /** \brief Return a const iterator a the end. */ virtual ConstVertexIterator ConstIteratorEnd() { return this->m_Vertices->end(); } /** \brief Return an iterator a the front. */ virtual VertexIterator IteratorBegin() { return this->m_Vertices->begin(); } /** \brief Return an iterator a the end. */ virtual VertexIterator IteratorEnd() { return this->m_Vertices->end(); } /** \brief Returns the number of contained vertices. */ virtual int GetSize() { return this->m_Vertices->size(); } // end of inline methods /** \brief Add a vertex at the end of the contour \param point - coordinates in 3D space. \param isControlPoint - is the vertex a special control point. */ virtual void AddVertex(mitk::Point3D &point, bool isControlPoint); /** \brief Add a vertex at the end of the contour \param vertex - a contour element vertex. */ virtual void AddVertex(VertexType &vertex); /** \brief Add a vertex at the front of the contour \param point - coordinates in 3D space. \param isControlPoint - is the vertex a control point. */ virtual void AddVertexAtFront(mitk::Point3D &point, bool isControlPoint); /** \brief Add a vertex at the front of the contour \param vertex - a contour element vertex. */ virtual void AddVertexAtFront(VertexType &vertex); /** \brief Add a vertex at a given index of the contour \param point - coordinates in 3D space. \param isControlPoint - is the vertex a special control point. \param index - the index to be inserted at. */ virtual void InsertVertexAtIndex(mitk::Point3D &point, bool isControlPoint, int index); /** \brief Set coordinates a given index. \param pointId Index of vertex. \param point Coordinates. */ virtual void SetVertexAt(int pointId, const mitk::Point3D &point); /** \brief Set vertex a given index. \param pointId Index of vertex. \param vertex Vertex. */ virtual void SetVertexAt(int pointId, const VertexType *vertex); /** \brief Returns the vertex a given index \param index */ virtual VertexType *GetVertexAt(int index); /** \brief Returns the approximate nearest vertex a given posoition in 3D space \param point - query position in 3D space. \param eps - the error bound for search algorithm. */ virtual VertexType *GetVertexAt(const mitk::Point3D &point, float eps); /** \brief Returns the index of the given vertex within the contour. \param vertex - the vertex to be searched. \return index of vertex. -1 if not found. */ virtual int GetIndex(const VertexType *vertex); /** \brief Returns the container of the vertices. */ VertexListType *GetVertexList(); /** \brief Returns whether the contour element is empty. */ bool IsEmpty(); /** \brief Returns if the conour is closed or not. */ virtual bool IsClosed(); /** \brief Returns whether a given point is near a contour, according to eps. \param point - query position in 3D space. \param eps - the error bound for search algorithm. */ virtual bool IsNearContour(const mitk::Point3D &point, float eps); /** \brief Close the contour. Connect first with last element. */ virtual void Close(); /** \brief Open the contour. Disconnect first and last element. */ virtual void Open(); /** \brief Set the contours IsClosed property. \param isClosed - true = closed; false = open; */ virtual void SetClosed(bool isClosed); /** \brief Concatenate the contuor with a another contour. All vertices of the other contour will be added after last vertex. \param other - the other contour \param check - set it true to avoid intersections */ void Concatenate(mitk::ContourElement *other, bool check); /** \brief Remove the given vertex from the container if exists. \param vertex - the vertex to be removed. */ virtual bool RemoveVertex(const VertexType *vertex); /** \brief Remove a vertex at given index within the container if exists. \param index - the index where the vertex should be removed. */ virtual bool RemoveVertexAt(int index); /** \brief Remove the approximate nearest vertex at given position in 3D space if one exists. \param point - query point in 3D space. \param eps - error bound for search algorithm. */ virtual bool RemoveVertexAt(mitk::Point3D &point, float eps); /** \brief Clear the storage container. */ virtual void Clear(); /** \brief Returns the approximate nearest vertex a given posoition in 3D space \param point - query position in 3D space. \param eps - the error bound for search algorithm. */ VertexType *BruteForceGetVertexAt(const mitk::Point3D &point, float eps); - /** \brief Returns the approximate nearest vertex a given posoition in 3D space - \param point - query position in 3D space. - \param eps - the error bound for search algorithm. - */ - // VertexType* OptimizedGetVertexAt(const mitk::Point3D &point, float eps); - VertexListType *GetControlVertices(); /** \brief Uniformly redistribute control points with a given period (in number of vertices) \param vertex - the vertex around which the redistribution is done. \param period - number of vertices between control points. */ void RedistributeControlVertices(const VertexType *vertex, int period); protected: mitkCloneMacro(Self); ContourElement(); ContourElement(const mitk::ContourElement &other); ~ContourElement() override; VertexListType *m_Vertices; // double ended queue with vertices bool m_IsClosed; }; } // namespace mitk #endif // _mitkContourElement_H_ diff --git a/Modules/Core/TestingHelper/include/mitkInteractionTestHelper.h b/Modules/Core/TestingHelper/include/mitkInteractionTestHelper.h index 71d54b482a..c1ba0efb79 100644 --- a/Modules/Core/TestingHelper/include/mitkInteractionTestHelper.h +++ b/Modules/Core/TestingHelper/include/mitkInteractionTestHelper.h @@ -1,143 +1,142 @@ /*============================================================================ 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 mitkInteractionTestHelper_h #define mitkInteractionTestHelper_h #include #include #include #include #include class vtkRenderWindow; class vtkRenderer; namespace mitk { /** @brief Creates everything needed to load and playback interaction events. * * The interaction is loaded from an xml file and the event are created. This file is * usually a recorded user interaction with the GUI. This can be done with InteractionEventRecorder * plugin. Also all necessary objects to handle interaction events are generated. * The user of this class is responsible to add the data object to interact with to the data storage * of InteractionTestHelper. And must also make sure that a proper data interactor is associated with the data * object. * * To test a PointSet interaction for instance make sure you have a PointSet node and a PointSetDataInteractor. * Then just add the node to the storage of the your InteractionTestHelper by calling * InteractionTestHelper::AddNodeToStorage. * Use InteractionTestHelper::PlaybackInteraction to execute. The result can afterwards be compared to a reference * object. * * Make sure to destroy the test helper instance after each test, since all render windows and its renderers have to * be * unregistered. * * \sa XML2EventParser * \sa EventFactory * \sa EventRecorder */ class MITKTESTINGHELPER_EXPORT InteractionTestHelper { public: /** * @brief InteractionTestHelper set up all neseccary objects by calling Initialize. * @param interactionXmlFilePath path to xml file containing events and configuration information for the render * windows. */ InteractionTestHelper(const std::string &interactionXmlFilePath); // unregisters all render windows and its renderers. virtual ~InteractionTestHelper(); /** @brief Returns the datastorage, in order to modify the data inside a rendering test. **/ mitk::DataStorage::Pointer GetDataStorage(); /** * @brief AddNodeToStorage Add a node to the datastorage and perform a reinit which is necessary for rendering. * @param node The data you want to add. */ void AddNodeToStorage(mitk::DataNode::Pointer node); /** * @brief PlaybackInteraction playback loaded interaction by passing events to the dispatcher. */ void PlaybackInteraction(); /** * @brief SetTimeStep Sets timesteps of all SliceNavigationControllers to given timestep. * @param newTimeStep new timestep * * Does the same as using ImageNavigators Time slider. Use this if your data was modified in a timestep other than * 0. */ void SetTimeStep(int newTimeStep); typedef std::vector RenderWindowListType; const RenderWindowListType &GetRenderWindowList() { return m_RenderWindowList; } /** * @brief GetRenderWindowByName Get renderWindow by the name of its renderer. * @param name The name of the renderer of the desired renderWindow. * @return nullptr if not found. */ RenderWindow *GetRenderWindowByName(const std::string &name); /** * @brief GetRenderWindowByDefaultViewDirection Get a renderWindow by its default viewdirection. * @param viewDirection * @return nullptr if not found. */ RenderWindow *GetRenderWindowByDefaultViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection); /** * @brief GetRenderWindow Get renderWindow at position 'index'. * @param index Position within the renderWindow list. * @return nullptr if index is out of bounds. */ RenderWindow *GetRenderWindow(unsigned int index); /** * @brief AddDisplayPlaneSubTree * * Creates DisplayPlanes that are shown in a 3D RenderWindow. */ void AddDisplayPlaneSubTree(); void Set3dCameraSettings(); protected: /** * @brief Initialize Internal method to initialize the renderwindow and set the datastorage. * @throws mitk::Exception if interaction xml file can not be loaded. */ void Initialize(const std::string &interactionXmlFilePath); /** * @brief LoadInteraction loads events from xml file. - * @param interactionXmlPath path to xml file with interaction events. */ void LoadInteraction(); mitk::XML2EventParser::EventContainerType m_Events; // List with loaded interaction events std::string m_InteractionFilePath; RenderWindowListType m_RenderWindowList; mitk::DataStorage::Pointer m_DataStorage; mitk::MouseModeSwitcher::Pointer m_MouseModeSwitcher; }; } // namespace mitk #endif diff --git a/Modules/Core/include/mitkPixelType.h b/Modules/Core/include/mitkPixelType.h index 8717986986..3464c89f37 100644 --- a/Modules/Core/include/mitkPixelType.h +++ b/Modules/Core/include/mitkPixelType.h @@ -1,299 +1,299 @@ /*============================================================================ 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 mitkPixelType_h #define mitkPixelType_h #include "mitkCommon.h" #include "mitkPixelTypeTraits.h" #include #include #include #include #include #include namespace mitk { template std::string PixelComponentTypeToString() { return itk::ImageIOBase::GetComponentTypeAsString(itk::ImageIOBase::MapPixelType::CType); } template std::string PixelTypeToString() { return std::string(); } /** * @brief Class for defining the data type of pixels * * To obtain additional type information not provided by this class * itk::ImageIOBase can be used by passing the return value of * PixelType::GetItkTypeId() to itk::ImageIOBase::SetPixelTypeInfo * and using the itk::ImageIOBase methods GetComponentType, * GetComponentTypeAsString, GetPixelType, GetPixelTypeAsString. * @ingroup Data */ class MITKCORE_EXPORT PixelType { public: typedef itk::ImageIOBase::IOPixelType ItkIOPixelType; typedef itk::ImageIOBase::IOComponentType ItkIOComponentType; PixelType(const mitk::PixelType &aPixelType); PixelType &operator=(const PixelType &other); itk::ImageIOBase::IOPixelType GetPixelType() const; /** * \brief Get the \a component type (the scalar (!) type). Each element * may contain m_NumberOfComponents (more than one) of these scalars. * */ int GetComponentType() const; /** * \brief Returns a string containing the ITK pixel type name. */ std::string GetPixelTypeAsString() const; /** * \brief Returns a string containing the name of the component. */ std::string GetComponentTypeAsString() const; /** * \brief Returns a string representing the pixel type and pixel components. */ std::string GetTypeAsString() const; /** * \brief Get size of the PixelType in bytes * * A RGBA PixelType of floats will return 4 * sizeof(float) */ size_t GetSize() const; /** * \brief Get the number of bits per element (of an * element) * * A vector of double with three components will return * 8*sizeof(double)*3. * \sa GetBitsPerComponent * \sa GetItkTypeId * \sa GetTypeId */ size_t GetBpe() const; /** * \brief Get the number of components of which each element consists * * Each pixel can consist of multiple components, e.g. RGB. */ size_t GetNumberOfComponents() const; /** * \brief Get the number of bits per components * \sa GetBitsPerComponent */ size_t GetBitsPerComponent() const; bool operator==(const PixelType &rhs) const; bool operator!=(const PixelType &rhs) const; ~PixelType(); private: friend PixelType MakePixelType(const itk::ImageIOBase *imageIO); template - friend PixelType MakePixelType(std::size_t numberOfComponents); + friend PixelType MakePixelType(std::size_t numOfComponents); template friend PixelType MakePixelType(); template friend PixelType MakePixelType(size_t); PixelType(const int componentType, const ItkIOPixelType pixelType, std::size_t bytesPerComponent, - std::size_t numberOfComponents, + std::size_t numOfComponents, const std::string &componentTypeName, const std::string &pixelTypeName); // default constructor is disabled on purpose PixelType(void); /** \brief the \a type_info of the scalar (!) component type. Each element may contain m_NumberOfComponents (more than one) of these scalars. */ int m_ComponentType; ItkIOPixelType m_PixelType; std::string m_ComponentTypeName; std::string m_PixelTypeName; std::size_t m_NumberOfComponents; std::size_t m_BytesPerComponent; }; /** * @brief deduct the PixelType for a given vtk image * * @param vtkimagedata the image the PixelType shall be deducted from * @return the mitk::PixelType */ MITKCORE_EXPORT mitk::PixelType MakePixelType(vtkImageData *vtkimagedata); /** * \brief A template method for creating a pixel type. */ template PixelType MakePixelType(std::size_t numOfComponents) { return PixelType(MapPixelType::value>::IOComponentType, MapPixelType::value>::IOPixelType, sizeof(ComponentT), numOfComponents, PixelComponentTypeToString(), PixelTypeToString()); } /** * \brief A template method for creating a pixel type. * * @deprecated, use version with one numOfComponents as function argument instead. */ template PixelType MakePixelType() { return MakePixelType(numOfComponents); } /** * \brief A helper template for compile-time checking of supported ITK image types. * * Unsupported image types will be marked by template specializations with * missing definitions; */ template struct AssertImageTypeIsValid { }; // The itk::VariableLengthVector pixel type is not supported in MITK if it is // used with an itk::Image (it cannot be represented as a mitk::Image object). // Use a itk::VectorImage instead. template struct AssertImageTypeIsValid, VImageDimension>>; /** \brief A template method for creating a MITK pixel type na ITK image type * * \param numOfComponents The number of components for the pixel type of the ITK image */ template PixelType MakePixelType(std::size_t numOfComponents) { AssertImageTypeIsValid(); // define new type, since the ::PixelType is used to distinguish between simple and compound types typedef typename ItkImageType::PixelType ImportPixelType; // get the component type ( is either directly ImportPixelType or ImportPixelType::ValueType for compound types ) typedef typename GetComponentType::ComponentType ComponentT; // The PixelType is the same as the ComponentT for simple types typedef typename ItkImageType::PixelType PixelT; // call the constructor return PixelType(MapPixelType::value>::IOComponentType, MapPixelType::value>::IOPixelType, sizeof(ComponentT), numOfComponents, PixelComponentTypeToString(), PixelTypeToString()); } /** \brief A template method for creating a MITK pixel type from an ITK image * pixel type and dimension * * \param numOfComponents The number of components for the pixel type \c TPixelType */ template PixelType MakePixelType(std::size_t numOfComponents) { typedef typename ImageTypeTrait::ImageType ItkImageType; return MakePixelType(numOfComponents); } /** \brief A template method for creating a MITK pixel type from an ITK image * pixel type and dimension * * For images where the number of components of the pixel type is determined at * runtime (e.g. pixel types like itk::VariableLengthVector) the * MakePixelType(std::size_t) function must be used. */ template PixelType MakePixelType() { if (ImageTypeTrait::IsVectorImage) { mitkThrow() << " Variable pixel type given but the length is not specified. Use the parametric MakePixelType( " "size_t ) method instead."; } // Use the InternalPixelType to get "1" for the number of components in case of // a itk::VectorImage typedef typename ItkImageType::InternalPixelType PixelT; const std::size_t numComp = ComponentsTrait::value, ItkImageType>::Size; // call the constructor return MakePixelType(numComp); } /** * \brief Create a MITK pixel type based on a itk::ImageIOBase object */ inline PixelType MakePixelType(const itk::ImageIOBase *imageIO) { return mitk::PixelType(imageIO->GetComponentType(), imageIO->GetPixelType(), imageIO->GetComponentSize(), imageIO->GetNumberOfComponents(), imageIO->GetComponentTypeAsString(imageIO->GetComponentType()), imageIO->GetPixelTypeAsString(imageIO->GetPixelType())); } /** \brief An interface to the MakePixelType method for creating scalar pixel types. * * Usage: for example MakeScalarPixelType() for a scalar short image */ template PixelType MakeScalarPixelType() { return MakePixelType(); } } // namespace mitk #endif /* mitkPixelType_h */ diff --git a/Modules/CppMicroServices/core/doc/doxygen/MicroServices_Resources.md b/Modules/CppMicroServices/core/doc/doxygen/MicroServices_Resources.md index c18d3bb0c9..9cb2102f78 100644 --- a/Modules/CppMicroServices/core/doc/doxygen/MicroServices_Resources.md +++ b/Modules/CppMicroServices/core/doc/doxygen/MicroServices_Resources.md @@ -1,75 +1,75 @@ The Resources System {#MicroServices_Resources} ==================== The C++ Micro Services library provides a generic resources system to embed arbitrary files into a module's shared library (the size limitation per resource is 2GB, due to the used ZIP format). The following features are supported: * Embed arbitrary data into shared or static modules or executables. * Data is embedded in a compressed format (zip) with a configurable compression level. * Resources are accessed via a Module instance, providing individual resource lookup and access for each module. * Resources are managed in a tree hierarchy, modeling the original child - parent relationship on the file-system. * The ModuleResource class provides a high-level API for accessing resource information and traversing the resource tree. * The ModuleResourceStream class provides an STL input stream derived class for the seamless usage of embedded resource data in third-party libraries. The following conventions and limitations apply: * Resource entries are stored with case-insensitive names. On case-sensitive file systemes, adding resources with the same name but different capitalization will lead to an error. * Looking up resources by name at runtime *is* case sensitive. * The CppMicroServices library will search for a valid zip file inside a shared library, starting from the end of the file. If other zip files are embedded in the module as well (e.g. as an additional resource embedded via the Windows RC compiler or using other techniques), it will stop at the first valid zip file and use it a the resource container. Embedding Resources in a %Module -------------------------------- Resources are embedded into a module's shared or static library (or into an executable) by using the `usResourceCompiler` executable. It will create a ZIP archive of all input files and can append it to the module file. -If you are using CMake, consider using the provided `#usFunctionEmbedResources` CMake macro which +If you are using CMake, consider using the provided `usFunctionEmbedResources` CMake macro which handles the invocation of the `usResourceCompiler` executable and sets up the correct file dependencies. Otherwise, you also need to make sure that the set of static modules linked into a shared module or executable is also in the input file list of your `usResourceCompiler` call for that shared module or executable. Here is a full example creating a module and embedding resource data: \include uServices-resources-cmake/CMakeLists_example.txt Accessing Resources at Runtime ------------------------------ Each module provides access to its embedded resources via the Module class which provides methods returning ModuleResource objects. The ModuleResourceStream class provides a std::istream compatible object to access the resource contents. The following example shows how to retrieve a resource from each currently loaded module whose path is specified by a module property: \snippet uServices-resources/main.cpp 2 This example could be enhanced to dynamically react to modules being loaded and unloaded, making use of the popular "extender pattern" from OSGi. Runtime overhead ---------------- The resources system has the following runtime characteristics: * During static initialization of a module, it's ZIP archive header data (if available) is parsed and stored in memory. * Querying `Module` or `ModuleResource` objects for resource information will not extract the embedded resource data and hence only has minimal runtime and memory overhead. * Creating a `ModuleResourceStream` object will allocate memory for the uncompressed resource data and inflate it. The memory will be free'ed after the `ModuleResourceStream` object is destroyed. diff --git a/Modules/CppMicroServices/core/doc/doxygen/MicroServices_TheModuleContext.md b/Modules/CppMicroServices/core/doc/doxygen/MicroServices_TheModuleContext.md index d3dd740cc0..15df41382c 100644 --- a/Modules/CppMicroServices/core/doc/doxygen/MicroServices_TheModuleContext.md +++ b/Modules/CppMicroServices/core/doc/doxygen/MicroServices_TheModuleContext.md @@ -1,38 +1,38 @@ The Module Context {#MicroServices_TheModuleContext} =================== In the context of the C++ Micro Services library, we will call all supported "shared library" types (DLL, DSO, DyLib, etc.) uniformly a *module*. A module accesses the C++ Micro Services API via a ModuleContext object, which is specific to each module. ### Creating a ModuleContext To create a ModuleContext object for a specific library, you have two options. If your project uses -CMake as the build system, use the supplied `#usFunctionGenerateModuleInit` CMake function to automatically +CMake as the build system, use the supplied `usFunctionGenerateModuleInit` CMake function to automatically create a source file and add it to your module's sources: ~~~{.cpp} set(module_srcs ) usFunctionGenerateModuleInit(module_srcs) add_library(mylib ${module_srcs}) set_property(TARGET ${mylib} APPEND PROPERTY COMPILE_DEFINITIONS US_MODULE_NAME=mylib) ~~~ You also need to specify a unique module name by using the `US_MODULE_NAME` compile definition as shown in the last line. The module name must be a valid C identifier and in the case of executables is required to be defined to `main`. If you do not use CMake, you have to add a call to the macro `#US_INITIALIZE_MODULE` in one of the source files of your module: \snippet uServices-modulecontext/main.cpp InitializeModule ### Getting a ModuleContext To retrieve the module specific ModuleContext object from anywhere in your module, use the -`#GetModuleContext` function: +`GetModuleContext` function: \snippet uServices-modulecontext/main.cpp GetModuleContext -Please note that trying to use `#GetModuleContext` without proper initialization code +Please note that trying to use `GetModuleContext` without proper initialization code in the using shared library while either lead to compile or rumtime errors. diff --git a/Modules/CppMicroServices/core/doc/doxygen/examples/MicroServices_Example1.md b/Modules/CppMicroServices/core/doc/doxygen/examples/MicroServices_Example1.md index 8b684bd413..afc7f9c11a 100644 --- a/Modules/CppMicroServices/core/doc/doxygen/examples/MicroServices_Example1.md +++ b/Modules/CppMicroServices/core/doc/doxygen/examples/MicroServices_Example1.md @@ -1,97 +1,97 @@ Example 1 - Service Event Listener {#MicroServices_Example1} ================================== This example creates a simple module that listens for service events. This example does not do much at first, because it only prints out the details of registering and unregistering services. In the next example we will create a module that implements a service, which will cause this module to actually do something. For now, we will just use this example to help us understand the basics of creating a module and its activator. A module gains access to the C++ Micro Services API using a unique instance of ModuleContext. This unique module context can be used during static initialization of the module or at any later point during the life-time of the module. To execute code during static initialization (and de-initialization) time, the module must provide an implementation of the ModuleActivator interface; this interface has two methods, Load() and Unload(), that both receive the module's context and are called when the module is loaded (statically initialized) and unloaded, respectively. \note You do not need to remember the ModuleContext instance within the ModuleActivator::Load() method and provide custom access methods for later retrieval. Use the GetModuleContext() function to easily retrieve the current module's context. In the following source code, our module implements the ModuleActivator interface and uses the context to add itself as a listener for service events (in the `eventlistener/Activator.cpp` file): \snippet eventlistener/Activator.cpp Activator After implementing the C++ source code for the module activator, we must *export* the activator such that the C++ Micro Services library can create an instance of it and call the `Load()` and `Unload()` methods: \dontinclude eventlistener/Activator.cpp \skipline US_EXPORT Now we need to compile the source code. This example uses CMake as the build system and the top-level CMakeLists.txt file could look like this: \dontinclude core/examples/CMakeLists.txt \skip project \until eventlistener and the CMakeLists.txt file in the eventlistener subdirectory is: \include eventlistener/CMakeLists.txt -The call to `#usFunctionGenerateModuleInit` is necessary to integrate the shared +The call to `usFunctionGenerateModuleInit` is necessary to integrate the shared library as a module within the C++ Micro Service library. If you are not using CMake, you have to place a macro call to `#US_INITIALIZE_MODULE` yourself into the module's source code, e.g. in `Activator.cpp`. Have a look at the Getting Started documentation for more details about using CMake or other build systems (e.g. Makefiles) when writing modules. To run the examples contained in the C++ Micro Services library, we use a small driver program called `usCoreExamplesDriver`: \verbatim CppMicroServices-build> bin/usCoreExamplesDriver > h h This help text l Load the module with id or name u Unload the module with id s Print status information q Quit > \endverbatim Typing `s` at the command prompt lists the available, loaded, and unloaded modules. To load the eventlistener module, type `l eventlistener` at the command prompt: \verbatim > s Id | Name | Status ----------------------------------- - | dictionaryclient | - - | dictionaryclient2 | - - | dictionaryclient3 | - - | dictionaryservice | - - | eventlistener | - - | frenchdictionary | - - | spellcheckclient | - - | spellcheckservice | - 1 | CppMicroServices | LOADED > l eventlistener Starting to listen for service events. > \endverbatim The above command loaded the eventlistener module (by loading its shared library). Keep in mind, that this module will not do much at this point since it only listens for service events and we are not registering any services. In the next example we will register a service that will generate an event for this module to receive. To exit the `usCoreExamplesDriver`, use the `q` command. Next: \ref MicroServices_Example2 diff --git a/Modules/IGTBase/include/mitkNavigationDataSet.h b/Modules/IGTBase/include/mitkNavigationDataSet.h index c7475addf8..e69b031e5a 100644 --- a/Modules/IGTBase/include/mitkNavigationDataSet.h +++ b/Modules/IGTBase/include/mitkNavigationDataSet.h @@ -1,170 +1,161 @@ /*============================================================================ 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 MITKNAVIGATIONDATASET_H_HEADER_INCLUDED_ #define MITKNAVIGATIONDATASET_H_HEADER_INCLUDED_ #include #include "mitkBaseData.h" #include "mitkNavigationData.h" namespace mitk { /** * \brief Data structure which stores streams of mitk::NavigationData for * multiple tools. * * Use mitk::NavigationDataRecorder to create these sets easily from pipelines. * Use mitk::NavigationDataPlayer to stream from these sets easily. * */ class MITKIGTBASE_EXPORT NavigationDataSet : public BaseData { public: /** * \brief This iterator iterates over the distinct time steps in this set. * * It returns an array of the length equal to GetNumberOfTools(), containing a * mitk::NavigationData for each tool.. */ typedef std::vector< std::vector >::iterator NavigationDataSetIterator; /** * \brief This iterator iterates over the distinct time steps in this set. And is const. * * It returns an array of the length equal to GetNumberOfTools(), containing a * mitk::NavigationData for each tool.. */ typedef std::vector< std::vector >::const_iterator NavigationDataSetConstIterator; mitkClassMacro(NavigationDataSet, BaseData); mitkNewMacro1Param(Self, unsigned int); /** * \brief Add mitk::NavigationData of the given tool to the Set. * * @param navigationDatas vector of mitk::NavigationData objects to be added. Make sure that the size of the * vector equals the number of tools given in the constructor * @return true if object was be added to the set successfully, false otherwise */ bool AddNavigationDatas( std::vector navigationDatas ); /** * \brief Get mitk::NavigationData from the given tool at given index. * * @param toolIndex Index of the tool from which mitk::NavigationData should be returned. * @param index Index of the mitk::NavigationData object that should be returned. * @return mitk::NavigationData at the specified indices, 0 if there is no object at the indices. */ NavigationData::Pointer GetNavigationDataForIndex( unsigned int index, unsigned int toolIndex ) const; - ///** - //* \brief Get last mitk::Navigation object for given tool whose timestamp is less than the given timestamp. - //* @param toolIndex Index of the tool from which mitk::NavigationData should be returned. - //* @param timestamp Timestamp for selecting last object before. - //* @return Last mitk::NavigationData with timestamp less than given timestamp, 0 if there is no adequate object. - //*/ - // Method not yet supported! - //NavigationData::Pointer GetNavigationDataBeforeTimestamp( mitk::NavigationData::TimeStampType timestamp , unsigned int toolIndex ) const; - /** * \brief Returns a vector that contains all tracking data for a given tool. * * This is a relatively expensive operation, as it requires the construction of a new vector. * * @param toolIndex Index of the tool for which the stream should be returned. * @return Returns a vector that contains all tracking data for a given tool. */ virtual std::vector< mitk::NavigationData::Pointer > GetDataStreamForTool(unsigned int toolIndex); /** * \brief Returns a vector that contains NavigationDatas for each tool for a given timestep. * * If GetNumberOFTools() equals four, then 4 NavigationDatas will be returned. * * @param index Index of the timeStep for which the datas should be returned. cannot be larger than mitk::NavigationDataSet::Size() * @return Returns a vector that contains all tracking data for a given tool. */ virtual std::vector< mitk::NavigationData::Pointer > GetTimeStep(unsigned int index) const; /** * \brief Returns the number of tools for which NavigationDatas are stored in this set. * * This is always equal to the number given in the constructor of this class. * * @return the number of tools for which NavigationDatas are stored in this set. */ unsigned int GetNumberOfTools() const; /** * \brief Returns the number of time steps stored in this NavigationDataSet. * * This is not the total number of Navigation Datas stored in this set, but the number stored for each tool. * i.e. the total number of NavigationDatas equals Size() * GetNumberOfTools(); * * @return Returns the number of time steps stored in this NavigationDataSet. */ unsigned int Size() const; /** * \brief Returns an iterator pointing to the first TimeStep. * * @return Returns an iterator pointing to the first TimeStep. */ virtual NavigationDataSetConstIterator Begin() const; /** * \brief Returns an iterator pointing behind to the last TimeStep. * * @return Returns an iterator pointing behind to the last TimeStep. */ virtual NavigationDataSetConstIterator End() const; // virtual methods, that need to be implemented, but aren't reasonable for NavigationData void SetRequestedRegionToLargestPossibleRegion( ) override; bool RequestedRegionIsOutsideOfTheBufferedRegion( ) override; bool VerifyRequestedRegion( ) override; void SetRequestedRegion( const itk::DataObject *data ) override; /** * \brief This overrid is probably a little hacky. See Bug 19086. */ bool IsEmpty() const override; //Converts Navigation Data for each tool to a Point Set and adds it to the data storage void ConvertNavigationDataToPointSet() const; protected: /** * \brief Constructs set with fixed number of tools. * @param numTools How many tools are used with this mitk::NavigationDataSet. */ NavigationDataSet( unsigned int numTools ); ~NavigationDataSet( ) override; /** * \brief Holds all the mitk::NavigationData objects managed by this class. * * The first dimension is the index of the navigation data, the second is the * tool to which this data belongs. i.e. the first dimension is usually the longer one. */ std::vector > m_NavigationDataVectors; /** * \brief The Number of Tools that this class is going to support. */ unsigned int m_NumberOfTools; }; } #endif // MITKNAVIGATIONDATASET_H_HEADER_INCLUDED_ diff --git a/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegEvalSettingsWidget.h b/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegEvalSettingsWidget.h index abbb5628ee..293db09e8c 100644 --- a/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegEvalSettingsWidget.h +++ b/Modules/MatchPointRegistrationUI/Qmitk/QmitkRegEvalSettingsWidget.h @@ -1,70 +1,69 @@ /*============================================================================ 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_REG_EVAL_SETTINGS_WIDGET_H #define QMITK_REG_EVAL_SETTINGS_WIDGET_H #include #include "ui_QmitkRegEvalSettingsWidget.h" #include #include /** * \class QmitkRegEvalSettingsWidget * \brief Widget that views the information and profile of an algorithm stored in an DLLInfo object. */ class MITKMATCHPOINTREGISTRATIONUI_EXPORT QmitkRegEvalSettingsWidget : public QWidget, private Ui::QmitkRegEvalSettingsWidget { Q_OBJECT public: QmitkRegEvalSettingsWidget(QWidget *parent = nullptr); /** * Configures the passed settings according to the current state of the * widget. - * \param pointer to a instance based on QmitkMappingJobSettings. * \pre settings must point to a valid instance.. */ void ConfigureControls(); public Q_SLOTS: /** * \brief Slot that can be used to set the node that should be configured by the widget.*/ void SetNode(mitk::DataNode *node); signals: void SettingsChanged(mitk::DataNode *node); protected Q_SLOTS: void OnComboStyleChanged(int); void OnBlend50Pushed(); void OnBlendTargetPushed(); void OnBlendMovingPushed(); void OnBlendTogglePushed(); void OnSlideBlendChanged(int); void OnSpinBlendChanged(int); void OnSpinCheckerChanged(int); void OnWipeStyleChanged(); void OnContourStyleChanged(); private: mitk::DataNode::Pointer m_selectedEvalNode; bool m_internalBlendUpdate; bool m_internalUpdate; }; #endif // QmitkRegEvalSettingsWidget_H diff --git a/Modules/Multilabel/mitkLabelSetImageToSurfaceFilter.h b/Modules/Multilabel/mitkLabelSetImageToSurfaceFilter.h index 034a04bcf1..c30ca766b1 100644 --- a/Modules/Multilabel/mitkLabelSetImageToSurfaceFilter.h +++ b/Modules/Multilabel/mitkLabelSetImageToSurfaceFilter.h @@ -1,157 +1,157 @@ /*============================================================================ 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 _mitkLabelSetImageToSurfaceFilter_H_ #define _mitkLabelSetImageToSurfaceFilter_H_ #include "MitkMultilabelExports.h" #include "mitkLabelSetImage.h" #include "mitkSurface.h" #include #include #include #include namespace mitk { /** * Generates surface meshes from a labelset image. * If you want to calculate a surface representation for all available labels, * you may call GenerateAllLabelsOn(). */ class MITKMULTILABEL_EXPORT LabelSetImageToSurfaceFilter : public SurfaceSource { public: mitkClassMacro(LabelSetImageToSurfaceFilter, SurfaceSource); itkNewMacro(Self); typedef LabelSetImage::PixelType LabelType; typedef std::map LabelMapType; typedef std::map IndexToLabelMapType; /** * Returns a const pointer to the labelset image set as input */ const mitk::Image *GetInput(void); /** * Set the labelset image to create a surface from. */ using ProcessObject::SetInput; virtual void SetInput(const mitk::Image *image); // virtual void SetObserver(mitk::ProcessObserver::Pointer observer); /** * Set whether you want to extract all labesl (true) or a single one. */ itkSetMacro(GenerateAllLabels, bool); /** * @returns if all labels or only a specific label should be * extracted. */ itkGetMacro(GenerateAllLabels, bool); itkBooleanMacro(GenerateAllLabels); /** * Set the label you want to extract. This method only has an effect, * if GenerateAllLabels() is set to false * @param _arg the label to extract, by default 1 */ itkSetMacro(RequestedLabel, int); /** * Returns the label you want to extract. This method only has an effect, * if GenerateAllLabels() is set to false - * @returns _arg the label to extract, by default 1 + * @return the label to extract, by default 1 */ itkGetMacro(RequestedLabel, int); /** * Sets the label value of the background. No surface will be generated for this label. * @param _arg the label of the background, by default 0 */ itkSetMacro(BackgroundLabel, int); /** * Gets the label value of the background. No surface will be generated for this label. - * @param _arg the label of the background, by default 0 + * @return the label of the background, by default 0 */ itkGetMacro(BackgroundLabel, int); /** * Sets whether to provide a smoothed surface */ itkSetMacro(UseSmoothing, int); /** * Sets the Sigma used in the gaussian smoothing */ itkSetMacro(Sigma, float); protected: LabelSetImageToSurfaceFilter(); ~LabelSetImageToSurfaceFilter() override; /** * Transforms a point by a 4x4 matrix */ template inline void mitkVtkLinearTransformPoint(T1 matrix[4][4], T2 in[3], T3 out[3]) { T3 x = matrix[0][0] * in[0] + matrix[0][1] * in[1] + matrix[0][2] * in[2] + matrix[0][3]; T3 y = matrix[1][0] * in[0] + matrix[1][1] * in[1] + matrix[1][2] * in[2] + matrix[1][3]; T3 z = matrix[2][0] * in[0] + matrix[2][1] * in[1] + matrix[2][2] * in[2] + matrix[2][3]; out[0] = x; out[1] = y; out[2] = z; } mitk::Image::Pointer m_ResultImage; template void InternalProcessing(const itk::Image *input, mitk::Surface *surface); bool m_GenerateAllLabels; int m_RequestedLabel; int m_BackgroundLabel; int m_UseSmoothing; float m_Sigma; LabelMapType m_AvailableLabels; IndexToLabelMapType m_IndexToLabels; mitk::Vector3D m_InputImageSpacing; void GenerateData() override; void GenerateOutputInformation() override; // mitk::ProcessObserver::Pointer m_Observer; }; } // end of namespace mitk #endif //_mitkLabelSetImageToSurfaceFilter_H_ diff --git a/Modules/OpenCL/mitkOclFilter.h b/Modules/OpenCL/mitkOclFilter.h index 4de5217d7a..b958ffaf56 100644 --- a/Modules/OpenCL/mitkOclFilter.h +++ b/Modules/OpenCL/mitkOclFilter.h @@ -1,159 +1,157 @@ /*============================================================================ 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 __mitkOclFilter_h #define __mitkOclFilter_h #include "mitkOclUtils.h" #include "mitkCommon.h" #include #include #include namespace mitk { /** @class OclFilter @brief Superclass for all OpenCL based filter. This class takes care of loading and compiling the external GPU program code. */ class MITKOPENCL_EXPORT OclFilter { public: /** * @brief Add a source file from the resource files to the * OpenCL shader file list. Multiple files can be added to the list. * * @param filename of the file in the resource system */ void AddSourceFile(const char* filename); /** * @brief Set specific compilerflags to compile the CL source. Default is set to nullptr; * example: "-cl-fast-relaxed-math -cl-mad-enable -cl-strict-aliasing" * * @param flags to the modulefolder that contains the gpuSource */ void SetCompilerFlags(const char* flags); /** * @brief Returns true if the initialization was successfull */ virtual bool IsInitialized(); /** * @brief Returns the amount of global memory of the used device in bytes */ virtual unsigned long GetDeviceMemory(); /** @brief Destructor */ virtual ~OclFilter(); protected: typedef std::vector CStringList; typedef std::vector ClSizeList; /** @brief Constructor */ OclFilter(); /** @brief Constructor ( overloaded ) */ OclFilter(const char* filename); /** @brief String that contains the compiler flags */ const char* m_ClCompilerFlags; /** @brief The compiled OpenCL program */ cl_program m_ClProgram; /** @brief Command queue for the filter */ cl_command_queue m_CommandQue; /** @brief Unique ID of the filter, needs to be specified in the constructor of the derived class */ std::string m_FilterID; /*! @brief source preambel for e.g. \c \#define commands to be inserted into the OpenCL source */ const char* m_Preambel; /** @brief List of sourcefiles that will be compiled for this filter.*/ CStringList m_ClFiles; /** @brief status of the filter */ bool m_Initialized; /** @brief The local work size fo the filter */ size_t m_LocalWorkSize[3]; /** @brief The global work size of the filter */ size_t m_GlobalWorkSize[3]; /** @brief Set the working size for the following OpenCL kernel call */ void SetWorkingSize(unsigned int locx, unsigned int dimx, unsigned int locy = 1, unsigned int dimy = 1, unsigned int locz = 1, unsigned int dimz = 1); /** @brief Execute the given kernel on the OpenCL Index-Space defined by the local and global work sizes */ bool ExecuteKernel( cl_kernel kernel, unsigned int workSizeDim ); /** @brief Execute the given kernel on the OpenCL Index-Space defined by the local and global work sizes, but divide it into chunks of dimension chunksDim */ bool ExecuteKernelChunks( cl_kernel kernel, unsigned int workSizeDim, size_t* chunksDim ); /** @brief Execute the given kernel on the OpenCL Index-Space defined by the local and global work sizes, but divide it into chunks of dimension chunksDim and wait between * batches of batchSize chunks a time of waitTimems milliseconds */ bool ExecuteKernelChunksInBatches(cl_kernel kernel, unsigned int workSizeDim, size_t* chunksDim, size_t batchSize, int waitTimems); /** * \brief Initialize all necessary parts of the filter * * The Initialize() method creates the command queue and the m_clProgram. * The program is either compiled from the given source or taken from the * OclResourceManager if the program was compiled already. */ bool Initialize(); /** * @brief Compile the program source - * - * @param preambel e.g. defines for the shader code */ void CompileSource(); /** * @brief Add some source code on the beginning of the loaded source * * In this way, some preprocessor flags for the CL compiler can at the beginning of the filter * @param preambel Source preambel for e.g. \c \#define commands to be inserted into the OpenCL source */ void SetSourcePreambel(const char* preambel); /** * @brief Get the Module of the filter. Needs to be implemented by every subclass. * The filter will load the OpenCL sourcefiles from this module context. */ virtual us::Module* GetModule() = 0; /** * @brief Helper functions that load sourcefiles from the module context in the Initialize function. * @param SourceCodeList holds the sourcecode for every file as string, the SourceCodeSizeList holst the * size of every file in bytes. * @param SourceCodeSizeList */ void LoadSourceFiles(CStringList &SourceCodeList, ClSizeList &SourceCodeSizeList); }; } #endif // __mitkOclFilter_h diff --git a/Modules/Segmentation/Algorithms/mitkContourUtils.h b/Modules/Segmentation/Algorithms/mitkContourUtils.h index 3040e042fa..66bb8b4a97 100644 --- a/Modules/Segmentation/Algorithms/mitkContourUtils.h +++ b/Modules/Segmentation/Algorithms/mitkContourUtils.h @@ -1,71 +1,73 @@ /*============================================================================ 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 mitkContourUtilshIncludett #define mitkContourUtilshIncludett #include "mitkContour.h" #include "mitkContourModel.h" #include "mitkImage.h" #include namespace mitk { /** * \brief Helpful methods for working with contours and images * * Legacy support for mitk::Contour * TODO remove this class when mitk::Contour is removed */ class MITKSEGMENTATION_EXPORT ContourUtils : public itk::Object { public: mitkClassMacroItkParent(ContourUtils, itk::Object); itkFactorylessNewMacro(Self); itkCloneMacro(Self); /** \brief Projects a contour onto an image point by point. Converts from world to index coordinates. \param slice \param contourIn3D \param correctionForIpSegmentation adds 0.5 to x and y index coordinates (difference between ipSegmentation and MITK contours) \param constrainToInside */ ContourModel::Pointer ProjectContourTo2DSlice(Image *slice, Contour *contourIn3D, bool correctionForIpSegmentation, bool constrainToInside); /** \brief Projects a slice index coordinates of a contour back into world coordinates. - \param correctionForIpSegmentation subtracts 0.5 to x and y index coordinates (difference between + \param sliceGeometry + \param contourIn2D + \param correctionForIpSegmentation subtracts 0.5 to x and y index coordinates (difference between ipSegmentation and MITK contours) */ ContourModel::Pointer BackProjectContourFrom2DSlice(const BaseGeometry *sliceGeometry, Contour *contourIn2D, bool correctionForIpSegmentation = false); /** \brief Fill a contour in a 2D slice with a specified pixel value. */ void FillContourInSlice(Contour *projectedContour, Image *sliceImage, int paintingPixelValue = 1); protected: ContourUtils(); ~ContourUtils() override; }; } #endif diff --git a/Modules/ToFHardware/PMD/mitkToFCameraPMDCamBoardController.h b/Modules/ToFHardware/PMD/mitkToFCameraPMDCamBoardController.h index 99902033e7..f8d6258c4b 100644 --- a/Modules/ToFHardware/PMD/mitkToFCameraPMDCamBoardController.h +++ b/Modules/ToFHardware/PMD/mitkToFCameraPMDCamBoardController.h @@ -1,95 +1,94 @@ /*============================================================================ 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 __mitkToFCameraPMDCamBoardController_h #define __mitkToFCameraPMDCamBoardController_h #include "MitkPMDExports.h" #include "mitkCommon.h" #include "mitkToFCameraPMDController.h" #include "itkObject.h" #include "itkObjectFactory.h" namespace mitk { /** * @brief Interface to the Time-of-Flight (ToF) camera PMD CamBoard * * * @ingroup ToFHardware */ class MITKPMD_EXPORT ToFCameraPMDCamBoardController : public ToFCameraPMDController { public: mitkClassMacro( ToFCameraPMDCamBoardController , ToFCameraPMDController ); itkFactorylessNewMacro(Self); itkCloneMacro(Self); /*! \brief opens a connection to the ToF camera and initializes the hardware specific members \return returns whether the connection was successful (true) or not (false) */ virtual bool OpenCameraConnection(); /*! \brief sets an additional distance offset which will be added to all distance values. \param offset offset in m */ bool SetDistanceOffset( float offset ); /*! \brief returns the currently applied distance offset in m - \param offset offset in m */ float GetDistanceOffset(); /*! \brief Setting the region of interest, the camera is configured to only output a certain area of the image. \param leftUpperCornerX x value of left upper corner of region \param leftUpperCornerY y value of left upper corner of region \param width width of region \param height height of region */ bool SetRegionOfInterest( unsigned int leftUpperCornerX, unsigned int leftUpperCornerY, unsigned int width, unsigned int height ); /*! \brief Setting the region of interest, the camera is configured to only output a certain area of the image. \param roi region of interest. roi[0]: x value of left upper corner, roi[1]: y value of left upper corner, roi[2]: width, roi[3]: height */ bool SetRegionOfInterest( unsigned int roi[4] ); /*! \brief returns the region of interest currently set \return currently set region of interest. */ unsigned int* GetRegionOfInterest(); /*! \brief Sets the field of view of the camera lens. \param fov field of view in degrees. The default value is 40 degrees. */ bool SetFieldOfView( float fov ); protected: ToFCameraPMDCamBoardController(); ~ToFCameraPMDCamBoardController(); /* \brief Transform the output of the camera, i.e. cut invalid pixels, and rotate 90 degrees counterclockwise \param input data array of original size (207x204) \param rotated output data array of reduced size (200x200) */ virtual void TransformCameraOutput(float* in, float* out, bool isDist); }; } //END mitk namespace #endif diff --git a/Modules/ToFHardware/PMD/mitkToFCameraPMDCamCubeController.h b/Modules/ToFHardware/PMD/mitkToFCameraPMDCamCubeController.h index b0c00d5d6a..6c83db4255 100644 --- a/Modules/ToFHardware/PMD/mitkToFCameraPMDCamCubeController.h +++ b/Modules/ToFHardware/PMD/mitkToFCameraPMDCamCubeController.h @@ -1,126 +1,125 @@ /*============================================================================ 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 __mitkToFCameraPMDCamCubeController_h #define __mitkToFCameraPMDCamCubeController_h #include #include "mitkCommon.h" #include "mitkToFCameraPMDController.h" #include "itkObject.h" #include "itkObjectFactory.h" namespace mitk { /** * @brief Interface to the Time-of-Flight (ToF) camera PMD CamCube * * * @ingroup ToFHardware */ class MITKPMD_EXPORT ToFCameraPMDCamCubeController : public ToFCameraPMDController { public: mitkClassMacro( ToFCameraPMDCamCubeController , ToFCameraPMDController ); itkFactorylessNewMacro(Self); itkCloneMacro(Self); /*! \brief opens a connection to the ToF camera and initializes the hardware specific members \return returns whether the connection was successful (true) or not (false) */ virtual bool OpenCameraConnection(); /*! \brief sets an additional distance offset which will be added to all distance values. \param offset offset in m \return returns whether set operation was successful (true) or not (false) */ bool SetDistanceOffset( float offset ); /*! \brief returns the currently applied distance offset in m - \param offset offset in m */ float GetDistanceOffset(); /*! \brief Setting the region of interest, the camera is configured to only output a certain area of the image. \param leftUpperCornerX x value of left upper corner of region \param leftUpperCornerY y value of left upper corner of region \param width width of region \param height height of region \return returns whether set operation was successful (true) or not (false) */ bool SetRegionOfInterest( unsigned int leftUpperCornerX, unsigned int leftUpperCornerY, unsigned int width, unsigned int height ); /*! \brief Setting the region of interest, the camera is configured to only output a certain area of the image. \param roi region of interest. roi[0]: x value of left upper corner, roi[1]: y value of left upper corner, roi[2]: width, roi[3]: height \return returns whether set operation was successful (true) or not (false) */ bool SetRegionOfInterest( unsigned int roi[4] ); /*! \brief returns the region of interest currently set \return currently set region of interest. */ unsigned int* GetRegionOfInterest(); /*! \brief sets the exposure mode of the CamCube \param mode exposure mode. 0: normal mode (one exposure), 1: Suppression of motion blur (SMB), minimizes the time needed to capture a distance image from the camera which results in a reduced amount of motion artifact but may lead to increased noise. \return returns whether set operation was successful (true) or not (false) */ bool SetExposureMode( int mode ); /*! \brief Sets the field of view of the camera lens. \param fov field of view in degrees. The default value is 40 degrees. \return returns whether set operation was successful (true) or not (false) */ bool SetFieldOfView( float fov ); /*! \brief Enable/Disable PMD fixed pattern noise (FPN) calibration \param on enabled (true), disabled (false) \return returns whether set operation was successful (true) or not (false) */ bool SetFPNCalibration( bool on ); /*! \brief Enable/Disable PMD fixed pattern phase noise (FPPN) calibration \param on enabled (true), disabled (false) \return returns whether set operation was successful (true) or not (false) */ bool SetFPPNCalibration( bool on ); /*! \brief Enable/Disable PMD linearity calibration \param on enabled (true), disabled (false) \return returns whether set operation was successful (true) or not (false) */ bool SetLinearityCalibration( bool on ); /*! \brief Enable/Disable PMD lens calibration \param on enabled (true), disabled (false) \return returns whether set operation was successful (true) or not (false) */ bool SetLensCalibration( bool on ); protected: virtual void TransformCameraOutput(float* in, float* out, bool isDist); ToFCameraPMDCamCubeController(); ~ToFCameraPMDCamCubeController(); private: }; } //END mitk namespace #endif diff --git a/Plugins/org.blueberry.core.commands/src/berryParameterizedCommand.h b/Plugins/org.blueberry.core.commands/src/berryParameterizedCommand.h index 1b4bc39516..acaf8bf4ff 100755 --- a/Plugins/org.blueberry.core.commands/src/berryParameterizedCommand.h +++ b/Plugins/org.blueberry.core.commands/src/berryParameterizedCommand.h @@ -1,334 +1,334 @@ /*============================================================================ 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 BERRYPARAMETERIZEDCOMMAND_H_ #define BERRYPARAMETERIZEDCOMMAND_H_ #include #include #include "common/berryCommandExceptions.h" #include #include #include namespace berry { struct IParameter; class Command; class Parameterization; /** *

* A command that has had one or more of its parameters specified. This class * serves as a utility class for developers that need to manipulate commands * with parameters. It handles the behaviour of generating a parameter map and a * human-readable name. *

*/ class BERRY_COMMANDS ParameterizedCommand: public Object { //implements Comparable { public: berryObjectMacro(ParameterizedCommand); /** * The index of the parameter id in the parameter values. * * @deprecated no longer used */ static const int INDEX_PARAMETER_ID; // = 0; /** * The index of the human-readable name of the parameter itself, in the * parameter values. * * @deprecated no longer used */ static const int INDEX_PARAMETER_NAME; // = 1; /** * The index of the human-readable name of the value of the parameter for * this command. * * @deprecated no longer used */ static const int INDEX_PARAMETER_VALUE_NAME; // = 2; /** * The index of the value of the parameter that the command can understand. * * @deprecated no longer used */ static const int INDEX_PARAMETER_VALUE_VALUE; // = 3; /** * Constructs a new instance of ParameterizedCommand with * specific values for zero or more of its parameters. * * @param command * The command that is parameterized; must not be * null. * @param parameterizations * An array of parameterizations binding parameters to values for * the command. This value may be null. */ ParameterizedCommand(const SmartPointer& command, const QList& parameterizations); bool operator<(const Object* object) const override; bool operator==(const Object* object) const override; /** * Executes this command with its parameters. This does extra checking to * see if the command is enabled and defined. If it is not both enabled and * defined, then the execution listeners will be notified and an exception * thrown. * * @param trigger * The object that triggered the execution; may be * null. * @param applicationContext * The state of the application at the time the execution was * triggered; may be null. * @return The result of the execution; may be null. * @throws ExecutionException * If the handler has problems executing this command. * @throws NotDefinedException * If the command you are trying to execute is not defined. * @throws NotEnabledException * If the command you are trying to execute is not enabled. * @throws NotHandledException * If there is no handler. */ Object::Pointer ExecuteWithChecks(const Object::ConstPointer& trigger, const Object::Pointer& applicationContext); /** * Returns the base command. It is possible for more than one parameterized * command to have the same identifier. * * @return The command; never null, but may be undefined. */ SmartPointer GetCommand() const; /** * Returns the command's base identifier. It is possible for more than one * parameterized command to have the same identifier. * * @return The command id; never null. */ QString GetId() const; /** * Returns a human-readable representation of this command with all of its * parameterizations. * * @return The human-readable representation of this parameterized command; * never null. * @throws NotDefinedException * If the underlying command is not defined. */ QString GetName() const; /** * Returns the parameter map, as can be used to construct an * ExecutionEvent. * * @return The map of parameter ids (String) to parameter * values (String). This map is never * null, but may be empty. */ QHash GetParameterMap() const; uint HashCode() const override; /** * Returns a \c String containing the command id, parameter ids and * parameter values for this \c ParameterizedCommand . The returned * \c String can be stored by a client and later used to reconstruct an * equivalent {@link ParameterizedCommand} using the * \c CommandManager.deserialize(String) method. *

* The syntax of the returned \c String is as follows: *

* *
- * serialization = commandId [ '(' parameters ')' ]
+ * serialization = commandId [ '(' parameters ')' ]
* parameters = parameter [ ',' parameters ]
- * parameter = parameterId [ '=' parameterValue ] + * parameter = parameterId [ '=' parameterValue ] *
* *

* In the syntax above, sections inside square-brackets are optional. The * characters in single quotes ((, ), * , and =) indicate literal characters. *

*

- * commandId represents the command id encoded with - * separator characters escaped. parameterId and - * parameterValue represent the parameter ids and + * commandId represents the command id encoded with + * separator characters escaped. parameterId and + * parameterValue represent the parameter ids and * values encoded with separator characters escaped. The separator * characters (, ), , and * = are escaped by prepending a %. This * requires % to be escaped, which is also done by prepending * a %. *

*

* The order of the parameters is not defined (and not important). A missing - * parameterValue indicates that the value of the + * parameterValue indicates that the value of the * parameter is null. *

*

* For example, the string shown below represents a serialized parameterized * command that can be used to show the Resource perspective: *

*

* org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.eclipse.ui.resourcePerspective) *

*

* This example shows the more general form with multiple parameters, * null value parameters, and escaped = in the * third parameter value. *

*

* command.id(param1.id=value1,param2.id,param3.id=esc%=val3) *

* * @return A string containing the escaped command id, parameter ids and * parameter values; never null. * @see CommandManager#deserialize(String) */ QString Serialize(); QString ToString() const override; /** *

* Generates all the possible combinations of command parameterizations for * the given command. If the command has no parameters, then this is simply * a parameterized version of that command. If a parameter is optional, both * the included and not included cases are considered. *

*

* If one of the parameters cannot be loaded due to a * ParameterValuesException, then it is simply ignored. *

* * @param command * The command for which the parameter combinations should be * generated; must not be null. * @return A collection of ParameterizedCommand instances * representing all of the possible combinations. This value is * never empty and it is never null. * @throws NotDefinedException * If the command is not defined. */ static QList GenerateCombinations(const SmartPointer command); /** * Take a command and a map of parameter IDs to values, and generate the * appropriate parameterized command. * * @param command * The command object. Must not be null. * @param parameters * A map of String parameter ids to objects. May be * null. * @return the parameterized command, or null if it could not * be generated */ static ParameterizedCommand::Pointer GenerateCommand(const SmartPointer command, const QHash& parameters); private: /** * The constant integer hash code value meaning the hash code has not yet * been computed. */ static const uint HASH_CODE_NOT_COMPUTED; // = 0; /** * A factor for computing the hash code for all parameterized commands. */ static const uint HASH_FACTOR; // = 89; /** * The seed for the hash code for all parameterized commands. */ static const uint HASH_INITIAL; /** * Escapes special characters in the command id, parameter ids and parameter * values for {@link #serialize()}. The special characters * {@link CommandManager#PARAMETER_START_CHAR}, * {@link CommandManager#PARAMETER_END_CHAR}, * {@link CommandManager#ID_VALUE_CHAR}, * {@link CommandManager#PARAMETER_SEPARATOR_CHAR} and * {@link CommandManager#ESCAPE_CHAR} are escaped by prepending a * {@link CommandManager#ESCAPE_CHAR} character. * * @param rawText * a String to escape special characters in for * serialization. * @return a String representing rawText with * special serialization characters escaped */ static QString Escape(const QString& rawText); /** * Generates every possible combination of parameter values for the given * parameters. Parameters values that cannot be initialized are just * ignored. Optional parameters are considered. * * @param startIndex * The index in the parameters that we should * process. This must be a valid index. * @param parameters * The parameters in to process; must not be null. * @return A collection (Collection) of combinations (List * of Parameterization). */ static QList > ExpandParameters(unsigned int startIndex, const QList >& parameters); /** * The base command which is being parameterized. This value is never * null. */ const SmartPointer command; /** * The hash code for this object. This value is computed lazily, and marked * as invalid when one of the values on which it is based changes. */ mutable uint hashCode; /** * This is an array of parameterization defined for this command. This value * may be null if the command has no parameters. */ QList parameterizations; mutable QString name; }; } #endif /* BERRYPARAMETERIZEDCOMMAND_H_ */ diff --git a/Plugins/org.blueberry.ui.qt/src/berryISaveablePart.h b/Plugins/org.blueberry.ui.qt/src/berryISaveablePart.h index 32e813c202..340b20e17a 100644 --- a/Plugins/org.blueberry.ui.qt/src/berryISaveablePart.h +++ b/Plugins/org.blueberry.ui.qt/src/berryISaveablePart.h @@ -1,117 +1,115 @@ /*============================================================================ 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 BERRYISAVEABLEPART_H_ #define BERRYISAVEABLEPART_H_ #include #include #include #include namespace berry { /** * Workbench parts implement or adapt to this interface to participate * in the enablement and execution of the Save and * Save As actions. * * @see IEditorPart */ struct BERRY_UI_QT ISaveablePart : public virtual Object { berryObjectMacro(berry::ISaveablePart); /** * The property id for isDirty. */ static const int PROP_DIRTY; // = IWorkbenchPartConstants.PROP_DIRTY; /** * Saves the contents of this part. *

* If the save is successful, the part should fire a property changed event * reflecting the new dirty state (PROP_DIRTY property). *

*

* If the save is cancelled through user action, or for any other reason, the * part should invoke setCancelled on the IProgressMonitor * to inform the caller. *

*

* This method is long-running; progress and cancellation are provided * by the given progress monitor. *

- * - * @param monitor the progress monitor */ virtual void DoSave(/*IProgressMonitor monitor*/) = 0; /** * Saves the contents of this part to another object. *

* Implementors are expected to open a "Save As" dialog where the user will * be able to select a new name for the contents. After the selection is made, * the contents should be saved to that new name. During this operation a * IProgressMonitor should be used to indicate progress. *

*

* If the save is successful, the part fires a property changed event * reflecting the new dirty state (PROP_DIRTY property). *

*/ virtual void DoSaveAs() = 0; /** * Returns whether the contents of this part have changed since the last save * operation. If this value changes the part must fire a property listener * event with PROP_DIRTY. *

* Note: this method is called often on a part open or part * activation switch, for example by actions to determine their * enabled status. *

* * @return true if the contents have been modified and need * saving, and false if they have not changed since the last * save */ virtual bool IsDirty() const = 0; /** * Returns whether the "Save As" operation is supported by this part. * * @return true if "Save As" is supported, and false * if not supported */ virtual bool IsSaveAsAllowed() const = 0; /** * Returns whether the contents of this part should be saved when the part * is closed. * * @return true if the contents of the part should be saved on * close, and false if the contents are expendable */ virtual bool IsSaveOnCloseNeeded() const = 0; }; } Q_DECLARE_INTERFACE(berry::ISaveablePart, "org.blueberry.ui.ISaveablePart") #endif /* BERRYISAVEABLEPART_H_ */ diff --git a/Plugins/org.blueberry.ui.qt/src/berrySaveable.h b/Plugins/org.blueberry.ui.qt/src/berrySaveable.h index 1657c74af5..33b3627e5a 100644 --- a/Plugins/org.blueberry.ui.qt/src/berrySaveable.h +++ b/Plugins/org.blueberry.ui.qt/src/berrySaveable.h @@ -1,225 +1,223 @@ /*============================================================================ 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 BERRYSAVEABLE_H_ #define BERRYSAVEABLE_H_ #include #include #include #include namespace berry { struct IWorkbenchPage; struct IWorkbenchPart; /** * A Saveable represents a unit of saveability, e.g. an editable * subset of the underlying domain model that may contain unsaved changes. * Different workbench parts (editors and views) may present the same saveables * in different ways. This interface allows the workbench to provide more * appropriate handling of operations such as saving and closing workbench * parts. For example, if two editors sharing the same saveable with unsaved * changes are closed simultaneously, the user is only prompted to save the * changes once for the shared saveable, rather than once for each editor. *

* Workbench parts that work in terms of saveables should implement * {@link ISaveablesSource}. *

* * @see ISaveablesSource */ class BERRY_UI_QT Saveable : /*public InternalSaveable*/ public virtual Object, public IAdaptable { public: berryObjectMacro(Saveable); typedef QSet Set; /** * Attempts to show this saveable in the given page and returns * true on success. The default implementation does nothing * and returns false. * * @param page * the workbench page in which to show this saveable * @return true if this saveable is now visible to the user * @since 3.3 */ virtual bool Show(SmartPointer page); /** * Returns the name of this saveable for display purposes. * * @return the model's name; never null. */ virtual QString GetName() const = 0; /** * Returns the tool tip text for this saveable. This text is used to * differentiate between two inputs with the same name. For instance, * MyClass.java in folder X and MyClass.java in folder Y. The format of the * text varies between input types. * * @return the tool tip text; never null */ virtual QString GetToolTipText() const = 0; /** * Returns the image descriptor for this saveable. * * @return the image descriptor for this model; may be null * if there is no image */ virtual QIcon GetImageDescriptor() const = 0; /** * Saves the contents of this saveable. *

* If the save is cancelled through user action, or for any other reason, * the part should invoke setCancelled on the * IProgressMonitor to inform the caller. *

*

* This method is long-running; progress and cancellation are provided by * the given progress monitor. *

* - * @param monitor - * the progress monitor * @throws CoreException * if the save fails; it is the caller's responsibility to * report the failure to the user */ virtual void DoSave(/*IProgressMonitor monitor*/) = 0; /** * Returns whether the contents of this saveable have changed since the last * save operation. *

* Note: this method is called frequently, for example by actions to * determine their enabled status. *

* * @return true if the contents have been modified and need * saving, and false if they have not changed since * the last save */ virtual bool IsDirty() const = 0; /** * Clients must implement equals and hashCode as defined in * \c Object.equals(Object) and \c Object.hashCode() . Two * saveables should be equal if their dirty state is shared, and saving one * will save the other. If two saveables are equal, their names, tooltips, * and images should be the same because only one of them will be shown when * prompting the user to save. * * @param object * @return true if this Saveable is equal to the given object */ bool operator<(const Object* object) const override = 0; /** * Clients must implement equals and hashCode as defined in * \c Object.equals(Object) and \c Object.hashCode() . Two * saveables should be equal if their dirty state is shared, and saving one * will save the other. If two saveables are equal, their hash codes MUST be * the same, and their names, tooltips, and images should be the same * because only one of them will be shown when prompting the user to save. *

* IMPORTANT: Implementers should ensure that the hashCode returned is * sufficiently unique so as not to collide with hashCodes returned by other * implementations. It is suggested that the defining plug-in's ID be used * as part of the returned hashCode, as in the following example: *

* *
    *     int PRIME = 31;
    *     int hash = ...; // compute the "normal" hash code, e.g. based on some identifier unique within the defining plug-in
    *     return hash * PRIME + MY_PLUGIN_ID.hashCode();
    * 
* * @return a hash code */ uint HashCode() const override = 0; /** * Disables the UI of the given parts containing this saveable if necessary. * This method is not intended to be called by clients. A corresponding call * to *

* Saveables that can be saved in the background should ensure that the user * cannot make changes to their data from the UI, for example by disabling * controls, unless they are prepared to handle this case. This method is * called on the UI thread after a job runnable has been returned from * doSave(IProgressMonitor, IShellProvider) and before * spinning the event loop. The closing flag indicates that * this saveable is currently being saved in response to closing a workbench * part, in which case further changes to this saveable through the UI must * be prevented. *

*

* The default implementation calls setEnabled(false) on the given parts' * composites. *

* * @param parts * the workbench parts containing this saveable * @param closing * a boolean flag indicating whether the save was triggered by a * request to close a workbench part, and all of the given parts * will be closed after the save operation finishes successfully. * * @since 3.3 */ virtual void DisableUI(const QList >& parts, bool closing); /** * Enables the UI of the given parts containing this saveable after a * background save operation has finished. This method is not intended to be * called by clients. *

* The default implementation calls setEnabled(true) on the given parts' * composites. *

* * @param parts * the workbench parts containing this saveable * * @since 3.3 */ virtual void EnableUI(QList >& parts); protected: /** * This implementation of IAdaptable.GetAdapterImpl(const std::type_info&) returns * null. Subclasses may override. This allows two unrelated * subclasses of Saveable to implement \c equals(Object) and * \c hashCode() based on an underlying implementation class that is * shared by both Saveable subclasses. * * @since 3.3 */ Object* GetAdapter(const QString& adapter) const override; }; } #endif /* BERRYSAVEABLE_H_ */ diff --git a/Plugins/org.blueberry.ui.qt/src/berryWorkbenchPlugin.h b/Plugins/org.blueberry.ui.qt/src/berryWorkbenchPlugin.h index 978e3ff5be..2b49a0e0f8 100644 --- a/Plugins/org.blueberry.ui.qt/src/berryWorkbenchPlugin.h +++ b/Plugins/org.blueberry.ui.qt/src/berryWorkbenchPlugin.h @@ -1,470 +1,469 @@ /*============================================================================ 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 BERRYWORKBENCHPLUGIN_H_ #define BERRYWORKBENCHPLUGIN_H_ #include #include #include #include #include #include "berryAbstractUICTKPlugin.h" #include "berryPlatformUI.h" #include "presentations/berryIPresentationFactory.h" #include "internal/berryViewRegistry.h" #include "internal/berryEditorRegistry.h" #include "internal/berryPerspectiveRegistry.h" #include "internal/intro/berryIntroRegistry.h" namespace berry { class QtStyleManager; /** * \ingroup org_blueberry_ui_internal * * This class represents the TOP of the workbench UI world * A plugin class is effectively an application wrapper * for a plugin & its classes. This class should be thought * of as the workbench UI's application class. * * This class is responsible for tracking various registries * font, preference, graphics, dialog store. * * This class is explicitly referenced by the * workbench plugin's "plugin.xml" and places it * into the UI start extension point of the main * overall application harness * * When is this class started? * When the Application * calls createExecutableExtension to create an executable * instance of our workbench class. */ class BERRY_UI_QT WorkbenchPlugin : public AbstractUICTKPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org_blueberry_ui_qt") Q_INTERFACES(ctkPluginActivator) private: //static const QString UI_BUNDLE_ACTIVATOR = "org.blueberry.ui.internal.UIPlugin"; //$NON-NLS-1$ // Default instance of the receiver static WorkbenchPlugin* inst; // The presentation factory IPresentationFactory* presentationFactory; // Manager that maps resources to descriptors of editors to use EditorRegistry* editorRegistry; // The context within which this plugin was started. ctkPluginContext* bundleContext; // Other data. //WorkbenchPreferenceManager preferenceManager; ViewRegistry* viewRegistry; PerspectiveRegistry* perspRegistry; IntroRegistry* introRegistry; //SharedImages sharedImages; QScopedPointer styleManager; public: /** * Global workbench ui plugin flag. Only workbench implementation is allowed to use this flag * All other plugins, examples, or test cases must *not* use this flag. */ static bool DEBUG; /** * The character used to separate preference page category ids */ static char PREFERENCE_PAGE_CATEGORY_SEPARATOR; /** * Create an instance of the WorkbenchPlugin. The workbench plugin is * effectively the "application" for the workbench UI. The entire UI * operates as a good plugin citizen. */ WorkbenchPlugin(); ~WorkbenchPlugin() override; /* * Creates an extension. If the extension plugin has not * been loaded a busy cursor will be activated during the duration of * the load. * * @param element the config element defining the extension * @param classAttribute the name of the attribute carrying the class * @return the extension object * @throws CoreException if the extension cannot be created */ // template // static E* CreateExtension(IConfigurationElement::ConstPointer element, // const QString& classAttribute) { // try { // // If plugin has been loaded create extension. // // Otherwise, show busy cursor then create extension. // if (BundleUtility.isActivated(element.getDeclaringExtension() // .getNamespace())) { // return element.createExecutableExtension(classAttribute); // } // final Object[] ret = new Object[1]; // final CoreException[] exc = new CoreException[1]; // BusyIndicator.showWhile(null, new Runnable() { // public void run() { // try { // ret[0] = element // .createExecutableExtension(classAttribute); // } catch (CoreException e) { // exc[0] = e; // } // } // }); // if (exc[0] != null) { // throw exc[0]; // } // return ret[0]; // // } catch (CoreException core) { // throw core; // } catch (Exception e) { // throw new CoreException(new Status(IStatus.ERR, PI_WORKBENCH, // IStatus.ERR, WorkbenchMessages.WorkbenchPlugin_extension,e)); // } // } /** * Answers whether the provided element either has an attribute with the * given name or a child element with the given name with an attribute * called class. * * @param element * the element to test * @param extensionName * the name of the extension to test for * @return whether or not the extension is declared */ static bool HasExecutableExtension(const IConfigurationElement::Pointer& element, const QString& extensionName); /** * Checks to see if the provided element has the syntax for an executable * extension with a given name that resides in a bundle that is already * active. Determining the bundle happens in one of two ways:
*
    *
  • The element has an attribute with the specified name or element text * in the form bundle.id/class.name[:optional attributes]
  • *
  • The element has a child element with the specified name that has a * plugin attribute
  • *
* * @param element * the element to test * @param extensionName * the name of the extension to test for * @return whether or not the bundle expressed by the above criteria is * active. If the bundle cannot be determined then the state of the * bundle that declared the element is returned. */ static bool IsBundleLoadedForExecutableExtension( const IConfigurationElement::Pointer& element, const QString& extensionName); /** * Returns the bundle that contains the class referenced by an executable * extension. Determining the bundle happens in one of two ways:
*
    *
  • The element has an attribute with the specified name or element text * in the form bundle.id/class.name[:optional attributes]
  • *
  • The element has a child element with the specified name that has a * plugin attribute
  • *
* * @param element * the element to test * @param extensionName * the name of the extension to test for * @return the bundle referenced by the extension. If that bundle cannot be * determined the bundle that declared the element is returned. Note * that this may be null. */ static QSharedPointer GetBundleForExecutableExtension( const IConfigurationElement::Pointer& element, const QString& extensionName); /** * Return the default instance of the receiver. This represents the runtime plugin. * @return WorkbenchPlugin * @see AbstractUICTKPlugin for the typical implementation pattern for plugin classes. */ static WorkbenchPlugin* GetDefault(); std::size_t GetBundleCount(); /** * Answer the manager that maps resource types to a the * description of the editor to use * @return IEditorRegistry the editor registry used * by this plug-in. */ IEditorRegistry* GetEditorRegistry(); /** * Answer the element factory for an id, or null. if not found. * @param targetID * @return IElementFactory */ IElementFactory* GetElementFactory(const QString& targetID) const; /** * Returns the presentation factory with the given id, or null if not found. - * @param targetID The id of the presentation factory to use. * @return IPresentationFactory or null * if not factory matches that id. */ IPresentationFactory* GetPresentationFactory(); private: /** * Looks up the configuration element with the given id on the given extension point * and instantiates the class specified by the class attributes. * * @param extensionPointId the extension point id (simple id) * @param elementName the name of the configuration element, or null * to match any element * @param targetID the target id * @return the instantiated extension object, or null if not found */ template C* CreateExtension(const QString& extensionPointId, const QString& elementName, const QString& targetID) { IExtensionPoint::Pointer extensionPoint = Platform::GetExtensionRegistry() ->GetExtensionPoint(PlatformUI::PLUGIN_ID() + "." + extensionPointId); if (extensionPoint == 0) { WorkbenchPlugin::Log("Unable to find extension. Extension point: " + extensionPointId + " not found"); return nullptr; } // Loop through the config elements. IConfigurationElement::Pointer targetElement(nullptr); QList elements( Platform::GetExtensionRegistry()->GetConfigurationElementsFor(PlatformUI::PLUGIN_ID() + "." + extensionPointId)); for (int j = 0; j < elements.size(); j++) { if (elementName == "" || elementName == elements[j]->GetName()) { QString strID = elements[j]->GetAttribute("id"); if (targetID == strID) { targetElement = elements[j]; break; } } } if (targetElement.IsNull()) { // log it since we cannot safely display a dialog. WorkbenchPlugin::Log("Unable to find extension: " + targetID + " in extension point: " + extensionPointId); return nullptr; } // Create the extension. try { return targetElement->CreateExecutableExtension("class"); } catch (const CoreException& /*e*/) { // log it since we cannot safely display a dialog. WorkbenchPlugin::Log("Unable to create extension: " + targetID + " in extension point: " + extensionPointId); } return nullptr; } public: /** * Return the perspective registry. * @return IPerspectiveRegistry. The registry for the receiver. */ IPerspectiveRegistry* GetPerspectiveRegistry(); /** * Returns the introduction registry. * * @return the introduction registry. */ IIntroRegistry* GetIntroRegistry(); /* * Get the preference manager. * @return PreferenceManager the preference manager for * the receiver. */ //PreferenceManager getPreferenceManager(); /** * Answer the view registry. * @return IViewRegistry the view registry for the * receiver. */ IViewRegistry* GetViewRegistry(); /** * Logs the given message to the platform log. * * If you have an exception in hand, call log(String, Throwable) instead. * * If you have a status object in hand call log(String, IStatus) instead. * * This convenience method is for internal use by the Workbench only and * must not be called outside the Workbench. * * @param message * A high level UI message describing when the problem happened. */ static void Log(const QString &message); /** * Log the throwable. * @param exc */ static void Log(const ctkException& exc); /** * Logs the given message and throwable to the platform log. * * If you have a status object in hand call log(String, IStatus) instead. * * This convenience method is for internal use by the Workbench only and * must not be called outside the Workbench. * * @param message * A high level UI message describing when the problem happened. * @param t * The throwable from where the problem actually occurred. */ static void Log(const QString &message, const ctkException& t); /** * Logs the given throwable to the platform log, indicating the class and * method from where it is being logged (this is not necessarily where it * occurred). * * This convenience method is for internal use by the Workbench only and * must not be called outside the Workbench. * * @param clazz * The calling class. * @param methodName * The calling method name. * @param t * The throwable from where the problem actually occurred. */ static void Log(const QString &clazz, const QString &methodName, const ctkException& t); /** * Logs the given message and status to the platform log. * * This convenience method is for internal use by the Workbench only and * must not be called outside the Workbench. * * @param message * A high level UI message describing when the problem happened. * May be null. * @param status * The status describing the problem. Must not be null. */ static void Log(const QString& message, const SmartPointer& status); /** * Log the status to the default log. * @param status */ static void Log(const SmartPointer& status); /* * (non-Javadoc) * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ void start(ctkPluginContext* context) override; /* * Return an array of all bundles contained in this workbench. * * @return an array of bundles in the workbench or an empty array if none */ //const QList GetBundles(); /** * Returns the bundle context associated with the workbench plug-in. * * @return the bundle context */ ctkPluginContext* GetPluginContext(); /* (non-Javadoc) * @see org.blueberry.ui.plugin.AbstractUICTKPlugin#stop(org.osgi.framework.BundleContext) */ void stop(ctkPluginContext* context) override; /** * FOR INTERNAL WORKBENCH USE ONLY. * * Returns the path to a location in the file system that can be used * to persist/restore state between workbench invocations. * If the location did not exist prior to this call it will be created. * Returns null if no such location is available. * * @return path to a location in the file system where this plug-in can * persist data between sessions, or null if no such * location is available. */ QString GetDataLocation() const; }; } #endif /*BERRYWORKBENCHPLUGIN_H_*/ diff --git a/Plugins/org.blueberry.ui.qt/src/presentations/berryIPresentationFactory.h b/Plugins/org.blueberry.ui.qt/src/presentations/berryIPresentationFactory.h index 710933f8c7..d343d2f512 100755 --- a/Plugins/org.blueberry.ui.qt/src/presentations/berryIPresentationFactory.h +++ b/Plugins/org.blueberry.ui.qt/src/presentations/berryIPresentationFactory.h @@ -1,181 +1,158 @@ /*============================================================================ 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 BERRYIPRESENTATIONFACTORY_H_ #define BERRYIPRESENTATIONFACTORY_H_ #include #include "berryStackPresentation.h" #include namespace berry { /** * This is a factory for presentation objects that control the appearance of * editors, views and other components in the workbench. * * @since 3.0 */ class BERRY_UI_QT IPresentationFactory { public: virtual ~IPresentationFactory(); /** * Bit value for the createSash method's 'style' parameter. * @since 3.4 */ static int SASHTYPE_NORMAL; // = 0; /** * Bit value for the createSash method's 'style' parameter. * @since 3.4 */ static int SASHTYPE_FLOATING; // = 1<<1; /** * Bit value for the createSash method's 'style' parameter. * @since 3.4 */ static int SASHORIENTATION_HORIZONTAL; // = SWT.HORIZONTAL; // 1<<8 /** * Bit value for the createSash method's 'style' parameter. * @since 3.4 */ static int SASHORIENTATION_VERTICAL; // = SWT.VERTICAL; // 1<<9 /** * Creates an editor presentation for presenting editors. *

* The presentation creates its controls under the given parent composite. *

* * @param parent * the parent composite to use for the presentation's controls * @param site * the site used for communication between the presentation and * the workbench * @return a newly created part presentation */ virtual StackPresentation::Pointer CreateEditorPresentation( QWidget* parent, IStackPresentationSite::Pointer site) = 0; /** * Creates a stack presentation for presenting regular docked views. *

* The presentation creates its controls under the given parent composite. *

* * @param parent * the parent composite to use for the presentation's controls * @param site * the site used for communication between the presentation and * the workbench * @return a newly created part presentation */ virtual StackPresentation::Pointer CreateViewPresentation(QWidget* parent, IStackPresentationSite::Pointer site) = 0; /** * Creates a standalone stack presentation for presenting a standalone view. * A standalone view cannot be docked together with other views. The title * of a standalone view may be hidden. *

* The presentation creates its controls under the given parent composite. *

* * @param parent * the parent composite to use for the presentation's controls * @param site * the site used for communication between the presentation and * the workbench * @param showTitle * true to show the title for the view, * false to hide it * @return a newly created part presentation */ virtual StackPresentation::Pointer CreateStandaloneViewPresentation( QWidget* parent, IStackPresentationSite::Pointer site, bool showTitle) = 0; - /** - * Creates the status line manager for the window. - * Subclasses may override. - * - * @return the window's status line manager - */ -// public IStatusLineManager createStatusLineManager() { -// return new StatusLineManager(); -// } - - /** - * Creates the control for the window's status line. - * Subclasses may override. - * - * @param statusLine the window's status line manager - * @param parent the parent composite - * @return the window's status line control - */ -// public Control createStatusLineControl(IStatusLineManager statusLine, -// Composite parent) { -// return ((StatusLineManager) statusLine).createControl(parent, SWT.NONE); -// } - /** * Returns a globally unique identifier for this type of presentation factory. This is used * to ensure that one presentation is not restored from mementos saved by a different * presentation. * * @return a globally unique identifier for this type of presentation factory. */ virtual QString GetId() = 0; /** * Creates the Sash control that is used to separate view and editor parts. * * @param parent the parent composite * @param style A bit set giving both the 'type' of the desired sash and * its orientation (i.e. one 'SASHTYPE' value and one "SASHORIENTATION" value). * @return the sash control * @since 3.4 */ virtual QWidget* CreateSash(QWidget* parent, int style) = 0; // { // int orientation = style & (SASHORIENTATION_HORIZONTAL // | SASHORIENTATION_VERTICAL); // Sash sash = new Sash(parent, orientation | SWT.SMOOTH); // return sash; // } /** * Returns the size of the Sash control that is used to separate view and editor parts. * * @param style A bit set giving both the 'type' of the desired sash and * its orientation. * @return the sash size * @since 3.4 */ virtual int GetSashSize(int style) = 0; /** * Applies changes of the current theme to the user interface. */ virtual void UpdateTheme() = 0; }; } Q_DECLARE_INTERFACE(berry::IPresentationFactory, "org.blueberry.ui.IPresentationFactory") #endif /* BERRYABSTRACTPRESENTATIONFACTORY_H_ */ diff --git a/Plugins/org.blueberry.ui.qt/src/presentations/berryIStackPresentationSite.h b/Plugins/org.blueberry.ui.qt/src/presentations/berryIStackPresentationSite.h index 089152e7c4..c32e544487 100755 --- a/Plugins/org.blueberry.ui.qt/src/presentations/berryIStackPresentationSite.h +++ b/Plugins/org.blueberry.ui.qt/src/presentations/berryIStackPresentationSite.h @@ -1,187 +1,172 @@ /*============================================================================ 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 BERRYISTACKPRESENTATIONSITE_H_ #define BERRYISTACKPRESENTATIONSITE_H_ #include #include #include "berryIPresentablePart.h" #include namespace berry { /** * Represents the main interface between a StackPresentation and the workbench. * * Not intended to be implemented by clients. * * @since 3.0 */ struct BERRY_UI_QT IStackPresentationSite : public Object { berryObjectMacro(berry::IStackPresentationSite); static int STATE_MINIMIZED; // = 0; static int STATE_MAXIMIZED; // = 1; static int STATE_RESTORED; // = 2; ~IStackPresentationSite() override; /** * Sets the state of the container. Called by the presentation when the * user causes the the container to be minimized, maximized, etc. * * @param newState one of the STATE_* constants */ virtual void SetState(int newState) = 0; /** * Returns the current state of the site (one of the STATE_* constants) * * @return the current state of the site (one of the STATE_* constants) */ virtual int GetState() = 0; /** * Returns true iff the site supports the given state * * @param state one of the STATE_* constants, above * @return true iff the site supports the given state */ virtual bool SupportsState(int state) = 0; /** * Begins dragging the given part * * @param beingDragged the part to drag (not null) * @param initialPosition the mouse position at the time of the initial mousedown * (display coordinates, not null) * @param keyboard true iff the drag was initiated via mouse dragging, * and false if the drag may be using the keyboard */ virtual void DragStart(IPresentablePart::Pointer beingDragged, QPoint& initialPosition, bool keyboard) = 0; /** * Closes the given set of parts. * * @param toClose the set of parts to close (Not null. All of the entries must be non-null) */ virtual void Close(const QList& toClose) = 0; /** * Begins dragging the entire stack of parts * * @param initialPosition the mouse position at the time of the initial mousedown (display coordinates, * not null) * @param keyboard true iff the drag was initiated via mouse dragging, * and false if the drag may be using the keyboard */ virtual void DragStart(QPoint& initialPosition, bool keyboard) = 0; /** * Returns true iff this site will allow the given part to be closed * * @param toClose part to test (not null) * @return true iff the part may be closed */ virtual bool IsCloseable(IPresentablePart::Pointer toClose) = 0; /** * Returns true iff the given part can be dragged. If this * returns false, the given part should not trigger a drag. * * @param toMove part to test (not null) * @return true iff this part is a valid drag source */ virtual bool IsPartMoveable(IPresentablePart::Pointer toMove) = 0; /** * Returns true iff this entire stack can be dragged * * @return true iff the stack can be dragged */ virtual bool IsStackMoveable() = 0; /** * Makes the given part active * * @param toSelect */ virtual void SelectPart(IPresentablePart::Pointer toSelect) = 0; /** * Returns the currently selected part or null if the stack is empty * * @return the currently selected part or null if the stack is empty */ virtual IPresentablePart::Pointer GetSelectedPart() = 0; - /** - * Adds system actions to the given menu manager. The site may - * make use of the following group ids: - *
    - *
  • close, for close actions
  • - *
  • size, for resize actions
  • - *
  • misc, for miscellaneous actions
  • - *
- * The presentation can control the insertion position by creating - * these group IDs where appropriate. - * - * @param menuManager the menu manager to populate - */ - //virtual void AddSystemActions(IMenuManager menuManager); - /** * Notifies the workbench that the preferred size of the presentation has * changed. Hints to the workbench that it should trigger a layout at the * next opportunity. * * @since 3.1 */ virtual void FlushLayout() = 0; /** * Returns the list of presentable parts currently in this site * * @return the list of presentable parts currently in this site * @since 3.1 */ virtual QList GetPartList() = 0; /** * Returns the property with the given id or null. Folder * properties are an extensible mechanism for perspective authors to * customize the appearance of view stacks. The list of customizable * properties is determined by the presentation factory, and set in the * perspective factory. * * @param id * Must not be null. * @return property value, or null if the property is not * set. * @since 3.3 */ virtual QString GetProperty(const QString& id) = 0; }; } #endif /* BERRYISTACKPRESENTATIONSITE_H_ */