Skip to content

Commit

Permalink
Rename presenter slot and move view getters together
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardWaiteSTFC committed Oct 18, 2024
1 parent cf62236 commit e9711cc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_cut_representation_parameters(self, vectors_in_plane, extents_in_plane,
axes_transform = self._sliceview_presenter.get_sliceinfo().get_northogonal_transform()
return xmin, xmax, ymin, ymax, thickness, axes_transform

def update_bin_params_from_cut_representation(self, xmin, xmax, ymin, ymax, thickness):
def handle_cut_representation_changed(self, xmin, xmax, ymin, ymax, thickness):
out_plane_vector = self.view.get_vector(2) # integrated dimension (last row in table)
vectors_in_plane, extents_in_plane, nbins_in_plane = self.model.calc_bin_params_from_cut_representation(
xmin, xmax, ymin, ymax, thickness, out_plane_vector
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_update_cut_with_invalid_bin_params(self, mock_get_bin_params):
self.mock_sv_presenter.perform_non_axis_aligned_cut.assert_not_called()

@mock.patch("mantidqt.widgets.sliceviewer.cutviewer.presenter.CutViewerPresenter.update_cut")
def test_update_bin_params_from_cut_representation(self, mock_update_cut):
def test_handle_cut_representation_changed(self, mock_update_cut):
xmin, xmax, ymin, ymax, thickness = 0, 1, 0, 1, 0.1
self.presenter.model.calc_bin_params_from_cut_representation.return_value = 3 * [None] # vecs, extents, nbins
self.presenter.model.calc_cut_representation_parameters.return_value = xmin, xmax, ymin, ymax, thickness
Expand All @@ -83,7 +83,7 @@ def test_update_bin_params_from_cut_representation(self, mock_update_cut):
self.presenter.view.get_extents.return_value = [-1, 1] # ignored
self.presenter.view.get_nbin.return_value = 2 # ignored

self.presenter.update_bin_params_from_cut_representation(xmin, xmax, ymin, ymax, thickness)
self.presenter.handle_cut_representation_changed(xmin, xmax, ymin, ymax, thickness)

mock_update_cut.assert_called_once()
# check last vector passed as out of plane vector
Expand Down
20 changes: 10 additions & 10 deletions qt/python/mantidqt/mantidqt/widgets/sliceviewer/cutviewer/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ def resizeEvent(self, event):
def get_step(self, irow):
return float(self.table.item(irow, 6).text())

def get_nbin(self, irow):
return int(self.table.item(irow, 5).text())

def get_extents(self, irow):
return [float(self.table.item(irow, icol).text()) for icol in (3, 4)] # start, stop

def get_vector(self, irow):
return [float(self.table.item(irow, icol).text()) for icol in range(3)]

# setters

def set_vector(self, irow, vector):
Expand All @@ -91,15 +100,6 @@ def update_step(self, irow, nbin):
extents = self.get_extents(irow)
self.set_step(irow, (extents[1] - extents[0]) / nbin)

def get_nbin(self, irow):
return int(self.table.item(irow, 5).text())

def get_extents(self, irow):
return [float(self.table.item(irow, icol).text()) for icol in (3, 4)] # start, stop

def get_vector(self, irow):
return [float(self.table.item(irow, icol).text()) for icol in range(3)]

def set_nbin(self, irow, nbin):
self.table.item(irow, 5).setData(Qt.EditRole, int(nbin))
self.update_step(irow, nbin)
Expand Down Expand Up @@ -132,7 +132,7 @@ def plot_cut_representation(self, xmin, xmax, ymin, ymax, thickness, axes_transf
self.cut_rep = CutRepresentation(self.canvas, self.on_representation_changed, xmin, xmax, ymin, ymax, thickness, axes_transform)

def on_representation_changed(self, xmin, xmax, ymin, ymax, thickness):
self.presenter.update_bin_params_from_cut_representation(xmin, xmax, ymin, ymax, thickness)
self.presenter.handle_cut_representation_changed(xmin, xmax, ymin, ymax, thickness)

# private api
def _setup_ui(self):
Expand Down

0 comments on commit e9711cc

Please sign in to comment.