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(IReader reader)
reader (IReader)

FunctionUi

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

Fields

_inner

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

_outer

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

Properties

Arguments

public FunctionArguments Arguments { get; }
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).
inherited fromFunctionUi

AssumeContinuous

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

Func

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

Function

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

GripsOn

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

Icon

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

Id

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

LatestGraphSegments

public IEnumerable<Point2d[]> LatestGraphSegments { get; }
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.
inherited fromFunctionUi

Nomen

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

Rank

public Rank Rank { get; set; }
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.
inherited fromFunctionUi

Selected

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

Tint

public OpenColor.Family Tint { get; set; }
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.
inherited fromFunctionUi

UserName

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

VariableArguments

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

Methods

AfterDrawGraphSegments

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

BeforeDrawGraphSegments

protected virtual void BeforeDrawGraphSegments(FunctionGraphics graphics)
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.
inherited fromFunctionUi
graphics (FunctionGraphics)Graphics object to draw with.

CanInsertVector

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

CanRemoveVector

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

CreateFromArguments

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

DrawGraph

public void DrawGraph(FunctionGraphics graphics)
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.
inherited fromFunctionUi
graphics (FunctionGraphics)Graphics object to draw with.

DrawGripFlourishes

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

DrawGripShapes

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

DrawHints

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

DrawScalarShapes

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

EstimateDistance

public virtual double EstimateDistance(Point2d locus, double radius)
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.
inherited fromFunctionUi
locus (Point2d)Point for distance estimate.
radius (double)Maximum sampling radius. Large numbers result in lots of sampling.
Smallest sampled distance or double.NaN if no sample was within radius.

EstimateProjection

public virtual Point2d EstimateProjection(Point2d locus, double radius)
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.
inherited fromFunctionUi
locus (Point2d)Point for closest point estimate.
radius (double)Maximum sampling radius.
Closest point or Point2d.Unset if no sample was within radius.

GraphSegments

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

OnFunctionChanged

public void OnFunctionChanged()
inherited fromFunctionUi

OverrideFunctionCache

#
[EditorBrowsable(EditorBrowsableState.Never)] protected internal void OverrideFunctionCache(T function)
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.
function (T)

PopulateMenu

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

SetupDrawing

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

Store

public virtual void Store(IWriter writer)
inherited fromFunctionUi
writer (IWriter)
Store

TintFor

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

TryInsertVector

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

TryRemoveVectors

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

Events

FunctionChanged

public event EventHandler 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.
inherited fromFunctionUi