Skip to content

Commit

Permalink
Fixed de-selecting shapes
Browse files Browse the repository at this point in the history
When shapes got selected, it was not possible to go back to a
visualization without shapes by just crtl-clicking all entries
in the shape list. Had do move around some stuff making the code
a bit less transparent.
  • Loading branch information
ceriottm committed Nov 5, 2024
1 parent a396348 commit dcb7fd2
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/structure/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,22 @@ export class MoleculeViewer {
return;
}

// resets shapes before checking if there are shapes to add
this._viewer.removeAllShapes();

// removeAllShapes also removes the unit cell, so let's add it back
if (this._options.unitCell.value) {
this._viewer.addUnitCell(this._current.model, {
box: { color: 'black' },
astyle: { hidden: true },
bstyle: { hidden: true },
cstyle: { hidden: true },
});
}

// removeAllShapes also removes the axes, so let's add them back
this._addAxes(this._options.axes.value);

this._updateStyle();
this._viewer.render();
});
Expand Down Expand Up @@ -1111,7 +1127,6 @@ export class MoleculeViewer {
if (this._current === undefined) {
return;
}

if (this._options.shape.value !== '') {
this._addShapes();
}
Expand Down Expand Up @@ -1182,21 +1197,6 @@ export class MoleculeViewer {
return;
}

this._viewer.removeAllShapes();

// removeAllShapes also removes the unit cell, so let's add it back
if (this._options.unitCell.value) {
this._viewer.addUnitCell(this._current.model, {
box: { color: 'black' },
astyle: { hidden: true },
bstyle: { hidden: true },
cstyle: { hidden: true },
});
}

// removeAllShapes also removes the axes, so let's add them back
this._addAxes(this._options.axes.value);

assert(this._current.atomLabels.length === 0);

const structure = this._current.structure;
Expand Down

0 comments on commit dcb7fd2

Please sign in to comment.