Compare commits
No commits in common. "c1ac20964e44b68b5212f96e5d5c55ff83317468" and "c4892b1f368764b7913bd0e13e132a3c6f884545" have entirely different histories.
c1ac20964e
...
c4892b1f36
11
App.xaml
11
App.xaml
|
@ -3,18 +3,7 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="clr-namespace:CtrEditor"
|
xmlns:local="clr-namespace:CtrEditor"
|
||||||
StartupUri="MainWindow.xaml">
|
StartupUri="MainWindow.xaml">
|
||||||
|
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<local:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
|
||||||
<local:LevelToHeightMultiConverter x:Key="LevelToHeightMultiConverter"/>
|
|
||||||
<local:WidthPercentageConverter x:Key="WidthPercentageConverter"/>
|
|
||||||
<local:DistanceToMarginConverter x:Key="DistanceToMarginConverter"/>
|
|
||||||
<local:MarginConverter x:Key="MarginConverter"/>
|
|
||||||
<local:FloatToFormattedStringConverter x:Key="floatFormatter"/>
|
|
||||||
<local:DoubleToFormattedStringConverter x:Key="doubleFormatter"/>
|
|
||||||
<local:BrushToColorNameConverter x:Key="BrushToColorNameConverter"/>
|
|
||||||
<local:VerticalPositionConverter x:Key="VerticalPositionConverter"/>
|
|
||||||
<local:SumConverter x:Key="SumConverter" />
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
|
|
||||||
|
|
|
@ -1,43 +1,15 @@
|
||||||
using System.Globalization;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace CtrEditor
|
namespace CtrEditor.Convertidores
|
||||||
{
|
{
|
||||||
public class SumConverter : IMultiValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
if (values.Length == 2 && values[0] is float value1 && values[1] is float value2)
|
|
||||||
{
|
|
||||||
return (double) (value1 + value2);
|
|
||||||
}
|
|
||||||
return DependencyProperty.UnsetValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class VerticalPositionConverter : IValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
if (value is double altura && double.TryParse(parameter?.ToString(), out double factor))
|
|
||||||
{
|
|
||||||
return altura * factor;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class HalfWidthConverter : IValueConverter
|
public class HalfWidthConverter : IValueConverter
|
||||||
{
|
{
|
||||||
|
@ -206,27 +178,6 @@ namespace CtrEditor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MarginConverter : IMultiValueConverter
|
|
||||||
{
|
|
||||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
if (values.Length == 4 &&
|
|
||||||
values[0] is double left &&
|
|
||||||
values[1] is double top &&
|
|
||||||
values[2] is double right &&
|
|
||||||
values[3] is double bottom)
|
|
||||||
{
|
|
||||||
return new Thickness(PixelToMeter.Instance.calc.MetersToPixels((float)left), PixelToMeter.Instance.calc.MetersToPixels((float)top), PixelToMeter.Instance.calc.MetersToPixels((float)right), PixelToMeter.Instance.calc.MetersToPixels((float)bottom));
|
|
||||||
}
|
|
||||||
return new Thickness();
|
|
||||||
}
|
|
||||||
|
|
||||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
|
||||||
{
|
|
||||||
throw new NotSupportedException("ConvertBack is not supported.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DistanceToMarginConverter : IValueConverter
|
public class DistanceToMarginConverter : IValueConverter
|
||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
@ -6,15 +6,9 @@
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
|
||||||
<Optimize>True</Optimize>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Remove="ObjetosSim\ucBasicExample.xaml.cs" />
|
|
||||||
<Compile Remove="ObjetosSim\ucTransporteCurva.xaml.cs" />
|
<Compile Remove="ObjetosSim\ucTransporteCurva.xaml.cs" />
|
||||||
<Compile Remove="Simulacion\FPhysics.cs" />
|
<Compile Remove="Simulacion\FPhysics.cs" />
|
||||||
<Compile Remove="Simulacion\GeometrySimulator.cs" />
|
<Compile Remove="Simulacion\GeometrySimulator.cs" />
|
||||||
|
@ -47,13 +41,10 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Remove="ObjetosSim\ucBasicExample.xaml" />
|
|
||||||
<Page Remove="ObjetosSim\ucTransporteCurva.xaml" />
|
<Page Remove="ObjetosSim\ucTransporteCurva.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="ObjetosSim\ucBasicExample.xaml" />
|
|
||||||
<None Include="ObjetosSim\ucBasicExample.xaml.cs" />
|
|
||||||
<None Include="Simulacion\FPhysics.cs" />
|
<None Include="Simulacion\FPhysics.cs" />
|
||||||
<None Include="Simulacion\GeometrySimulator.cs" />
|
<None Include="Simulacion\GeometrySimulator.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -61,6 +52,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Aether.Physics2D" Version="2.1.0" />
|
<PackageReference Include="Aether.Physics2D" Version="2.1.0" />
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||||
|
<PackageReference Include="FarseerPhysics" Version="3.5.0" />
|
||||||
<PackageReference Include="LiveChartsCore.SkiaSharpView.WPF" Version="2.0.0-rc2" />
|
<PackageReference Include="LiveChartsCore.SkiaSharpView.WPF" Version="2.0.0-rc2" />
|
||||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
|
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
@ -96,19 +88,4 @@
|
||||||
<Resource Include="imagenes\tank.png" />
|
<Resource Include="imagenes\tank.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Properties\Settings.Designer.cs">
|
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Settings.settings</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="Properties\Settings.settings">
|
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -10,6 +10,7 @@ using CtrEditor.Siemens;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -33,8 +34,6 @@ namespace CtrEditor
|
||||||
|
|
||||||
private readonly DispatcherTimer _timerSimulacion;
|
private readonly DispatcherTimer _timerSimulacion;
|
||||||
|
|
||||||
public Canvas MainCanvas;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private DatosDeTrabajo datosDeTrabajo;
|
private DatosDeTrabajo datosDeTrabajo;
|
||||||
|
|
||||||
|
@ -358,7 +357,7 @@ namespace CtrEditor
|
||||||
stopwatch_SimModel_last = stopwatch_Sim.Elapsed.TotalMilliseconds;
|
stopwatch_SimModel_last = stopwatch_Sim.Elapsed.TotalMilliseconds;
|
||||||
|
|
||||||
// Eliminar el diseño de Debug luego de 2 segundos
|
// Eliminar el diseño de Debug luego de 2 segundos
|
||||||
if (TiempoDesdeStartSimulacion > 12000)
|
if (TiempoDesdeStartSimulacion > 2000)
|
||||||
simulationManager.Debug_ClearSimulationShapes();
|
simulationManager.Debug_ClearSimulationShapes();
|
||||||
else
|
else
|
||||||
TiempoDesdeStartSimulacion += (float)elapsedMilliseconds;
|
TiempoDesdeStartSimulacion += (float)elapsedMilliseconds;
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:Siemens="clr-namespace:CtrEditor.Siemens"
|
xmlns:Siemens="clr-namespace:CtrEditor.Siemens"
|
||||||
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||||
xmlns:ObjetosSim="clr-namespace:CtrEditor.ObjetosSim" x:Class="CtrEditor.MainWindow"
|
xmlns:ObjetosSim="clr-namespace:CtrEditor.ObjetosSim" x:Class="CtrEditor.MainWindow"
|
||||||
Height="900" Width="1600" WindowState="Maximized"
|
Height="900" Width="1600" WindowState="Maximized"
|
||||||
ResizeMode="CanResize" Title="{Binding directorioTrabajo}" Icon="/app2.png">
|
ResizeMode="CanResize" Title="{Binding directorioTrabajo}" Icon="/app2.png">
|
||||||
|
@ -13,7 +14,9 @@
|
||||||
</Window.DataContext>
|
</Window.DataContext>
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
|
<convert:FloatToFormattedStringConverter x:Key="floatFormatter"/>
|
||||||
|
<convert:DoubleToFormattedStringConverter x:Key="doubleFormatter"/>
|
||||||
|
<convert:BrushToColorNameConverter x:Key="BrushToColorNameConverter"/>
|
||||||
|
|
||||||
<!-- Style for Start/Stop Button -->
|
<!-- Style for Start/Stop Button -->
|
||||||
<Style x:Key="StartStopButtonStyle" TargetType="Button">
|
<Style x:Key="StartStopButtonStyle" TargetType="Button">
|
||||||
|
|
|
@ -10,7 +10,7 @@ using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
using Binding = System.Windows.Data.Binding;
|
using Binding = System.Windows.Data.Binding;
|
||||||
|
@ -65,7 +65,6 @@ namespace CtrEditor
|
||||||
viewModel.ImageSelected += ViewModel_ImageSelected;
|
viewModel.ImageSelected += ViewModel_ImageSelected;
|
||||||
viewModel?.LoadInitialData(); // Carga la primera imagen por defecto una vez cargada la ventana principal
|
viewModel?.LoadInitialData(); // Carga la primera imagen por defecto una vez cargada la ventana principal
|
||||||
viewModel.simulationManager.DebugCanvas = ImagenEnTrabajoCanvas;
|
viewModel.simulationManager.DebugCanvas = ImagenEnTrabajoCanvas;
|
||||||
viewModel.MainCanvas = ImagenEnTrabajoCanvas;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
>
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osBotella/>
|
<vm:osBotella/>
|
||||||
</UserControl.DataContext>
|
</UserControl.DataContext>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
//using using Microsoft.Xna.Framework;
|
//using using Microsoft.Xna.Framework;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
|
@ -1,10 +1,15 @@
|
||||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucBotellaCuello"
|
<UserControl x:Class="CtrEditor.ObjetosSim.Dinamicos.ucBotellaCuello"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osBotellaCuello/>
|
<vm:osBotella/>
|
||||||
</UserControl.DataContext>
|
</UserControl.DataContext>
|
||||||
|
|
||||||
<Ellipse Height="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}"
|
<Ellipse Height="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}"
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
//using using Microsoft.Xna.Framework;
|
//using using Microsoft.Xna.Framework;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using nkast.Aether.Physics2D.Common;
|
using nkast.Aether.Physics2D.Common;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace CtrEditor.ObjetosSim
|
namespace CtrEditor.ObjetosSim.Dinamicos
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for ucBotellaCuelloCuello.xaml
|
/// Interaction logic for ucBotellaCuelloCuello.xaml
|
||||||
|
|
|
@ -3,9 +3,14 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osFiller/>
|
<vm:osFiller/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -3,8 +3,16 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
|
mc:Ignorable="d"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
<convert:LevelToHeightMultiConverter x:Key="LevelToHeightMultiConverter"/>
|
||||||
|
<convert:WidthPercentageConverter x:Key="WidthPercentageConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osTanque Alto="1" Ancho="1" Angulo="-4" />
|
<vm:osTanque Alto="1" Ancho="1" Angulo="-4" />
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -4,10 +4,11 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
|
mc:Ignorable="d"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
<Storyboard x:Key="PulsingStoryboard" RepeatBehavior="Forever">
|
<Storyboard x:Key="PulsingStoryboard" RepeatBehavior="Forever">
|
||||||
<DoubleAnimation
|
<DoubleAnimation
|
||||||
Storyboard.TargetName="AnimatedEllipse"
|
Storyboard.TargetName="AnimatedEllipse"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
|
@ -4,7 +4,12 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osGuia/>
|
<vm:osGuia/>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,13 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:localuc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
xmlns:localuc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||||
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osTransporteCurva />
|
<vm:osTransporteCurva />
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
|
@ -4,9 +4,13 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
<convert:DistanceToMarginConverter x:Key="DistanceToMarginConverter"/>
|
||||||
|
|
||||||
<!-- Define the VisualBrush for the conveyor belt pattern -->
|
<!-- Define the VisualBrush for the conveyor belt pattern -->
|
||||||
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
|
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
|
||||||
<VisualBrush.Transform>
|
<VisualBrush.Transform>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
|
|
||||||
|
|
|
@ -1,86 +0,0 @@
|
||||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucTransporteGuiasUnion"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
|
||||||
xmlns:uc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
|
||||||
mc:Ignorable="d">
|
|
||||||
|
|
||||||
<UserControl.Resources>
|
|
||||||
<!-- Define the VisualBrush for the conveyor belt pattern -->
|
|
||||||
<VisualBrush x:Key="BeltBrushA" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
|
|
||||||
<VisualBrush.Transform>
|
|
||||||
<TransformGroup>
|
|
||||||
<TranslateTransform/>
|
|
||||||
</TransformGroup>
|
|
||||||
</VisualBrush.Transform>
|
|
||||||
<VisualBrush.Visual>
|
|
||||||
<Canvas>
|
|
||||||
<Rectangle Fill="#FFBFBFBF" Width="10" Height="10"/>
|
|
||||||
<Rectangle Fill="LightGray" Width="10" Height="10" Canvas.Left="10"/>
|
|
||||||
</Canvas>
|
|
||||||
</VisualBrush.Visual>
|
|
||||||
</VisualBrush>
|
|
||||||
<VisualBrush x:Key="BeltBrushB" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
|
|
||||||
<VisualBrush.Transform>
|
|
||||||
<TransformGroup>
|
|
||||||
<TranslateTransform/>
|
|
||||||
</TransformGroup>
|
|
||||||
</VisualBrush.Transform>
|
|
||||||
<VisualBrush.Visual>
|
|
||||||
<Canvas>
|
|
||||||
<Rectangle Fill="#FFBFBFBF" Width="10" Height="10"/>
|
|
||||||
<Rectangle Fill="LightGray" Width="10" Height="10" Canvas.Left="10"/>
|
|
||||||
</Canvas>
|
|
||||||
</VisualBrush.Visual>
|
|
||||||
</VisualBrush>
|
|
||||||
|
|
||||||
</UserControl.Resources>
|
|
||||||
|
|
||||||
<UserControl.DataContext>
|
|
||||||
<vm:osTransporteGuiasUnion/>
|
|
||||||
</UserControl.DataContext>
|
|
||||||
|
|
||||||
<Grid>
|
|
||||||
<Canvas x:Name="Canvas" RenderTransformOrigin="0,0">
|
|
||||||
<Canvas.RenderTransform>
|
|
||||||
<TransformGroup>
|
|
||||||
<ScaleTransform/>
|
|
||||||
<SkewTransform/>
|
|
||||||
<RotateTransform Angle="{Binding Angulo}"/>
|
|
||||||
<TranslateTransform/>
|
|
||||||
</TransformGroup>
|
|
||||||
</Canvas.RenderTransform>
|
|
||||||
<Rectangle x:Name="TransporteA" Width="{Binding AnchoTransporte_oculto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}"
|
|
||||||
Fill="{StaticResource BeltBrushA}"
|
|
||||||
/>
|
|
||||||
<Rectangle x:Name="TransporteB" Width="{Binding AnchoTransporte_oculto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}"
|
|
||||||
Fill="{StaticResource BeltBrushB}"
|
|
||||||
Canvas.Top="{Binding Alto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1.05}"
|
|
||||||
Canvas.Left="{Binding AnchoRecto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<uc:ThreeLinesControl x:Name="GuiaSuperior" AnchoRecto="{Binding AnchoRecto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
AnchoCentro="{Binding AnchoCentral, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
Altura="{Binding Alto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
AltoGuia="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
Canvas.Top="{Binding Distance, Converter={StaticResource MeterToPixelConverter},ConverterParameter=-1}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<uc:ThreeLinesControl x:Name="GuiaInferior" AnchoRecto="{Binding AnchoRecto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
AnchoCentro="{Binding AnchoCentral, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
Altura="{Binding Alto, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}"
|
|
||||||
AltoGuia="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter},ConverterParameter=1}">
|
|
||||||
<Canvas.Top>
|
|
||||||
<MultiBinding Converter="{StaticResource SumConverter}">
|
|
||||||
<Binding Path="Alto" Converter="{StaticResource MeterToPixelConverter}" ConverterParameter="1.0" />
|
|
||||||
<Binding Path="Distance" Converter="{StaticResource MeterToPixelConverter}" ConverterParameter="1.0" />
|
|
||||||
</MultiBinding>
|
|
||||||
</Canvas.Top>
|
|
||||||
</uc:ThreeLinesControl>
|
|
||||||
</Canvas>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
|
@ -1,375 +0,0 @@
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Animation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
|
||||||
using CtrEditor.Siemens;
|
|
||||||
using CtrEditor.Simulacion;
|
|
||||||
using SkiaSharp;
|
|
||||||
|
|
||||||
namespace CtrEditor.ObjetosSim
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for ucTransporteGuiasUnion.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class osTransporteGuiasUnion : osBase, IosBase
|
|
||||||
{
|
|
||||||
private osBase _osMotorA = null;
|
|
||||||
private osBase _osMotorB = null;
|
|
||||||
|
|
||||||
Dictionary<Rectangle, simTransporte> SimGeometriaT;
|
|
||||||
Dictionary<Rectangle, simGuia> SimGeometriaG;
|
|
||||||
Dictionary<Rectangle, Storyboard> Storyboards;
|
|
||||||
Dictionary<Rectangle, BoolReference> TransportsDirection;
|
|
||||||
Dictionary<Rectangle, FloatReference> TransportsVelocidad;
|
|
||||||
|
|
||||||
public static string NombreClase()
|
|
||||||
{
|
|
||||||
return "Transporte Guias Union";
|
|
||||||
}
|
|
||||||
private string nombre = NombreClase();
|
|
||||||
public override string Nombre
|
|
||||||
{
|
|
||||||
get => nombre;
|
|
||||||
set => SetProperty(ref nombre, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
public string motorA;
|
|
||||||
|
|
||||||
partial void OnMotorAChanged(string value)
|
|
||||||
{
|
|
||||||
_osMotorA = ObtenerLink(MotorA, typeof(osVMmotorSim));
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
public float velocidadActualA;
|
|
||||||
|
|
||||||
partial void OnVelocidadActualAChanged(float value)
|
|
||||||
{
|
|
||||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
|
||||||
{
|
|
||||||
var transporte = uc.TransporteA;
|
|
||||||
SetSpeed(transporte);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
bool invertirDireccionA;
|
|
||||||
|
|
||||||
partial void OnInvertirDireccionAChanged(bool value)
|
|
||||||
{
|
|
||||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
|
||||||
{
|
|
||||||
var transporte = uc.TransporteA;
|
|
||||||
|
|
||||||
SetSpeed(transporte);
|
|
||||||
ActualizarStoryboards(transporte);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
public string motorB;
|
|
||||||
|
|
||||||
partial void OnMotorBChanged(string value)
|
|
||||||
{
|
|
||||||
_osMotorB = ObtenerLink(MotorB, typeof(osVMmotorSim));
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
public float velocidadActualB;
|
|
||||||
|
|
||||||
partial void OnVelocidadActualBChanged(float value)
|
|
||||||
{
|
|
||||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
|
||||||
{
|
|
||||||
var transporte = uc.TransporteB;
|
|
||||||
SetSpeed(transporte);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
bool invertirDireccionB;
|
|
||||||
|
|
||||||
partial void OnInvertirDireccionBChanged(bool value)
|
|
||||||
{
|
|
||||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
|
||||||
{
|
|
||||||
var transporte = uc.TransporteB;
|
|
||||||
|
|
||||||
SetSpeed(transporte);
|
|
||||||
ActualizarStoryboards(transporte);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
public float anchoRecto;
|
|
||||||
[ObservableProperty]
|
|
||||||
public float anchoCentral;
|
|
||||||
|
|
||||||
|
|
||||||
partial void OnAnchoRectoChanged(float value)
|
|
||||||
{
|
|
||||||
AnchoTransporte_oculto = anchoRecto + anchoCentral;
|
|
||||||
}
|
|
||||||
|
|
||||||
partial void OnAnchoCentralChanged(float value)
|
|
||||||
{
|
|
||||||
AnchoTransporte_oculto = anchoRecto + anchoCentral;
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
public float anchoTransporte_oculto;
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
public float alto;
|
|
||||||
|
|
||||||
partial void OnAltoChanged(float value)
|
|
||||||
{
|
|
||||||
// ActualizarGeometrias();
|
|
||||||
}
|
|
||||||
|
|
||||||
[ObservableProperty]
|
|
||||||
public float angulo;
|
|
||||||
[ObservableProperty]
|
|
||||||
public float frictionCoefficient;
|
|
||||||
[ObservableProperty]
|
|
||||||
public float velMax50hz;
|
|
||||||
[ObservableProperty]
|
|
||||||
public float tiempoRampa;
|
|
||||||
[ObservableProperty]
|
|
||||||
public bool esMarcha;
|
|
||||||
[ObservableProperty]
|
|
||||||
private float distance;
|
|
||||||
[ObservableProperty]
|
|
||||||
private float altoGuia;
|
|
||||||
|
|
||||||
void ActualizarStoryboards(Rectangle transporte)
|
|
||||||
{
|
|
||||||
if (!Storyboards.Keys.Contains(transporte)) return;
|
|
||||||
|
|
||||||
var direccion = TransportsDirection[transporte].Value;
|
|
||||||
var velocidad = TransportsVelocidad[transporte].Value;
|
|
||||||
|
|
||||||
Storyboards[transporte] = CrearAnimacionMultiStoryBoardTrasnporte(Storyboards[transporte], transporte, direccion);
|
|
||||||
ActualizarAnimacionMultiStoryBoardTransporte(Storyboards[transporte], velocidad);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetSpeed(Rectangle transporte)
|
|
||||||
{
|
|
||||||
if (!Storyboards.Keys.Contains(transporte)) return;
|
|
||||||
|
|
||||||
var invertirDireccion = TransportsDirection[transporte].Value;
|
|
||||||
var velocidad = TransportsVelocidad[transporte].Value;
|
|
||||||
|
|
||||||
if (invertirDireccion)
|
|
||||||
SimGeometriaT[transporte]?.SetSpeed(-velocidad);
|
|
||||||
else
|
|
||||||
SimGeometriaT[transporte]?.SetSpeed(velocidad);
|
|
||||||
|
|
||||||
ActualizarAnimacionMultiStoryBoardTransporte(Storyboards[transporte], velocidad);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ActualizarGeometrias()
|
|
||||||
{
|
|
||||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
|
||||||
{
|
|
||||||
foreach (var transporte in SimGeometriaT)
|
|
||||||
{
|
|
||||||
UpdateRectangle(transporte.Value, transporte.Key, Alto, AnchoTransporte_oculto, Angulo);
|
|
||||||
ActualizarStoryboards(transporte.Key);
|
|
||||||
SetSpeed(transporte.Key);
|
|
||||||
}
|
|
||||||
foreach (var l in SimGeometriaG)
|
|
||||||
UpdateOrCreateLine(l.Value, l.Key);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public osTransporteGuiasUnion()
|
|
||||||
{
|
|
||||||
AnchoRecto = 0.5f;
|
|
||||||
AnchoCentral = 0.5f;
|
|
||||||
Alto = 0.10f;
|
|
||||||
AltoGuia = 0.03f;
|
|
||||||
Distance = 0.02f;
|
|
||||||
SimGeometriaT = new Dictionary<Rectangle, simTransporte>();
|
|
||||||
SimGeometriaG = new Dictionary<Rectangle, simGuia>();
|
|
||||||
Storyboards = new Dictionary<Rectangle, Storyboard>();
|
|
||||||
TransportsDirection = new Dictionary<Rectangle, BoolReference>();
|
|
||||||
TransportsVelocidad = new Dictionary<Rectangle, FloatReference>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void UpdateGeometryStart()
|
|
||||||
{
|
|
||||||
// Se llama antes de la simulacion
|
|
||||||
ActualizarGeometrias();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void SimulationStop()
|
|
||||||
{
|
|
||||||
// Se llama al detener la simulacion
|
|
||||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
|
||||||
{
|
|
||||||
SetSpeed(uc.TransporteB);
|
|
||||||
SetSpeed(uc.TransporteA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void UpdatePLC(PLCModel plc, int elapsedMilliseconds)
|
|
||||||
{
|
|
||||||
if (_osMotorA != null)
|
|
||||||
{
|
|
||||||
if (_osMotorA is osVMmotorSim motor)
|
|
||||||
VelocidadActualA = motor.Velocidad;
|
|
||||||
}
|
|
||||||
else if (MotorA.Length > 0)
|
|
||||||
_osMotorA = ObtenerLink(MotorA, typeof(osVMmotorSim));
|
|
||||||
|
|
||||||
if (_osMotorB != null)
|
|
||||||
{
|
|
||||||
if (_osMotorB is osVMmotorSim motor)
|
|
||||||
VelocidadActualB = motor.Velocidad;
|
|
||||||
}
|
|
||||||
else if (MotorB.Length > 0)
|
|
||||||
_osMotorB = ObtenerLink(MotorB, typeof(osVMmotorSim));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void ucLoaded()
|
|
||||||
{
|
|
||||||
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
|
||||||
// crear el objeto de simulacion
|
|
||||||
ActualizarLeftTop();
|
|
||||||
|
|
||||||
// El UserControl ya se ha cargado y podemos obtener las coordenadas para
|
|
||||||
// crear el objeto de simulacion
|
|
||||||
if (_visualRepresentation is ucTransporteGuiasUnion uc)
|
|
||||||
{
|
|
||||||
foreach (var child in uc.Canvas.Children)
|
|
||||||
if (child is Rectangle rect)
|
|
||||||
if (rect.Name.StartsWith("Transporte"))
|
|
||||||
{
|
|
||||||
SimGeometriaT.Add(rect,AddRectangle(simulationManager, rect, Alto, AnchoTransporte_oculto, Angulo));
|
|
||||||
Storyboards.Add(rect,CrearAnimacionMultiStoryBoardTrasnporte(rect,false));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var child in uc.GuiaSuperior.Canvas.Children)
|
|
||||||
if (child is Rectangle rect)
|
|
||||||
SimGeometriaG.Add(rect, AddLine(simulationManager, rect));
|
|
||||||
|
|
||||||
foreach (var child in uc.GuiaInferior.Canvas.Children)
|
|
||||||
if (child is Rectangle rect)
|
|
||||||
SimGeometriaG.Add(rect, AddLine(simulationManager, rect));
|
|
||||||
|
|
||||||
TransportsDirection.Add(uc.TransporteA, new BoolReference(() => InvertirDireccionA, value => InvertirDireccionA = value));
|
|
||||||
TransportsDirection.Add(uc.TransporteB, new BoolReference(() => InvertirDireccionB, value => InvertirDireccionB = value));
|
|
||||||
|
|
||||||
TransportsVelocidad.Add(uc.TransporteA, new FloatReference(() => VelocidadActualA, value => VelocidadActualA = value));
|
|
||||||
TransportsVelocidad.Add(uc.TransporteB, new FloatReference(() => VelocidadActualB, value => VelocidadActualB = value));
|
|
||||||
|
|
||||||
}
|
|
||||||
OnMotorAChanged(MotorA);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override void ucUnLoaded()
|
|
||||||
{
|
|
||||||
// El UserControl se esta eliminando
|
|
||||||
// eliminar el objeto de simulacion
|
|
||||||
foreach (var s in SimGeometriaT)
|
|
||||||
simulationManager.Remove(s.Value);
|
|
||||||
foreach (var s in SimGeometriaG)
|
|
||||||
simulationManager.Remove(s.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BoolReference
|
|
||||||
{
|
|
||||||
private Func<bool> getter;
|
|
||||||
private Action<bool> setter;
|
|
||||||
|
|
||||||
public BoolReference(Func<bool> getter, Action<bool> setter)
|
|
||||||
{
|
|
||||||
this.getter = getter;
|
|
||||||
this.setter = setter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Value
|
|
||||||
{
|
|
||||||
get => getter();
|
|
||||||
set => setter(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class FloatReference
|
|
||||||
{
|
|
||||||
private Func<float> getter;
|
|
||||||
private Action<float> setter;
|
|
||||||
|
|
||||||
public FloatReference(Func<float> getter, Action<float> setter)
|
|
||||||
{
|
|
||||||
this.getter = getter;
|
|
||||||
this.setter = setter;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float Value
|
|
||||||
{
|
|
||||||
get => getter();
|
|
||||||
set => setter(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public partial class ucTransporteGuiasUnion : UserControl, IDataContainer
|
|
||||||
{
|
|
||||||
public osBase? Datos { get; set; }
|
|
||||||
|
|
||||||
public ucTransporteGuiasUnion()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.Loaded += OnLoaded;
|
|
||||||
this.Unloaded += OnUnloaded;
|
|
||||||
}
|
|
||||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Datos?.ucLoaded();
|
|
||||||
}
|
|
||||||
private void OnUnloaded(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
Datos?.ucUnLoaded();
|
|
||||||
}
|
|
||||||
public void Resize(float width, float height)
|
|
||||||
{
|
|
||||||
if (Datos is osTransporteGuiasUnion datos)
|
|
||||||
datos.AnchoRecto = PixelToMeter.Instance.calc.PixelsToMeters(width);
|
|
||||||
}
|
|
||||||
public void Move(float LeftPixels, float TopPixels)
|
|
||||||
{
|
|
||||||
if (Datos != null)
|
|
||||||
{
|
|
||||||
Datos.Left = PixelToMeter.Instance.calc.PixelsToMeters(LeftPixels);
|
|
||||||
Datos.Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void Rotate(float Angle)
|
|
||||||
{
|
|
||||||
if (Datos != null)
|
|
||||||
if (Datos is osTransporteGuiasUnion datos)
|
|
||||||
datos.Angulo = Angle;
|
|
||||||
}
|
|
||||||
public void Highlight(bool State) { }
|
|
||||||
public int ZIndex()
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,10 +4,13 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
|
mc:Ignorable="d"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
|
||||||
<!-- Define the VisualBrush for the conveyor belt pattern -->
|
<!-- Define the VisualBrush for the conveyor belt pattern -->
|
||||||
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
|
<VisualBrush x:Key="BeltBrush" TileMode="Tile" Viewport="0,0,20,10" ViewportUnits="Absolute" Viewbox="0,0,20,10" ViewboxUnits="Absolute">
|
||||||
<VisualBrush.Transform>
|
<VisualBrush.Transform>
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.Windows.Controls;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
|
@ -4,9 +4,13 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
|
mc:Ignorable="d"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osVMmotorSim ImageSource_oculta="/imagenes/motorNegro.png" />
|
<vm:osVMmotorSim ImageSource_oculta="/imagenes/motorNegro.png" />
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -4,10 +4,15 @@
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osBoton Color="#FFADE6C0" ColorButton_oculto="#FFC72323"/>
|
<vm:osBoton Color="#FFADE6C0" ColorButton_oculto="#FFC72323"/>
|
||||||
</UserControl.DataContext>
|
</UserControl.DataContext>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -4,8 +4,13 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||||
|
mc:Ignorable="d"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osGearEncoder Dientes="9"/>
|
<vm:osGearEncoder Dientes="9"/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -4,9 +4,13 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||||
|
mc:Ignorable="d"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osPhotocell Color="#FFCA1C1C"/>
|
<vm:osPhotocell Color="#FFCA1C1C"/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
@ -46,7 +46,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
EscribirBitTag(TagPhotocell_OUT, !LuzCortada);
|
EscribirBitTag(TagPhotocell_OUT, !LuzCortada);
|
||||||
else
|
else
|
||||||
EscribirBitTag(TagPhotocell_OUT, LuzCortada);
|
EscribirBitTag(TagPhotocell_OUT, LuzCortada);
|
||||||
if (Filter_Frecuency < 1)
|
if (filter_Frecuency < 1)
|
||||||
{
|
{
|
||||||
Filter_Frecuency = 1;
|
Filter_Frecuency = 1;
|
||||||
Frecuency = 0;
|
Frecuency = 0;
|
||||||
|
|
|
@ -4,8 +4,13 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
|
mc:Ignorable="d"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osSensTemperatura />
|
<vm:osSensTemperatura />
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -4,10 +4,15 @@
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osAnalogTag/>
|
<vm:osAnalogTag/>
|
||||||
</UserControl.DataContext>
|
</UserControl.DataContext>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -4,10 +4,15 @@
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osBoolTag/>
|
<vm:osBoolTag/>
|
||||||
</UserControl.DataContext>
|
</UserControl.DataContext>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
Background="LightGray"
|
mc:Ignorable="d"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d">
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||||
|
Background="LightGray">
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osConsensGeneric />
|
<vm:osConsensGeneric />
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucTrace3"
|
<UserControl x:Class="CtrEditor.ObjetosSim.Traces.ucTrace3"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
Background="#FFECECEC"
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim.Traces"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d" Background="#FFECECEC">
|
||||||
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osTrace3 Descripcion_Serie_1="Serie 1" Max_Cantidad_Elementos="100"/>
|
<vm:osTrace3 Descripcion_Serie_1="Serie 1" Max_Cantidad_Elementos="100"/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
@ -7,7 +7,7 @@ using System.Windows.Shapes;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Runtime.Intrinsics;
|
using System.Runtime.Intrinsics;
|
||||||
|
|
||||||
namespace CtrEditor.ObjetosSim
|
namespace CtrEditor.ObjetosSim.Traces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for ucTrace3.xaml
|
/// Interaction logic for ucTrace3.xaml
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucTraceSimple"
|
<UserControl x:Class="CtrEditor.ObjetosSim.Traces.ucTraceSimple"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim.Traces"
|
||||||
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
|
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
|
||||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
mc:Ignorable="d">
|
|
||||||
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
<vm:osTraceSimple Alto="3" Ancho="6"/>
|
<vm:osTraceSimple Alto="3" Ancho="6"/>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
@ -11,7 +11,7 @@ using LiveChartsCore.SkiaSharpView;
|
||||||
using LiveChartsCore.Defaults;
|
using LiveChartsCore.Defaults;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace CtrEditor.ObjetosSim
|
namespace CtrEditor.ObjetosSim.Traces
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for ucTraceSimple.xaml
|
/// Interaction logic for ucTraceSimple.xaml
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using System.Windows.Data;
|
using System.Windows.Data;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
<UserControl x:Class="CtrEditor.ObjetosSim.UserControls.ThreeLinesControl"
|
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
mc:Ignorable="d"
|
|
||||||
Width="Auto" Height="Auto">
|
|
||||||
|
|
||||||
<Grid>
|
|
||||||
<Canvas x:Name="Canvas"/>
|
|
||||||
</Grid>
|
|
||||||
</UserControl>
|
|
|
@ -1,144 +0,0 @@
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
|
|
||||||
namespace CtrEditor.ObjetosSim.UserControls
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Interaction logic for ThreeLinesControl.xaml
|
|
||||||
/// </summary>
|
|
||||||
public partial class ThreeLinesControl : UserControl
|
|
||||||
{
|
|
||||||
private Rectangle _liz;
|
|
||||||
private Rectangle _lc;
|
|
||||||
private Rectangle _lde;
|
|
||||||
|
|
||||||
public ThreeLinesControl()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
this.Loaded += ThreeLinesControl_Loaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ThreeLinesControl_Loaded(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
CreateOrUpdateRectangles();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double AnchoRecto
|
|
||||||
{
|
|
||||||
get { return (double)GetValue(AnchoRectoProperty); }
|
|
||||||
set { SetValue(AnchoRectoProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly DependencyProperty AnchoRectoProperty =
|
|
||||||
DependencyProperty.Register("AnchoRecto", typeof(double), typeof(ThreeLinesControl), new PropertyMetadata(100.0, OnDimensionsChanged));
|
|
||||||
|
|
||||||
public double AnchoCentro
|
|
||||||
{
|
|
||||||
get { return (double)GetValue(AnchoCentroProperty); }
|
|
||||||
set { SetValue(AnchoCentroProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly DependencyProperty AnchoCentroProperty =
|
|
||||||
DependencyProperty.Register("AnchoCentro", typeof(double), typeof(ThreeLinesControl), new PropertyMetadata(100.0, OnDimensionsChanged));
|
|
||||||
|
|
||||||
public double Altura
|
|
||||||
{
|
|
||||||
get { return (double)GetValue(AlturaProperty); }
|
|
||||||
set { SetValue(AlturaProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly DependencyProperty AlturaProperty =
|
|
||||||
DependencyProperty.Register("Altura", typeof(double), typeof(ThreeLinesControl), new PropertyMetadata(100.0, OnDimensionsChanged));
|
|
||||||
|
|
||||||
public double AltoGuia
|
|
||||||
{
|
|
||||||
get { return (double)GetValue(AltoGuiaProperty); }
|
|
||||||
set { SetValue(AltoGuiaProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static readonly DependencyProperty AltoGuiaProperty =
|
|
||||||
DependencyProperty.Register("AltoGuia", typeof(double), typeof(ThreeLinesControl), new PropertyMetadata(10.0, OnDimensionsChanged));
|
|
||||||
|
|
||||||
private static void OnDimensionsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
var control = d as ThreeLinesControl;
|
|
||||||
control?.CreateOrUpdateRectangles();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateOrUpdateRectangles()
|
|
||||||
{
|
|
||||||
if (_liz == null || _lc == null || _lde == null)
|
|
||||||
{
|
|
||||||
// Crear Liz
|
|
||||||
_liz = new Rectangle
|
|
||||||
{
|
|
||||||
Width = AnchoRecto,
|
|
||||||
Height = AltoGuia,
|
|
||||||
Fill = Brushes.Blue
|
|
||||||
};
|
|
||||||
Canvas.SetLeft(_liz, 0);
|
|
||||||
Canvas.SetTop(_liz, -AltoGuia / 2);
|
|
||||||
Canvas.Children.Add(_liz);
|
|
||||||
|
|
||||||
// Crear Lc
|
|
||||||
_lc = new Rectangle
|
|
||||||
{
|
|
||||||
Width = CalculateLcWidth(),
|
|
||||||
Height = AltoGuia,
|
|
||||||
Fill = Brushes.Red,
|
|
||||||
RenderTransformOrigin = new Point(0, 0.5)
|
|
||||||
};
|
|
||||||
_lc.RenderTransform = new RotateTransform(GetRotationAngle(AnchoCentro, Altura));
|
|
||||||
Canvas.SetLeft(_lc, AnchoRecto);
|
|
||||||
Canvas.SetTop(_lc, -AltoGuia / 2);
|
|
||||||
Canvas.Children.Add(_lc);
|
|
||||||
|
|
||||||
// Crear Lde
|
|
||||||
_lde = new Rectangle
|
|
||||||
{
|
|
||||||
Width = AnchoRecto,
|
|
||||||
Height = AltoGuia,
|
|
||||||
Fill = Brushes.Green
|
|
||||||
};
|
|
||||||
Canvas.SetLeft(_lde, AnchoRecto + AnchoCentro);
|
|
||||||
Canvas.SetTop(_lde, Altura - AltoGuia / 2);
|
|
||||||
Canvas.Children.Add(_lde);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Actualizar Liz
|
|
||||||
_liz.Width = AnchoRecto;
|
|
||||||
_liz.Height = AltoGuia;
|
|
||||||
Canvas.SetLeft(_liz, 0);
|
|
||||||
Canvas.SetTop(_liz, -AltoGuia / 2);
|
|
||||||
|
|
||||||
// Actualizar Lc
|
|
||||||
_lc.Width = CalculateLcWidth();
|
|
||||||
_lc.Height = AltoGuia;
|
|
||||||
_lc.RenderTransform = new RotateTransform(GetRotationAngle(AnchoCentro, Altura));
|
|
||||||
Canvas.SetLeft(_lc, AnchoRecto);
|
|
||||||
Canvas.SetTop(_lc, -AltoGuia / 2);
|
|
||||||
|
|
||||||
// Actualizar Lde
|
|
||||||
_lde.Width = AnchoRecto;
|
|
||||||
_lde.Height = AltoGuia;
|
|
||||||
Canvas.SetLeft(_lde, AnchoRecto + AnchoCentro);
|
|
||||||
Canvas.SetTop(_lde, Altura - AltoGuia / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Método auxiliar para calcular la hipotenusa
|
|
||||||
private double CalculateLcWidth()
|
|
||||||
{
|
|
||||||
return Math.Sqrt(Math.Pow(AnchoCentro, 2) + Math.Pow(Altura, 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
private double GetRotationAngle(double anchoCentro, double altura)
|
|
||||||
{
|
|
||||||
return Math.Atan2(altura, anchoCentro) * 180 / Math.PI;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,17 +1,29 @@
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using CtrEditor.Simulacion;
|
using CtrEditor.Simulacion;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using nkast.Aether.Physics2D.Common;
|
using nkast.Aether.Physics2D.Common;
|
||||||
|
using FarseerPhysics.Dynamics;
|
||||||
using Siemens.Simatic.Simulation.Runtime;
|
using Siemens.Simatic.Simulation.Runtime;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Input;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows.Shapes;
|
using HarfBuzzSharp;
|
||||||
using System.Windows.Controls;
|
|
||||||
|
|
||||||
namespace CtrEditor.ObjetosSim
|
namespace CtrEditor.ObjetosSim
|
||||||
{
|
{
|
||||||
|
@ -234,12 +246,19 @@ namespace CtrEditor.ObjetosSim
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Storyboard CrearAnimacionMultiStoryBoardTrasnporte(Rectangle transporte, bool invertirDireccion)
|
protected void CrearAnimacionStoryBoardTrasnporte(System.Windows.Shapes.Rectangle transporte, bool invertirDireccion)
|
||||||
{
|
{
|
||||||
if (_visualRepresentation == null) return null;
|
if (_visualRepresentation == null) return;
|
||||||
if (transporte == null) return null;
|
if (transporte == null) return;
|
||||||
|
|
||||||
Storyboard storyboard = new Storyboard();
|
// Detener y eliminar el storyboard existente si hay uno
|
||||||
|
if (_storyboard != null)
|
||||||
|
{
|
||||||
|
_storyboard.Stop();
|
||||||
|
_storyboard.Children.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
_storyboard = new Storyboard();
|
||||||
var animation = new DoubleAnimation
|
var animation = new DoubleAnimation
|
||||||
{
|
{
|
||||||
From = invertirDireccion ? 20 : 0,
|
From = invertirDireccion ? 20 : 0,
|
||||||
|
@ -249,43 +268,20 @@ namespace CtrEditor.ObjetosSim
|
||||||
};
|
};
|
||||||
Storyboard.SetTarget(animation, transporte);
|
Storyboard.SetTarget(animation, transporte);
|
||||||
Storyboard.SetTargetProperty(animation, new PropertyPath("(Rectangle.Fill).(VisualBrush.Transform).(TransformGroup.Children)[0].(TranslateTransform.X)"));
|
Storyboard.SetTargetProperty(animation, new PropertyPath("(Rectangle.Fill).(VisualBrush.Transform).(TransformGroup.Children)[0].(TranslateTransform.X)"));
|
||||||
storyboard.Children.Add(animation);
|
_storyboard.Children.Add(animation);
|
||||||
storyboard.Begin();
|
_storyboard.Begin();
|
||||||
storyboard.SetSpeedRatio(0);
|
_storyboard.SetSpeedRatio(0);
|
||||||
return storyboard;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Storyboard CrearAnimacionMultiStoryBoardTrasnporte(Storyboard storyboard, Rectangle transporte, bool invertirDireccion)
|
|
||||||
{
|
|
||||||
// Detener y eliminar el storyboard existente si hay uno
|
|
||||||
if (storyboard != null)
|
|
||||||
{
|
|
||||||
storyboard.Stop();
|
|
||||||
storyboard.Children.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
return CrearAnimacionMultiStoryBoardTrasnporte(transporte, invertirDireccion);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void ActualizarAnimacionMultiStoryBoardTransporte(Storyboard storyboard, float velocidadActual)
|
|
||||||
{
|
|
||||||
if (_visualRepresentation == null) return;
|
|
||||||
if (storyboard == null) return;
|
|
||||||
|
|
||||||
if (!_mainViewModel.IsSimulationRunning)
|
|
||||||
storyboard.SetSpeedRatio(0);
|
|
||||||
else
|
|
||||||
storyboard.SetSpeedRatio(Math.Abs(velocidadActual));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void CrearAnimacionStoryBoardTrasnporte(Rectangle transporte, bool invertirDireccion)
|
|
||||||
{
|
|
||||||
_storyboard = CrearAnimacionMultiStoryBoardTrasnporte(_storyboard, transporte, invertirDireccion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ActualizarAnimacionStoryBoardTransporte(float velocidadActual)
|
protected void ActualizarAnimacionStoryBoardTransporte(float velocidadActual)
|
||||||
{
|
{
|
||||||
ActualizarAnimacionMultiStoryBoardTransporte(_storyboard, velocidadActual);
|
if (_visualRepresentation == null) return;
|
||||||
|
if (_storyboard == null) return;
|
||||||
|
|
||||||
|
if (!_mainViewModel.IsSimulationRunning)
|
||||||
|
_storyboard.SetSpeedRatio(0);
|
||||||
|
else
|
||||||
|
_storyboard.SetSpeedRatio(Math.Abs(velocidadActual));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -387,49 +383,11 @@ namespace CtrEditor.ObjetosSim
|
||||||
public float CanvasGetTopinMeter()
|
public float CanvasGetTopinMeter()
|
||||||
{
|
{
|
||||||
if (_visualRepresentation != null)
|
if (_visualRepresentation != null)
|
||||||
return PixelToMeter.Instance.calc.PixelsToMeters((float)System.Windows.Controls.Canvas.GetTop(_visualRepresentation));
|
return PixelToMeter.Instance.calc.PixelsToMeters((float)Canvas.GetTop(_visualRepresentation));
|
||||||
else return 0f;
|
else return 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float PixelsToMeters(float pixel)
|
public (Vector2 TopLeft, Vector2 BottomRight) GetRectangleCoordinatesInMeter(System.Windows.Shapes.Rectangle rect)
|
||||||
{
|
|
||||||
return PixelToMeter.Instance.calc.PixelsToMeters(pixel);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2 PixelsToMeters(Vector2 pixel)
|
|
||||||
{
|
|
||||||
return new Vector2(PixelsToMeters(pixel.X),PixelsToMeters(pixel.Y));
|
|
||||||
}
|
|
||||||
|
|
||||||
public float MeterToPixels(float meter)
|
|
||||||
{
|
|
||||||
return PixelToMeter.Instance.calc.MetersToPixels(meter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2 MeterToPixels(Vector2 meter)
|
|
||||||
{
|
|
||||||
return new Vector2(MeterToPixels(meter.X), MeterToPixels(meter.Y));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static GeneralTransform GetTransformToRoot(Visual visual)
|
|
||||||
{
|
|
||||||
// Crear una transformación acumulativa inicial
|
|
||||||
GeneralTransformGroup transformGroup = new GeneralTransformGroup();
|
|
||||||
|
|
||||||
// Recorrer hacia arriba el árbol visual, acumulando las transformaciones
|
|
||||||
while (visual != null)
|
|
||||||
{
|
|
||||||
GeneralTransform transform = visual.TransformToAncestor(visual);
|
|
||||||
transformGroup.Children.Insert(0, transform);
|
|
||||||
visual = VisualTreeHelper.GetParent(visual) as Visual;
|
|
||||||
}
|
|
||||||
|
|
||||||
return transformGroup;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public (Vector2 TopLeft, Vector2 BottomRight) GetRectangleCoordinatesInMeter(Rectangle rect)
|
|
||||||
{
|
{
|
||||||
if (rect != null)
|
if (rect != null)
|
||||||
{
|
{
|
||||||
|
@ -449,45 +407,31 @@ namespace CtrEditor.ObjetosSim
|
||||||
else return (new Vector2(0, 0), new Vector2(0, 0));
|
else return (new Vector2(0, 0), new Vector2(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public (Vector2 Start, Vector2 End) GetCenterLineVectors(Rectangle rect)
|
public (Vector2 Start, Vector2 End) GetCenterLineVectors(System.Windows.Shapes.Rectangle rect)
|
||||||
{
|
{
|
||||||
if (rect == null)
|
if (rect == null)
|
||||||
return (new Vector2(0, 0), new Vector2(0, 0));
|
return (new Vector2(0, 0), new Vector2(0, 0));
|
||||||
|
|
||||||
Vector2 start = new Vector2(0, 0);
|
var _canvasLeft = CanvasGetLeftinMeter();
|
||||||
Vector2 end = new Vector2(0, 0);
|
var _canvasTop = CanvasGetTopinMeter();
|
||||||
|
|
||||||
// Usar Dispatcher para asegurar la ejecución en el hilo correcto
|
var transform = rect.TransformToAncestor(_visualRepresentation);
|
||||||
_visualRepresentation?.Dispatcher.Invoke(() =>
|
|
||||||
{
|
|
||||||
// Asegúrate de que el control está en el árbol visual y actualizado
|
|
||||||
if (_visualRepresentation.IsLoaded && rect.IsLoaded)
|
|
||||||
{
|
|
||||||
_visualRepresentation.UpdateLayout();
|
|
||||||
|
|
||||||
var _canvasLeft = CanvasGetLeftinMeter();
|
// Puntos en coordenadas locales del rectángulo no rotado
|
||||||
var _canvasTop = CanvasGetTopinMeter();
|
Point startLocal = new Point(0, rect.ActualHeight / 2);
|
||||||
|
Point endLocal = new Point(rect.ActualWidth, rect.ActualHeight / 2);
|
||||||
|
|
||||||
var transform = rect.TransformToAncestor(_visualRepresentation);
|
// Transformar estos puntos al sistema de coordenadas del ancestro
|
||||||
|
Point transformedStart = transform.Transform(startLocal);
|
||||||
|
Point transformedEnd = transform.Transform(endLocal);
|
||||||
|
|
||||||
// Puntos en coordenadas locales del rectángulo no rotado
|
// Convierte a unidades de Farseer (metros en este caso)
|
||||||
Point startLocal = new Point(0, rect.ActualHeight / 2);
|
Vector2 start = new Vector2(PixelToMeter.Instance.calc.PixelsToMeters((float)transformedStart.X) + _canvasLeft, PixelToMeter.Instance.calc.PixelsToMeters((float)transformedStart.Y) + _canvasTop);
|
||||||
Point endLocal = new Point(rect.ActualWidth, rect.ActualHeight / 2);
|
Vector2 end = new Vector2(PixelToMeter.Instance.calc.PixelsToMeters((float)transformedEnd.X) + _canvasLeft, PixelToMeter.Instance.calc.PixelsToMeters((float)transformedEnd.Y) + _canvasTop);
|
||||||
|
|
||||||
// Transformar estos puntos al sistema de coordenadas del ancestro
|
|
||||||
Point transformedStart = transform.Transform(startLocal);
|
|
||||||
Point transformedEnd = transform.Transform(endLocal);
|
|
||||||
|
|
||||||
// Convierte a unidades de Farseer (metros en este caso)
|
|
||||||
start = new Vector2(PixelToMeter.Instance.calc.PixelsToMeters((float)transformedStart.X) + _canvasLeft, PixelToMeter.Instance.calc.PixelsToMeters((float)transformedStart.Y) + _canvasTop);
|
|
||||||
end = new Vector2(PixelToMeter.Instance.calc.PixelsToMeters((float)transformedEnd.X) + _canvasLeft, PixelToMeter.Instance.calc.PixelsToMeters((float)transformedEnd.Y) + _canvasTop);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return (start, end);
|
return (start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Vector2 GetCurveCenterInMeter(float RadioExterno)
|
public Vector2 GetCurveCenterInMeter(float RadioExterno)
|
||||||
{
|
{
|
||||||
var _canvasLeft = CanvasGetLeftinMeter();
|
var _canvasLeft = CanvasGetLeftinMeter();
|
||||||
|
@ -501,7 +445,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
return new Vector2((float)centerX, (float)centerY);
|
return new Vector2((float)centerX, (float)centerY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2 GetRectangleCenter(Rectangle wpfRect)
|
public Vector2 GetRectangleCenter(System.Windows.Shapes.Rectangle wpfRect)
|
||||||
{
|
{
|
||||||
var coords = GetRectangleCoordinatesInMeter(wpfRect);
|
var coords = GetRectangleCoordinatesInMeter(wpfRect);
|
||||||
|
|
||||||
|
@ -514,13 +458,13 @@ namespace CtrEditor.ObjetosSim
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void UpdateRectangle(simTransporte simRect, Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
public void UpdateRectangle(simTransporte simRect, System.Windows.Shapes.Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
||||||
{
|
{
|
||||||
if (simRect != null)
|
if (simRect != null)
|
||||||
simRect.Create(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo);
|
simRect.Create(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateRectangle(simBarrera simRect, Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
public void UpdateRectangle(simBarrera simRect, System.Windows.Shapes.Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
||||||
{
|
{
|
||||||
if (simRect != null)
|
if (simRect != null)
|
||||||
simRect.Create(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo);
|
simRect.Create(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo);
|
||||||
|
@ -536,21 +480,20 @@ namespace CtrEditor.ObjetosSim
|
||||||
return simulationManager.AddCurve(RadioInterno, RadioExterno, startAngle, endAngle, GetCurveCenterInMeter(RadioExterno));
|
return simulationManager.AddCurve(RadioInterno, RadioExterno, startAngle, endAngle, GetCurveCenterInMeter(RadioExterno));
|
||||||
}
|
}
|
||||||
|
|
||||||
public simTransporte AddRectangle(SimulationManagerFP simulationManager, Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
public simTransporte AddRectangle(SimulationManagerFP simulationManager, System.Windows.Shapes.Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
||||||
{
|
{
|
||||||
return simulationManager.AddRectangle(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo);
|
return simulationManager.AddRectangle(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public simBarrera AddBarrera(SimulationManagerFP simulationManager, Rectangle wpfRect, float Alto, float Ancho, float Angulo, bool detectarCuello)
|
public simBarrera AddBarrera(SimulationManagerFP simulationManager, System.Windows.Shapes.Rectangle wpfRect, float Alto, float Ancho, float Angulo, bool detectarCuello)
|
||||||
{
|
{
|
||||||
return simulationManager.AddBarrera(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo, detectarCuello);
|
return simulationManager.AddBarrera(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo, detectarCuello);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateOrCreateLine(simGuia simGuia, Rectangle wpfRect)
|
public void UpdateOrCreateLine(simGuia simGuia, System.Windows.Shapes.Rectangle wpfRect)
|
||||||
{
|
{
|
||||||
if (simGuia != null)
|
if (simGuia != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
var coords = GetCenterLineVectors(wpfRect);
|
var coords = GetCenterLineVectors(wpfRect);
|
||||||
|
|
||||||
// Crear o actualizar simRectangle
|
// Crear o actualizar simRectangle
|
||||||
|
@ -558,7 +501,7 @@ namespace CtrEditor.ObjetosSim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public simGuia AddLine(SimulationManagerFP simulationManager, Rectangle wpfRect)
|
public simGuia AddLine(SimulationManagerFP simulationManager, System.Windows.Shapes.Rectangle wpfRect)
|
||||||
{
|
{
|
||||||
var coords = GetCenterLineVectors(wpfRect);
|
var coords = GetCenterLineVectors(wpfRect);
|
||||||
return simulationManager.AddLine(coords.Start, coords.End);
|
return simulationManager.AddLine(coords.Start, coords.End);
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
xmlns:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||||
>
|
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||||
|
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
|
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<UserControl.DataContext>
|
<UserControl.DataContext>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using CtrEditor.Siemens;
|
using CtrEditor.Siemens;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// This code was generated by a tool.
|
|
||||||
// Runtime Version:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
|
||||||
// the code is regenerated.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace CtrEditor.Properties {
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
|
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
|
||||||
|
|
||||||
public static Settings Default {
|
|
||||||
get {
|
|
||||||
return defaultInstance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version='1.0' encoding='utf-8'?>
|
|
||||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
|
||||||
<Profiles>
|
|
||||||
<Profile Name="(Default)" />
|
|
||||||
</Profiles>
|
|
||||||
</SettingsFile>
|
|
|
@ -1,15 +1,23 @@
|
||||||
using System.Windows.Controls;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using CtrEditor.ObjetosSim;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using nkast.Aether.Physics2D;
|
||||||
using nkast.Aether.Physics2D.Dynamics;
|
using nkast.Aether.Physics2D.Dynamics;
|
||||||
using nkast.Aether.Physics2D.Common;
|
using nkast.Aether.Physics2D.Common;
|
||||||
using nkast.Aether.Physics2D.Collision.Shapes;
|
using nkast.Aether.Physics2D.Collision.Shapes;
|
||||||
using nkast.Aether.Physics2D.Dynamics.Contacts;
|
using nkast.Aether.Physics2D.Dynamics.Contacts;
|
||||||
|
using nkast.Aether.Physics2D.Collision;
|
||||||
|
using Transform = nkast.Aether.Physics2D.Common.Transform;
|
||||||
using nkast.Aether.Physics2D.Dynamics.Joints;
|
using nkast.Aether.Physics2D.Dynamics.Joints;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
namespace CtrEditor.Simulacion
|
namespace CtrEditor.Simulacion
|
||||||
{
|
{
|
||||||
|
@ -25,14 +33,6 @@ namespace CtrEditor.Simulacion
|
||||||
_world.Remove(Body);
|
_world.Remove(Body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static float GradosARadianes(float grados)
|
|
||||||
{
|
|
||||||
return (float)(grados * (Math.PI / 180));
|
|
||||||
}
|
|
||||||
public static float RadianesAGrados(float radianes)
|
|
||||||
{
|
|
||||||
return (float)(radianes * (180 / Math.PI));
|
|
||||||
}
|
|
||||||
public void SetPosition(float x, float y)
|
public void SetPosition(float x, float y)
|
||||||
{
|
{
|
||||||
Body.SetTransform(new Vector2(x, y), Body.Rotation);
|
Body.SetTransform(new Vector2(x, y), Body.Rotation);
|
||||||
|
@ -62,8 +62,8 @@ namespace CtrEditor.Simulacion
|
||||||
_deferredActions = deferredActions;
|
_deferredActions = deferredActions;
|
||||||
_innerRadius = innerRadius;
|
_innerRadius = innerRadius;
|
||||||
_outerRadius = outerRadius;
|
_outerRadius = outerRadius;
|
||||||
_startAngle = GradosARadianes(startAngle);
|
_startAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(startAngle);
|
||||||
_endAngle = GradosARadianes(endAngle);
|
_endAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(endAngle);
|
||||||
Create(position);
|
Create(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ namespace CtrEditor.Simulacion
|
||||||
if (_world == null) return;
|
if (_world == null) return;
|
||||||
_innerRadius = innerRadius;
|
_innerRadius = innerRadius;
|
||||||
_outerRadius = outerRadius;
|
_outerRadius = outerRadius;
|
||||||
_startAngle = GradosARadianes(startAngle);
|
_startAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(startAngle);
|
||||||
_endAngle = GradosARadianes(endAngle);
|
_endAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(endAngle);
|
||||||
Create(position);
|
Create(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,8 +197,8 @@ namespace CtrEditor.Simulacion
|
||||||
|
|
||||||
public float Angle
|
public float Angle
|
||||||
{
|
{
|
||||||
get { return RadianesAGrados(Body.Rotation); }
|
get { return Microsoft.Xna.Framework.MathHelper.ToDegrees(Body.Rotation); }
|
||||||
set { Body.Rotation = GradosARadianes(value); }
|
set { Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public new void SetPosition(float x, float y)
|
public new void SetPosition(float x, float y)
|
||||||
|
@ -229,7 +229,7 @@ namespace CtrEditor.Simulacion
|
||||||
Body = _world.CreateRectangle( width, height, 1f, position);
|
Body = _world.CreateRectangle( width, height, 1f, position);
|
||||||
Body.FixtureList[0].IsSensor = true;
|
Body.FixtureList[0].IsSensor = true;
|
||||||
Body.BodyType = BodyType.Static;
|
Body.BodyType = BodyType.Static;
|
||||||
Body.Rotation = GradosARadianes(angle);
|
Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(angle);
|
||||||
Body.Tag = this; // Importante para la identificación durante la colisión
|
Body.Tag = this; // Importante para la identificación durante la colisión
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,8 +257,8 @@ namespace CtrEditor.Simulacion
|
||||||
|
|
||||||
public float Angle
|
public float Angle
|
||||||
{
|
{
|
||||||
get { return RadianesAGrados(Body.Rotation); }
|
get { return Microsoft.Xna.Framework.MathHelper.ToDegrees(Body.Rotation); }
|
||||||
set { Body.Rotation = GradosARadianes(value); }
|
set { Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public new void SetPosition(float x, float y)
|
public new void SetPosition(float x, float y)
|
||||||
|
@ -282,7 +282,7 @@ namespace CtrEditor.Simulacion
|
||||||
Body = _world.CreateRectangle( width, height, 1f, position);
|
Body = _world.CreateRectangle( width, height, 1f, position);
|
||||||
Body.FixtureList[0].IsSensor = true;
|
Body.FixtureList[0].IsSensor = true;
|
||||||
Body.BodyType = BodyType.Static;
|
Body.BodyType = BodyType.Static;
|
||||||
Body.Rotation = GradosARadianes(angle);
|
Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(angle);
|
||||||
Body.Tag = this; // Importante para la identificación durante la colisión
|
Body.Tag = this; // Importante para la identificación durante la colisión
|
||||||
LuzCortada = 0;
|
LuzCortada = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ using FarseerPhysics.Dynamics;
|
||||||
using FarseerPhysics.Factories;
|
using FarseerPhysics.Factories;
|
||||||
using FarseerPhysics.Collision.Shapes;
|
using FarseerPhysics.Collision.Shapes;
|
||||||
using nkast.Aether.Physics2D.Common;
|
using nkast.Aether.Physics2D.Common;
|
||||||
|
using CtrEditor.Convertidores;
|
||||||
using FarseerPhysics.Common;
|
using FarseerPhysics.Common;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using FarseerPhysics.Collision;
|
||||||
using Microsoft.VisualBasic.Devices;
|
using Microsoft.VisualBasic.Devices;
|
||||||
using nkast.Aether.Physics2D.Common;
|
using nkast.Aether.Physics2D.Common;
|
||||||
|
|
||||||
|
|
|
@ -146,13 +146,13 @@ namespace CtrEditor.Simulacion
|
||||||
float radius = circleShape.Radius;
|
float radius = circleShape.Radius;
|
||||||
float halfSide = radius; // El lado del cuadrado inscrito es igual al radio
|
float halfSide = radius; // El lado del cuadrado inscrito es igual al radio
|
||||||
|
|
||||||
Vector2[] squareVertices = new Vector2[]
|
Vector2[] squareVertices =
|
||||||
{
|
[
|
||||||
new Vector2(-halfSide, -halfSide),
|
new Vector2(-halfSide, -halfSide),
|
||||||
new Vector2(halfSide, -halfSide),
|
new Vector2(halfSide, -halfSide),
|
||||||
new Vector2(halfSide, halfSide),
|
new Vector2(halfSide, halfSide),
|
||||||
new Vector2(-halfSide, halfSide)
|
new Vector2(-halfSide, halfSide)
|
||||||
};
|
];
|
||||||
|
|
||||||
foreach (var vertex in squareVertices)
|
foreach (var vertex in squareVertices)
|
||||||
{
|
{
|
||||||
|
@ -164,7 +164,6 @@ namespace CtrEditor.Simulacion
|
||||||
return vertices;
|
return vertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Vector2 RotatePoint(Vector2 point, Vector2 origin, float rotation)
|
private static Vector2 RotatePoint(Vector2 point, Vector2 origin, float rotation)
|
||||||
{
|
{
|
||||||
float cos = (float)Math.Cos(rotation);
|
float cos = (float)Math.Cos(rotation);
|
||||||
|
|
Loading…
Reference in New Issue