Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a way to preserve user-preferred mesh grid state #1460

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions mxcubeweb/core/components/sampleview.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ def handle_grid_result(self, shape):

def update_shapes(self, shapes):
updated_shapes = []

for s in shapes:
shape_data = from_camel(s)
pos = []
Expand All @@ -285,6 +284,8 @@ def update_shapes(self, shapes):
# If shape does not exist add it
if not shape:
refs, t = shape_data.pop("refs", []), shape_data.pop("t", "")
state = shape_data.pop("state", "SAVED")
user_state = shape_data.pop("user_state", "SAVED")

# Store pixels per mm for third party software, to facilitate
# certain calculations
Expand Down Expand Up @@ -329,13 +330,15 @@ def update_shapes(self, shapes):
pos.append(center_positions)

shape = HWR.beamline.sample_view.add_shape_from_mpos(
pos, (x, y), t
pos, (x, y), t, state, user_state
)
except Exception:
logging.getLogger("HWR.MX3").info(shape_data)

else:
shape = HWR.beamline.sample_view.add_shape_from_refs(refs, t)
shape = HWR.beamline.sample_view.add_shape_from_refs(
refs, t, state, user_state
)

# shape will be none if creation failed, so we check if shape exists
# before setting additional parameters
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/SampleView/GridForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ export default function GridForm(props) {
const gridControlList = [];

for (const grid of Object.values(gridList)) {
const selectedStyle = selectedGrids.includes(grid.id) ? 'selected' : '';
const vdim = grid.numRows * (grid.cellHeight + grid.cellVSpace);
const hdim = grid.numCols * (grid.cellWidth + grid.cellHSpace);

gridControlList.push(
<tr
className={selectedStyle}
data-selected={selectedGrids.includes(grid.id)}
data-user-hidden={grid.userState === 'HIDDEN'}
key={grid.name}
onClick={(e) => selectGrid([grid], e.ctrlKey)}
>
Expand Down
2 changes: 2 additions & 0 deletions ui/src/components/SampleView/SampleImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,10 @@ export default class SampleImage extends React.Component {

if (grid.state === 'HIDDEN') {
grid.state = 'SAVED';
grid.user_state = 'SAVED';
} else {
grid.state = 'HIDDEN';
grid.user_state = 'HIDDEN';
}

this.props.sampleViewActions.updateShapes([grid]);
Expand Down
8 changes: 6 additions & 2 deletions ui/src/components/SampleView/SampleView.css
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,12 @@
border-radius: 4px;
}

.selected {
background-color: #dff0d8 !important;
table.table-striped > tbody > tr[data-selected='true'] {
background-color: #dff0d8;
color: #000;
font-weight: bold;
}

table.table-striped > tbody > tr[data-user-hidden='true'] {
background-color: #aaa;
}
Loading