FunctionUi

References
public abstract class FunctionUi : IStorable
Non-generic function UI.

Constructors

FunctionUi

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

FunctionUi

#
protected FunctionUi(
reader
)

Fields

_inner

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

_outer

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

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; }

AssumeContinuous

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

Function

#
The function hosted by the UI.
public abstract Function Function { get; }

GripsOn

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

Icon

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

Id

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

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 DrawGraph(FunctionGraphics) from whatever 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; }

Nomen

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

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; }

Selected

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

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 TintFor(Color) when a concrete Color is needed.
public OpenColor.Family Tint { get; set; }

UserName

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

VariableArguments

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

Methods

AfterDrawGraphSegments

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

BeforeDrawGraphSegments

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

CanInsertVector

#
Test whether a grip can be inserted at or near a coordinate.
public abstract 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 abstract bool CanRemoveVector()

DrawGraph

#
Draw this function graph into a graphics context. Non-virtual: subclasses customise the rendering via GraphSegments(FunctionGraphics) (the polyline itself) and the BeforeDrawGraphSegments(FunctionGraphics) / 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.
)

DrawGripFlourishes

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

DrawGripShapes

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

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.
)

DrawScalarShapes

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

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.
)
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.
)
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.
)

OnFunctionChanged

#
Raise the FunctionChanged event.
public void OnFunctionChanged()

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.
)

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
)

Store

#
public virtual void Store(
writer
)
Store

TintFor

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

TryInsertVector

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

TryRemoveVectors

#
Try and remove a set of grips.
public abstract 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