Compare commits
2 Commits
c4892b1f36
...
c1ac20964e
Author | SHA1 | Date |
---|---|---|
Miguel | c1ac20964e | |
Miguel | 268b66ad76 |
11
App.xaml
11
App.xaml
|
@ -3,7 +3,18 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:CtrEditor"
|
||||
StartupUri="MainWindow.xaml">
|
||||
|
||||
<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>
|
||||
|
||||
|
|
|
@ -6,9 +6,15 @@
|
|||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<Optimize>True</Optimize>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="ObjetosSim\ucBasicExample.xaml.cs" />
|
||||
<Compile Remove="ObjetosSim\ucTransporteCurva.xaml.cs" />
|
||||
<Compile Remove="Simulacion\FPhysics.cs" />
|
||||
<Compile Remove="Simulacion\GeometrySimulator.cs" />
|
||||
|
@ -41,10 +47,13 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Page Remove="ObjetosSim\ucBasicExample.xaml" />
|
||||
<Page Remove="ObjetosSim\ucTransporteCurva.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="ObjetosSim\ucBasicExample.xaml" />
|
||||
<None Include="ObjetosSim\ucBasicExample.xaml.cs" />
|
||||
<None Include="Simulacion\FPhysics.cs" />
|
||||
<None Include="Simulacion\GeometrySimulator.cs" />
|
||||
</ItemGroup>
|
||||
|
@ -52,7 +61,6 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Aether.Physics2D" Version="2.1.0" />
|
||||
<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="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
|
@ -88,4 +96,19 @@
|
|||
<Resource Include="imagenes\tank.png" />
|
||||
</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>
|
||||
|
|
|
@ -10,7 +10,6 @@ using CtrEditor.Siemens;
|
|||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using System.Windows;
|
||||
using CtrEditor.Convertidores;
|
||||
using CtrEditor.Simulacion;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
@ -34,6 +33,8 @@ namespace CtrEditor
|
|||
|
||||
private readonly DispatcherTimer _timerSimulacion;
|
||||
|
||||
public Canvas MainCanvas;
|
||||
|
||||
[ObservableProperty]
|
||||
private DatosDeTrabajo datosDeTrabajo;
|
||||
|
||||
|
@ -357,7 +358,7 @@ namespace CtrEditor
|
|||
stopwatch_SimModel_last = stopwatch_Sim.Elapsed.TotalMilliseconds;
|
||||
|
||||
// Eliminar el diseño de Debug luego de 2 segundos
|
||||
if (TiempoDesdeStartSimulacion > 2000)
|
||||
if (TiempoDesdeStartSimulacion > 12000)
|
||||
simulationManager.Debug_ClearSimulationShapes();
|
||||
else
|
||||
TiempoDesdeStartSimulacion += (float)elapsedMilliseconds;
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Siemens="clr-namespace:CtrEditor.Siemens"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:Siemens="clr-namespace:CtrEditor.Siemens"
|
||||
xmlns:ObjetosSim="clr-namespace:CtrEditor.ObjetosSim" x:Class="CtrEditor.MainWindow"
|
||||
Height="900" Width="1600" WindowState="Maximized"
|
||||
ResizeMode="CanResize" Title="{Binding directorioTrabajo}" Icon="/app2.png">
|
||||
|
@ -14,9 +13,7 @@
|
|||
</Window.DataContext>
|
||||
|
||||
<Window.Resources>
|
||||
<convert:FloatToFormattedStringConverter x:Key="floatFormatter"/>
|
||||
<convert:DoubleToFormattedStringConverter x:Key="doubleFormatter"/>
|
||||
<convert:BrushToColorNameConverter x:Key="BrushToColorNameConverter"/>
|
||||
|
||||
|
||||
<!-- Style for Start/Stop Button -->
|
||||
<Style x:Key="StartStopButtonStyle" TargetType="Button">
|
||||
|
|
|
@ -10,7 +10,7 @@ using System.Windows.Media;
|
|||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
using Binding = System.Windows.Data.Binding;
|
||||
|
@ -65,6 +65,7 @@ namespace CtrEditor
|
|||
viewModel.ImageSelected += ViewModel_ImageSelected;
|
||||
viewModel?.LoadInitialData(); // Carga la primera imagen por defecto una vez cargada la ventana principal
|
||||
viewModel.simulationManager.DebugCanvas = ImagenEnTrabajoCanvas;
|
||||
viewModel.MainCanvas = ImagenEnTrabajoCanvas;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,8 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
>
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osBotella/>
|
||||
</UserControl.DataContext>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
//using using Microsoft.Xna.Framework;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
<UserControl x:Class="CtrEditor.ObjetosSim.Dinamicos.ucBotellaCuello"
|
||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucBotellaCuello"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osBotella/>
|
||||
<vm:osBotellaCuello/>
|
||||
</UserControl.DataContext>
|
||||
|
||||
<Ellipse Height="{Binding Diametro, Converter={StaticResource MeterToPixelConverter}}"
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
//using using Microsoft.Xna.Framework;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace CtrEditor.ObjetosSim.Dinamicos
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ucBotellaCuelloCuello.xaml
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
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:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osFiller/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -3,16 +3,8 @@
|
|||
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:local="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
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>
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osTanque Alto="1" Ancho="1" Angulo="-4" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,11 +4,10 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
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:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
<Storyboard x:Key="PulsingStoryboard" RepeatBehavior="Forever">
|
||||
<DoubleAnimation
|
||||
Storyboard.TargetName="AnimatedEllipse"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using System.Windows;
|
||||
|
|
|
@ -4,12 +4,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osGuia/>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
|
||||
|
|
|
@ -3,13 +3,9 @@
|
|||
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:localuc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:localuc="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osTransporteCurva />
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
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:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
<convert:DistanceToMarginConverter x:Key="DistanceToMarginConverter"/>
|
||||
|
||||
<!-- 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.Transform>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
<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>
|
|
@ -0,0 +1,375 @@
|
|||
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,13 +4,10 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
|
||||
<!-- 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.Transform>
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Windows.Controls;
|
|||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using CtrEditor.Simulacion;
|
||||
using System.Windows.Input;
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
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:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osVMmotorSim ImageSource_oculta="/imagenes/motorNegro.png" />
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osBoton Color="#FFADE6C0" ColorButton_oculto="#FFC72323"/>
|
||||
</UserControl.DataContext>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,13 +4,8 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||
mc:Ignorable="d"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osGearEncoder Dientes="9"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,13 +4,9 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CtrEditor.ObjetosSim.UserControls"
|
||||
mc:Ignorable="d"
|
||||
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>
|
||||
<vm:osPhotocell Color="#FFCA1C1C"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Simulacion;
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
|
@ -46,7 +46,7 @@ namespace CtrEditor.ObjetosSim
|
|||
EscribirBitTag(TagPhotocell_OUT, !LuzCortada);
|
||||
else
|
||||
EscribirBitTag(TagPhotocell_OUT, LuzCortada);
|
||||
if (filter_Frecuency < 1)
|
||||
if (Filter_Frecuency < 1)
|
||||
{
|
||||
Filter_Frecuency = 1;
|
||||
Frecuency = 0;
|
||||
|
|
|
@ -4,13 +4,8 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
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:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osSensTemperatura />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osAnalogTag/>
|
||||
</UserControl.DataContext>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -4,15 +4,10 @@
|
|||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osBoolTag/>
|
||||
</UserControl.DataContext>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
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"
|
||||
Background="LightGray"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
Background="LightGray">
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osConsensGeneric />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
<UserControl x:Class="CtrEditor.ObjetosSim.Traces.ucTrace3"
|
||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucTrace3"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ei="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim.Traces"
|
||||
mc:Ignorable="d" Background="#FFECECEC">
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
Background="#FFECECEC"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osTrace3 Descripcion_Serie_1="Serie 1" Max_Cantidad_Elementos="100"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
@ -7,7 +7,7 @@ using System.Windows.Shapes;
|
|||
using CtrEditor.Siemens;
|
||||
using System.Runtime.Intrinsics;
|
||||
|
||||
namespace CtrEditor.ObjetosSim.Traces
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ucTrace3.xaml
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
<UserControl x:Class="CtrEditor.ObjetosSim.Traces.ucTraceSimple"
|
||||
<UserControl x:Class="CtrEditor.ObjetosSim.ucTraceSimple"
|
||||
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"
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim.Traces"
|
||||
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.WPF;assembly=LiveChartsCore.SkiaSharpView.WPF"
|
||||
xmlns:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
</UserControl.Resources>
|
||||
xmlns:vm="clr-namespace:CtrEditor.ObjetosSim"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:osTraceSimple Alto="3" Ancho="6"/>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
@ -11,7 +11,7 @@ using LiveChartsCore.SkiaSharpView;
|
|||
using LiveChartsCore.Defaults;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace CtrEditor.ObjetosSim.Traces
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ucTraceSimple.xaml
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Windows.Controls;
|
||||
using CtrEditor.Simulacion;
|
||||
using System.Reflection;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using System.Windows.Data;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<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>
|
|
@ -0,0 +1,144 @@
|
|||
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,29 +1,17 @@
|
|||
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.Threading.Tasks;
|
||||
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.Simulacion;
|
||||
using System.Windows.Media;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using Siemens.Simatic.Simulation.Runtime;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Input;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Diagnostics;
|
||||
using HarfBuzzSharp;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace CtrEditor.ObjetosSim
|
||||
{
|
||||
|
@ -246,19 +234,12 @@ namespace CtrEditor.ObjetosSim
|
|||
return null;
|
||||
}
|
||||
|
||||
protected void CrearAnimacionStoryBoardTrasnporte(System.Windows.Shapes.Rectangle transporte, bool invertirDireccion)
|
||||
protected Storyboard CrearAnimacionMultiStoryBoardTrasnporte(Rectangle transporte, bool invertirDireccion)
|
||||
{
|
||||
if (_visualRepresentation == null) return;
|
||||
if (transporte == null) return;
|
||||
if (_visualRepresentation == null) return null;
|
||||
if (transporte == null) return null;
|
||||
|
||||
// Detener y eliminar el storyboard existente si hay uno
|
||||
if (_storyboard != null)
|
||||
{
|
||||
_storyboard.Stop();
|
||||
_storyboard.Children.Clear();
|
||||
}
|
||||
|
||||
_storyboard = new Storyboard();
|
||||
Storyboard storyboard = new Storyboard();
|
||||
var animation = new DoubleAnimation
|
||||
{
|
||||
From = invertirDireccion ? 20 : 0,
|
||||
|
@ -268,20 +249,43 @@ namespace CtrEditor.ObjetosSim
|
|||
};
|
||||
Storyboard.SetTarget(animation, transporte);
|
||||
Storyboard.SetTargetProperty(animation, new PropertyPath("(Rectangle.Fill).(VisualBrush.Transform).(TransformGroup.Children)[0].(TranslateTransform.X)"));
|
||||
_storyboard.Children.Add(animation);
|
||||
_storyboard.Begin();
|
||||
_storyboard.SetSpeedRatio(0);
|
||||
storyboard.Children.Add(animation);
|
||||
storyboard.Begin();
|
||||
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)
|
||||
{
|
||||
if (_visualRepresentation == null) return;
|
||||
if (_storyboard == null) return;
|
||||
|
||||
if (!_mainViewModel.IsSimulationRunning)
|
||||
_storyboard.SetSpeedRatio(0);
|
||||
else
|
||||
_storyboard.SetSpeedRatio(Math.Abs(velocidadActual));
|
||||
ActualizarAnimacionMultiStoryBoardTransporte(_storyboard, velocidadActual);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -383,11 +387,49 @@ namespace CtrEditor.ObjetosSim
|
|||
public float CanvasGetTopinMeter()
|
||||
{
|
||||
if (_visualRepresentation != null)
|
||||
return PixelToMeter.Instance.calc.PixelsToMeters((float)Canvas.GetTop(_visualRepresentation));
|
||||
return PixelToMeter.Instance.calc.PixelsToMeters((float)System.Windows.Controls.Canvas.GetTop(_visualRepresentation));
|
||||
else return 0f;
|
||||
}
|
||||
|
||||
public (Vector2 TopLeft, Vector2 BottomRight) GetRectangleCoordinatesInMeter(System.Windows.Shapes.Rectangle rect)
|
||||
public float PixelsToMeters(float pixel)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@ -407,31 +449,45 @@ namespace CtrEditor.ObjetosSim
|
|||
else return (new Vector2(0, 0), new Vector2(0, 0));
|
||||
}
|
||||
|
||||
public (Vector2 Start, Vector2 End) GetCenterLineVectors(System.Windows.Shapes.Rectangle rect)
|
||||
public (Vector2 Start, Vector2 End) GetCenterLineVectors(Rectangle rect)
|
||||
{
|
||||
if (rect == null)
|
||||
return (new Vector2(0, 0), new Vector2(0, 0));
|
||||
|
||||
var _canvasLeft = CanvasGetLeftinMeter();
|
||||
var _canvasTop = CanvasGetTopinMeter();
|
||||
Vector2 start = new Vector2(0, 0);
|
||||
Vector2 end = new Vector2(0, 0);
|
||||
|
||||
var transform = rect.TransformToAncestor(_visualRepresentation);
|
||||
// Usar Dispatcher para asegurar la ejecución en el hilo correcto
|
||||
_visualRepresentation?.Dispatcher.Invoke(() =>
|
||||
{
|
||||
// Asegúrate de que el control está en el árbol visual y actualizado
|
||||
if (_visualRepresentation.IsLoaded && rect.IsLoaded)
|
||||
{
|
||||
_visualRepresentation.UpdateLayout();
|
||||
|
||||
// Puntos en coordenadas locales del rectángulo no rotado
|
||||
Point startLocal = new Point(0, rect.ActualHeight / 2);
|
||||
Point endLocal = new Point(rect.ActualWidth, rect.ActualHeight / 2);
|
||||
var _canvasLeft = CanvasGetLeftinMeter();
|
||||
var _canvasTop = CanvasGetTopinMeter();
|
||||
|
||||
// Transformar estos puntos al sistema de coordenadas del ancestro
|
||||
Point transformedStart = transform.Transform(startLocal);
|
||||
Point transformedEnd = transform.Transform(endLocal);
|
||||
var transform = rect.TransformToAncestor(_visualRepresentation);
|
||||
|
||||
// Convierte a unidades de Farseer (metros en este caso)
|
||||
Vector2 start = new Vector2(PixelToMeter.Instance.calc.PixelsToMeters((float)transformedStart.X) + _canvasLeft, PixelToMeter.Instance.calc.PixelsToMeters((float)transformedStart.Y) + _canvasTop);
|
||||
Vector2 end = new Vector2(PixelToMeter.Instance.calc.PixelsToMeters((float)transformedEnd.X) + _canvasLeft, PixelToMeter.Instance.calc.PixelsToMeters((float)transformedEnd.Y) + _canvasTop);
|
||||
// Puntos en coordenadas locales del rectángulo no rotado
|
||||
Point startLocal = new Point(0, rect.ActualHeight / 2);
|
||||
Point endLocal = new Point(rect.ActualWidth, rect.ActualHeight / 2);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
public Vector2 GetCurveCenterInMeter(float RadioExterno)
|
||||
{
|
||||
var _canvasLeft = CanvasGetLeftinMeter();
|
||||
|
@ -445,7 +501,7 @@ namespace CtrEditor.ObjetosSim
|
|||
return new Vector2((float)centerX, (float)centerY);
|
||||
}
|
||||
|
||||
public Vector2 GetRectangleCenter(System.Windows.Shapes.Rectangle wpfRect)
|
||||
public Vector2 GetRectangleCenter(Rectangle wpfRect)
|
||||
{
|
||||
var coords = GetRectangleCoordinatesInMeter(wpfRect);
|
||||
|
||||
|
@ -458,13 +514,13 @@ namespace CtrEditor.ObjetosSim
|
|||
|
||||
|
||||
|
||||
public void UpdateRectangle(simTransporte simRect, System.Windows.Shapes.Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
||||
public void UpdateRectangle(simTransporte simRect, Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
||||
{
|
||||
if (simRect != null)
|
||||
simRect.Create(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo);
|
||||
}
|
||||
|
||||
public void UpdateRectangle(simBarrera simRect, System.Windows.Shapes.Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
||||
public void UpdateRectangle(simBarrera simRect, Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
||||
{
|
||||
if (simRect != null)
|
||||
simRect.Create(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo);
|
||||
|
@ -480,20 +536,21 @@ namespace CtrEditor.ObjetosSim
|
|||
return simulationManager.AddCurve(RadioInterno, RadioExterno, startAngle, endAngle, GetCurveCenterInMeter(RadioExterno));
|
||||
}
|
||||
|
||||
public simTransporte AddRectangle(SimulationManagerFP simulationManager, System.Windows.Shapes.Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
||||
public simTransporte AddRectangle(SimulationManagerFP simulationManager, Rectangle wpfRect, float Alto, float Ancho, float Angulo)
|
||||
{
|
||||
return simulationManager.AddRectangle(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo);
|
||||
}
|
||||
|
||||
public simBarrera AddBarrera(SimulationManagerFP simulationManager, System.Windows.Shapes.Rectangle wpfRect, float Alto, float Ancho, float Angulo, bool detectarCuello)
|
||||
public simBarrera AddBarrera(SimulationManagerFP simulationManager, Rectangle wpfRect, float Alto, float Ancho, float Angulo, bool detectarCuello)
|
||||
{
|
||||
return simulationManager.AddBarrera(Ancho, Alto, GetRectangleCenter(wpfRect), Angulo, detectarCuello);
|
||||
}
|
||||
|
||||
public void UpdateOrCreateLine(simGuia simGuia, System.Windows.Shapes.Rectangle wpfRect)
|
||||
public void UpdateOrCreateLine(simGuia simGuia, Rectangle wpfRect)
|
||||
{
|
||||
if (simGuia != null)
|
||||
{
|
||||
|
||||
var coords = GetCenterLineVectors(wpfRect);
|
||||
|
||||
// Crear o actualizar simRectangle
|
||||
|
@ -501,7 +558,7 @@ namespace CtrEditor.ObjetosSim
|
|||
}
|
||||
}
|
||||
|
||||
public simGuia AddLine(SimulationManagerFP simulationManager, System.Windows.Shapes.Rectangle wpfRect)
|
||||
public simGuia AddLine(SimulationManagerFP simulationManager, Rectangle wpfRect)
|
||||
{
|
||||
var coords = GetCenterLineVectors(wpfRect);
|
||||
return simulationManager.AddLine(coords.Start, coords.End);
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
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:convert="clr-namespace:CtrEditor.Convertidores">
|
||||
|
||||
>
|
||||
|
||||
<UserControl.Resources>
|
||||
<convert:MeterToPixelConverter x:Key="MeterToPixelConverter"/>
|
||||
|
||||
</UserControl.Resources>
|
||||
|
||||
<UserControl.DataContext>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using CtrEditor.Convertidores;
|
||||
|
||||
using CtrEditor.Siemens;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?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,23 +1,15 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using System.Windows;
|
||||
using System.Diagnostics;
|
||||
using CtrEditor.ObjetosSim;
|
||||
using System.Windows.Documents;
|
||||
using nkast.Aether.Physics2D;
|
||||
using nkast.Aether.Physics2D.Dynamics;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
using nkast.Aether.Physics2D.Collision.Shapes;
|
||||
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 static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
|
||||
namespace CtrEditor.Simulacion
|
||||
{
|
||||
|
@ -33,6 +25,14 @@ namespace CtrEditor.Simulacion
|
|||
_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)
|
||||
{
|
||||
Body.SetTransform(new Vector2(x, y), Body.Rotation);
|
||||
|
@ -62,8 +62,8 @@ namespace CtrEditor.Simulacion
|
|||
_deferredActions = deferredActions;
|
||||
_innerRadius = innerRadius;
|
||||
_outerRadius = outerRadius;
|
||||
_startAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(startAngle);
|
||||
_endAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(endAngle);
|
||||
_startAngle = GradosARadianes(startAngle);
|
||||
_endAngle = GradosARadianes(endAngle);
|
||||
Create(position);
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,8 @@ namespace CtrEditor.Simulacion
|
|||
if (_world == null) return;
|
||||
_innerRadius = innerRadius;
|
||||
_outerRadius = outerRadius;
|
||||
_startAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(startAngle);
|
||||
_endAngle = Microsoft.Xna.Framework.MathHelper.ToRadians(endAngle);
|
||||
_startAngle = GradosARadianes(startAngle);
|
||||
_endAngle = GradosARadianes(endAngle);
|
||||
Create(position);
|
||||
}
|
||||
|
||||
|
@ -197,8 +197,8 @@ namespace CtrEditor.Simulacion
|
|||
|
||||
public float Angle
|
||||
{
|
||||
get { return Microsoft.Xna.Framework.MathHelper.ToDegrees(Body.Rotation); }
|
||||
set { Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(value); }
|
||||
get { return RadianesAGrados(Body.Rotation); }
|
||||
set { Body.Rotation = GradosARadianes(value); }
|
||||
}
|
||||
|
||||
public new void SetPosition(float x, float y)
|
||||
|
@ -229,7 +229,7 @@ namespace CtrEditor.Simulacion
|
|||
Body = _world.CreateRectangle( width, height, 1f, position);
|
||||
Body.FixtureList[0].IsSensor = true;
|
||||
Body.BodyType = BodyType.Static;
|
||||
Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(angle);
|
||||
Body.Rotation = GradosARadianes(angle);
|
||||
Body.Tag = this; // Importante para la identificación durante la colisión
|
||||
}
|
||||
}
|
||||
|
@ -257,8 +257,8 @@ namespace CtrEditor.Simulacion
|
|||
|
||||
public float Angle
|
||||
{
|
||||
get { return Microsoft.Xna.Framework.MathHelper.ToDegrees(Body.Rotation); }
|
||||
set { Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(value); }
|
||||
get { return RadianesAGrados(Body.Rotation); }
|
||||
set { Body.Rotation = GradosARadianes(value); }
|
||||
}
|
||||
|
||||
public new void SetPosition(float x, float y)
|
||||
|
@ -282,7 +282,7 @@ namespace CtrEditor.Simulacion
|
|||
Body = _world.CreateRectangle( width, height, 1f, position);
|
||||
Body.FixtureList[0].IsSensor = true;
|
||||
Body.BodyType = BodyType.Static;
|
||||
Body.Rotation = Microsoft.Xna.Framework.MathHelper.ToRadians(angle);
|
||||
Body.Rotation = GradosARadianes(angle);
|
||||
Body.Tag = this; // Importante para la identificación durante la colisión
|
||||
LuzCortada = 0;
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ using FarseerPhysics.Dynamics;
|
|||
using FarseerPhysics.Factories;
|
||||
using FarseerPhysics.Collision.Shapes;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
using CtrEditor.Convertidores;
|
||||
|
||||
using FarseerPhysics.Common;
|
||||
using System.Windows;
|
||||
using System.Diagnostics;
|
||||
|
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FarseerPhysics.Collision;
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
using nkast.Aether.Physics2D.Common;
|
||||
|
||||
|
|
|
@ -146,13 +146,13 @@ namespace CtrEditor.Simulacion
|
|||
float radius = circleShape.Radius;
|
||||
float halfSide = radius; // El lado del cuadrado inscrito es igual al radio
|
||||
|
||||
Vector2[] squareVertices =
|
||||
[
|
||||
new Vector2(-halfSide, -halfSide),
|
||||
new Vector2(halfSide, -halfSide),
|
||||
new Vector2(halfSide, halfSide),
|
||||
new Vector2(-halfSide, halfSide)
|
||||
];
|
||||
Vector2[] squareVertices = new Vector2[]
|
||||
{
|
||||
new Vector2(-halfSide, -halfSide),
|
||||
new Vector2(halfSide, -halfSide),
|
||||
new Vector2(halfSide, halfSide),
|
||||
new Vector2(-halfSide, halfSide)
|
||||
};
|
||||
|
||||
foreach (var vertex in squareVertices)
|
||||
{
|
||||
|
@ -164,6 +164,7 @@ namespace CtrEditor.Simulacion
|
|||
return vertices;
|
||||
}
|
||||
|
||||
|
||||
private static Vector2 RotatePoint(Vector2 point, Vector2 origin, float rotation)
|
||||
{
|
||||
float cos = (float)Math.Cos(rotation);
|
||||
|
|
|
@ -1,15 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows;
|
||||
|
||||
namespace CtrEditor.Convertidores
|
||||
namespace CtrEditor
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -178,6 +206,27 @@ namespace CtrEditor.Convertidores
|
|||
}
|
||||
}
|
||||
|
||||
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 object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
Loading…
Reference in New Issue