Se añadió la funcionalidad para crear y actualizar animaciones de transporte circular en la clase osBase y se integró en ucTransporteCurva. Se implementaron métodos para gestionar la dirección de las animaciones y se mejoró la lógica de actualización de geometrías. Además, se realizaron ajustes en el XAML de CircularSegment para incluir un patrón visual en el Path.
This commit is contained in:
parent
ac8773ebc7
commit
da8d0516cb
|
@ -46,6 +46,11 @@ namespace CtrEditor.ObjetosSim
|
||||||
partial void OnInvertirDireccionChanged(bool value)
|
partial void OnInvertirDireccionChanged(bool value)
|
||||||
{
|
{
|
||||||
SetSpeed();
|
SetSpeed();
|
||||||
|
if (_visualRepresentation is ucTransporteCurva uc)
|
||||||
|
{
|
||||||
|
CrearAnimacionStoryBoardTrasnporteCircular(uc.Transporte.TransportePath, InvertirDireccion);
|
||||||
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetSpeed()
|
void SetSpeed()
|
||||||
|
@ -54,6 +59,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
Simulation_TransporteCurva?.SetSpeed(-VelocidadActual);
|
Simulation_TransporteCurva?.SetSpeed(-VelocidadActual);
|
||||||
else
|
else
|
||||||
Simulation_TransporteCurva?.SetSpeed(VelocidadActual);
|
Simulation_TransporteCurva?.SetSpeed(VelocidadActual);
|
||||||
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
|
@ -127,14 +133,14 @@ namespace CtrEditor.ObjetosSim
|
||||||
[Hidden]
|
[Hidden]
|
||||||
public float AnguloFinal
|
public float AnguloFinal
|
||||||
{
|
{
|
||||||
get => Angulo+Arco_en_grados;
|
get => Angulo + Arco_en_grados;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ActualizarGeometrias()
|
private void ActualizarGeometrias()
|
||||||
{
|
{
|
||||||
if (_visualRepresentation is ucTransporteCurva uc)
|
if (_visualRepresentation is ucTransporteCurva uc)
|
||||||
{
|
{
|
||||||
UpdateCurve(Simulation_TransporteCurva, RadioInterno, RadioExterno, Angulo, Angulo+Arco_en_grados);
|
UpdateCurve(Simulation_TransporteCurva, RadioInterno, RadioExterno, Angulo, Angulo + Arco_en_grados);
|
||||||
SetSpeed();
|
SetSpeed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,9 +211,14 @@ namespace CtrEditor.ObjetosSim
|
||||||
{
|
{
|
||||||
// Se llama antes de la simulacion
|
// Se llama antes de la simulacion
|
||||||
ActualizarGeometrias();
|
ActualizarGeometrias();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SimulationStop()
|
||||||
|
{
|
||||||
|
// Se llama al detener la simulacion
|
||||||
|
ActualizarAnimacionStoryBoardTransporte(VelocidadActual);
|
||||||
|
}
|
||||||
|
|
||||||
public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
|
public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
|
||||||
{
|
{
|
||||||
if (Motor != null)
|
if (Motor != null)
|
||||||
|
@ -225,13 +236,13 @@ namespace CtrEditor.ObjetosSim
|
||||||
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
||||||
// crear el objeto de simulacion
|
// crear el objeto de simulacion
|
||||||
base.ucLoaded();
|
base.ucLoaded();
|
||||||
|
|
||||||
OnId_MotorChanged(Id_Motor); // Link Id_Motor = Motor
|
OnId_MotorChanged(Id_Motor); // Link Id_Motor = Motor
|
||||||
|
|
||||||
if (_visualRepresentation is ucTransporteCurva uc)
|
if (_visualRepresentation is ucTransporteCurva uc)
|
||||||
Simulation_TransporteCurva = AddCurve(RadioInterno,RadioExterno, Angulo, Angulo + Arco_en_grados);
|
{
|
||||||
|
Simulation_TransporteCurva = AddCurve(RadioInterno, RadioExterno, Angulo, Angulo + Arco_en_grados);
|
||||||
// AddCurve(float innerRadius, float outerRadius, float startAngle, float endAngle, Vector2 position)
|
CrearAnimacionStoryBoardTrasnporteCircular(uc.Transporte.TransportePath, InvertirDireccion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public override void ucUnLoaded()
|
public override void ucUnLoaded()
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,23 @@
|
||||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||||
mc:Ignorable="d" Name="circularSegmentControl">
|
mc:Ignorable="d" Name="circularSegmentControl">
|
||||||
<Canvas>
|
<Canvas>
|
||||||
<Path Name="path" Stroke="Black" Fill="LightBlue" StrokeThickness="1">
|
<Path Name="path" Stroke="Black" StrokeThickness="1">
|
||||||
|
<Path.Fill>
|
||||||
|
<VisualBrush TileMode="Tile" Viewport="0,0,20,20" ViewportUnits="Absolute">
|
||||||
|
<VisualBrush.Transform>
|
||||||
|
<TransformGroup>
|
||||||
|
<TranslateTransform X="0" Y="0"/>
|
||||||
|
</TransformGroup>
|
||||||
|
</VisualBrush.Transform>
|
||||||
|
<VisualBrush.Visual>
|
||||||
|
<Canvas Width="20" Height="20">
|
||||||
|
<!-- Patrón de rayas radiales que simulan el movimiento tangencial -->
|
||||||
|
<Rectangle Fill="LightGray" Width="10" Height="10" Canvas.Left="0" Canvas.Top="0"/>
|
||||||
|
<Rectangle Fill="GhostWhite" Width="10" Height="10" Canvas.Left="0" Canvas.Top="10"/>
|
||||||
|
</Canvas>
|
||||||
|
</VisualBrush.Visual>
|
||||||
|
</VisualBrush>
|
||||||
|
</Path.Fill>
|
||||||
<Path.RenderTransform>
|
<Path.RenderTransform>
|
||||||
<RotateTransform Angle="{Binding Angle, ElementName=circularSegmentControl}"/>
|
<RotateTransform Angle="{Binding Angle, ElementName=circularSegmentControl}"/>
|
||||||
</Path.RenderTransform>
|
</Path.RenderTransform>
|
||||||
|
|
|
@ -59,6 +59,9 @@ namespace CtrEditor.ObjetosSim.UserControls
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Propiedad pública para acceder al Path desde código externo
|
||||||
|
public System.Windows.Shapes.Path TransportePath => path;
|
||||||
|
|
||||||
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
(d as CircularSegment)?.DrawSegment();
|
(d as CircularSegment)?.DrawSegment();
|
||||||
|
|
|
@ -1153,6 +1153,27 @@ namespace CtrEditor.ObjetosSim
|
||||||
return storyboard;
|
return storyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Storyboard CrearAnimacionMultiStoryBoardTrasnporteCircular(System.Windows.Shapes.Path transporte, bool invertirDireccion)
|
||||||
|
{
|
||||||
|
if (_visualRepresentation == null) return null;
|
||||||
|
if (transporte == null) return null;
|
||||||
|
|
||||||
|
Storyboard storyboard = new Storyboard();
|
||||||
|
var animation = new DoubleAnimation
|
||||||
|
{
|
||||||
|
From = invertirDireccion ? 20 : 0,
|
||||||
|
To = invertirDireccion ? 0 : 20, // Total Pixels Brush
|
||||||
|
Duration = TimeSpan.FromSeconds(PixelToMeter.Instance.calc.PixelsToMeters(20) * 60),
|
||||||
|
RepeatBehavior = RepeatBehavior.Forever
|
||||||
|
};
|
||||||
|
Storyboard.SetTarget(animation, transporte);
|
||||||
|
Storyboard.SetTargetProperty(animation, new PropertyPath("(Path.Fill).(VisualBrush.Transform).(TransformGroup.Children)[0].(TranslateTransform.Y)"));
|
||||||
|
storyboard.Children.Add(animation);
|
||||||
|
storyboard.Begin();
|
||||||
|
storyboard.SetSpeedRatio(0);
|
||||||
|
return storyboard;
|
||||||
|
}
|
||||||
|
|
||||||
protected Storyboard CrearAnimacionMultiStoryBoardTrasnporte(Storyboard storyboard, Rectangle transporte, bool invertirDireccion)
|
protected Storyboard CrearAnimacionMultiStoryBoardTrasnporte(Storyboard storyboard, Rectangle transporte, bool invertirDireccion)
|
||||||
{
|
{
|
||||||
// Detener y eliminar el storyboard existente si hay uno
|
// Detener y eliminar el storyboard existente si hay uno
|
||||||
|
@ -1165,6 +1186,18 @@ namespace CtrEditor.ObjetosSim
|
||||||
return CrearAnimacionMultiStoryBoardTrasnporte(transporte, invertirDireccion);
|
return CrearAnimacionMultiStoryBoardTrasnporte(transporte, invertirDireccion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Storyboard CrearAnimacionMultiStoryBoardTrasnporteCircular(Storyboard storyboard, System.Windows.Shapes.Path transporte, bool invertirDireccion)
|
||||||
|
{
|
||||||
|
// Detener y eliminar el storyboard existente si hay uno
|
||||||
|
if (storyboard != null)
|
||||||
|
{
|
||||||
|
storyboard.Stop();
|
||||||
|
storyboard.Children.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
return CrearAnimacionMultiStoryBoardTrasnporteCircular(transporte, invertirDireccion);
|
||||||
|
}
|
||||||
|
|
||||||
protected void ActualizarAnimacionMultiStoryBoardTransporte(Storyboard storyboard, float velocidadActual)
|
protected void ActualizarAnimacionMultiStoryBoardTransporte(Storyboard storyboard, float velocidadActual)
|
||||||
{
|
{
|
||||||
if (_visualRepresentation == null) return;
|
if (_visualRepresentation == null) return;
|
||||||
|
@ -1181,6 +1214,11 @@ namespace CtrEditor.ObjetosSim
|
||||||
_storyboard = CrearAnimacionMultiStoryBoardTrasnporte(_storyboard, transporte, invertirDireccion);
|
_storyboard = CrearAnimacionMultiStoryBoardTrasnporte(_storyboard, transporte, invertirDireccion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void CrearAnimacionStoryBoardTrasnporteCircular(System.Windows.Shapes.Path transporte, bool invertirDireccion)
|
||||||
|
{
|
||||||
|
_storyboard = CrearAnimacionMultiStoryBoardTrasnporteCircular(_storyboard, transporte, invertirDireccion);
|
||||||
|
}
|
||||||
|
|
||||||
protected void ActualizarAnimacionStoryBoardTransporte(float velocidadActual)
|
protected void ActualizarAnimacionStoryBoardTransporte(float velocidadActual)
|
||||||
{
|
{
|
||||||
ActualizarAnimacionMultiStoryBoardTransporte(_storyboard, velocidadActual);
|
ActualizarAnimacionMultiStoryBoardTransporte(_storyboard, velocidadActual);
|
||||||
|
|
Loading…
Reference in New Issue