Tool Compatibility

Nov 2, 2011 at 9:48 PM

I'd vote for increased compatibility with similar projects. For example, tools tend to operate on files (hence they are not heavily dependent on the ocx). It think it would be great to be able to share tools between DotSpatial and MapWindow 4. A similar effort is being made to reuse Whitebox tools in DotSpatial.

Coordinator
Nov 3, 2011 at 1:30 PM

I agree.

We should try to arrange this.

Nov 3, 2011 at 10:17 PM

If it helps, here's the interface DotSpatial currently uses.

    /// <summary>
    /// Defines the way a tool interfaces with the toolbox
    /// </summary>
    [InheritedExport]
    public interface ITool
    {
        /// <summary>
        /// Returns the name of the tool
        /// </summary>
        string Name
        {
            get;
        }

        /// <summary>
        /// A UniqueName Identifying this Tool, if another tool with the same UniqueName exists this tool will not be loaded. The is persisted by the model builder in saved files.
        /// </summary>
        string AssemblyQualifiedName
        {
            get;
        }


        /// <summary>
        /// Returns the category of tool that the ITool should be added to
        /// </summary>
        string Category
        {
            get;
        }

        /// <summary>
        /// Returns the Version of the tool
        /// </summary>
        string Version
        {
            get;
        }

        /// <summary>
        /// Returns the Author of the tool's name
        /// </summary>
        string Author
        {
            get;
        }

        /// <summary>
        /// The parameters array should be populated with default values here
        /// </summary>
        void Initialize();


        /// <summary>
        /// Returns a brief description displayed when the user hovers over the tool in the toolbox
        /// </summary>
        string ToolTip
        {
            get;
        }

        /// <summary>
        /// Fires when one of the paramters value has beend changed, usually when a user changes a input or output parameters value, this can be used to populate other parameters default values.
        /// </summary>
        void ParameterChanged(Parameter sender);

        /// <summary>
        /// Gets or Sets the input paramater array
        /// </summary>
        Parameter[] InputParameters
        {
            get;
        }

        /// <summary>
        /// Gets or Sets the output paramater array
        /// </summary>
        Parameter[] OutputParameters
        {
            get;
        }

        /// <summary>
        /// Once the parameters have been configured the Execute command can be called, it returns true if succesful
        /// </summary>
        /// <param name="cancelProgressHandler">A cancel progress handler that used to indicate how much of the tool is done</param>
        /// <returns></returns>
        bool Execute(ICancelProgressHandler cancelProgressHandler);

        /// <summary>
        /// 32x32 Bitmap - The Large icon that will appears in the Tool Dialog Next to the tools name
        /// </summary>
        Bitmap Icon
        {
            get;
        }

        /// <summary>
        /// Image displayed in the help area when no input field is selected
        /// </summary>
        Bitmap HelpImage
        {
            get;
        }

        /// <summary>
        /// Help text to be displayed when no input field is selected
        /// </summary>
        string Description
        {
            get;
        }

        /// <summary>
        /// Returns the address of the tools help web page in HTTP://... format. Return a empty string to hide the help hyperlink.
        /// </summary>
        string HelpUrl
        {
            get;
        }
    }

 

 

Nov 3, 2011 at 10:18 PM

Tool implements many of those members, so the tool developer has fewer they have to deal with, but the flexibility if they need it...

    public abstract class Tool : DotSpatial.Extensions.AssemblyInformation, ITool
    {
        #region Constants and Fields

        private string author;
        private string description;
        private string helpUrl;
        private string name;

        #endregion

        #region Public Properties

        public override string Author
        {
            get
            {
                if (author == null)
                    author = base.Author;

                return author;
            }
            set
            {
                author = value;
            }
        }

        public virtual string Category { get; set; }

        public override string Description
        {
            get
            {
                if (description == null)
                    description = base.Description;

                return description;
            }
            set
            {
                description = value;
            }
        }

        public virtual Bitmap HelpImage { get; set; }

        public virtual string HelpUrl
        {
            get
            {
                if (helpUrl == null) return "http://www.mapwindow.org/";
                return helpUrl;
            }
            set
            {
                helpUrl = value;
            }
        }

        public virtual Bitmap Icon { get; set; }

        public abstract Parameter[] InputParameters { get; }

        public override string Name
        {
            get
            {
                if (name == null)
                    name = base.Name;

                return name;
            }
            set
            {
                name = value;
            }
        }

        public abstract Parameter[] OutputParameters { get; }

        public virtual string ToolTip { get; set; }

        #endregion

        #region Public Methods

        public abstract bool Execute(ICancelProgressHandler cancelProgressHandler);

        public abstract void Initialize();

        public virtual void ParameterChanged(Parameter sender) { }

        #endregion
    }

Coordinator
Nov 4, 2011 at 7:39 AM

Thanks Matthew,

This is very helpful.
We should try to use this interface as well.

Nov 4, 2011 at 8:28 PM

If you want, we could have a separate "project" that defines interfaces we want to share.

 

As far as I know, some of this code was create for "demonstration purposes." So we might want to take a closer look before propping it up as a standard. For example, exposing 

Parameter[]

Seems non-standard (for .Net).