-
Notifications
You must be signed in to change notification settings - Fork 2
/
PlotResults.cs
158 lines (141 loc) · 8.78 KB
/
PlotResults.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Media;
using LiveCharts;
using LiveCharts.Configurations;
using LiveCharts.Defaults;
using LiveCharts.WinForms;
namespace SectionCutter
{
class PlotResults
{
public PlotResults () { }
//listResults is all of the gathered F1,F2, F3, M1... from each load step.
//SelectedObjects = load steps you want to plot
//range of values = the coordinates of where the cut is located.
//shear chart = cartiesian chart for chart of interest
public static void GraphShearResults(List<SectionResults> listResults, List<string> SelectedObjects, double[] rangeofvalues, LiveCharts.WinForms.CartesianChart shearChart, int givenIndex)
{
// Define your DangerBrush
shearChart.Series.Clear();
SolidColorBrush DangerBrush = new SolidColorBrush(Color.FromRgb(255,215, 0));
if (SelectedObjects.Count <= 1)
{
List<ChartValues<LiveCharts.Defaults.ObservablePoint>> plottingPoints = new List<ChartValues<LiveCharts.Defaults.ObservablePoint>>();
for (int i = 0; i < SelectedObjects.Count; i++)
{
ChartValues<LiveCharts.Defaults.ObservablePoint> shearPoints = new LiveCharts.ChartValues<LiveCharts.Defaults.ObservablePoint>();
for (int j = 0; j < listResults[0].F1.Length; j++)
{
shearPoints.Add(new LiveCharts.Defaults.ObservablePoint { X = rangeofvalues[j], Y = listResults[0].F1[j] });
}
var scatterShearSeries = new LiveCharts.Wpf.LineSeries
{
Title = listResults[0].LoadDirection, //this will need to be written, map to name of load case selected.
Values = shearPoints,
Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 140, 105)),
Fill = System.Windows.Media.Brushes.Transparent,
};
var Mapper = Mappers.Xy<ObservablePoint>()
.X((value, index) => value.X) // Keep the X value unchanged
.Y((value, index) => value.Y) // Keep the Y value unchanged
.Fill((value, index) => index == givenIndex ? DangerBrush : null)
.Stroke((value, index) => index == givenIndex ? DangerBrush : null);
scatterShearSeries.Configuration = Mapper;
//shearChart.Series.Clear();
shearChart.Series.Add(scatterShearSeries);
}
}
else
{
List<ChartValues<LiveCharts.Defaults.ObservablePoint>> plottingPoints = new List<ChartValues<LiveCharts.Defaults.ObservablePoint>>();
for (int i = 0; i < SelectedObjects.Count; i++)
{
int mySelectedDirection = 0;
mySelectedDirection = listResults.FindIndex(x => x.LoadDirection == SelectedObjects[i]);
ChartValues<LiveCharts.Defaults.ObservablePoint> shearPoints = new LiveCharts.ChartValues<LiveCharts.Defaults.ObservablePoint>();
for (int j = 0; j < listResults[mySelectedDirection].F1.Length; j++)
{
shearPoints.Add(new LiveCharts.Defaults.ObservablePoint { X = rangeofvalues[j], Y = listResults[mySelectedDirection].F1[j] });
}
var scatterShearSeries = new LiveCharts.Wpf.LineSeries
{
Title = listResults[mySelectedDirection].LoadDirection, //this will need to be written, map to name of load case selected.
Values = shearPoints,
Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 140, 105)),
Fill = System.Windows.Media.Brushes.Transparent,
};
var Mapper = Mappers.Xy<ObservablePoint>()
.X((value, index) => value.X) // Keep the X value unchanged
.Y((value, index) => value.Y) // Keep the Y value unchanged
.Fill((value, index) => index == givenIndex ? DangerBrush : null)
.Stroke((value, index) => index == givenIndex ? DangerBrush : null);
scatterShearSeries.Configuration = Mapper;
shearChart.Series.Add(scatterShearSeries);
}
}
}
public static void GraphMomentResults(List<SectionResults> listResults, List<string> SelectedObjects, double[] rangeofvalues, LiveCharts.WinForms.CartesianChart momentChart, int givenIndex)
{
momentChart.Series.Clear();
SolidColorBrush DangerBrush = new SolidColorBrush(Color.FromRgb(255, 215, 0));
if (SelectedObjects.Count <= 1)
{
List<ChartValues<LiveCharts.Defaults.ObservablePoint>> plottingPoints = new List<ChartValues<LiveCharts.Defaults.ObservablePoint>>();
for (int i = 0; i < SelectedObjects.Count; i++)
{
ChartValues<LiveCharts.Defaults.ObservablePoint> momentPoints = new LiveCharts.ChartValues<LiveCharts.Defaults.ObservablePoint>();
for (int j = 0; j < listResults[0].F1.Length; j++)
{
momentPoints.Add(new LiveCharts.Defaults.ObservablePoint { X = rangeofvalues[j], Y = listResults[0].M3[j] });
}
var scatterShearSeries = new LiveCharts.Wpf.LineSeries
{
Title = listResults[0].LoadDirection, //this will need to be written, map to name of load case selected.
Values = momentPoints,
Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 140, 105)),
Fill = System.Windows.Media.Brushes.Transparent,
};
var Mapper = Mappers.Xy<ObservablePoint>()
.X((value, index) => value.X) // Keep the X value unchanged
.Y((value, index) => value.Y) // Keep the Y value unchanged
.Fill((value, index) => index == givenIndex ? DangerBrush : null)
.Stroke((value, index) => index == givenIndex ? DangerBrush : null);
scatterShearSeries.Configuration = Mapper;
momentChart.Series.Add(scatterShearSeries);
}
}
else
{
List<ChartValues<LiveCharts.Defaults.ObservablePoint>> plottingPoints = new List<ChartValues<LiveCharts.Defaults.ObservablePoint>>();
for (int i = 0; i < SelectedObjects.Count; i++)
{
int mySelectedDirection = listResults.FindIndex(x => x.LoadDirection == SelectedObjects[i]);
ChartValues<LiveCharts.Defaults.ObservablePoint> momentPoints = new LiveCharts.ChartValues<LiveCharts.Defaults.ObservablePoint>();
for (int j = 0; j < listResults[mySelectedDirection].F1.Length; j++)
{
momentPoints.Add(new LiveCharts.Defaults.ObservablePoint { X = rangeofvalues[j], Y = listResults[mySelectedDirection].M3[j] });
}
var scatterShearSeries = new LiveCharts.Wpf.LineSeries
{
Title = listResults[mySelectedDirection].LoadDirection, //this will need to be written, map to name of load case selected.
Values = momentPoints,
Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 140, 105)),
Fill = System.Windows.Media.Brushes.Transparent,
};
var Mapper = Mappers.Xy<ObservablePoint>()
.X((value, index) => value.X) // Keep the X value unchanged
.Y((value, index) => value.Y) // Keep the Y value unchanged
.Fill((value, index) => index == givenIndex ? DangerBrush : null)
.Stroke((value, index) => index == givenIndex ? DangerBrush : null);
scatterShearSeries.Configuration = Mapper;
momentChart.Series.Add(scatterShearSeries);
}
}
}
}
}