FunctionUi<T>

FunctionUi
public abstract class FunctionUi<T> : FunctionUi
Abstract class for function interfaces.
TType of Function to wrap. where Function

Constructors

FunctionUi

#
protected FunctionUi(
reader
)

FunctionUi

#
Construct the base function.
protected FunctionUi(
T
original,
Initial function.
icon
Function icon.
)

Fields

_inner

Actual state of the inner colour as determined by the SetupDrawing method.
protected Color _inner
inherited fromFunctionUi

_outer

Actual state of the outer colour as determined by the SetupDrawing method.
protected Color _outer
inherited fromFunctionUi

Properties

Arguments

Gets all the arguments associated with this function. Arguments can be either of type Vector (i.e. 2D grips) or Scalar (i.e. 1D sliders) or referents (i.e. 1D functions).
public FunctionArguments Arguments { get; }
inherited fromFunctionUi

AssumeContinuous

Override this property and return false if the underlying function is expected to contain discontinuities.
protected virtual bool AssumeContinuous { get; }
inherited fromFunctionUi

Func

#
Gets the function representing the current state.
public T Func { get; }

Function

#
[EditorBrowsable(EditorBrowsableState.Never)] public override Function Function { get; }

GripsOn

Gets or sets whether the grips (and scalars) of this function ought to be drawn.
public bool GripsOn { get; set; }
inherited fromFunctionUi

Icon

Gets the icon associated with this function.
public IIcon Icon { get; }
inherited fromFunctionUi

Id

Gets the identifier of this UI instance.
public Guid Id { get; }
inherited fromFunctionUi

LatestGraphSegments

The polyline segments the graph was most recently drawn with, in graph (content) coordinates. Empty when the function hasn't been drawn yet. Populated by FunctionUi.DrawGraph(FunctionGraphics) from whatever FunctionUi.GraphSegments(FunctionGraphics) yields, so subclasses that override GraphSegments (LinearFunction, ThresholdFunction, etc.) contribute here too. Hit-testing uses these so the click tolerance matches the rendered pixels exactly.
public IEnumerable<Point2d[]> LatestGraphSegments { get; }
inherited fromFunctionUi

Nomen

Gets the description of this function.
public Nomen Nomen { get; }
inherited fromFunctionUi

Rank

Gets or sets the stature of this function. The stature controls the visual style of the function, as well as its inclusion in any outputted collection.
public Rank Rank { get; set; }
inherited fromFunctionUi

Selected

Gets or sets the selected state.
public bool Selected { get; set; }
inherited fromFunctionUi

Tint

Gets or sets the Open-Color family used to tint this function. A concrete shade is resolved at draw time based on the current background so the function stays legible under any theme. Use FunctionUi.TintFor(Color) when a concrete Color is needed.
public OpenColor.Family Tint { get; set; }
inherited fromFunctionUi

UserName

Gets or sets the user name assigned to this function.
public string UserName { get; set; }
inherited fromFunctionUi

VariableArguments

Override this property if your function has a variable number of vector arguments.
protected virtual bool VariableArguments { get; }
inherited fromFunctionUi

Methods

AfterDrawGraphSegments

Draw any decoration that should appear on top of the graph polyline. Called from FunctionUi.DrawGraph(FunctionGraphics) after the polyline has been rendered.
protected virtual void AfterDrawGraphSegments(
graphics
Graphics object to draw with.
)
inherited fromFunctionUi

BeforeDrawGraphSegments

Draw any decoration that should appear behind the graph polyline. Called from FunctionUi.DrawGraph(FunctionGraphics) after FunctionUi.GraphSegments(FunctionGraphics) has run, so FunctionUi.LatestGraphSegments is populated and available.
protected virtual void BeforeDrawGraphSegments(
graphics
Graphics object to draw with.
)
inherited fromFunctionUi

CanInsertVector

#
Test whether a grip can be inserted at or near a coordinate.
public override bool CanInsertVector(
location,
Initial grip insertion coordinate.
out Point2d
actualLocation
Modified grip insertion coordinate.
)
True if grip can be inserted at modifiedCoordinate.

CanRemoveVector

#
Override this method to specifically okay removal off a specific grip.
protected override bool CanRemoveVector()

CreateFromArguments

#
This method is called by the base class whenever the equation needs to be updated to reflect the current grip state.
protected abstract T CreateFromArguments()

DrawGraph

Draw this function graph into a graphics context. Non-virtual: subclasses customise the rendering via FunctionUi.GraphSegments(FunctionGraphics) (the polyline itself) and the FunctionUi.BeforeDrawGraphSegments(FunctionGraphics) / FunctionUi.AfterDrawGraphSegments(FunctionGraphics) hooks (any decorations before or after the curve). This keeps pen setup, rank thickness rules, obscure dashing, and segment capture in one place.
public void DrawGraph(
graphics
Graphics object to draw with.
)
inherited fromFunctionUi

DrawGripFlourishes

Draw all grip flourishes associated with this function.
public virtual void DrawGripFlourishes(
graphics
Graphics object to draw with.
)
inherited fromFunctionUi

DrawGripShapes

Draw all grips associated with this function.
public virtual void DrawGripShapes(
graphics
Graphics object to draw with.
)
inherited fromFunctionUi

DrawHints

Draw the visual hints such as asymptotes, limits and markers associated with this function.
public virtual void DrawHints(
graphics
Graphics object to draw with.
)
inherited fromFunctionUi

DrawScalarShapes

Draw all scalars associated with this function.
public virtual void DrawScalarShapes(
graphics
Graphics object to draw with.
)
inherited fromFunctionUi

EstimateDistance

Compute an estimate of the distance from the function to the given point. This estimate is done by sampling the function at small intervals around the point. Note: implementors may choose to override this method and provide analytic distance measurements.
public virtual double EstimateDistance(
locus,
Point for distance estimate.
radius
Maximum sampling radius. Large numbers result in lots of sampling.
)
inherited fromFunctionUi
Smallest sampled distance or double.NaN if no sample was within radius.

EstimateProjection

Compute an estimate of the point on the function closest to a search point. This estimate is done by sampling the function at small intervals around the point.
public virtual Point2d EstimateProjection(
locus,
Point for closest point estimate.
radius
Maximum sampling radius.
)
inherited fromFunctionUi
Closest point or Point2d.Unset if no sample was within radius.

GraphSegments

Override this method if you think you can provide a more performant way to generate a graphics path representing the graph curve.
protected virtual IEnumerable<Point2d[]> GraphSegments(
graphics
Drawing properties.
)
inherited fromFunctionUi

OnFunctionChanged

public void OnFunctionChanged()
inherited fromFunctionUi

OverrideFunctionCache

#
Override the cached function. You typically never need this. It's here for those rare cases where grips or scalars are modified in such a way so as to not affect the underlying function.
[EditorBrowsable(EditorBrowsableState.Never)] protected internal void OverrideFunctionCache(
T
function
)

PopulateMenu

Invoked when the context menu for this function is about to be shown.
public virtual void PopulateMenu(
ContextMenu
menu,
Menu to append items to.
coordinate,
Location from whence the menu was requested.
Argument
parameter
Parameter associated with menu coordinate, if any.
)
inherited fromFunctionUi

SetupDrawing

Must be called prior to any draw method. This will ensure the colours and layout are correct.
public virtual void SetupDrawing(
graphics,
animate = true
)
inherited fromFunctionUi

Store

public virtual void Store(
writer
)
inherited fromFunctionUi
Store

TintFor

Resolve FunctionUi.Tint into a concrete colour that stands out against the supplied background.
public Color TintFor(
Color
background
Background the tint must contrast with.
)
inherited fromFunctionUi

TryInsertVector

#
Try and insert a grip at a coordinate.
public override bool TryInsertVector(
location
Grip location.
)
True if grip was inserted.

TryRemoveVectors

#
Try and remove a set of grips.
public override bool TryRemoveVectors(
vectors
Vectors whose removal is indicated.
)
True if the function changed state.

Events

FunctionChanged

Raised when the shape of the function changes due to non-grip/scalar events, for example when the function is modified via a custom menu item.
public event EventHandler FunctionChanged
inherited fromFunctionUi