forked from amkovkov/GranuSightSoftware2
fix: typos
TOO many typos
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Avalonia;
|
||||
|
||||
namespace GSS2.Core.Extentions;
|
||||
namespace GSS2.Core.UI.Extensions;
|
||||
|
||||
public static class PointHelper
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using Avalonia.Media;
|
||||
using Avalonia.Styling;
|
||||
using Avalonia.Threading;
|
||||
|
||||
using GSS2.Core.Extentions;
|
||||
using GSS2.Core.Extensions;
|
||||
|
||||
namespace GSS2.UI.Core;
|
||||
|
||||
@@ -91,7 +91,7 @@ public class SectionPanel : Panel
|
||||
}
|
||||
|
||||
|
||||
private readonly Dictionary<Control, int> _childIndeces = new Dictionary<Control, int>();
|
||||
private readonly Dictionary<Control, int> _childIndices = new Dictionary<Control, int>();
|
||||
private bool _initialized = false;
|
||||
private int _previousIndex = 0;
|
||||
|
||||
@@ -135,9 +135,9 @@ public class SectionPanel : Panel
|
||||
|
||||
if (_initialized)
|
||||
{
|
||||
_childIndeces.Clear();
|
||||
_childIndices.Clear();
|
||||
foreach (var (i, child) in Children.Enumerate())
|
||||
_childIndeces.Add(child, i);
|
||||
_childIndices.Add(child, i);
|
||||
}
|
||||
}
|
||||
panel.InvalidateArrange();
|
||||
@@ -272,7 +272,7 @@ public class SectionPanel : Panel
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var (child, i) in _childIndeces)
|
||||
foreach (var (child, i) in _childIndices)
|
||||
{
|
||||
var transform = child.RenderTransform as TranslateTransform;
|
||||
if (transform is null)
|
||||
@@ -303,13 +303,13 @@ public class SectionPanel : Panel
|
||||
if (!_initialized)
|
||||
{
|
||||
foreach (var (i, child) in Children.Enumerate())
|
||||
_childIndeces.Add(child, i);
|
||||
_childIndices.Add(child, i);
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
if (_previousIndex == CurrentIndex)
|
||||
{
|
||||
foreach (var (child, i) in _childIndeces)
|
||||
foreach (var (child, i) in _childIndices)
|
||||
{
|
||||
var rect = Orientation switch
|
||||
{
|
||||
@@ -334,27 +334,27 @@ public class SectionPanel : Panel
|
||||
{
|
||||
int indexSingleShift = indexShift / Math.Abs(indexShift);
|
||||
|
||||
var firstIndex = _childIndeces.Min(ch => ch.Value);
|
||||
var lastIndex = _childIndeces.Max(ch => ch.Value);
|
||||
var firstIndex = _childIndices.Min(ch => ch.Value);
|
||||
var lastIndex = _childIndices.Max(ch => ch.Value);
|
||||
|
||||
if (indexSingleShift == -1 &&
|
||||
_previousIndex - 1 < firstIndex)
|
||||
{
|
||||
var newIndex = firstIndex - 1;
|
||||
var (child, _) = _childIndeces.MaxBy(ch => ch.Value);
|
||||
var (child, _) = _childIndices.MaxBy(ch => ch.Value);
|
||||
InstantTransform(child, -Children.Count(), size);
|
||||
|
||||
_childIndeces[child] = newIndex;
|
||||
_childIndices[child] = newIndex;
|
||||
}
|
||||
|
||||
if (indexSingleShift == 1 &&
|
||||
_previousIndex + 1 > lastIndex)
|
||||
{
|
||||
var newIndex = lastIndex + 1;
|
||||
var (child, _) = _childIndeces.MinBy(ch => ch.Value);
|
||||
var (child, _) = _childIndices.MinBy(ch => ch.Value);
|
||||
InstantTransform(child, Children.Count(), size);
|
||||
|
||||
_childIndeces[child] = newIndex;
|
||||
_childIndices[child] = newIndex;
|
||||
}
|
||||
|
||||
List<Task> animations = new List<Task>();
|
||||
|
||||
@@ -11,7 +11,7 @@ using Avalonia.Media.Imaging;
|
||||
using Avalonia.Threading;
|
||||
|
||||
using GSS2.Core.Hardware;
|
||||
using GSS2.Core.Extentions;
|
||||
using GSS2.Core.Extensions;
|
||||
using GSS2.Core.Analysis.AmineContent.Database.Calibration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@@ -319,7 +319,7 @@ public partial class AmineContentSeparatorCalibrationViewModel : ViewModelBase
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
[RelayCommand] private void CencelImageCapturing() => _captureImagesTaskCts?.Cancel();
|
||||
[RelayCommand] private void CancelImageCapturing() => _captureImagesTaskCts?.Cancel();
|
||||
[RelayCommand] private void ImagesSectionPrevious() => ImagesSectionCurrentIndex--;
|
||||
[RelayCommand] private void ImagesSectionNext() => ImagesSectionCurrentIndex++;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ public partial class CameraViewModel : ViewModelBase, IDisposable
|
||||
private readonly CameraService _cameraService;
|
||||
private readonly System.Timers.Timer _renderTimer;
|
||||
|
||||
public event EventHandler? RenderReqested;
|
||||
public event EventHandler? RenderRequested;
|
||||
|
||||
[ObservableProperty] private Color _background = Colors.Transparent;
|
||||
[ObservableProperty] private Stretch _stretchMode = Stretch.Uniform;
|
||||
@@ -34,7 +34,7 @@ public partial class CameraViewModel : ViewModelBase, IDisposable
|
||||
_renderTimer.Elapsed += (_, _) =>
|
||||
{
|
||||
if (!_cameraService.IsImageCapturing)
|
||||
RenderReqested?.Invoke(this, new EventArgs());
|
||||
RenderRequested?.Invoke(this, new EventArgs());
|
||||
};
|
||||
|
||||
_logger.LogInformation("Initialized");
|
||||
|
||||
@@ -13,13 +13,13 @@ public partial class IlluminatorControllerViewModel : ViewModelBase
|
||||
private readonly ILogger<IlluminatorControllerViewModel> _logger;
|
||||
private readonly IlluminatorService _illuminatorService;
|
||||
|
||||
private bool _whiteIntencityChanging = false;
|
||||
private bool _uv365IntencityChanging = false;
|
||||
private bool _uv254IntencityChanging = false;
|
||||
private bool _whiteIntensityChanging = false;
|
||||
private bool _uv365IntensityChanging = false;
|
||||
private bool _uv254IntensityChanging = false;
|
||||
|
||||
[ObservableProperty] private double _whiteIntencity;
|
||||
[ObservableProperty] private double _uv365Intencity;
|
||||
[ObservableProperty] private double _uv254Intencity;
|
||||
[ObservableProperty] private double _whiteIntensity;
|
||||
[ObservableProperty] private double _uv365Intensity;
|
||||
[ObservableProperty] private double _uv254Intensity;
|
||||
[ObservableProperty] private bool _enabled;
|
||||
[ObservableProperty] Orientation _orientation;
|
||||
|
||||
@@ -30,38 +30,38 @@ public partial class IlluminatorControllerViewModel : ViewModelBase
|
||||
|
||||
_illuminatorService = illuminatorService;
|
||||
|
||||
WhiteIntencity = 0;
|
||||
Uv365Intencity = 0;
|
||||
Uv254Intencity = 0;
|
||||
WhiteIntensity = 0;
|
||||
Uv365Intensity = 0;
|
||||
Uv254Intensity = 0;
|
||||
Orientation = Orientation.Horizontal;
|
||||
Enabled = false;
|
||||
|
||||
_logger.LogInformation("Initialized");
|
||||
}
|
||||
|
||||
partial void OnWhiteIntencityChanged(double value)
|
||||
partial void OnWhiteIntensityChanged(double value)
|
||||
{
|
||||
if (_whiteIntencityChanging)
|
||||
if (_whiteIntensityChanging)
|
||||
return;
|
||||
_whiteIntencityChanging = true;
|
||||
_whiteIntensityChanging = true;
|
||||
_illuminatorService.SetIntensity(white: value);
|
||||
_whiteIntencityChanging = false;
|
||||
_whiteIntensityChanging = false;
|
||||
}
|
||||
partial void OnUv365IntencityChanged(double value)
|
||||
partial void OnUv365IntensityChanged(double value)
|
||||
{
|
||||
if (_uv365IntencityChanging)
|
||||
if (_uv365IntensityChanging)
|
||||
return;
|
||||
_uv365IntencityChanging = true;
|
||||
_uv365IntensityChanging = true;
|
||||
_illuminatorService.SetIntensity(uv365: value);
|
||||
_uv365IntencityChanging = false;
|
||||
_uv365IntensityChanging = false;
|
||||
}
|
||||
partial void OnUv254IntencityChanged(double value)
|
||||
partial void OnUv254IntensityChanged(double value)
|
||||
{
|
||||
if (_uv254IntencityChanging)
|
||||
if (_uv254IntensityChanging)
|
||||
return;
|
||||
_uv254IntencityChanging = true;
|
||||
_uv254IntensityChanging = true;
|
||||
_illuminatorService.SetIntensity(uv254: value);
|
||||
_uv254IntencityChanging = false;
|
||||
_uv254IntensityChanging = false;
|
||||
}
|
||||
|
||||
partial void OnEnabledChanged(bool value)
|
||||
|
||||
@@ -98,7 +98,7 @@ public partial class ResourcesViewModel : ViewModelBase, IDisposable
|
||||
]
|
||||
);
|
||||
}
|
||||
ResourceBarViewModel CreateBarViewModel(ILogger<ResourceBarViewModel> logger, Func<LiveChartsCore.Kernel.ChartPoint<ObservableValue, LiveChartsCore.SkiaSharpView.Drawing.Geometries.DoughnutGeometry, LiveChartsCore.SkiaSharpView.Drawing.Geometries.LabelGeometry>, string> formater)
|
||||
ResourceBarViewModel CreateBarViewModel(ILogger<ResourceBarViewModel> logger, Func<LiveChartsCore.Kernel.ChartPoint<ObservableValue, LiveChartsCore.SkiaSharpView.Drawing.Geometries.DoughnutGeometry, LiveChartsCore.SkiaSharpView.Drawing.Geometries.LabelGeometry>, string> formatter)
|
||||
{
|
||||
return new ResourceBarViewModel(
|
||||
logger: logger,
|
||||
@@ -111,7 +111,7 @@ public partial class ResourcesViewModel : ViewModelBase, IDisposable
|
||||
ShowDataLabels = true,
|
||||
IsHoverable = false,
|
||||
HoverPushout = 0,
|
||||
DataLabelsFormatter = formater,
|
||||
DataLabelsFormatter = formatter,
|
||||
DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.ChartCenter,
|
||||
DataLabelsPaint = new SolidColorPaint(SKColors.White)
|
||||
},
|
||||
|
||||
@@ -187,7 +187,7 @@
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- Изображениямя -->
|
||||
<!-- Изображения -->
|
||||
<Grid ColumnSpacing="5" RowSpacing="5">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
@@ -435,7 +435,7 @@
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Command="{Binding CencelImageCapturingCommand}"
|
||||
Command="{Binding CancelImageCapturingCommand}"
|
||||
Content="Отменить съёмку"
|
||||
IsVisible="{Binding CaptureImagesTask, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
|
||||
@@ -443,7 +443,7 @@
|
||||
|
||||
</core:SectionPanel>
|
||||
|
||||
<!-- Общие конпки гланой панели -->
|
||||
<!-- Общие кнопки главной панели -->
|
||||
<Button
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
|
||||
@@ -14,7 +14,7 @@ using Avalonia.Input;
|
||||
|
||||
using GSS2.UI.Core.ViewModels;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using GSS2.Core.Extentions;
|
||||
using GSS2.Core.UI.Extensions;
|
||||
|
||||
namespace GSS2.UI.Core.Views;
|
||||
|
||||
@@ -40,9 +40,9 @@ public partial class CameraView : OpenGlControlBase
|
||||
public const int EGL_DMA_BUF_PLANE0_OFFSET_EXT = 0x3273;
|
||||
public const int EGL_DMA_BUF_PLANE0_PITCH_EXT = 0x3274;
|
||||
|
||||
public delegate IntPtr GlEGLImageTargetTexture2DOESDeligate(int target, IntPtr image);
|
||||
public delegate IntPtr EglCreateImageKHRDeligate(IntPtr dpy, IntPtr ctx, int target, IntPtr buffer, int[] attribs);
|
||||
public delegate bool EglDestroyImageKHRDeligate(IntPtr dpy, IntPtr image);
|
||||
public delegate IntPtr GlEGLImageTargetTexture2DOESDelegate(int target, IntPtr image);
|
||||
public delegate IntPtr EglCreateImageKHRDelegate(IntPtr dpy, IntPtr ctx, int target, IntPtr buffer, int[] attribs);
|
||||
public delegate bool EglDestroyImageKHRDelegate(IntPtr dpy, IntPtr image);
|
||||
|
||||
private const string VERTEX_SHADER = @"
|
||||
#version 300 es
|
||||
@@ -91,19 +91,19 @@ public partial class CameraView : OpenGlControlBase
|
||||
public int UUvLocation { get; }
|
||||
public int VAO { get; }
|
||||
public int VBO { get; }
|
||||
public EglCreateImageKHRDeligate EglCreateImageKHR { get; }
|
||||
public EglDestroyImageKHRDeligate EglDestroyImageKHR { get; }
|
||||
public GlEGLImageTargetTexture2DOESDeligate GlEGLImageTargetTexture2DOES { get; }
|
||||
public EglCreateImageKHRDelegate EglCreateImageKHR { get; }
|
||||
public EglDestroyImageKHRDelegate EglDestroyImageKHR { get; }
|
||||
public GlEGLImageTargetTexture2DOESDelegate GlEGLImageTargetTexture2DOES { get; }
|
||||
|
||||
public OpenGLContext(GlInterface gl)
|
||||
{
|
||||
var glExtensions = gl.GetString(GlConsts.GL_EXTENSIONS);
|
||||
if (glExtensions is null)
|
||||
throw new Exception("GL extentions query returned null string");
|
||||
throw new Exception("GL extensions query returned null string");
|
||||
|
||||
if (!glExtensions.Contains("GL_OES_EGL_image") &&
|
||||
!glExtensions.Contains("GL_OES_EGL_image_external"))
|
||||
throw new Exception("Required GL extentions \"GL_OES_EGL_image_external\" or \"GL_OES_EGL_image\" not found");
|
||||
throw new Exception("Required GL extensions \"GL_OES_EGL_image_external\" or \"GL_OES_EGL_image\" not found");
|
||||
|
||||
EglDisplay = eglGetCurrentDisplay();
|
||||
if (EglDisplay == IntPtr.Zero)
|
||||
@@ -111,25 +111,25 @@ public partial class CameraView : OpenGlControlBase
|
||||
|
||||
var eglExtensions = Marshal.PtrToStringAnsi(eglQueryString(EglDisplay, EglConsts.EGL_EXTENSIONS));
|
||||
if (eglExtensions is null)
|
||||
throw new Exception("EGL extentions query returned null");
|
||||
throw new Exception("EGL extensions query returned null");
|
||||
|
||||
if (!eglExtensions.Contains("EGL_EXT_image_dma_buf_import"))
|
||||
throw new Exception("Required EGL extention \"EGL_EXT_image_dma_buf_import\" not found");
|
||||
throw new Exception("Required EGL extension \"EGL_EXT_image_dma_buf_import\" not found");
|
||||
|
||||
var pEglCreateImageKHR = eglGetProcAddress("eglCreateImageKHR");
|
||||
if (pEglCreateImageKHR == IntPtr.Zero)
|
||||
throw new Exception("Required EGL method \"eglCreateImageKHR\" not found");
|
||||
EglCreateImageKHR = Marshal.GetDelegateForFunctionPointer<EglCreateImageKHRDeligate>(pEglCreateImageKHR);
|
||||
EglCreateImageKHR = Marshal.GetDelegateForFunctionPointer<EglCreateImageKHRDelegate>(pEglCreateImageKHR);
|
||||
|
||||
var pEglDestroyImageKHR = eglGetProcAddress("eglDestroyImageKHR");
|
||||
if (pEglDestroyImageKHR == IntPtr.Zero)
|
||||
throw new Exception("Required EGL method \"eglDestroyImageKHR\" not found");
|
||||
EglDestroyImageKHR = Marshal.GetDelegateForFunctionPointer<EglDestroyImageKHRDeligate>(pEglDestroyImageKHR);
|
||||
EglDestroyImageKHR = Marshal.GetDelegateForFunctionPointer<EglDestroyImageKHRDelegate>(pEglDestroyImageKHR);
|
||||
|
||||
var pGlEGLImageTargetTexture2DOES = eglGetProcAddress("glEGLImageTargetTexture2DOES");
|
||||
if (pGlEGLImageTargetTexture2DOES == IntPtr.Zero)
|
||||
throw new Exception("Required EGL method \"glEGLImageTargetTexture2DOES\" not found");
|
||||
GlEGLImageTargetTexture2DOES = Marshal.GetDelegateForFunctionPointer<GlEGLImageTargetTexture2DOESDeligate>(pGlEGLImageTargetTexture2DOES);
|
||||
GlEGLImageTargetTexture2DOES = Marshal.GetDelegateForFunctionPointer<GlEGLImageTargetTexture2DOESDelegate>(pGlEGLImageTargetTexture2DOES);
|
||||
|
||||
Texture = gl.GenTexture(); ThrowIfOpenGLError(gl);
|
||||
gl.BindTexture(GlConsts.GL_TEXTURE_2D, Texture); ThrowIfOpenGLError(gl);
|
||||
@@ -189,7 +189,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
}
|
||||
|
||||
private readonly ILogger<CameraView> _logger;
|
||||
private readonly Dictionary<int, IntPtr> _importedDmaBufers = new Dictionary<int, nint>();
|
||||
private readonly Dictionary<int, IntPtr> _importedDmaBuffers = new Dictionary<int, nint>();
|
||||
private bool _isViewFinderStarted = false;
|
||||
private OpenGLContext? _openGLContext = null;
|
||||
private Point? _lastMousePosition = null;
|
||||
@@ -238,7 +238,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
try
|
||||
{
|
||||
viewModel.StartViewFinder();
|
||||
viewModel.RenderReqested += RenderReqested;
|
||||
viewModel.RenderRequested += RenderRequested;
|
||||
_isViewFinderStarted = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -257,7 +257,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
try
|
||||
{
|
||||
viewModel.StopViewFinder();
|
||||
foreach (var (fd, image) in _importedDmaBufers)
|
||||
foreach (var (fd, image) in _importedDmaBuffers)
|
||||
_openGLContext?.EglDestroyImageKHR!(_openGLContext.EglDisplay, image);
|
||||
_isViewFinderStarted = false;
|
||||
}
|
||||
@@ -265,7 +265,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
{
|
||||
_logger.LogCritical(ex, "Exception while view finder stop");
|
||||
}
|
||||
viewModel.RenderReqested -= RenderReqested;
|
||||
viewModel.RenderRequested -= RenderRequested;
|
||||
}
|
||||
else if (_isViewFinderStarted)
|
||||
_logger.LogCritical("Cannot stop view finder, data context is null or not camera view model");
|
||||
@@ -282,7 +282,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
|
||||
// Рассчитываем позицию в координатах изображения (до масштабирования)
|
||||
var imageX = (position.X - Bounds.Width / 2 - _panX) / _zoom;
|
||||
var imageY = (-position.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертированна
|
||||
var imageY = (-position.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертирована
|
||||
|
||||
// Применяем масштаб
|
||||
float zoomFactor = ea.Delta.Y > 0 ? 1.1f : 1 / 1.1f;
|
||||
@@ -294,7 +294,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
{
|
||||
// Пересчитываем смещение так, чтобы указатель остался на месте
|
||||
_panX = (float)(position.X - Bounds.Width / 2 - imageX * _zoom);
|
||||
_panY = (float)(-position.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертированна
|
||||
_panY = (float)(-position.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертирована
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -358,7 +358,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
}
|
||||
var position = ea.GetPosition(this);
|
||||
_panX -= (float)(_lastMousePosition.Value.X - position.X);
|
||||
_panY += (float)(_lastMousePosition.Value.Y - position.Y); // Ось Y инвертированна
|
||||
_panY += (float)(_lastMousePosition.Value.Y - position.Y); // Ось Y инвертирована
|
||||
_lastMousePosition = position;
|
||||
}
|
||||
else if (ea.Pointer.Type == PointerType.Touch)
|
||||
@@ -376,11 +376,11 @@ public partial class CameraView : OpenGlControlBase
|
||||
return;
|
||||
}
|
||||
|
||||
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то токлько перемещение
|
||||
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то только перемещение
|
||||
{
|
||||
var position = ea.GetPosition(this);
|
||||
_panX -= (float)(_lastTouchPositions[ea.Pointer.Id].X - position.X);
|
||||
_panY += (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертированна
|
||||
_panY += (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертирована
|
||||
_lastTouchPositions[ea.Pointer.Id] = position;
|
||||
}
|
||||
else if (_lastTouchPositions.Count() == 2) // Если два прикосновения, то перемещение с приближением
|
||||
@@ -402,14 +402,14 @@ public partial class CameraView : OpenGlControlBase
|
||||
newZoom = (float)Math.Clamp(newZoom, 1f, 10f);
|
||||
|
||||
var imageX = (newCenter.X - Bounds.Width / 2 - _panX) / _zoom;
|
||||
var imageY = (-newCenter.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертированна
|
||||
var imageY = (-newCenter.Y + Bounds.Height / 2 - _panY) / _zoom; // Ось Y инвертирована
|
||||
|
||||
_zoom = newZoom;
|
||||
|
||||
if (_zoom > 1f)
|
||||
{
|
||||
_panX = (float)(newCenter.X - Bounds.Width / 2 - imageX * _zoom);
|
||||
_panY = (float)(-newCenter.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертированна
|
||||
_panY = (float)(-newCenter.Y + Bounds.Height / 2 - imageY * _zoom); // Ось Y инвертирована
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -427,7 +427,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
context.FillRectangle(new SolidColorBrush(Background), new Rect(0, 0, Bounds.Width, Bounds.Height));
|
||||
base.Render(context);
|
||||
}
|
||||
private void RenderReqested(object? sender, EventArgs ea) => Dispatcher.UIThread.Invoke(() => RequestNextFrameRendering());
|
||||
private void RenderRequested(object? sender, EventArgs ea) => Dispatcher.UIThread.Invoke(() => RequestNextFrameRendering());
|
||||
|
||||
protected override void OnOpenGlInit(GlInterface gl)
|
||||
{
|
||||
@@ -463,36 +463,36 @@ public partial class CameraView : OpenGlControlBase
|
||||
return;
|
||||
var (frameBuffer, streamConfiguration) = frame.Value;
|
||||
|
||||
// 0. Проверяем что полученый фрейм ожидаемый праильный формат
|
||||
// 0. Проверяем что полученный фрейм ожидаемый правильный формат
|
||||
var width = streamConfiguration.Size.Width;
|
||||
if (width <= 0)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected frame width >= 0, got {}", streamConfiguration.Size.Width);
|
||||
_logger.LogError("Cannot render frame, stream configuration validation error, expected frame width >= 0, got {}", streamConfiguration.Size.Width);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
var height = streamConfiguration.Size.Height;
|
||||
if (height <= 0)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected frame height >= 0, got {}", streamConfiguration.Size.Height);
|
||||
_logger.LogError("Cannot render frame, stream configuration validation error, expected frame height >= 0, got {}", streamConfiguration.Size.Height);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
if (streamConfiguration.PixelFormat.Fourcc != OpenGLContext.DRM_FORMAT_BGRX8888)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected forcc: 0x{:X}, got 0x{:X}", OpenGLContext.DRM_FORMAT_BGRX8888, streamConfiguration.PixelFormat.Fourcc);
|
||||
_logger.LogError("Cannot render frame, stream configuration validation error, expected fourcc: 0x{:X}, got 0x{:X}", OpenGLContext.DRM_FORMAT_BGRX8888, streamConfiguration.PixelFormat.Fourcc);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
if (streamConfiguration.PixelFormat.Modifier != 0)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, stream configuration vaildation error, expected DRM modifier: 0x{:X}, got 0x{:X}", 0, streamConfiguration.PixelFormat.Modifier);
|
||||
_logger.LogError("Cannot render frame, stream configuration validation error, expected DRM modifier: 0x{:X}, got 0x{:X}", 0, streamConfiguration.PixelFormat.Modifier);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
if (frameBuffer.Planes.Count() != 1)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, planes vaildation error, expected planes count: 0, got {}", frameBuffer.Planes.Count());
|
||||
_logger.LogError("Cannot render frame, planes validation error, expected planes count: 0, got {}", frameBuffer.Planes.Count());
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
@@ -506,7 +506,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
var fd = plane.Fd.Get();
|
||||
if (fd <= 0)
|
||||
{
|
||||
_logger.LogError("Cannot render frame, FD vaildation error, FD >= 0, got 0x{:X}", fd);
|
||||
_logger.LogError("Cannot render frame, FD validation error, FD >= 0, got 0x{:X}", fd);
|
||||
(DataContext as CameraViewModel)?.ReturnViewFinderFrame(frameBuffer);
|
||||
return;
|
||||
}
|
||||
@@ -521,10 +521,10 @@ public partial class CameraView : OpenGlControlBase
|
||||
|
||||
// 2. Создаём EGL изображение из dma-buf
|
||||
IntPtr image;
|
||||
if (_importedDmaBufers.ContainsKey(fd))
|
||||
if (_importedDmaBuffers.ContainsKey(fd))
|
||||
{
|
||||
// 2.1. Если EGL изображение для fd уже создано, то берём его из словаря
|
||||
image = _importedDmaBufers[fd];
|
||||
image = _importedDmaBuffers[fd];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -540,7 +540,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
EglConsts.EGL_NONE
|
||||
};
|
||||
image = _openGLContext.EglCreateImageKHR.Invoke(_openGLContext.EglDisplay, IntPtr.Zero, OpenGLContext.EGL_LINUX_DMA_BUF_EXT, IntPtr.Zero, attribs);
|
||||
_importedDmaBufers.Add(fd, image);
|
||||
_importedDmaBuffers.Add(fd, image);
|
||||
}
|
||||
|
||||
// 3. Биндим текстуры текстуры
|
||||
@@ -550,7 +550,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
// 4. Привязываем EGL изображение к текстуре
|
||||
_openGLContext.GlEGLImageTargetTexture2DOES!(GlConsts.GL_TEXTURE_2D, image);
|
||||
|
||||
// 5. Вычисляем матрицы транформаций
|
||||
// 5. Вычисляем матрицы трансформаций
|
||||
var mvp = ComputeMvp(stretchMode, width, height);
|
||||
var zoom = Matrix4x4.CreateScale(_zoom, _zoom, 1f);
|
||||
var translate = Matrix4x4.CreateTranslation((float)(_panX / Bounds.Width * 2), (float)(_panY / Bounds.Height * 2), 0);
|
||||
@@ -597,7 +597,7 @@ public partial class CameraView : OpenGlControlBase
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Exception whiel OpenGL render");
|
||||
_logger.LogError(ex, "Exception while OpenGL render");
|
||||
}
|
||||
}
|
||||
private Matrix4x4 ComputeMvp(Stretch stretch, float imageWidth, float imageHeight)
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
Orientation="Horizontal"
|
||||
Spacing="20">
|
||||
|
||||
<Slider Classes="horizontal" Value="{Binding WhiteIntencity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding Uv365Intencity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding Uv254Intencity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding WhiteIntensity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding Uv365Intensity}" />
|
||||
<Slider Classes="horizontal" Value="{Binding Uv254Intensity}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
@@ -71,9 +71,9 @@
|
||||
Orientation="Vertical"
|
||||
Spacing="20">
|
||||
|
||||
<Slider Classes="vertical" Value="{Binding WhiteIntencity}" />
|
||||
<Slider Classes="vertical" Value="{Binding Uv365Intencity}" />
|
||||
<Slider Classes="vertical" Value="{Binding Uv254Intencity}" />
|
||||
<Slider Classes="vertical" Value="{Binding WhiteIntensity}" />
|
||||
<Slider Classes="vertical" Value="{Binding Uv365Intensity}" />
|
||||
<Slider Classes="vertical" Value="{Binding Uv254Intensity}" />
|
||||
|
||||
</StackPanel>
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ using Avalonia.Media;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Controls;
|
||||
|
||||
using GSS2.Core.Extentions;
|
||||
using GSS2.Core.UI.Extensions;
|
||||
|
||||
namespace GSS2.UI.Core;
|
||||
|
||||
public class ZoomPanImage : Control
|
||||
{
|
||||
private Point? _lastmousePosition = null;
|
||||
private Point? _lastMousePosition = null;
|
||||
private Dictionary<int, Point>? _lastTouchPositions = null;
|
||||
private float _zoom = 1;
|
||||
private float _panX = 0;
|
||||
@@ -103,7 +103,7 @@ public class ZoomPanImage : Control
|
||||
_panY = 0f;
|
||||
}
|
||||
else
|
||||
_lastmousePosition = ea.GetPosition(this);
|
||||
_lastMousePosition = ea.GetPosition(this);
|
||||
}
|
||||
}
|
||||
else if (ea.Pointer.Type == PointerType.Touch)
|
||||
@@ -124,7 +124,7 @@ public class ZoomPanImage : Control
|
||||
if (ea.Pointer.Type == PointerType.Mouse)
|
||||
{
|
||||
if (!ea.Properties.IsLeftButtonPressed)
|
||||
_lastmousePosition = null;
|
||||
_lastMousePosition = null;
|
||||
}
|
||||
else if (ea.Pointer.Type == PointerType.Touch)
|
||||
{
|
||||
@@ -138,15 +138,15 @@ public class ZoomPanImage : Control
|
||||
{
|
||||
if (ea.Pointer.Type == PointerType.Mouse)
|
||||
{
|
||||
if (_lastmousePosition is null || _zoom == 1) // Если кнопка не нажата или зум == 1, то ничего не делаем
|
||||
if (_lastMousePosition is null || _zoom == 1) // Если кнопка не нажата или зум == 1, то ничего не делаем
|
||||
{
|
||||
base.OnPointerMoved(ea);
|
||||
return;
|
||||
}
|
||||
var position = ea.GetPosition(this);
|
||||
_panX -= (float)(_lastmousePosition.Value.X - position.X);
|
||||
_panY -= (float)(_lastmousePosition.Value.Y - position.Y);
|
||||
_lastmousePosition = position;
|
||||
_panX -= (float)(_lastMousePosition.Value.X - position.X);
|
||||
_panY -= (float)(_lastMousePosition.Value.Y - position.Y);
|
||||
_lastMousePosition = position;
|
||||
}
|
||||
else if (ea.Pointer.Type == PointerType.Touch)
|
||||
{
|
||||
@@ -163,11 +163,11 @@ public class ZoomPanImage : Control
|
||||
return;
|
||||
}
|
||||
|
||||
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то токлько перемещение
|
||||
if (_lastTouchPositions.Count() == 1 && _zoom != 1) // Если есть только одно прикосновение и зум != 1, то только перемещение
|
||||
{
|
||||
var position = ea.GetPosition(this);
|
||||
_panX -= (float)(_lastTouchPositions[ea.Pointer.Id].X - position.X);
|
||||
_panY -= (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертированна
|
||||
_panY -= (float)(_lastTouchPositions[ea.Pointer.Id].Y - position.Y); // Ось Y инвертирована
|
||||
_lastTouchPositions[ea.Pointer.Id] = position;
|
||||
}
|
||||
else if (_lastTouchPositions.Count() == 2) // Если два прикосновения, то перемещение с приближением
|
||||
|
||||
Reference in New Issue
Block a user