Skip to content

Commit

Permalink
New Settings for ROI Corners and Button Opacity
Browse files Browse the repository at this point in the history
 Tracker Box Style;
 Average Coherence Value
 Fixing Freq Analysis Export
 CoM Values Export with Timestamped File Names
 Last Selected Tab in Spectral Analysis
  • Loading branch information
tesar-tech committed Jan 1, 2024
1 parent 48c725d commit 60a7eac
Show file tree
Hide file tree
Showing 17 changed files with 405 additions and 225 deletions.
7 changes: 7 additions & 0 deletions NoApp/LongTimeNoTouch.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,10 @@ Usual issues when updating TremAn app after longer period of time.
- Micorosoft Entra application
- Click on the item, genereate new secret
- Paste the secrete into Client Secret and password on Project settings-> Service connections -> NaWinDevCenter

## The package "apppxbundle" is taking a long time to process.

- In dashboard under submission, under packages with error.
- Dont understand it, but when I "refresh" the store association on the app it works:
https://stackoverflow.com/a/62310133/1154773

7 changes: 2 additions & 5 deletions TremAn3.Core/Results.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ namespace TremAn3.Core
/// </summary>
public class Results
{

//public List<double> FreqProgress { get; set; } = new List<double>();
//public List<double> FreqProgressTime { get; set; }

public void SetComXAndFrameTimes(List<double> comx, List<double> frametimes)
{
{
ComX = comx;
FrameTimes = frametimes.Select(x => TimeSpan.FromSeconds(x)).ToList();
}
Expand All @@ -36,7 +35,6 @@ public void SetComY(List<double> comy)
//public ResultsModel ResultsModel { get; set; } = new ResultsModel();

public Dictionary<DataSeriesType, DataResult> DataResultsDict { get; set; } = new Dictionary<DataSeriesType, DataResult>();

}

public class DataResult
Expand All @@ -50,7 +48,6 @@ public class DataResult
}
public enum DataSeriesType
{
Psd, ComX, ComY, AmpSpec, FreqProgress, Coherence,Welch
Psd = 0, ComX = 1, ComY = 2, AmpSpec = 3, FreqProgress = 4, Coherence = 5, Welch = 6
}

}
4 changes: 3 additions & 1 deletion TremAn3/Helpers/StaticConverters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public static double SpectralAnalysisBiggerToggleToSizeOfPlot(bool? IsChecked)
}

public static string DoubleDoubleToStringPercent(double val) => $"{val:00.00} % ";


public static string DoubleFormatter(double val) => $"{val:0.00}";




Expand Down
40 changes: 23 additions & 17 deletions TremAn3/Services/ExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using System.Threading.Tasks;
using ViewModels;

public class ExportService
public class ExportService
{
public async void ExportComValuesAsync()
public async void ExportComValuesAsync()
{
var rois = ViewModelLocator.Current.DrawingRectanglesViewModel.SelectionRectanglesViewModels.Where(x => x.IsShowInPlot && x.ComputationViewModel.HasResult).ToList();
if (rois.Count == 0)
Expand Down Expand Up @@ -43,11 +43,12 @@ public async void ExportComValuesAsync()
headers: yHeaders.Prepend("time[s]"));

var mainViewModel = ViewModelLocator.Current.MainViewModel;
var name = $"{mainViewModel.MediaPlayerViewModel.VideoPropsViewModel.DisplayName}_CoM_Values";
var name = $"{mainViewModel.MediaPlayerViewModel.VideoPropsViewModel.DisplayName}_" +
$"{ViewModelLocator.Current.PastMeasurementsViewModel.SelectedMeasurementVm.DateTime:yyyy-MM-dd_HH-mm-ss}_CoM_Values";
var (status, newName) = await CsvExport.ExportStringAsCsvAsync(str, name);
mainViewModel.NotifyBasedOnStatus(status, newName);
}
public async Task ExportFreqAnalysisToCsvAsync()
public async Task ExportFreqAnalysisToCsvAsync()
{
var rois = ViewModelLocator.Current.DrawingRectanglesViewModel.SelectionRectanglesViewModels.Where(x => x.IsShowInPlot && x.ComputationViewModel.HasResult).ToList();

Expand All @@ -57,29 +58,34 @@ public async Task ExportFreqAnalysisToCsvAsync()
return;
}

List<List<double>> values = new();
List<string> headers = new();
List<List<double>> values = [];
List<string> headers = [];

foreach (var dataSeriesType in new List<DataSeriesType>
{
DataSeriesType.Psd, DataSeriesType.AmpSpec, DataSeriesType.Welch, DataSeriesType.FreqProgress
})
List<DataSeriesType> toExportDataSeries = [DataSeriesType.Psd, DataSeriesType.AmpSpec, DataSeriesType.Welch, DataSeriesType.FreqProgress];
foreach (var dataSeriesType in toExportDataSeries)
{
var xValues = rois[0].ComputationViewModel.Algorithm.Results.DataResultsDict[dataSeriesType].X;
values.Add(xValues);
var roi0DataResult = rois[0].ComputationViewModel.Algorithm.Results.DataResultsDict[dataSeriesType];
if(!roi0DataResult.IsOk) continue;
values.Add(roi0DataResult.X);
headers.Add($"freq[Hz]_{dataSeriesType}");
foreach (var roi in rois)
{
var yValues = roi.ComputationViewModel.Algorithm.Results.DataResultsDict[dataSeriesType].Y;
List<double> yValues = roi.ComputationViewModel.Algorithm.Results.DataResultsDict[dataSeriesType].Y;
values.Add(yValues);
headers.Add($"{dataSeriesType}__{roi}");
}
}
var roi1Roi2Coherence = ViewModelLocator.Current.MainViewModel.FreqCounterViewModel.CurrentGlobalScopedResultsViewModel.DataResultsDict[DataSeriesType.Coherence];
values.Add(roi1Roi2Coherence.X);
headers.Add("freq[Hz]_coherence_roi1_roi2");
values.Add(roi1Roi2Coherence.Y);
headers.Add("coherence_roi1_roi2");
if (roi1Roi2Coherence.IsOk)
{
values.Add(roi1Roi2Coherence.X);
headers.Add("freq[Hz]_coherence_roi1_roi2");
values.Add(roi1Roi2Coherence.Y);
headers.Add("coherence_roi1_roi2");
values.Add([ViewModelLocator.Current.MainViewModel.FreqCounterViewModel.CurrentGlobalScopedResultsViewModel.CoherenceAverage]);
headers.Add("coherence_roi1_roi2_average");

}

var str = CsvBuilder.GetCsvFromListOfLists(values: values,
(ViewModelLocator.Current.SettingsViewModel.DecimalSeparator, ViewModelLocator.Current.SettingsViewModel.CsvElementSeparator), headers: headers);
Expand Down
10 changes: 5 additions & 5 deletions TremAn3/Services/StoringMeasurementsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public async Task DisplayMeasurementByModelAsync(MeasurementModel measurementMod
mainVm.MediaPlayerViewModel.MediaControllingViewModel.PositionSeconds = measurementModel.PositionSeconds;
mainVm.MediaPlayerViewModel.FreqCounterViewModel.Maxrange = measurementModel.Maxrange;
mainVm.MediaPlayerViewModel.FreqCounterViewModel.Minrange = measurementModel.Minrange;

mainVm.MediaPlayerViewModel.FreqCounterViewModel.FreqProgressViewModel.SegmnetSize = measurementModel.FreqProgressSegmnetSize;

ViewModelLocator.Current.DrawingRectanglesViewModel.RemoveRois();
foreach (var roiRes in measurementModel.VectorsDataModel.RoiResultModels)
{

//this creates roi on video
var selvm = ViewModelLocator.Current.DrawingRectanglesViewModel.CreateROIFromModel(roiRes);

Expand All @@ -47,17 +47,17 @@ public async Task DisplayMeasurementByModelAsync(MeasurementModel measurementMod

foreach (var gsdm in measurementModel.VectorsDataModel.GlobalScopedDataResultsModels)
{
DataResult dr = new DataResult
DataResult dr = new()
{
Y = gsdm.Y,
X = gsdm.X,
ErrorMessage = gsdm.ErrorMessage
};
rvm.DataResultsDict.Add(gsdm.DataSeriesType, dr);
rvm.DataResultsDict.Add(gsdm.DataSeriesType, dr);
}

mainVm.FreqCounterViewModel.CurrentGlobalScopedResultsViewModel = rvm;

await mainVm.FreqCounterViewModel.CurrentGlobalScopedResultsViewModel.ComputeAdditionalResults();


await mainVm.FreqCounterViewModel.DisplayPlots(false);
Expand Down
2 changes: 1 addition & 1 deletion TremAn3/TremAn3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<LangVersion>11</LangVersion>
<LangVersion>12</LangVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProjectGuid>{21E2606A-1739-4034-B6B1-043D8BA0DA61}</ProjectGuid>
Expand Down
21 changes: 14 additions & 7 deletions TremAn3/ViewModels/FreqCounterViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ private void MediaControllingViewModel_PositionChanged(double value)
}


public DrawingRectanglesViewModel DrawingRectanglesViewModel
{
get { return ViewModelLocator.Current.DrawingRectanglesViewModel; }
}
public DrawingRectanglesViewModel DrawingRectanglesViewModel => ViewModelLocator.Current.DrawingRectanglesViewModel;


private double _ProgressPercentage;
Expand All @@ -90,9 +87,17 @@ private void RefreshPlots()
PlotModelsContainerViewModel.InvalidateAllPlots(true);
}

public FreqProgressViewModel FreqProgressViewModel { get; set; } = new FreqProgressViewModel();
public FreqProgressViewModel FreqProgressViewModel { get; set; } = new();


private ResultsViewModel _CurrentGlobalScopedResultsViewModel = new();

public ResultsViewModel CurrentGlobalScopedResultsViewModel
{
get => _CurrentGlobalScopedResultsViewModel;
set => Set(ref _CurrentGlobalScopedResultsViewModel, value);
}

public ResultsViewModel CurrentGlobalScopedResultsViewModel { get; set; } = new ResultsViewModel();


public async Task DisplayPlots(bool doComputation, DataSeriesType? dataSeriesType = null)
Expand Down Expand Up @@ -172,6 +177,8 @@ await CurrentGlobalScopedResultsViewModel.ComputeAllResults(ParentVm.MediaPlayer
s.ItemsSource = (res.X.Zip(res.Y, (x, y) => new DataPoint(x, y)));
pwmt.PlotModel.Series.Add(s);
s.Color = OxyColors.Black;
s.TrackerFormatString = "{0}\n{1}: {2:0.000}\n{3}: {4:0.000}";

}
else
{
Expand Down Expand Up @@ -216,7 +223,7 @@ await CurrentGlobalScopedResultsViewModel.ComputeAllResults(ParentVm.MediaPlayer
// }

// freqProgressPlotModel.Series.Add(comp.LineSeriesDict[DataSeriesType.FreqProgress]);
// //get maximum to better view
// //get maximum to better view
// //maxYOfFreqProgress = maxYOfFreqProgress < comp.Algorithm.Results.FreqProgress.Max() ? comp.Algorithm.Results.FreqProgress.Max() : maxYOfFreqProgress;
// }

Expand Down
2 changes: 2 additions & 0 deletions TremAn3/ViewModels/PlotModelWithTypeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class PlotModelWithTypeViewModel : ViewModelBase
public PlotModel PlotModel { get; set; }

public DataSeriesType DataSeriesType { get; set; }

public DataPoint? CurrentDataPoint { get; set; }
}

//public static class PlotModelCollectionExtensions
Expand Down
128 changes: 72 additions & 56 deletions TremAn3/ViewModels/PlotModelsContainerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,82 +9,98 @@
using System.Threading.Tasks;
using TremAn3.Core;

namespace TremAn3.ViewModels
namespace TremAn3.ViewModels;

public class PlotModelsContainerViewModel : ViewModelBase
{
public class PlotModelsContainerViewModel : ViewModelBase
{

public void SetAllModelsToNoData()
{
PlotModels.ToList().ForEach(x => x.PlotModel = getPlotModelWithNoDataText());
PlotModelsGlobalScope.ToList().ForEach(x => x.PlotModel = getPlotModelWithNoDataText());
}
public void SetFreqProgressToNoData()
{
PlotModels.First(x => x.DataSeriesType == DataSeriesType.FreqProgress).PlotModel = getPlotModelWithNoDataText();
}
public void SetAllModelsToNoData()
{
PlotModels.ToList().ForEach(x => x.PlotModel = getPlotModelWithNoDataText());
PlotModelsGlobalScope.ToList().ForEach(x => x.PlotModel = getPlotModelWithNoDataText());
}
public void SetFreqProgressToNoData()
{
PlotModels.First(x => x.DataSeriesType == DataSeriesType.FreqProgress).PlotModel = getPlotModelWithNoDataText();
}

public void InvalidateTimePlots(bool updateData)
{
PlotModels.Where(x =>
x.DataSeriesType == DataSeriesType.FreqProgress ||
x.DataSeriesType == DataSeriesType.ComX ||
x.DataSeriesType == DataSeriesType.ComY)
public void InvalidateTimePlots(bool updateData)
{
PlotModels.Where(x =>
x.DataSeriesType == DataSeriesType.FreqProgress ||
x.DataSeriesType == DataSeriesType.ComX ||
x.DataSeriesType == DataSeriesType.ComY)
.ToList().ForEach(x=>x.PlotModel.InvalidatePlot(updateData));
}
public void InvalidateAllPlots(bool updateData)
{
PlotModels.ToList().ForEach(x => x.PlotModel.InvalidatePlot(updateData));
PlotModelsGlobalScope.ToList().ForEach(x => x.PlotModel.InvalidatePlot(updateData));
}
}
public void InvalidateAllPlots(bool updateData)
{
PlotModels.ToList().ForEach(x => x.PlotModel.InvalidatePlot(updateData));
PlotModelsGlobalScope.ToList().ForEach(x => x.PlotModel.InvalidatePlot(updateData));
}

//there is one line series for every roi. For example amp spectrum
public List<PlotModelWithTypeViewModel> PlotModels { get; set; } =
new List<PlotModelWithTypeViewModel>();
//there is one line series for every roi. For example amp spectrum
public List<PlotModelWithTypeViewModel> PlotModels { get; set; } = [];


//there is only one series for all rois. For example coherence
public List<PlotModelWithTypeViewModel> PlotModelsGlobalScope { get; set; } =
new List<PlotModelWithTypeViewModel>();
//there is only one series for all rois. For example coherence
public List<PlotModelWithTypeViewModel> PlotModelsGlobalScope { get; set; } = [];


private PlotModel getPlotModelWithNoDataText()
{
return new PlotModel { Title = "No Data" };
}
private PlotModel getPlotModelWithNoDataText()
{
return new PlotModel { Title = "No Data" };
}

private string currentDataPointString;
//when moving annotation on plot, all plots change this.. waiting for the future
public string CurrentDataPointString
{
get => currentDataPointString;
private set => Set(ref currentDataPointString, value);
}

/// <summary>
/// this needs to be done when new plotModel is presented.
/// </summary>

public PlotModel GetPlotModelByDsTypeOrCreateNew( DataSeriesType type)
{
var plotModel = PlotModels.SingleOrDefault(x => x.DataSeriesType == type);
private string GetCurrentDataPoint(PlotModelWithTypeViewModel plotModel)
{
return plotModel?.CurrentDataPoint == null
? "no data point"
: $"X: {plotModel.CurrentDataPoint.Value.X:0.00}, Y: {plotModel.CurrentDataPoint.Value.Y:0.00} ";
}

if (plotModel == null)//adding new plot models, when xaml asks for them
{
plotModel = new PlotModelWithTypeViewModel() { DataSeriesType = type };
PlotModels.Add(plotModel);
}
return plotModel.PlotModel;
/// <summary>
/// this needs to be done when new plotModel is presented.
/// </summary>

}
public PlotModel GetPlotModelByDsTypeOrCreateNew( DataSeriesType type)
{
var plotModel = PlotModels.SingleOrDefault(x => x.DataSeriesType == type);

public PlotModel GetGlobalScopedPlotModelByDsTypeOrCreateNew(DataSeriesType type)
if (plotModel == null)//adding new plot models, when xaml asks for them
{
var plotModel = PlotModelsGlobalScope.SingleOrDefault(x => x.DataSeriesType == type);
plotModel = new PlotModelWithTypeViewModel() { DataSeriesType = type };
PlotModels.Add(plotModel);
}
if(plotModel.PlotModel!=null )
plotModel.PlotModel.TrackerChanged += (sender, args) => {
plotModel.CurrentDataPoint = args?.HitResult?.DataPoint;
CurrentDataPointString = GetCurrentDataPoint(plotModel);
};
return plotModel.PlotModel;

if (plotModel == null)//adding new plot models, when xaml asks for them
{
plotModel = new PlotModelWithTypeViewModel() { DataSeriesType = type };
PlotModelsGlobalScope.Add(plotModel);
}
return plotModel.PlotModel;
}

}
public PlotModel GetGlobalScopedPlotModelByDsTypeOrCreateNew(DataSeriesType type)
{
var plotModel = PlotModelsGlobalScope.SingleOrDefault(x => x.DataSeriesType == type);

if (plotModel == null)//adding new plot models, when xaml asks for them
{
plotModel = new PlotModelWithTypeViewModel() { DataSeriesType = type };
PlotModelsGlobalScope.Add(plotModel);
}
return plotModel.PlotModel;

}


}
Loading

0 comments on commit 60a7eac

Please sign in to comment.