Add GraphSettings
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -30,9 +31,19 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public override SeriesCollection GetSeriesCollection()
|
||||
public override GraphSettings GetGraphSettings()
|
||||
{
|
||||
return base.GetSeriesCollection();
|
||||
var graphSettings = base.GetGraphSettings();
|
||||
var graphLimitGraphPoint = new List<GraphPoint>();
|
||||
foreach (GraphPoint point in graphSettings.GraphPoints)
|
||||
{
|
||||
if (point.X > leftBound && point.X < rightBound)
|
||||
{
|
||||
graphLimitGraphPoint.Add(point);
|
||||
}
|
||||
}
|
||||
graphSettings.GraphPoints = graphLimitGraphPoint;
|
||||
return graphSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -10,13 +11,13 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
public class LimYDecorator : FunctionDecorator
|
||||
{
|
||||
private double leftBound;
|
||||
private double rightBound;
|
||||
public LimYDecorator(IOneVariableFunction function, double leftBound, double rightBound) : base(function)
|
||||
private double downBound;
|
||||
private double upBound;
|
||||
public LimYDecorator(IOneVariableFunction function, double downBound, double upBound) : base(function)
|
||||
{
|
||||
Name = $"y\u2208[{leftBound};{rightBound}]";
|
||||
this.leftBound = leftBound;
|
||||
this.rightBound = rightBound;
|
||||
Name = $"y\u2208[{downBound};{upBound}]";
|
||||
this.downBound = downBound;
|
||||
this.upBound = upBound;
|
||||
}
|
||||
public override bool Check()
|
||||
{
|
||||
@@ -25,15 +26,25 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
public override double GetByX(double xValue)
|
||||
{
|
||||
var y = base.GetByX(xValue);
|
||||
if (y > leftBound && y < rightBound)
|
||||
if (y > downBound && y < upBound)
|
||||
{
|
||||
return y;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public override SeriesCollection GetSeriesCollection()
|
||||
public override GraphSettings GetGraphSettings()
|
||||
{
|
||||
return base.GetSeriesCollection();
|
||||
var graphSettings = base.GetGraphSettings();
|
||||
var graphLimitGraphPoint = new List<GraphPoint>();
|
||||
foreach (GraphPoint point in graphSettings.GraphPoints)
|
||||
{
|
||||
if (point.Y > downBound && point.Y < upBound)
|
||||
{
|
||||
graphLimitGraphPoint.Add(point);
|
||||
}
|
||||
}
|
||||
graphSettings.GraphPoints = graphLimitGraphPoint;
|
||||
return graphSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -24,9 +25,14 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
return base.GetByX(factor * xValue);
|
||||
}
|
||||
public override SeriesCollection GetSeriesCollection()
|
||||
public override GraphSettings GetGraphSettings()
|
||||
{
|
||||
return base.GetSeriesCollection();
|
||||
var graphSettings = base.GetGraphSettings();
|
||||
foreach(GraphPoint point in graphSettings.GraphPoints)
|
||||
{
|
||||
point.Y = GetByX(point.X);
|
||||
}
|
||||
return graphSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using LiveCharts;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -24,9 +25,14 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
return factor * base.GetByX(xValue);
|
||||
}
|
||||
public override SeriesCollection GetSeriesCollection()
|
||||
public override GraphSettings GetGraphSettings()
|
||||
{
|
||||
return base.GetSeriesCollection();
|
||||
var graphSettings = base.GetGraphSettings();
|
||||
foreach (GraphPoint point in graphSettings.GraphPoints)
|
||||
{
|
||||
point.Y = GetByX(point.X);
|
||||
}
|
||||
return graphSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Documents;
|
||||
using StructureHelperCommon.Services;
|
||||
using LiveCharts.Wpf;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions
|
||||
{
|
||||
@@ -24,18 +26,6 @@ namespace StructureHelperCommon.Models.Functions
|
||||
public string Name { get; set; }
|
||||
public string Description { get ; set; }
|
||||
public int Step { get; set; }
|
||||
private List<GraphPoint> table;
|
||||
public List<GraphPoint> Table
|
||||
{
|
||||
get
|
||||
{
|
||||
return CalculateTable();
|
||||
}
|
||||
set
|
||||
{
|
||||
table = value;
|
||||
}
|
||||
}
|
||||
public string Formula { get; set; }
|
||||
|
||||
public Guid Id => throw new NotImplementedException();
|
||||
@@ -86,23 +76,19 @@ namespace StructureHelperCommon.Models.Functions
|
||||
public double GetByX(double xValue)
|
||||
{
|
||||
double yValue = 0;
|
||||
yValue = Math.Round(Math.Pow(xValue, 2), 2); //Временное тестовой выражение квадратичной параболы, будет разбор выражения
|
||||
yValue = Math.Round(Math.Pow(xValue, 2), 2); //Временно выражение квадратичной параболы, будет разбор выражения
|
||||
return yValue;
|
||||
}
|
||||
private List<GraphPoint> CalculateTable()
|
||||
public GraphSettings GetGraphSettings()
|
||||
{
|
||||
var table = new List<GraphPoint>();
|
||||
var graphSettings = new GraphSettings(Color, Color);
|
||||
var stepLenght = Math.Abs(MaxArg - MinArg) / Step;
|
||||
for (double x = MinArg; x < MaxArg; x += stepLenght)
|
||||
{
|
||||
var graphPoint = new GraphPoint(x, GetByX(x));
|
||||
table.Add(graphPoint);
|
||||
graphSettings.GraphPoints.Add(graphPoint);
|
||||
}
|
||||
return table;
|
||||
}
|
||||
public SeriesCollection GetSeriesCollection()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return graphSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using System.Windows.Media;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using StructureHelperCommon.Services;
|
||||
|
||||
namespace StructureHelperCommon.Models.Functions
|
||||
{
|
||||
@@ -57,7 +58,6 @@ namespace StructureHelperCommon.Models.Functions
|
||||
public object Clone()
|
||||
{
|
||||
var tableFunction = new TableFunction();
|
||||
|
||||
//Здесь будет стратегия
|
||||
tableFunction.Type = Type;
|
||||
tableFunction.Name = $"{Name} {COPY}";
|
||||
@@ -74,12 +74,20 @@ namespace StructureHelperCommon.Models.Functions
|
||||
{
|
||||
//Реализовать взятие значения из таблицы и интерполяцию по таблице
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
return 100;
|
||||
}
|
||||
|
||||
public SeriesCollection GetSeriesCollection()
|
||||
public GraphSettings GetGraphSettings()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var graphSettings = new GraphSettings(Color, Color);
|
||||
foreach(GraphPoint point in Table)
|
||||
{
|
||||
var graphPoint = new GraphPoint(point.X, GetByX(point.X));
|
||||
graphSettings.GraphPoints.Add(graphPoint);
|
||||
}
|
||||
return graphSettings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user