Binding function tree
This commit is contained in:
@@ -177,6 +177,7 @@ namespace StructureHelper.Windows.MainGraph
|
||||
Function = new FormulaFunction(isUser: true);
|
||||
}
|
||||
Function.Name = Name;
|
||||
Function.FullName = Name;
|
||||
Function.Description = Description;
|
||||
Function.IsUser = true;
|
||||
(Function as FormulaFunction).Step = Step;
|
||||
|
||||
@@ -141,6 +141,7 @@ namespace StructureHelper.Windows.MainGraph
|
||||
Function = new TableFunction(isUser: true);
|
||||
}
|
||||
Function.Name = Name;
|
||||
Function.FullName = Name;
|
||||
Function.Description = Description;
|
||||
Function.IsUser = true;
|
||||
(Function as TableFunction).Table = Table.OrderBy(x => x.X).ToList();
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TreeView Name="FunctionTreeView"
|
||||
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
Margin="5"
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
private LineSeries lineSeries;
|
||||
private SeriesCollection seriesCollection;
|
||||
private List<string> labels;
|
||||
readonly ObservableCollection<TreeViewItemViewModel> _tree;
|
||||
readonly TreeViewItemViewModel _root;
|
||||
private ObservableCollection<TreeViewItemViewModel> _tree;
|
||||
private TreeViewItemViewModel _root;
|
||||
readonly ICommand _searchCommand;
|
||||
private RelayCommand _getYCommand;
|
||||
private RelayCommand _scaleCommand;
|
||||
@@ -96,6 +96,11 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
public ObservableCollection<TreeViewItemViewModel> Tree
|
||||
{
|
||||
get => _tree;
|
||||
set
|
||||
{
|
||||
_tree = value;
|
||||
OnPropertyChanged(nameof(Tree));
|
||||
}
|
||||
}
|
||||
public GraphVisualProps VisualProps { get; } = new GraphVisualProps();
|
||||
public ICommand GetYCommand
|
||||
@@ -129,8 +134,12 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
public TreeGraphViewModel(IOneVariableFunction rootFunction)
|
||||
{
|
||||
RootFunction = rootFunction;
|
||||
RunTreeView(rootFunction);
|
||||
}
|
||||
private void RunTreeView(IOneVariableFunction rootFunction)
|
||||
{
|
||||
_root = new TreeViewItemViewModel(rootFunction, this);
|
||||
_tree = new ObservableCollection<TreeViewItemViewModel>
|
||||
Tree = new ObservableCollection<TreeViewItemViewModel>
|
||||
(
|
||||
new ObservableCollection<TreeViewItemViewModel>()
|
||||
{
|
||||
@@ -189,6 +198,7 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
return;
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void Limit(object parameter)
|
||||
{
|
||||
@@ -228,6 +238,7 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
return;
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void Delete()
|
||||
{
|
||||
@@ -242,6 +253,7 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
return;
|
||||
}
|
||||
selectedTreeViewItemParent.Children.Remove(selectedTreeViewItem);
|
||||
Save();
|
||||
}
|
||||
private void Rename(object parameter)
|
||||
{
|
||||
@@ -262,6 +274,7 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
{
|
||||
selectedTreeViewItem.Name = renameViewModel.FunctionName;
|
||||
}
|
||||
Save();
|
||||
}
|
||||
private void NewTree()
|
||||
{
|
||||
@@ -274,7 +287,8 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
treeGraph.DataContext = treeGraphVM;
|
||||
treeGraphVM.TreeGraphView_win = treeGraph;
|
||||
treeGraph.ShowDialog();
|
||||
//Сохранить поддерево
|
||||
Save();
|
||||
RunTreeView(RootFunction);
|
||||
}
|
||||
public void DrawGraph()
|
||||
{
|
||||
@@ -297,13 +311,24 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
}
|
||||
public void Save()
|
||||
{
|
||||
|
||||
|
||||
|
||||
GetFunctionTree(Tree, RootFunction);
|
||||
}
|
||||
private List<IOneVariableFunction> GetFunctionChildern(TreeViewItemViewModel item)
|
||||
private void GetFunctionTree(ObservableCollection<TreeViewItemViewModel> tree, IOneVariableFunction function)
|
||||
{
|
||||
return null;
|
||||
function.Functions.Clear();
|
||||
foreach (TreeViewItemViewModel item in tree)
|
||||
{
|
||||
if (item.Function is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
function.Functions.Add(item.Function);
|
||||
if (item.Children.Count > 0)
|
||||
{
|
||||
var newTree = item.Children;
|
||||
GetFunctionTree(newTree, item.Function);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace StructureHelper.Windows.TreeGraph
|
||||
readonly IOneVariableFunction _function;
|
||||
readonly TreeGraphViewModel _treeGraphViewModel;
|
||||
|
||||
bool _isExpanded;
|
||||
bool _isExpanded = true;
|
||||
bool _isSelected;
|
||||
|
||||
public TreeViewItemViewModel(IOneVariableFunction function, TreeGraphViewModel treeGraphViewModel) : this(function, null, treeGraphViewModel)
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
public FunctionType Type { get; set; }
|
||||
public FunctionPurpose FunctionPurpose { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public List<GraphPoint> Table { get; set; }
|
||||
public double MinArg { get; set; }
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace StructureHelperCommon.Infrastructures.Interfaces
|
||||
public FunctionType Type { get; set; }
|
||||
public FunctionPurpose FunctionPurpose { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public double MinArg { get; set; }
|
||||
public double MaxArg { get; set; }
|
||||
|
||||
@@ -99,6 +99,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
|
||||
new TableFunction()
|
||||
{
|
||||
Name = "Not StressStrain",
|
||||
FullName = "Not StressStrain",
|
||||
FunctionPurpose = FunctionPurpose.FireProtection,
|
||||
Table = new List<GraphPoint>()
|
||||
{
|
||||
@@ -115,6 +116,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
|
||||
new TableFunction()
|
||||
{
|
||||
Name = "Табличная системная функция",
|
||||
FullName = "Табличная системная функция",
|
||||
FunctionPurpose = FunctionPurpose.StressStrain,
|
||||
Table = new List<GraphPoint>()
|
||||
{
|
||||
@@ -131,6 +133,7 @@ namespace StructureHelperCommon.Infrastructures.Settings
|
||||
new FormulaFunction()
|
||||
{
|
||||
Name = "Формульная системная функция",
|
||||
FullName = "Формульная системная функция",
|
||||
FunctionPurpose = FunctionPurpose.StressStrain,
|
||||
Formula = "x^2",
|
||||
Step = 100,
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
public LimXDecorator(IOneVariableFunction function, double leftBound, double rightBound) : base(function)
|
||||
{
|
||||
Name = $"x\u2208[{leftBound};{rightBound}]";
|
||||
FullName = $"{function.FullName}/{Name}";
|
||||
this.leftBound = leftBound;
|
||||
this.rightBound = rightBound;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
public LimYDecorator(IOneVariableFunction function, double downBound, double upBound) : base(function)
|
||||
{
|
||||
Name = $"y\u2208[{downBound};{upBound}]";
|
||||
FullName = $"{function.FullName}/{Name}";
|
||||
this.downBound = downBound;
|
||||
this.upBound = upBound;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
this.factor = factor;
|
||||
Name = $"y=f({factor}x)";
|
||||
FullName = $"{function.FullName}/{Name}";
|
||||
}
|
||||
public override bool Check()
|
||||
{
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace StructureHelperCommon.Models.Functions.Decorator
|
||||
{
|
||||
this.factor = factor;
|
||||
Name = $"y={factor}f(x)";
|
||||
FullName = $"{function.FullName}/{Name}";
|
||||
}
|
||||
public override bool Check()
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace StructureHelperCommon.Models.Functions
|
||||
public FunctionPurpose FunctionPurpose { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Description { get ; set; }
|
||||
public int Step { get; set; }
|
||||
public string Formula
|
||||
@@ -88,6 +89,7 @@ namespace StructureHelperCommon.Models.Functions
|
||||
var formulaFunction = new FormulaFunction();
|
||||
formulaFunction.Type = Type;
|
||||
formulaFunction.Name = $"{Name} {COPY}";
|
||||
formulaFunction.FullName = formulaFunction.Name;
|
||||
formulaFunction.Description = Description;
|
||||
formulaFunction.Formula = Formula;
|
||||
formulaFunction.IsUser = true;
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace StructureHelperCommon.Models.Functions
|
||||
public FunctionPurpose FunctionPurpose { get; set; }
|
||||
public string Group { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string FullName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public List<GraphPoint> Table { get; set; }
|
||||
public Guid Id => throw new NotImplementedException();
|
||||
@@ -62,6 +63,7 @@ namespace StructureHelperCommon.Models.Functions
|
||||
var tableFunction = new TableFunction();
|
||||
tableFunction.Type = Type;
|
||||
tableFunction.Name = $"{Name} {COPY}";
|
||||
tableFunction.FullName = tableFunction.Name;
|
||||
tableFunction.Description = Description;
|
||||
var newTable = new List<GraphPoint>();
|
||||
Table.ForEach(x => newTable.Add(x.Clone() as GraphPoint));
|
||||
@@ -71,7 +73,6 @@ namespace StructureHelperCommon.Models.Functions
|
||||
tableFunction.FunctionPurpose = FunctionPurpose;
|
||||
return tableFunction;
|
||||
}
|
||||
|
||||
public double GetByX(double xValue)
|
||||
{
|
||||
double yValue = 0;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StructureHelperCommon.Infrastructures.Commands;
|
||||
using LiveCharts.Wpf;
|
||||
using StructureHelperCommon.Infrastructures.Commands;
|
||||
using StructureHelperCommon.Infrastructures.Interfaces;
|
||||
using StructureHelperCommon.Infrastructures.Settings;
|
||||
using StructureHelperCommon.Models.Functions;
|
||||
@@ -27,7 +28,7 @@ namespace StructureHelperCommon.Windows
|
||||
public string SPECIAL { get; } = "Special Limit State";
|
||||
public string CREATE_MATERIAL { get; } = "Create Function Material";
|
||||
private const string ERROR_TEXT_1 = "Not all material states have functions ";
|
||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; }
|
||||
public ObservableCollection<IOneVariableFunction> Functions { get; set; } = new ObservableCollection<IOneVariableFunction>();
|
||||
public IOneVariableFunction Func_ST_ULS { get; set; }
|
||||
public IOneVariableFunction Func_ST_SLS { get; set; }
|
||||
public IOneVariableFunction Func_ST_Special { get; set; }
|
||||
@@ -37,8 +38,23 @@ namespace StructureHelperCommon.Windows
|
||||
public FunctionStorage FunctionStorage { get; set; } = new();
|
||||
public FunctionSelectionVM()
|
||||
{
|
||||
var listFunctions = ProgramSetting.Functions.Where(x => x.FunctionPurpose == Infrastructures.Enums.FunctionPurpose.StressStrain).ToList();
|
||||
Functions = new ObservableCollection<IOneVariableFunction>();
|
||||
var stressStrainFunctions = new ObservableCollection<IOneVariableFunction>
|
||||
(
|
||||
ProgramSetting.Functions
|
||||
.Where(x => x.FunctionPurpose == Infrastructures.Enums.FunctionPurpose.StressStrain)
|
||||
);
|
||||
GetFunctionsFromTree(stressStrainFunctions);
|
||||
}
|
||||
private void GetFunctionsFromTree(ObservableCollection<IOneVariableFunction> stressStrainFunctions)
|
||||
{
|
||||
foreach (IOneVariableFunction func in stressStrainFunctions)
|
||||
{
|
||||
Functions.Add(func);
|
||||
if (func.Functions.Count > 0)
|
||||
{
|
||||
GetFunctionsFromTree(func.Functions);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void CreateFunctionMaterial(object parameter)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</Style>
|
||||
<Style x:Key="FuncComboBox" TargetType="ComboBox">
|
||||
<Setter Property="ItemsSource" Value="{Binding Functions}"/>
|
||||
<Setter Property="DisplayMemberPath" Value="Name"/>
|
||||
<Setter Property="DisplayMemberPath" Value="FullName"/>
|
||||
<Setter Property="Margin" Value="10"/>
|
||||
</Style>
|
||||
</Window.Resources>
|
||||
|
||||
Reference in New Issue
Block a user