MathSculptorInterface: Difference between revisions
Jump to navigation
Jump to search
New page: I'm still in the process of updating the documentation... Please check back shortly. |
mNo edit summary |
||
| Line 1: | Line 1: | ||
I'm still in the process of updating the documentation... Please check back shortly. | I'm still in the process of updating the documentation... Please check back shortly. ---- | ||
<pre> | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
using System.Drawing; | |||
using System.ComponentModel; | |||
namespace Burhop.MathSculptor | |||
{ | |||
/// <summary> | |||
/// A simple 3 byte structure for X,Y,Z values</summary> | |||
/// <remarks> | |||
/// X,Y,Z values range from 0 to 255</remarks> | |||
public struct xyz | |||
{ | |||
/// <summary> | |||
/// X value ranging from 0-255 | |||
/// </summary> | |||
public byte x; | |||
/// <summary> | |||
/// Y value ranging from 0-255 | |||
/// </summary> | |||
public byte y; | |||
/// <summary> | |||
/// Y value ranging from 0-255 | |||
/// </summary> | |||
public byte z; | |||
}; | |||
/// <summary> | |||
/// General interface for Math Sculptor Function Parameters. ISculptParam objects | |||
/// are passed between your addin and external code. You generally do not want to | |||
/// implement this interface directly, Rather one of the sub interfaces should be used. | |||
/// </summary> | |||
public interface ISculptParam | |||
{ | |||
/// <summary> | |||
/// The Name of the Parameter such as "Height", "Radius","Number", etc. | |||
/// </summary> | |||
string Name | |||
{ | |||
get; | |||
} | |||
/// <summary> | |||
/// A brief description of the parameter which might be displayed in a ToolTop | |||
/// </summary> | |||
string Description | |||
{ | |||
get; | |||
} | |||
/// <summary> | |||
/// The Type of the parameter, generally the ISculptParm*T* Type child class "/> | |||
/// </summary> | |||
Type Type | |||
{ | |||
get; | |||
} | |||
}; | |||
/// <summary> | |||
/// A template Interface used to to work with different types. This allows | |||
/// new parameter types to be added as needed. Common types are bool, int, and float | |||
/// </summary> | |||
/// <typeparam name="T">Generally, bool, int, float.</typeparam> | |||
public interface ISculptParam<T> : ISculptParam | |||
{ | |||
/// <summary> | |||
/// The current value of this parameter. It should be set initially to the default | |||
/// value of your parameter. The framework (such as Math Sculpt) will set this | |||
/// value and provide it to you on update. | |||
/// </summary> | |||
T Value | |||
{ | |||
get; | |||
set; | |||
} | |||
/// <summary> | |||
/// The lowest valid value for this parameter. For example, a radius parameter may | |||
/// only accept values greater than 0. | |||
/// </summary> | |||
T LowValue | |||
{ | |||
get; | |||
set; | |||
} | |||
/// <summary> | |||
/// The highest valud value for this parameter. For example, a radius parameter may | |||
/// need to stay bellow 127 to avoid creating cycles outside the 0 to 255 volume of a | |||
/// sculptured primitive. | |||
/// </summary> | |||
T HighValue | |||
{ | |||
get; | |||
set; | |||
} | |||
} | |||
/// <summary> | |||
/// The primary Math Sculpt Interface for accessing your alrgorithm/function | |||
/// and for getting information about the Addin Tool to display to the user. | |||
/// | |||
/// </summary> | |||
public interface ISculptAddin | |||
{ | |||
/// <summary> | |||
/// Gets an XYZ set of values given the u and v parameter | |||
/// </summary> | |||
/// <param name="u">u parameter 0. to 1. </param> | |||
/// <param name="v">v parameter 0. to 1. </param> | |||
/// <returns>The XYZ coordinate for that parameter pair</returns> | |||
xyz getXYZ(double u, double v); | |||
/// <summary> | |||
/// An small image to display in the UI. It should give a hit as to what your | |||
/// AddinTool does. | |||
/// </summary> | |||
System.Drawing.Image IconImage | |||
{ | |||
get; | |||
} | |||
/// <summary> | |||
/// Short Description of the Addin Tool, usually less than 80 characters. For | |||
/// Math Sculpt, this will be displayed in the UI. | |||
/// </summary> | |||
string Description | |||
{ | |||
get; | |||
} | |||
/// <summary> | |||
/// A long Description of the Addin Tool that provides additional information. | |||
/// </summary> | |||
string LongDescription | |||
{ | |||
get; | |||
} | |||
/// <summary> | |||
/// Provides a list of the parameters for this Addin Tool. On start up, | |||
/// the frameworkk will ask for the list of parameters and create the | |||
/// the corresponding UI needed to modify them. As the values change, the | |||
/// parameters are "set". The Framework is expected to pass back | |||
/// the list of parameters to your addin in the same order it was given. | |||
/// </summary> | |||
List<ISculptParam> Params | |||
{ | |||
get; | |||
set; | |||
} | |||
} | |||
/// <summary> | |||
/// Provides a contrete utility class for common Parameters | |||
/// This class should not be used in any Frameworks. It is a utility class | |||
/// for Addin developers. | |||
/// </summary> | |||
public abstract class SculptParam : ISculptParam | |||
{ | |||
string name; | |||
string description; | |||
/// <summary> | |||
/// The Name of the Parameter such as "Height", "Radius","Number", etc. | |||
/// </summary> | |||
public string Name | |||
{ | |||
get { return name; } | |||
set { name = value; } | |||
} | |||
/// <summary> | |||
/// A brief description of the parameter which might be displayed in a ToolTop | |||
/// </summary> | |||
public string Description | |||
{ | |||
get { return Description; } | |||
set { description = value; } | |||
} | |||
/// <summary> | |||
/// The Type of the parameter, generally the ISculptParm*T* Type child class "/> | |||
/// </summary> | |||
public abstract Type Type { get;} | |||
} | |||
/// <summary> | |||
/// Provides a contrete utility template class for Parameters | |||
/// This class should not be used in any Frameworks. It is a utility class | |||
/// for Addin developers to avoid having to implement the same code over and over. | |||
/// For example, for interger parameters, use "int" as the Type. | |||
/// </summary> | |||
public class SculptParam<T> : SculptParam,ISculptParam<T> | |||
{ | |||
T value; | |||
T highValue; | |||
T lowValue; | |||
public override Type Type | |||
{ | |||
get { return typeof(ISculptParam<T>); } | |||
} | |||
public T Value | |||
{ | |||
get { return value; } | |||
set {this.value = value;} | |||
} | |||
public T LowValue | |||
{ | |||
get { return lowValue; } | |||
set { this.lowValue = value; } | |||
} | |||
public T HighValue | |||
{ | |||
get{ return highValue; } | |||
set { this.highValue = value; } | |||
} | |||
} | |||
} | |||
</pre> | |||
Revision as of 13:49, 24 June 2007
I'm still in the process of updating the documentation... Please check back shortly. ----
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.ComponentModel;
namespace Burhop.MathSculptor
{
/// <summary>
/// A simple 3 byte structure for X,Y,Z values</summary>
/// <remarks>
/// X,Y,Z values range from 0 to 255</remarks>
public struct xyz
{
/// <summary>
/// X value ranging from 0-255
/// </summary>
public byte x;
/// <summary>
/// Y value ranging from 0-255
/// </summary>
public byte y;
/// <summary>
/// Y value ranging from 0-255
/// </summary>
public byte z;
};
/// <summary>
/// General interface for Math Sculptor Function Parameters. ISculptParam objects
/// are passed between your addin and external code. You generally do not want to
/// implement this interface directly, Rather one of the sub interfaces should be used.
/// </summary>
public interface ISculptParam
{
/// <summary>
/// The Name of the Parameter such as "Height", "Radius","Number", etc.
/// </summary>
string Name
{
get;
}
/// <summary>
/// A brief description of the parameter which might be displayed in a ToolTop
/// </summary>
string Description
{
get;
}
/// <summary>
/// The Type of the parameter, generally the ISculptParm*T* Type child class "/>
/// </summary>
Type Type
{
get;
}
};
/// <summary>
/// A template Interface used to to work with different types. This allows
/// new parameter types to be added as needed. Common types are bool, int, and float
/// </summary>
/// <typeparam name="T">Generally, bool, int, float.</typeparam>
public interface ISculptParam<T> : ISculptParam
{
/// <summary>
/// The current value of this parameter. It should be set initially to the default
/// value of your parameter. The framework (such as Math Sculpt) will set this
/// value and provide it to you on update.
/// </summary>
T Value
{
get;
set;
}
/// <summary>
/// The lowest valid value for this parameter. For example, a radius parameter may
/// only accept values greater than 0.
/// </summary>
T LowValue
{
get;
set;
}
/// <summary>
/// The highest valud value for this parameter. For example, a radius parameter may
/// need to stay bellow 127 to avoid creating cycles outside the 0 to 255 volume of a
/// sculptured primitive.
/// </summary>
T HighValue
{
get;
set;
}
}
/// <summary>
/// The primary Math Sculpt Interface for accessing your alrgorithm/function
/// and for getting information about the Addin Tool to display to the user.
///
/// </summary>
public interface ISculptAddin
{
/// <summary>
/// Gets an XYZ set of values given the u and v parameter
/// </summary>
/// <param name="u">u parameter 0. to 1. </param>
/// <param name="v">v parameter 0. to 1. </param>
/// <returns>The XYZ coordinate for that parameter pair</returns>
xyz getXYZ(double u, double v);
/// <summary>
/// An small image to display in the UI. It should give a hit as to what your
/// AddinTool does.
/// </summary>
System.Drawing.Image IconImage
{
get;
}
/// <summary>
/// Short Description of the Addin Tool, usually less than 80 characters. For
/// Math Sculpt, this will be displayed in the UI.
/// </summary>
string Description
{
get;
}
/// <summary>
/// A long Description of the Addin Tool that provides additional information.
/// </summary>
string LongDescription
{
get;
}
/// <summary>
/// Provides a list of the parameters for this Addin Tool. On start up,
/// the frameworkk will ask for the list of parameters and create the
/// the corresponding UI needed to modify them. As the values change, the
/// parameters are "set". The Framework is expected to pass back
/// the list of parameters to your addin in the same order it was given.
/// </summary>
List<ISculptParam> Params
{
get;
set;
}
}
/// <summary>
/// Provides a contrete utility class for common Parameters
/// This class should not be used in any Frameworks. It is a utility class
/// for Addin developers.
/// </summary>
public abstract class SculptParam : ISculptParam
{
string name;
string description;
/// <summary>
/// The Name of the Parameter such as "Height", "Radius","Number", etc.
/// </summary>
public string Name
{
get { return name; }
set { name = value; }
}
/// <summary>
/// A brief description of the parameter which might be displayed in a ToolTop
/// </summary>
public string Description
{
get { return Description; }
set { description = value; }
}
/// <summary>
/// The Type of the parameter, generally the ISculptParm*T* Type child class "/>
/// </summary>
public abstract Type Type { get;}
}
/// <summary>
/// Provides a contrete utility template class for Parameters
/// This class should not be used in any Frameworks. It is a utility class
/// for Addin developers to avoid having to implement the same code over and over.
/// For example, for interger parameters, use "int" as the Type.
/// </summary>
public class SculptParam<T> : SculptParam,ISculptParam<T>
{
T value;
T highValue;
T lowValue;
public override Type Type
{
get { return typeof(ISculptParam<T>); }
}
public T Value
{
get { return value; }
set {this.value = value;}
}
public T LowValue
{
get { return lowValue; }
set { this.lowValue = value; }
}
public T HighValue
{
get{ return highValue; }
set { this.highValue = value; }
}
}
}