GUI: WIP - option to load image for grid scan automatically
This commit is contained in:
@@ -4,7 +4,7 @@ from enum import Enum
|
||||
from PySide6.QtCore import QObject, Signal, Slot, QPointF
|
||||
from PySide6.QtGui import QPainter, QPen, QColor, QBrush
|
||||
from PySide6.QtCore import Qt, QRect
|
||||
from typing import List, Optional
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from aaredaqlib.coordinate import Coordinate, SmargonCoordinate
|
||||
from aaredaqlib.models import DAQStatusModel
|
||||
@@ -175,6 +175,31 @@ class RasterGridManager(QObject):
|
||||
def clear_completed_grids(self):
|
||||
self.__completed_grids.clear()
|
||||
|
||||
def get_grid_coord(self, grid: RasterGridRequest, point: QPointF) -> Tuple[int, int]:
|
||||
point_bl = self.__geom.picture_to_sample(Coordinate(x=point.x(), y=point.y()))
|
||||
|
||||
delta = point_bl - self.__geom.smargon_to_beamline(grid.request.smargon.sh_mm)
|
||||
|
||||
elem_x = grid.request.grid_size_mm.x
|
||||
elem_y = grid.request.grid_size_mm.y
|
||||
|
||||
cell_x = math.floor(delta.x / elem_x)
|
||||
cell_y = math.floor(delta.y / elem_y)
|
||||
|
||||
return cell_x, cell_y
|
||||
|
||||
def load_image(self, point: QPointF):
|
||||
for grid in self.__completed_grids:
|
||||
if self._is_grid_visible(grid.request):
|
||||
|
||||
n_x = grid.request.n_x
|
||||
n_y = grid.request.n_y
|
||||
cell_x, cell_y = self.get_grid_coord(grid.request, point)
|
||||
|
||||
if 0 <= cell_x < n_x and 0 <= cell_y < n_y:
|
||||
cell = cell_y * n_x + cell_x
|
||||
print(f"Load {grid.result.file_prefix} {grid.result.images[cell].number}")
|
||||
|
||||
def is_part_of_active_grid(self, point: QPointF) -> bool:
|
||||
if not self._is_grid_visible(self.__active_grid):
|
||||
return False
|
||||
@@ -188,17 +213,10 @@ class RasterGridManager(QObject):
|
||||
def is_part_of_completed_grid(self, point: QPointF) -> str:
|
||||
for grid in self.__completed_grids:
|
||||
if self._is_grid_visible(grid.request):
|
||||
point_bl = self.__geom.picture_to_sample(Coordinate(x=point.x(), y=point.y()))
|
||||
|
||||
delta = point_bl - self.__geom.smargon_to_beamline(grid.request.smargon.sh_mm)
|
||||
|
||||
n_x = grid.request.n_x
|
||||
n_y = grid.request.n_y
|
||||
elem_x = grid.request.grid_size_mm.x
|
||||
elem_y = grid.request.grid_size_mm.y
|
||||
cell_x, cell_y = self.get_grid_coord(grid.request, point)
|
||||
|
||||
cell_x = math.floor(delta.x / elem_x)
|
||||
cell_y = math.floor(delta.y / elem_y)
|
||||
if 0 <= cell_x < n_x and 0 <= cell_y < n_y:
|
||||
cell = cell_y * n_x + cell_x
|
||||
txt = ""
|
||||
|
||||
Reference in New Issue
Block a user