// Copyright (C) Stichting Deltares 2018. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using System.Windows.Forms;
using Core.Common.Base;
using Core.Components.Gis.Data;
using Core.Components.Gis.Forms;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Forms.Factories;
using Ringtoets.Common.Forms.Helpers;
using Ringtoets.Integration.Data;
using Ringtoets.Integration.Forms.Factories;
using Ringtoets.Integration.Forms.Observers;
namespace Ringtoets.Integration.Forms.Views
{
///
/// The map view for the assembly result per section for all failure mechanisms of
/// the .
///
public partial class AssemblyResultPerSectionMapView : UserControl, IMapView
{
private readonly MapLineData assemblyResultsMapData;
private readonly MapLineData referenceLineMapData;
private readonly MapPointData hydraulicBoundaryLocationsMapData;
private Observer assessmentSectionObserver;
private Observer referenceLineObserver;
private Observer hydraulicBoundaryLocationsObserver;
private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForFactorizedSignalingNormObserver;
private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForSignalingNormObserver;
private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForLowerLimitNormObserver;
private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForFactorizedLowerLimitNormObserver;
private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForFactorizedSignalingNormObserver;
private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForSignalingNormObserver;
private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForLowerLimitNormObserver;
private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForFactorizedLowerLimitNormObserver;
///
/// Creates a new instance of .
///
/// The to create the view for.
/// Thrown when
/// is null.
public AssemblyResultPerSectionMapView(AssessmentSection assessmentSection)
{
if (assessmentSection == null)
{
throw new ArgumentNullException(nameof(assessmentSection));
}
InitializeComponent();
AssessmentSection = assessmentSection;
CreateObservers();
var mapDataCollection = new MapDataCollection("Assemblagekaart");
assemblyResultsMapData = CombinedSectionAssemblyMapDataFactory.CreateCombinedSectionAssemblyResultMapData();
referenceLineMapData = RingtoetsMapDataFactory.CreateReferenceLineMapData();
hydraulicBoundaryLocationsMapData = RingtoetsMapDataFactory.CreateHydraulicBoundaryLocationsMapData();
mapDataCollection.Add(assemblyResultsMapData);
mapDataCollection.Add(hydraulicBoundaryLocationsMapData);
mapDataCollection.Add(referenceLineMapData);
SetAllMapDataFeatures();
ringtoetsMapControl.SetAllData(mapDataCollection, assessmentSection.BackgroundData);
}
///
/// Gets the the view belongs to.
///
public AssessmentSection AssessmentSection { get; }
public object Data { get; set; }
public IMapControl Map
{
get
{
return ringtoetsMapControl.MapControl;
}
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
assessmentSectionObserver.Dispose();
referenceLineObserver.Dispose();
waterLevelCalculationsForFactorizedSignalingNormObserver.Dispose();
waterLevelCalculationsForSignalingNormObserver.Dispose();
waterLevelCalculationsForLowerLimitNormObserver.Dispose();
waterLevelCalculationsForFactorizedLowerLimitNormObserver.Dispose();
waveHeightCalculationsForFactorizedSignalingNormObserver.Dispose();
waveHeightCalculationsForSignalingNormObserver.Dispose();
waveHeightCalculationsForLowerLimitNormObserver.Dispose();
waveHeightCalculationsForFactorizedLowerLimitNormObserver.Dispose();
hydraulicBoundaryLocationsObserver.Dispose();
components?.Dispose();
}
base.Dispose(disposing);
}
private void CreateObservers()
{
referenceLineObserver = new Observer(UpdateReferenceLineMapData)
{
Observable = AssessmentSection
};
assessmentSectionObserver = new Observer(UpdateAssemblyResultsMapData)
{
Observable = new AssessmentSectionResultObserver(AssessmentSection)
};
waterLevelCalculationsForFactorizedSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
AssessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm, UpdateHydraulicBoundaryLocationsMapData);
waterLevelCalculationsForSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
AssessmentSection.WaterLevelCalculationsForSignalingNorm, UpdateHydraulicBoundaryLocationsMapData);
waterLevelCalculationsForLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
AssessmentSection.WaterLevelCalculationsForLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData);
waterLevelCalculationsForFactorizedLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
AssessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData);
waveHeightCalculationsForFactorizedSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
AssessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm, UpdateHydraulicBoundaryLocationsMapData);
waveHeightCalculationsForSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
AssessmentSection.WaveHeightCalculationsForSignalingNorm, UpdateHydraulicBoundaryLocationsMapData);
waveHeightCalculationsForLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
AssessmentSection.WaveHeightCalculationsForLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData);
waveHeightCalculationsForFactorizedLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
AssessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData);
hydraulicBoundaryLocationsObserver = new Observer(UpdateHydraulicBoundaryLocationsMapData)
{
Observable = AssessmentSection.HydraulicBoundaryDatabase.Locations
};
}
private void SetAllMapDataFeatures()
{
SetReferenceLineMapData();
SetHydraulicBoundaryLocationsMapData();
SetAssemblyResultsMapData();
}
private void UpdateAssemblyResultsMapData()
{
SetAssemblyResultsMapData();
assemblyResultsMapData.NotifyObservers();
}
private void SetAssemblyResultsMapData()
{
assemblyResultsMapData.Features = AssessmentSectionAssemblyMapDataFeaturesFactory.CreateCombinedFailureMechanismSectionAssemblyFeatures(AssessmentSection);
}
#region ReferenceLine MapData
private void UpdateReferenceLineMapData()
{
SetReferenceLineMapData();
referenceLineMapData.NotifyObservers();
}
private void SetReferenceLineMapData()
{
referenceLineMapData.Features = RingtoetsMapDataFeaturesFactory.CreateReferenceLineFeatures(AssessmentSection.ReferenceLine,
AssessmentSection.Id,
AssessmentSection.Name);
}
#endregion
#region HydraulicBoundaryLocations MapData
private void UpdateHydraulicBoundaryLocationsMapData()
{
SetHydraulicBoundaryLocationsMapData();
hydraulicBoundaryLocationsMapData.NotifyObservers();
}
private void SetHydraulicBoundaryLocationsMapData()
{
hydraulicBoundaryLocationsMapData.Features = RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(AssessmentSection);
}
#endregion
}
}