diff --git a/marge/controller/controller_plot3d.py b/marge/controller/controller_plot3d.py index 3a77bc0f..955c384d 100644 --- a/marge/controller/controller_plot3d.py +++ b/marge/controller/controller_plot3d.py @@ -10,6 +10,12 @@ from marge.widgets.widget_plot3d import Plot3DWidget import marge.configs.hw_config as hw import pyqtgraph as pg +from marge.seq.pulserver_console import console_mode + +#: Sign of the box's turn on the Transversal plane about MaRGE's axis 0. The box +#: turns from axis 2 towards axis 1, about -axis 0; pulserver's console reads +#: the angle as right-handed about the axis, so it takes the sign that says so. +TRANSVERSAL_TURN = -1 if console_mode() else 1 class Plot3DController(Plot3DWidget): @@ -57,7 +63,7 @@ def __init__(self, data=np.array([]), x_label='', y_label='', title='', *args, * self.roiFOV.setPen(pg.mkPen('r', width=3)) self.roiFOV.hoverPen = pg.mkPen('g', width=3) self.roiFOV.addScaleHandle([1, 1], [0.5, 0.5]) - # self.roiFOV.addRotateHandle([0, 0], [0.5, 0.5]) + self.roiFOV.addRotateHandle([0, 0], [0.5, 0.5]) # Manage colors for h in self.roiFOV.handles: @@ -136,13 +142,13 @@ def menuClicked(self): y_axis = 0 z_axis = 2 elif self.title == "Coronal": - a = -1 + a = 1 d = [1, 1] #[RL, IS] x_axis = 2 y_axis = 0 z_axis = 1 elif self.title == "Transversal": - a = 1 + a = TRANSVERSAL_TURN d = [1, 1] #[RL, PA] x_axis = 2 y_axis = 1 @@ -156,9 +162,14 @@ def menuClicked(self): if self.seq_name in defaultsequences.keys(): roi_fov = np.array(defaultsequences[self.seq_name].mapVals['fov']) * 1e-2 # m roi_pos = np.array(defaultsequences[self.seq_name].mapVals['dfov']) * 1e-3 # m + # The box is drawn turned only on the plane whose normal is the rotation axis + seq_vals = defaultsequences[self.seq_name].mapVals + axis = np.asarray(seq_vals.get('rotationAxis', [0, 0, 0]), dtype=float) + roi_angle = a * float(seq_vals.get('angle', 0.0)) if axis[z_axis] != 0 and np.count_nonzero(axis) == 1 else 0.0 else: roi_fov = img_fov roi_pos = [0.0, 0.0, 0.0] + roi_angle = 0.0 img_fov_px = np.array(np.shape(self.getProcessedImage()))[1::] img_fov_ru = [img_fov[x_axis], img_fov[y_axis]] @@ -172,7 +183,7 @@ def menuClicked(self): # Set roi size and angle self.roiFOV.setPos(roi_pos_px, update=False) self.roiFOV.setSize(roi_fov_px, update=False) - self.roiFOV.setAngle(0.0, update=False) + self.roiFOV.setAngle(roi_angle, center=[0.5, 0.5], update=False) self.roiFOV.stateChanged() # Show the roi @@ -212,7 +223,7 @@ def roiFOVChanged(self): y_axis = 0 z_axis = 1 elif self.title == "Transversal": - a = 1 + a = TRANSVERSAL_TURN d = [1, 1] x_axis = 2 y_axis = 1 diff --git a/marge/seq/pulserver_console.py b/marge/seq/pulserver_console.py index 61fae539..cbbad0fd 100644 --- a/marge/seq/pulserver_console.py +++ b/marge/seq/pulserver_console.py @@ -528,6 +528,9 @@ def __init__(self) -> None: self.addParameter(key="pulserverConsole", val=True) self.addParameter(key="fov", val=[25.6, 25.6, 25.6], units=1e-2) self.addParameter(key="dfov", val=[0.0, 0.0, 0.0], units=1e-3) + # Carried so that the localizer's FOV box is redrawn turned as planned. + self.addParameter(key="angle", val=0.0, units=1) + self.addParameter(key="rotationAxis", val=[1.0, 0.0, 0.0], units=1) self.files: list[bytes] = [] def sequenceRun(self, plotSeq=0, demo=False) -> bool: # noqa: N802 -- MaRGE's API diff --git a/marge/ui/window_main.py b/marge/ui/window_main.py index 3c9fd683..44e4aa44 100644 --- a/marge/ui/window_main.py +++ b/marge/ui/window_main.py @@ -5,6 +5,7 @@ """ import datetime +import sys from PyQt5.QtWidgets import ( QMainWindow, QStatusBar, QWidget, QHBoxLayout, QVBoxLayout, QTableWidget, QSizePolicy @@ -158,3 +159,10 @@ def __init__(self, session, demo=False, parent=None): # Add printer self.printer = Printer(main=self) + + def show(self): + """Show the window; in a browser tab, filling the tab, so that the history below the figures is in view.""" + if sys.platform == "emscripten": + self.showMaximized() + else: + super().show()