Add function parser
This commit is contained in:
@@ -23,8 +23,8 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
private const string DEFAULT_NAME = "Put function name here...";
|
private const string DEFAULT_NAME = "Put function name here...";
|
||||||
private const string DEFAULT_DESCRIPTION = "Put function description here...";
|
private const string DEFAULT_DESCRIPTION = "Put function description here...";
|
||||||
private const string DEFAULT_FORMULA = "x^2";
|
private const string DEFAULT_FORMULA = "x^2";
|
||||||
private const double DEFAULT_LEFT_BOUND = -500;
|
private const double DEFAULT_LEFT_BOUND = 1;
|
||||||
private const double DEFAULT_RIGHT_BOUND = 500;
|
private const double DEFAULT_RIGHT_BOUND = 1000;
|
||||||
private const int DEFAULT_STEP = 100;
|
private const int DEFAULT_STEP = 100;
|
||||||
private const int MAX_STEP = 1000;
|
private const int MAX_STEP = 1000;
|
||||||
public char GREATER { get; } = '\u2265';
|
public char GREATER { get; } = '\u2265';
|
||||||
@@ -171,6 +171,8 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
(Function as FormulaFunction).Step = Step;
|
(Function as FormulaFunction).Step = Step;
|
||||||
(Function as FormulaFunction).Formula = Formula;
|
(Function as FormulaFunction).Formula = Formula;
|
||||||
Function.Color = Color;
|
Function.Color = Color;
|
||||||
|
Function.MinArg = LeftBound;
|
||||||
|
Function.MaxArg = RightBound;
|
||||||
var window = parameter as Window;
|
var window = parameter as Window;
|
||||||
if (LeftBound > RightBound)
|
if (LeftBound > RightBound)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ namespace StructureHelper.Windows.MainGraph
|
|||||||
f2.Name = "Формульная системная функция";
|
f2.Name = "Формульная системная функция";
|
||||||
f2.Formula = "x^2";
|
f2.Formula = "x^2";
|
||||||
f2.Step = 100;
|
f2.Step = 100;
|
||||||
f2.MinArg = -1000;
|
f2.MinArg = 1;
|
||||||
f2.MaxArg = 1000;
|
f2.MaxArg = 1000;
|
||||||
f2.IsUser = false;
|
f2.IsUser = false;
|
||||||
f2.Description = "Описание формульной системной функции";
|
f2.Description = "Описание формульной системной функции";
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
|||||||
|
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||||
public Color Color { get; set; }
|
public Color Color { get; set; }
|
||||||
|
public string Trace { get; set; }
|
||||||
|
|
||||||
public FunctionDecorator(IOneVariableFunction function)
|
public FunctionDecorator(IOneVariableFunction function)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
|||||||
public double MinArg { get; set; }
|
public double MinArg { get; set; }
|
||||||
public double MaxArg { get; set; }
|
public double MaxArg { get; set; }
|
||||||
public Color Color { get; set; }
|
public Color Color { get; set; }
|
||||||
|
public string Trace { get; set; }
|
||||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
||||||
public bool Check();
|
public bool Check();
|
||||||
public double GetByX(double xValue);
|
public double GetByX(double xValue);
|
||||||
|
|||||||
@@ -13,11 +13,15 @@ using System.Windows.Documents;
|
|||||||
using StructureHelperCommon.Services;
|
using StructureHelperCommon.Services;
|
||||||
using LiveCharts.Wpf;
|
using LiveCharts.Wpf;
|
||||||
using StructureHelperCommon.Services.ColorServices;
|
using StructureHelperCommon.Services.ColorServices;
|
||||||
|
using FunctionParser;
|
||||||
|
|
||||||
namespace StructureHelperCommon.Models.Functions
|
namespace StructureHelperCommon.Models.Functions
|
||||||
{
|
{
|
||||||
public class FormulaFunction : IOneVariableFunction
|
public class FormulaFunction : IOneVariableFunction
|
||||||
{
|
{
|
||||||
|
private double current_xValue;
|
||||||
|
private string formula;
|
||||||
|
private Expression expression;
|
||||||
private const string COPY = "copy";
|
private const string COPY = "copy";
|
||||||
public const string GROUP_TYPE_1 = "System function";
|
public const string GROUP_TYPE_1 = "System function";
|
||||||
public const string GROUP_TYPE_2 = "User function";
|
public const string GROUP_TYPE_2 = "User function";
|
||||||
@@ -27,13 +31,36 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Description { get ; set; }
|
public string Description { get ; set; }
|
||||||
public int Step { get; set; }
|
public int Step { get; set; }
|
||||||
public string Formula { get; set; }
|
public string Formula
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return formula;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
formula = value;
|
||||||
|
Expression = new Expression(value, new string[] { "x" }, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public Expression Expression
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
expression = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
public Guid Id => throw new NotImplementedException();
|
public Guid Id => throw new NotImplementedException();
|
||||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>();
|
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>();
|
||||||
public double MinArg { get; set; }
|
public double MinArg { get; set; }
|
||||||
public double MaxArg { get; set; }
|
public double MaxArg { get; set; }
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||||
public Color Color { get; set; }
|
public Color Color { get; set; }
|
||||||
|
public string Trace { get; set; }
|
||||||
|
|
||||||
public FormulaFunction(bool isUser = false)
|
public FormulaFunction(bool isUser = false)
|
||||||
{
|
{
|
||||||
@@ -55,7 +82,6 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
var formulaFunction = new FormulaFunction();
|
var formulaFunction = new FormulaFunction();
|
||||||
@@ -76,7 +102,9 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public double GetByX(double xValue)
|
public double GetByX(double xValue)
|
||||||
{
|
{
|
||||||
double yValue = 0;
|
double yValue = 0;
|
||||||
yValue = Math.Round(Math.Pow(xValue, 2), 2); //Временно выражение квадратичной параболы, будет разбор выражения
|
current_xValue = xValue;
|
||||||
|
Check();
|
||||||
|
yValue = Math.Round(Expression.CalculateValue(new double[] { xValue }), 2);
|
||||||
return yValue;
|
return yValue;
|
||||||
}
|
}
|
||||||
public GraphSettings GetGraphSettings()
|
public GraphSettings GetGraphSettings()
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public double MaxArg { get; set; }
|
public double MaxArg { get; set; }
|
||||||
public IShiftTraceLogger? TraceLogger { get; set; }
|
public IShiftTraceLogger? TraceLogger { get; set; }
|
||||||
public Color Color { get; set; }
|
public Color Color { get; set; }
|
||||||
|
public string Trace { get; set; }
|
||||||
|
|
||||||
public TableFunction(bool isUser = false)
|
public TableFunction(bool isUser = false)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="FunctionParser">
|
||||||
|
<HintPath>..\..\FunctionParser\FunctionParser\bin\Debug\FunctionParser.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="LoaderCalculator">
|
<Reference Include="LoaderCalculator">
|
||||||
<HintPath>..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>
|
<HintPath>..\StructureHelper\Libraries\LoaderCalculator.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|||||||
Reference in New Issue
Block a user