Mejorado logica de Zindex para los Panel Plate y los ExtraccionTag. Las osGuia ahora al modificar la posicion se actualiza la simulacion en tiempo real.
This commit is contained in:
parent
c8abb98c7d
commit
261fe679d8
|
@ -12,6 +12,7 @@ namespace CtrEditor.FuncionesBase
|
|||
Estaticos = 2,
|
||||
Generadores = 3,
|
||||
Guias = 4,
|
||||
ExtraccionTag = 5,
|
||||
Dinamicos = 10,
|
||||
Descarte = 11,
|
||||
Fotocelula = 12,
|
||||
|
|
|
@ -247,28 +247,31 @@ namespace CtrEditor
|
|||
double rectSize = 10;
|
||||
RemoveResizeRectangles();
|
||||
|
||||
// Obtener el BoundingBox aproximado del UserControl
|
||||
Rect boundingBox = VisualTreeHelper.GetDescendantBounds(userControl);
|
||||
if (userControl is IDataContainer dataContainer && dataContainer.Datos is osBase mvBase && mvBase.Show_On_This_Page)
|
||||
{
|
||||
|
||||
// Transformar el BoundingBox a las coordenadas del Canvas
|
||||
GeneralTransform transform = userControl.TransformToAncestor(ImagenEnTrabajoCanvas);
|
||||
Rect transformedBoundingBox = transform.TransformBounds(boundingBox);
|
||||
// Obtener el BoundingBox aproximado del UserControl
|
||||
Rect boundingBox = VisualTreeHelper.GetDescendantBounds(userControl);
|
||||
|
||||
FuncionesBase.MutableRect rectBox = new FuncionesBase.MutableRect(transformedBoundingBox);
|
||||
rectBox.Left -= (float)rectSize;
|
||||
rectBox.Right += (float)rectSize;
|
||||
rectBox.Top -= (float)rectSize;
|
||||
rectBox.Bottom += (float)rectSize;
|
||||
// Transformar el BoundingBox a las coordenadas del Canvas
|
||||
GeneralTransform transform = userControl.TransformToAncestor(ImagenEnTrabajoCanvas);
|
||||
Rect transformedBoundingBox = transform.TransformBounds(boundingBox);
|
||||
|
||||
transformedBoundingBoxCenter.X = transformedBoundingBox.Left + transformedBoundingBox.Width / 2;
|
||||
transformedBoundingBoxCenter.Y = transformedBoundingBox.Top + transformedBoundingBox.Height / 2;
|
||||
FuncionesBase.MutableRect rectBox = new FuncionesBase.MutableRect(transformedBoundingBox);
|
||||
rectBox.Left -= (float)rectSize;
|
||||
rectBox.Right += (float)rectSize;
|
||||
rectBox.Top -= (float)rectSize;
|
||||
rectBox.Bottom += (float)rectSize;
|
||||
|
||||
// Cargar el cursor personalizado para rotación
|
||||
Cursor rotationCursorRx = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationRx.cur")).Stream);
|
||||
Cursor rotationCursorSx = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationSx.cur")).Stream);
|
||||
transformedBoundingBoxCenter.X = transformedBoundingBox.Left + transformedBoundingBox.Width / 2;
|
||||
transformedBoundingBoxCenter.Y = transformedBoundingBox.Top + transformedBoundingBox.Height / 2;
|
||||
|
||||
// Calcular las posiciones de los rectángulos de redimensionamiento
|
||||
var positions = new List<Tuple<Point, string>>()
|
||||
// Cargar el cursor personalizado para rotación
|
||||
Cursor rotationCursorRx = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationRx.cur")).Stream);
|
||||
Cursor rotationCursorSx = new Cursor(Application.GetResourceStream(new Uri("pack://application:,,,/CtrEditor;component/Icons/rotationSx.cur")).Stream);
|
||||
|
||||
// Calcular las posiciones de los rectángulos de redimensionamiento
|
||||
var positions = new List<Tuple<Point, string>>()
|
||||
{
|
||||
new Tuple<Point, string>(new Point(rectBox.Left, rectBox.Top), "TopLeft"),
|
||||
new Tuple<Point, string>(new Point(rectBox.Right, rectBox.Top), "TopRight"),
|
||||
|
@ -280,68 +283,69 @@ namespace CtrEditor
|
|||
new Tuple<Point, string>(new Point(rectBox.Right, rectBox.Top + rectBox.Height / 2), "CenterRight")
|
||||
};
|
||||
|
||||
foreach (var position in positions)
|
||||
{
|
||||
Rectangle rect = new Rectangle
|
||||
foreach (var position in positions)
|
||||
{
|
||||
Width = rectSize,
|
||||
Height = rectSize,
|
||||
Fill = Brushes.Transparent,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 1,
|
||||
Tag = position.Item2 // Asignar la etiqueta
|
||||
};
|
||||
Rectangle rect = new Rectangle
|
||||
{
|
||||
Width = rectSize,
|
||||
Height = rectSize,
|
||||
Fill = Brushes.Transparent,
|
||||
Stroke = Brushes.Black,
|
||||
StrokeThickness = 1,
|
||||
Tag = position.Item2 // Asignar la etiqueta
|
||||
};
|
||||
|
||||
// Establecer el cursor adecuado
|
||||
switch (position.Item2)
|
||||
{
|
||||
case "TopLeft":
|
||||
rect.Cursor = Cursors.Arrow;
|
||||
rect.Stroke = Brushes.Gray;
|
||||
break;
|
||||
case "TopRight":
|
||||
rect.Cursor = rotationCursorRx; // Cursor de rotación
|
||||
rect.Stroke = Brushes.Red;
|
||||
break;
|
||||
case "BottomLeft":
|
||||
rect.Cursor = rotationCursorSx; // Cursor de rotación
|
||||
rect.Stroke = Brushes.DarkRed;
|
||||
break;
|
||||
case "BottomRight":
|
||||
rect.Cursor = Cursors.SizeNWSE; // Cursor de dimensionar altura y anchura
|
||||
rect.Stroke = Brushes.Blue;
|
||||
break;
|
||||
case "TopCenter":
|
||||
rect.Cursor = Cursors.Arrow;
|
||||
rect.Stroke = Brushes.Gray;
|
||||
break;
|
||||
case "BottomCenter":
|
||||
rect.Cursor = Cursors.SizeNS; // Cursor de dimensionar altura
|
||||
rect.Stroke = Brushes.Blue;
|
||||
break;
|
||||
case "CenterLeft":
|
||||
rect.Cursor = rotationCursorRx; // Cursor de rotación
|
||||
rect.Stroke = Brushes.Red;
|
||||
break;
|
||||
case "CenterRight":
|
||||
rect.Cursor = Cursors.SizeWE; // Cursor de dimensionar anchura
|
||||
rect.Stroke = Brushes.Blue;
|
||||
break;
|
||||
// Establecer el cursor adecuado
|
||||
switch (position.Item2)
|
||||
{
|
||||
case "TopLeft":
|
||||
rect.Cursor = Cursors.Arrow;
|
||||
rect.Stroke = Brushes.Gray;
|
||||
break;
|
||||
case "TopRight":
|
||||
rect.Cursor = rotationCursorRx; // Cursor de rotación
|
||||
rect.Stroke = Brushes.Red;
|
||||
break;
|
||||
case "BottomLeft":
|
||||
rect.Cursor = rotationCursorSx; // Cursor de rotación
|
||||
rect.Stroke = Brushes.DarkRed;
|
||||
break;
|
||||
case "BottomRight":
|
||||
rect.Cursor = Cursors.SizeNWSE; // Cursor de dimensionar altura y anchura
|
||||
rect.Stroke = Brushes.Blue;
|
||||
break;
|
||||
case "TopCenter":
|
||||
rect.Cursor = Cursors.Arrow;
|
||||
rect.Stroke = Brushes.Gray;
|
||||
break;
|
||||
case "BottomCenter":
|
||||
rect.Cursor = Cursors.SizeNS; // Cursor de dimensionar altura
|
||||
rect.Stroke = Brushes.Blue;
|
||||
break;
|
||||
case "CenterLeft":
|
||||
rect.Cursor = rotationCursorRx; // Cursor de rotación
|
||||
rect.Stroke = Brushes.Red;
|
||||
break;
|
||||
case "CenterRight":
|
||||
rect.Cursor = Cursors.SizeWE; // Cursor de dimensionar anchura
|
||||
rect.Stroke = Brushes.Blue;
|
||||
break;
|
||||
}
|
||||
|
||||
Canvas.SetLeft(rect, position.Item1.X - rectSize / 2);
|
||||
Canvas.SetTop(rect, position.Item1.Y - rectSize / 2);
|
||||
|
||||
rect.MouseLeftButtonDown += UserControl_MouseLeftButtonDown;
|
||||
rect.MouseMove += UserControl_MouseMove;
|
||||
rect.MouseLeftButtonUp += UserControl_MouseLeftButtonUp;
|
||||
rect.MouseLeave += ResizeRectangle_MouseLeave;
|
||||
|
||||
resizeRectangles.Add(rect);
|
||||
ImagenEnTrabajoCanvas.Children.Add(rect);
|
||||
Canvas.SetZIndex(rect, ((int)ZIndexEnum.RectangulosPropiead));
|
||||
|
||||
ResetTimerRemoveResizeRectangles();
|
||||
}
|
||||
|
||||
Canvas.SetLeft(rect, position.Item1.X - rectSize / 2);
|
||||
Canvas.SetTop(rect, position.Item1.Y - rectSize / 2);
|
||||
|
||||
rect.MouseLeftButtonDown += UserControl_MouseLeftButtonDown;
|
||||
rect.MouseMove += UserControl_MouseMove;
|
||||
rect.MouseLeftButtonUp += UserControl_MouseLeftButtonUp;
|
||||
rect.MouseLeave += ResizeRectangle_MouseLeave;
|
||||
|
||||
resizeRectangles.Add(rect);
|
||||
ImagenEnTrabajoCanvas.Children.Add(rect);
|
||||
Canvas.SetZIndex(rect, ((int)ZIndexEnum.RectangulosPropiead));
|
||||
|
||||
ResetTimerRemoveResizeRectangles();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -536,7 +540,7 @@ namespace CtrEditor
|
|||
var newY = Canvas.GetTop(_currentDraggingControl) + dy;
|
||||
|
||||
mvBase.Move(newX, newY);
|
||||
// dataContainer.Move((float)newX, (float)newY);
|
||||
// dataContainer.Move((float)newX, (float)newY);
|
||||
}
|
||||
if (ActivateRotation)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,11 @@ namespace CtrEditor.ObjetosSim
|
|||
UpdateOrCreateLine(SimGeometria, uc.Guia);
|
||||
}
|
||||
|
||||
public override void OnMoveResizeRotate()
|
||||
{
|
||||
ActualizarGeometrias();
|
||||
}
|
||||
|
||||
public osGuia()
|
||||
{
|
||||
Ancho = 1;
|
||||
|
|
|
@ -224,7 +224,7 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos
|
|||
public void Highlight(bool State) { }
|
||||
public ZIndexEnum ZIndex()
|
||||
{
|
||||
return ZIndexEnum.Estaticos;
|
||||
return ZIndexEnum.ExtraccionTag;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,6 @@ namespace CtrEditor.ObjetosSim
|
|||
[property: Category("Layout:")]
|
||||
private float left;
|
||||
|
||||
|
||||
public void CheckData()
|
||||
{
|
||||
if (Id is null)
|
||||
|
@ -164,6 +163,7 @@ namespace CtrEditor.ObjetosSim
|
|||
var Delta_H = PixelToMeter.Instance.calc.PixelsToMeters(Delta_H_pixels);
|
||||
|
||||
OnResize(Delta_W, Delta_H);
|
||||
OnMoveResizeRotate();
|
||||
|
||||
if ((Angulo >= 45 && Angulo <= 135) || (Angulo >= 225 && Angulo <= 315))
|
||||
{
|
||||
|
@ -186,9 +186,10 @@ namespace CtrEditor.ObjetosSim
|
|||
}
|
||||
public void Move(float LeftPixels, float TopPixels)
|
||||
{
|
||||
OnMove(LeftPixels, TopPixels);
|
||||
Left = PixelToMeter.Instance.calc.PixelsToMeters(LeftPixels);
|
||||
Top = PixelToMeter.Instance.calc.PixelsToMeters(TopPixels);
|
||||
OnMove(LeftPixels, TopPixels);
|
||||
OnMoveResizeRotate();
|
||||
}
|
||||
public virtual void OnMove(float LeftPixels, float TopPixels) { }
|
||||
|
||||
|
@ -205,9 +206,12 @@ namespace CtrEditor.ObjetosSim
|
|||
Angulo -= 360;
|
||||
|
||||
OnRotate(Delta_Angle);
|
||||
OnMoveResizeRotate();
|
||||
}
|
||||
public virtual void OnRotate(float Delta_Angle) { }
|
||||
|
||||
public virtual void OnMoveResizeRotate() { }
|
||||
|
||||
public void InicializaNuevoObjeto()
|
||||
{
|
||||
Id = new UniqueId().ObtenerNuevaID();
|
||||
|
|
Loading…
Reference in New Issue