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