Compare commits
No commits in common. "2e8c3b7d8314ce3c34dbda44e8f0b4118bbd60bb" and "9ed8a0b7bd140e8056f69da9516efa1b2388e4f4" have entirely different histories.
2e8c3b7d83
...
9ed8a0b7bd
|
@ -39,8 +39,6 @@ namespace CtrEditor
|
|||
public ObservableCollection<TipoSimulable> ListaOsBase { get; } = new ObservableCollection<TipoSimulable>();
|
||||
public Stopwatch stopwatch_PLCRefresh;
|
||||
public Stopwatch stopwatch_SimRefresh;
|
||||
private float TiempoDesdeStartSimulacion;
|
||||
private bool Debug_SimulacionCreado = false;
|
||||
|
||||
public SimulationManagerFP simulationManager = new SimulationManagerFP();
|
||||
|
||||
|
@ -328,8 +326,6 @@ namespace CtrEditor
|
|||
objetoSimulable.UpdateGeometryStart();
|
||||
|
||||
simulationManager.Debug_DrawInitialBodies();
|
||||
TiempoDesdeStartSimulacion = 0;
|
||||
Debug_SimulacionCreado = true;
|
||||
|
||||
_timerSimulacion.Start();
|
||||
simulationManager.stopwatch.Start();
|
||||
|
@ -339,11 +335,6 @@ namespace CtrEditor
|
|||
|
||||
private void StopSimulation()
|
||||
{
|
||||
if (Debug_SimulacionCreado)
|
||||
{
|
||||
simulationManager.Debug_ClearSimulationShapes();
|
||||
Debug_SimulacionCreado = false;
|
||||
}
|
||||
_timerSimulacion.Stop();
|
||||
simulationManager.stopwatch.Stop();
|
||||
stopwatch_SimRefresh.Stop();
|
||||
|
@ -356,12 +347,6 @@ 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();
|
||||
|
||||
|
|
|
@ -10,29 +10,23 @@
|
|||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
<Storyboard x:Key="PulsingStoryboard" RepeatBehavior="Forever">
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="AnimatedEllipse"
|
||||
Storyboard.TargetName="PulsingEllipse"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"
|
||||
From="1" To="0.5" Duration="0:0:1" AutoReverse="True" />
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="AnimatedEllipse"
|
||||
Storyboard.TargetName="PulsingEllipse"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"
|
||||
From="1" To="0.5" Duration="0:0:1" AutoReverse="True" />
|
||||
</Storyboard>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<Ellipse
|
||||
<Ellipse x:Name="PulsingEllipse"
|
||||
Height="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}"
|
||||
Width="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}"
|
||||
Stroke="Yellow"
|
||||
Fill="Black"
|
||||
Opacity="0.5"/>
|
||||
<Ellipse x:Name="AnimatedEllipse"
|
||||
Height="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}"
|
||||
Width="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}"
|
||||
Stroke="Blue"
|
||||
Fill="Transparent"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
Opacity="0.5"
|
||||
Width="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}">
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform />
|
||||
|
|
|
@ -4,7 +4,6 @@ using CtrEditor.Simulacion;
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Windows.Media.Animation;
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -25,7 +24,6 @@ namespace CtrEditor.ObjetosSim
|
|||
set
|
||||
{
|
||||
_centro.X = value + Diametro / 2;
|
||||
ActualizarGeometrias();
|
||||
CanvasSetLeftinMeter(value);
|
||||
OnPropertyChanged(nameof(CenterX));
|
||||
OnPropertyChanged(nameof(Left));
|
||||
|
@ -37,7 +35,6 @@ namespace CtrEditor.ObjetosSim
|
|||
set
|
||||
{
|
||||
_centro.Y = value + Diametro / 2;
|
||||
ActualizarGeometrias();
|
||||
CanvasSetTopinMeter(value);
|
||||
OnPropertyChanged(nameof(CenterY));
|
||||
OnPropertyChanged(nameof(Top));
|
||||
|
@ -150,11 +147,6 @@ 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)
|
||||
{
|
||||
|
|
|
@ -42,16 +42,13 @@ namespace CtrEditor.Simulacion
|
|||
_radius = diameter / 2;
|
||||
Create(Body.Position); // Recrear el círculo con el nuevo tamaño
|
||||
}
|
||||
public void RemoverBody()
|
||||
|
||||
public void Create(Vector2 position)
|
||||
{
|
||||
if (Body != null)
|
||||
{
|
||||
_world.RemoveBody(Body);
|
||||
}
|
||||
}
|
||||
public void Create(Vector2 position)
|
||||
{
|
||||
RemoverBody();
|
||||
Body = BodyFactory.CreateCircle(_world, _radius, 1f, position);
|
||||
|
||||
Body.FixtureList[0].IsSensor = true;
|
||||
|
@ -95,16 +92,13 @@ namespace CtrEditor.Simulacion
|
|||
var newShape = new PolygonShape(PolygonTools.CreateRectangle(width / 2, height / 2), 1f);
|
||||
Body.CreateFixture(newShape);
|
||||
}
|
||||
public void RemoverBody()
|
||||
|
||||
public void Create(float width, float height, Vector2 position, float angle = 0)
|
||||
{
|
||||
if (Body != null)
|
||||
{
|
||||
_world.RemoveBody(Body);
|
||||
}
|
||||
}
|
||||
public void Create(float width, float height, Vector2 position, float angle = 0)
|
||||
{
|
||||
RemoverBody();
|
||||
Body = BodyFactory.CreateRectangle(_world, width, height, 1f, position);
|
||||
Body.FixtureList[0].IsSensor = true;
|
||||
Body.BodyType = BodyType.Static;
|
||||
|
@ -123,16 +117,13 @@ namespace CtrEditor.Simulacion
|
|||
_world = world;
|
||||
Create(start, end);
|
||||
}
|
||||
public void RemoverBody()
|
||||
|
||||
public void Create(Vector2 start, Vector2 end)
|
||||
{
|
||||
if (Body != null)
|
||||
{
|
||||
_world.RemoveBody(Body);
|
||||
_world.RemoveBody(Body); // Elimina el cuerpo anterior si existe
|
||||
}
|
||||
}
|
||||
public void Create(Vector2 start, Vector2 end)
|
||||
{
|
||||
RemoverBody();
|
||||
Body = BodyFactory.CreateEdge(_world, start, end);
|
||||
Body.BodyType = BodyType.Static;
|
||||
Body.UserData = this; // Importante para la identificación durante la colisión
|
||||
|
@ -187,16 +178,13 @@ namespace CtrEditor.Simulacion
|
|||
}
|
||||
set { _mass = value; }
|
||||
}
|
||||
public void RemoverBody()
|
||||
|
||||
private void Create(Vector2 position)
|
||||
{
|
||||
if (Body != null)
|
||||
{
|
||||
_world.RemoveBody(Body);
|
||||
_world.RemoveBody(Body); // Remover el cuerpo anterior si existe
|
||||
}
|
||||
}
|
||||
private void Create(Vector2 position)
|
||||
{
|
||||
RemoverBody();
|
||||
Body = BodyFactory.CreateCircle(_world, _radius, 1f, position);
|
||||
Body.BodyType = BodyType.Dynamic;
|
||||
|
||||
|
@ -333,19 +321,15 @@ namespace CtrEditor.Simulacion
|
|||
switch (Objeto)
|
||||
{
|
||||
case simBotella obj:
|
||||
obj.RemoverBody();
|
||||
circles.Remove(obj);
|
||||
break;
|
||||
case simTransporte obj:
|
||||
obj.RemoverBody();
|
||||
rectangles.Remove(obj);
|
||||
break;
|
||||
case simGuia obj:
|
||||
obj.RemoverBody();
|
||||
lines.Remove(obj);
|
||||
break;
|
||||
case simDescarte obj:
|
||||
obj.RemoverBody();
|
||||
descartes.Remove(obj);
|
||||
break;
|
||||
default:
|
||||
|
@ -383,7 +367,7 @@ namespace CtrEditor.Simulacion
|
|||
|
||||
public void Debug_DrawInitialBodies()
|
||||
{
|
||||
Debug_ClearSimulationShapes();
|
||||
ClearSimulationShapes();
|
||||
world.Step(0.01f); // Para actualizar la BodyList
|
||||
foreach (Body body in world.BodyList)
|
||||
{
|
||||
|
@ -394,7 +378,7 @@ namespace CtrEditor.Simulacion
|
|||
}
|
||||
}
|
||||
|
||||
public void Debug_ClearSimulationShapes()
|
||||
private void ClearSimulationShapes()
|
||||
{
|
||||
var simulationShapes = simulationCanvas.Children.OfType<System.Windows.Shapes.Shape>().Where(s => s.Tag as string == "Simulation").ToList();
|
||||
foreach (var shape in simulationShapes)
|
||||
|
|
Loading…
Reference in New Issue