Add function trace
This commit is contained in:
@@ -43,8 +43,8 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Background="LightYellow"
|
Background="LightYellow"
|
||||||
Text="{Binding Trace, UpdateSourceTrigger=PropertyChanged}"
|
Text="{Binding Trace, UpdateSourceTrigger=PropertyChanged}"
|
||||||
TextAlignment="Center"
|
TextAlignment="Left"
|
||||||
FontSize="20"
|
FontFamily="Cascadia Mono"
|
||||||
TextWrapping="Wrap">
|
TextWrapping="Wrap">
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
public IOneVariableFunction function;
|
public IOneVariableFunction function;
|
||||||
private double argument;
|
private double argument;
|
||||||
private double value;
|
private double value;
|
||||||
private string trace = "Будет логика расчёта";
|
private string trace = "Press \"Get value\" to calculation...\n\n\n";
|
||||||
public IOneVariableFunction Function
|
public IOneVariableFunction Function
|
||||||
{
|
{
|
||||||
get => function;
|
get => function;
|
||||||
@@ -55,7 +55,8 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
private void GetValue()
|
private void GetValue()
|
||||||
{
|
{
|
||||||
Value = Function.GetByX(Argument);
|
Value = Function.GetByX(Argument);
|
||||||
Trace = "трасса";
|
Trace += Function.GetTrace();
|
||||||
|
Trace += "\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
v.DataContext = vm;
|
v.DataContext = vm;
|
||||||
if (v.ShowDialog() == true)
|
if (v.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
SelectedFuntion = new ScaleXDecorator(SelectedFuntion, vm.ScaleFactor);
|
var newFunction = new ScaleXDecorator(SelectedFuntion, vm.ScaleFactor);
|
||||||
var child = new TreeViewItemViewModel(SelectedFuntion, selectedTreeViewItem, this);
|
var child = new TreeViewItemViewModel(newFunction, selectedTreeViewItem, this);
|
||||||
selectedTreeViewItem.Children.Add(child);
|
selectedTreeViewItem.Children.Add(child);
|
||||||
selectedTreeViewItem.IsExpanded = true;
|
selectedTreeViewItem.IsExpanded = true;
|
||||||
}
|
}
|
||||||
@@ -149,8 +149,8 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
v.DataContext = vm;
|
v.DataContext = vm;
|
||||||
if (v.ShowDialog() == true)
|
if (v.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
SelectedFuntion = new ScaleYDecorator(SelectedFuntion, vm.ScaleFactor);
|
var newFunction = new ScaleYDecorator(SelectedFuntion, vm.ScaleFactor);
|
||||||
var child = new TreeViewItemViewModel(SelectedFuntion, selectedTreeViewItem, this);
|
var child = new TreeViewItemViewModel(newFunction, selectedTreeViewItem, this);
|
||||||
selectedTreeViewItem.Children.Add(child);
|
selectedTreeViewItem.Children.Add(child);
|
||||||
selectedTreeViewItem.IsExpanded = true;
|
selectedTreeViewItem.IsExpanded = true;
|
||||||
}
|
}
|
||||||
@@ -176,8 +176,8 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
v.DataContext = vm;
|
v.DataContext = vm;
|
||||||
if (v.ShowDialog() == true)
|
if (v.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
SelectedFuntion = new LimXDecorator(SelectedFuntion, vm.LeftBound, vm.RightBound);
|
var newFunction = new LimXDecorator(SelectedFuntion, vm.LeftBound, vm.RightBound);
|
||||||
var child = new TreeViewItemViewModel(SelectedFuntion, selectedTreeViewItem, this);
|
var child = new TreeViewItemViewModel(newFunction, selectedTreeViewItem, this);
|
||||||
selectedTreeViewItem.Children.Add(child);
|
selectedTreeViewItem.Children.Add(child);
|
||||||
selectedTreeViewItem.IsExpanded = true;
|
selectedTreeViewItem.IsExpanded = true;
|
||||||
}
|
}
|
||||||
@@ -188,8 +188,8 @@ namespace StructureHelper.Windows.TreeGraph
|
|||||||
v.DataContext = vm;
|
v.DataContext = vm;
|
||||||
if (v.ShowDialog() == true)
|
if (v.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
SelectedFuntion = new LimYDecorator(SelectedFuntion, vm.LeftBound, vm.RightBound);
|
var newFunction = new LimYDecorator(SelectedFuntion, vm.LeftBound, vm.RightBound);
|
||||||
var child = new TreeViewItemViewModel(SelectedFuntion, selectedTreeViewItem, this);
|
var child = new TreeViewItemViewModel(newFunction, selectedTreeViewItem, this);
|
||||||
selectedTreeViewItem.Children.Add(child);
|
selectedTreeViewItem.Children.Add(child);
|
||||||
selectedTreeViewItem.IsExpanded = true;
|
selectedTreeViewItem.IsExpanded = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,5 +52,9 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
|||||||
{
|
{
|
||||||
return function.GetGraphSettings();
|
return function.GetGraphSettings();
|
||||||
}
|
}
|
||||||
|
public virtual string GetTrace()
|
||||||
|
{
|
||||||
|
return function.GetTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,5 +30,6 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
|||||||
public bool Check();
|
public bool Check();
|
||||||
public double GetByX(double xValue);
|
public double GetByX(double xValue);
|
||||||
public GraphSettings GetGraphSettings();
|
public GraphSettings GetGraphSettings();
|
||||||
|
public string GetTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using LiveCharts;
|
using FunctionParser;
|
||||||
|
using LiveCharts;
|
||||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||||
using StructureHelperCommon.Services;
|
using StructureHelperCommon.Services;
|
||||||
using System;
|
using System;
|
||||||
@@ -25,11 +26,15 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
|||||||
}
|
}
|
||||||
public override double GetByX(double xValue)
|
public override double GetByX(double xValue)
|
||||||
{
|
{
|
||||||
|
double yValue = 0;
|
||||||
if (xValue >= leftBound && xValue <= rightBound)
|
if (xValue >= leftBound && xValue <= rightBound)
|
||||||
{
|
{
|
||||||
return base.GetByX(xValue);
|
yValue = base.GetByX(xValue);
|
||||||
}
|
}
|
||||||
return 0;
|
Trace = string.Empty;
|
||||||
|
Trace += $"Lim X: {Name}, Input: {xValue}, Output: {xValue};\n";
|
||||||
|
Trace += base.GetTrace();
|
||||||
|
return yValue;
|
||||||
}
|
}
|
||||||
public override GraphSettings GetGraphSettings()
|
public override GraphSettings GetGraphSettings()
|
||||||
{
|
{
|
||||||
@@ -49,5 +54,9 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
|||||||
graphSettings.GraphPoints = graphLimitGraphPoint;
|
graphSettings.GraphPoints = graphLimitGraphPoint;
|
||||||
return graphSettings;
|
return graphSettings;
|
||||||
}
|
}
|
||||||
|
public override string GetTrace()
|
||||||
|
{
|
||||||
|
return Trace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,19 +25,24 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
|||||||
}
|
}
|
||||||
public override double GetByX(double xValue)
|
public override double GetByX(double xValue)
|
||||||
{
|
{
|
||||||
|
double retValue = 0;
|
||||||
var y = base.GetByX(xValue);
|
var y = base.GetByX(xValue);
|
||||||
if (y > downBound && y < upBound)
|
if (y > downBound && y < upBound)
|
||||||
{
|
{
|
||||||
return y;
|
retValue = y;
|
||||||
}
|
}
|
||||||
else if (y <= downBound)
|
else if (y <= downBound)
|
||||||
{
|
{
|
||||||
return downBound;
|
retValue = downBound;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return upBound;
|
retValue = upBound;
|
||||||
}
|
}
|
||||||
|
Trace = string.Empty;
|
||||||
|
Trace += base.GetTrace();
|
||||||
|
Trace += $"Lim Y: {Name}, Input: {y}, Output: {retValue};\n";
|
||||||
|
return retValue;
|
||||||
}
|
}
|
||||||
public override GraphSettings GetGraphSettings()
|
public override GraphSettings GetGraphSettings()
|
||||||
{
|
{
|
||||||
@@ -65,5 +70,9 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
|||||||
graphSettings.GraphPoints = graphLimitGraphPoint;
|
graphSettings.GraphPoints = graphLimitGraphPoint;
|
||||||
return graphSettings;
|
return graphSettings;
|
||||||
}
|
}
|
||||||
|
public override string GetTrace()
|
||||||
|
{
|
||||||
|
return Trace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,12 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
|||||||
}
|
}
|
||||||
public override double GetByX(double xValue)
|
public override double GetByX(double xValue)
|
||||||
{
|
{
|
||||||
return base.GetByX(factor * xValue);
|
double yValue = base.GetByX(factor * xValue);
|
||||||
|
Trace = string.Empty;
|
||||||
|
Trace += $"Scale X: {Name}, Input: {xValue}, Output: {factor * xValue};\n";
|
||||||
|
Trace += base.GetTrace();
|
||||||
|
return yValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
public override GraphSettings GetGraphSettings()
|
public override GraphSettings GetGraphSettings()
|
||||||
{
|
{
|
||||||
@@ -34,5 +39,9 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
|||||||
}
|
}
|
||||||
return graphSettings;
|
return graphSettings;
|
||||||
}
|
}
|
||||||
|
public override string GetTrace()
|
||||||
|
{
|
||||||
|
return Trace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,13 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
|||||||
}
|
}
|
||||||
public override double GetByX(double xValue)
|
public override double GetByX(double xValue)
|
||||||
{
|
{
|
||||||
return factor * base.GetByX(xValue);
|
double functionValue = base.GetByX(xValue);
|
||||||
|
double yValue = factor * functionValue;
|
||||||
|
Trace = string.Empty;
|
||||||
|
Trace += base.GetTrace();
|
||||||
|
Trace += $"Scale Y: {Name}, Input: {functionValue}, Output: {yValue};\n";
|
||||||
|
return yValue;
|
||||||
|
|
||||||
}
|
}
|
||||||
public override GraphSettings GetGraphSettings()
|
public override GraphSettings GetGraphSettings()
|
||||||
{
|
{
|
||||||
@@ -34,5 +40,9 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
|||||||
}
|
}
|
||||||
return graphSettings;
|
return graphSettings;
|
||||||
}
|
}
|
||||||
|
public override string GetTrace()
|
||||||
|
{
|
||||||
|
return Trace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,8 +85,6 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
var formulaFunction = new FormulaFunction();
|
var formulaFunction = new FormulaFunction();
|
||||||
|
|
||||||
//Здесь будет стратегия
|
|
||||||
formulaFunction.Type = Type;
|
formulaFunction.Type = Type;
|
||||||
formulaFunction.Name = $"{Name} {COPY}";
|
formulaFunction.Name = $"{Name} {COPY}";
|
||||||
formulaFunction.Description = Description;
|
formulaFunction.Description = Description;
|
||||||
@@ -104,6 +102,8 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
double yValue = 0;
|
double yValue = 0;
|
||||||
current_xValue = xValue;
|
current_xValue = xValue;
|
||||||
yValue = Math.Round(Expression.CalculateValue(new double[] { xValue }), 2);
|
yValue = Math.Round(Expression.CalculateValue(new double[] { xValue }), 2);
|
||||||
|
Trace = string.Empty;
|
||||||
|
Trace += $"Function: {Formula}, Input: {xValue}, Output: {yValue};\n";
|
||||||
return yValue;
|
return yValue;
|
||||||
}
|
}
|
||||||
public GraphSettings GetGraphSettings()
|
public GraphSettings GetGraphSettings()
|
||||||
@@ -117,5 +117,9 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
}
|
}
|
||||||
return graphSettings;
|
return graphSettings;
|
||||||
}
|
}
|
||||||
|
public string GetTrace()
|
||||||
|
{
|
||||||
|
return Trace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
public object Clone()
|
public object Clone()
|
||||||
{
|
{
|
||||||
var tableFunction = new TableFunction();
|
var tableFunction = new TableFunction();
|
||||||
//Здесь будет стратегия
|
|
||||||
tableFunction.Type = Type;
|
tableFunction.Type = Type;
|
||||||
tableFunction.Name = $"{Name} {COPY}";
|
tableFunction.Name = $"{Name} {COPY}";
|
||||||
tableFunction.Description = Description;
|
tableFunction.Description = Description;
|
||||||
@@ -73,6 +72,7 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
|
|
||||||
public double GetByX(double xValue)
|
public double GetByX(double xValue)
|
||||||
{
|
{
|
||||||
|
double yValue = 0;
|
||||||
GraphPoint leftBound = null;
|
GraphPoint leftBound = null;
|
||||||
GraphPoint rightBound = null;
|
GraphPoint rightBound = null;
|
||||||
for (int i = 0; i < Table.Count - 1; i++)
|
for (int i = 0; i < Table.Count - 1; i++)
|
||||||
@@ -81,18 +81,20 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
rightBound = Table[i + 1];
|
rightBound = Table[i + 1];
|
||||||
if (xValue == leftBound.X)
|
if (xValue == leftBound.X)
|
||||||
{
|
{
|
||||||
return leftBound.Y;
|
yValue = leftBound.Y;
|
||||||
}
|
}
|
||||||
else if (xValue == rightBound.X)
|
else if (xValue == rightBound.X)
|
||||||
{
|
{
|
||||||
return rightBound.Y;
|
yValue = rightBound.Y;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return MathUtils.Interpolation(xValue, leftBound.X, rightBound.X, leftBound.Y, rightBound.Y);
|
yValue = MathUtils.Interpolation(xValue, leftBound.X, rightBound.X, leftBound.Y, rightBound.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
Trace = string.Empty;
|
||||||
|
Trace += $"From table, Input: {xValue}, Output: {yValue};\n";
|
||||||
|
return yValue;
|
||||||
}
|
}
|
||||||
public GraphSettings GetGraphSettings()
|
public GraphSettings GetGraphSettings()
|
||||||
{
|
{
|
||||||
@@ -104,5 +106,9 @@ namespace StructureHelperCommon.Models.Functions
|
|||||||
}
|
}
|
||||||
return graphSettings;
|
return graphSettings;
|
||||||
}
|
}
|
||||||
|
public string GetTrace()
|
||||||
|
{
|
||||||
|
return Trace;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,18 +44,5 @@ namespace StructureHelperCommon.Services
|
|||||||
_lineSeries.Fill = Brushes.Transparent;
|
_lineSeries.Fill = Brushes.Transparent;
|
||||||
return _lineSeries;
|
return _lineSeries;
|
||||||
}
|
}
|
||||||
/*public SeriesCollection GetSeriesCollection()
|
|
||||||
{
|
|
||||||
foreach (GraphPoint point in GraphPoints)
|
|
||||||
{
|
|
||||||
_chartValues.Add(Math.Round(point.Y, 2));
|
|
||||||
}
|
|
||||||
_lineSeries.Values = _chartValues;
|
|
||||||
_lineSeries.Stroke = new SolidColorBrush(_strokeColor);
|
|
||||||
|
|
||||||
_lineSeries.Fill = Brushes.Transparent;
|
|
||||||
_seriesCollection.Add(_lineSeries);
|
|
||||||
return _seriesCollection;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user