diff --git a/MainViewModel.cs b/MainViewModel.cs index 132d3e9..3ed9ca7 100644 --- a/MainViewModel.cs +++ b/MainViewModel.cs @@ -39,6 +39,8 @@ namespace CtrEditor public ObservableCollection ListaOsBase { get; } = new ObservableCollection(); public Stopwatch stopwatch_PLCRefresh; public Stopwatch stopwatch_SimRefresh; + private float TiempoDesdeStartSimulacion; + private bool Debug_SimulacionCreado = false; public SimulationManagerFP simulationManager = new SimulationManagerFP(); @@ -326,6 +328,8 @@ namespace CtrEditor objetoSimulable.UpdateGeometryStart(); simulationManager.Debug_DrawInitialBodies(); + TiempoDesdeStartSimulacion = 0; + Debug_SimulacionCreado = true; _timerSimulacion.Start(); simulationManager.stopwatch.Start(); @@ -335,6 +339,11 @@ namespace CtrEditor private void StopSimulation() { + if (Debug_SimulacionCreado) + { + simulationManager.Debug_ClearSimulationShapes(); + Debug_SimulacionCreado = false; + } _timerSimulacion.Stop(); simulationManager.stopwatch.Stop(); stopwatch_SimRefresh.Stop(); @@ -347,6 +356,12 @@ namespace CtrEditor stopwatch_SimRefresh.Stop(); float elapsedMilliseconds = (float)stopwatch_SimRefresh.Elapsed.TotalMilliseconds; + // Eliminar el diseño de Debug luego de 2 segundos + if (TiempoDesdeStartSimulacion > 2000) + simulationManager.Debug_ClearSimulationShapes(); + else + TiempoDesdeStartSimulacion += elapsedMilliseconds; + // Reiniciar el cronómetro para la próxima medición stopwatch_SimRefresh.Restart(); diff --git a/ObjetosSim/ucDescarte.xaml b/ObjetosSim/ucDescarte.xaml index eaf43ba..26cb01f 100644 --- a/ObjetosSim/ucDescarte.xaml +++ b/ObjetosSim/ucDescarte.xaml @@ -10,23 +10,29 @@ - + + Width="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}" + Stroke="Blue" + Fill="Transparent" + RenderTransformOrigin="0.5,0.5"> diff --git a/ObjetosSim/ucDescarte.xaml.cs b/ObjetosSim/ucDescarte.xaml.cs index 883172d..93e9690 100644 --- a/ObjetosSim/ucDescarte.xaml.cs +++ b/ObjetosSim/ucDescarte.xaml.cs @@ -4,6 +4,7 @@ using CtrEditor.Simulacion; using System.Windows; using System.Windows.Controls; using Microsoft.Xna.Framework; +using System.Windows.Media.Animation; namespace CtrEditor.ObjetosSim { /// @@ -24,6 +25,7 @@ namespace CtrEditor.ObjetosSim set { _centro.X = value + Diametro / 2; + ActualizarGeometrias(); CanvasSetLeftinMeter(value); OnPropertyChanged(nameof(CenterX)); OnPropertyChanged(nameof(Left)); @@ -35,6 +37,7 @@ namespace CtrEditor.ObjetosSim set { _centro.Y = value + Diametro / 2; + ActualizarGeometrias(); CanvasSetTopinMeter(value); OnPropertyChanged(nameof(CenterY)); OnPropertyChanged(nameof(Top)); @@ -147,6 +150,11 @@ namespace CtrEditor.ObjetosSim private void OnLoaded(object sender, RoutedEventArgs e) { Datos?.ucLoaded(); + Storyboard storyboard = this.Resources["PulsingStoryboard"] as Storyboard; + if (storyboard != null) + { + storyboard.Begin(); + } } private void OnUnloaded(object sender, RoutedEventArgs e) { diff --git a/Simulacion/FPhysics.cs b/Simulacion/FPhysics.cs index b769b2d..743ea88 100644 --- a/Simulacion/FPhysics.cs +++ b/Simulacion/FPhysics.cs @@ -367,7 +367,7 @@ namespace CtrEditor.Simulacion public void Debug_DrawInitialBodies() { - ClearSimulationShapes(); + Debug_ClearSimulationShapes(); world.Step(0.01f); // Para actualizar la BodyList foreach (Body body in world.BodyList) { @@ -378,7 +378,7 @@ namespace CtrEditor.Simulacion } } - private void ClearSimulationShapes() + public void Debug_ClearSimulationShapes() { var simulationShapes = simulationCanvas.Children.OfType().Where(s => s.Tag as string == "Simulation").ToList(); foreach (var shape in simulationShapes)