Skip to content

Commit

Permalink
Implement changes following a review
Browse files Browse the repository at this point in the history
  • Loading branch information
MBartkowiakSTFC committed Feb 17, 2025
1 parent 570c1a1 commit cd008a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 5 additions & 9 deletions MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/MolecularViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@ def array_to_3d_imagedata(data: np.ndarray, spacing: Tuple[float]):
else:
image.AllocateScalars(vtk.VTK_DOUBLE, 1)

for i in range(nx):
for j in range(ny):
for k in range(nz):
image.SetScalarComponentFromDouble(i, j, k, 0, data[i, j, k])
for (i, j, k), val in np.ndenumerate(data):
image.SetScalarComponentFromDouble(i, j, k, 0, val)

return image

Expand Down Expand Up @@ -262,13 +260,11 @@ def _draw_isosurface(self, index: int, params=None):
grid_step = radius / fine_sampling

span = upper_limit - lower_limit
grid_steps = [int(x) for x in span / grid_step]
gdim = (grid_steps[0], grid_steps[1], grid_steps[2])
grid_steps = list((span // grid_step).astype(int))
gdim = tuple(grid_steps[0:3])
grid = np.zeros(gdim, dtype=np.int32)

indices = np.floor((coords - lower_limit.reshape((1, 3))) / grid_step).astype(
int
)
indices = ((coords - lower_limit.reshape((1, 3))) // grid_step).astype(int)
unique_indices, counts = np.unique(indices, return_counts=True, axis=0)
grid[tuple(unique_indices.T)] += counts
self._atomic_trace_histogram = smear_grid(grid, fine_sampling)
Expand Down
6 changes: 3 additions & 3 deletions MDANSE_GUI/Src/MDANSE_GUI/MolecularViewer/TraceWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def validate(self, input_string: str, position: int):
else:
state = QValidator.State.Invalid
else:
if len(rgb) > 3:
if any([x > 255 for x in rgb]):
state = QValidator.State.Invalid
elif len(rgb) > 3:
state = QValidator.State.Invalid
elif len(rgb) == 3:
if all([(x >= 0) and (x < 256) for x in rgb]):
state = QValidator.State.Acceptable
elif any([x > 255 for x in rgb]):
state = QValidator.State.Invalid
else:
state = QValidator.State.Intermediate
return state, input_string, position
Expand Down

0 comments on commit cd008a4

Please sign in to comment.