ScaleXDecorator done

This commit is contained in:
Иван Ивашкин
2024-10-29 23:58:25 +05:00
parent 2738b1b7b3
commit 49d04c7bcc
18 changed files with 173 additions and 78 deletions

View File

@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="StructureHelperCommon.Models.Functions.TableFunction" BaseTypeListCollapsed="true">
<Position X="3" Y="3" Width="1.5" />
<Position X="3" Y="5.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAgAAAAAAAAAAAAAAAQAAAAIAAAAAQAAAAAAAAA=</HashCode>
<HashCode>BAACgEgAAAAgACIAAAAAQAYAAAAMAAAAAQAAAAAAgBA=</HashCode>
<FileName>Models\Functions\TableFunction.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="StructureHelperCommon.Models.Functions.FormulaFunction" BaseTypeListCollapsed="true">
<Position X="1.25" Y="3" Width="1.5" />
<Position X="1.25" Y="5.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAgAAAAAAAAAAAAAAAQAAAAIAAAAAQAAAAAAAAA=</HashCode>
<HashCode>BAACgEgAAAAgACJAAgAAQAYAAAAIBAAAIQAAAAAAgBA=</HashCode>
<FileName>Models\Functions\FormulaFunction.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
@@ -19,30 +19,9 @@
<Interface Name="StructureHelperCommon.Infrastructures.Interfaces.IOneVariableFunction">
<Position X="2" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAgAAAAAAAAAAAAAAAQAAAAIAAAAAQAAAAAAAAA=</HashCode>
<HashCode>BAAAgEgAAAAgACAAAAAAQAYAAAAIAAAAAQAAAAAAgAA=</HashCode>
<FileName>Infrastructures\Interfaces\IOneVariableFunction.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="StructureHelperCommon.Models.Functions.IScaleFunction">
<Position X="7.75" Y="3" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Models\Functions\IScaleFunction.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="StructureHelperCommon.Models.Functions.ILimitFunction">
<Position X="5.75" Y="3" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Models\Functions\ILimitFunction.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="StructureHelperCommon.Infrastructures.Interfaces.IFunctionDecorator">
<Position X="6.25" Y="0.5" Width="2.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Infrastructures\Interfaces\IFunctionDecorator.cs</FileName>
</TypeIdentifier>
</Interface>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -0,0 +1,46 @@
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Models;
using StructureHelperCommon.Models.Functions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public abstract class FunctionDecorator : IOneVariableFunction
{
protected IOneVariableFunction function;
public bool IsUser { get; set; }
public string Group { get; set; }
public FunctionType Type { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public List<GraphPoint> Table { get; set; }
public double MinArg { get; set; }
public double MaxArg { get; set; }
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>();
public Guid Id => throw new NotImplementedException();
public IShiftTraceLogger? TraceLogger { get; set; }
public FunctionDecorator(IOneVariableFunction function)
{
this.function = function;
}
public virtual bool Check()
{
return function.Check();
}
public virtual object Clone()
{
return function.Clone();
}
public virtual double GetByX(double xValue)
{
return function.GetByX(xValue);
}
}
}

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IFunctionDecorator
{
public IOneVariableFunction OneVariableFunction { get; }
}
}

View File

@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace StructureHelperCommon.Infrastructures.Interfaces
{
public interface IOneVariableFunction : ICloneable, ISaveable
public interface IOneVariableFunction : ICloneable, ISaveable, ILogic
{
public const string GROUP_TYPE_1 = "System function";
public const string GROUP_TYPE_2 = "User function";

View File

@@ -0,0 +1,32 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Functions.Decorator
{
public class LimXDecorator : FunctionDecorator
{
private double leftBound;
private double rightBound;
public LimXDecorator(IOneVariableFunction function, double leftBound, double rightBound) : base(function)
{
this.leftBound = leftBound;
this.rightBound = rightBound;
}
public override bool Check()
{
return base.Check();
}
public override double GetByX(double xValue)
{
if (xValue > leftBound && xValue < rightBound)
{
return base.GetByX(xValue);
}
return 0;
}
}
}

View File

@@ -0,0 +1,27 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Functions.Decorator
{
public class ScaleXDecorator : FunctionDecorator
{
private double factor;
public ScaleXDecorator(IOneVariableFunction function, double factor) : base(function)
{
this.factor = factor;
Name = $"{function.Name}, y=f({factor}x)";
}
public override bool Check()
{
return base.Check();
}
public override double GetByX(double xValue)
{
return base.GetByX(factor * xValue);
}
}
}

View File

@@ -41,6 +41,7 @@ namespace StructureHelperCommon.Models.Functions
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>();
public double MinArg { get; set; }
public double MaxArg { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public FormulaFunction(bool isUser = false)
{

View File

@@ -1,14 +0,0 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Functions
{
public interface ILimitFunction : IFunctionDecorator
{
public void Limit();
}
}

View File

@@ -1,14 +0,0 @@
using StructureHelperCommon.Infrastructures.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Models.Functions
{
public interface IScaleFunction : IFunctionDecorator
{
public void Scale();
}
}

View File

@@ -29,6 +29,7 @@ namespace StructureHelperCommon.Models.Functions
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>();
public double MinArg { get; set; }
public double MaxArg { get; set; }
public IShiftTraceLogger? TraceLogger { get; set; }
public TableFunction(bool isUser = false)
{
@@ -68,7 +69,9 @@ namespace StructureHelperCommon.Models.Functions
public double GetByX(double xValue)
{
throw new NotImplementedException();
//Реализовать взятие значения из таблицы и интерполяцию по таблице
return 100;
}
}
}