Skip to content

Commit

Permalink
fix show hydrogen bonds
Browse files Browse the repository at this point in the history
  • Loading branch information
superstar54 committed Nov 16, 2024
1 parent 0029fab commit 26743c1
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/atoms/plugins/bond.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ export class BondManager {

const stickBondMesh = drawStick(this.viewer.originalAtoms, this.bondList, this.bondMap["sticks"], this.viewer.cutoffs, this.bondRadius, this.viewer._materialType, atomColors);
const { bondMesh, bondCap } = drawStick(this.viewer.originalAtoms, this.bondList, this.bondMap["stickCaps"], this.viewer.cutoffs, this.bondRadius, this.viewer._materialType, atomColors, true);
const dashedBondLine = drawLine(this.viewer.originalAtoms, this.bondList, this.bondMap["dashedLines"], this.viewer.cutoffs, "dashed", atomColors);
let dashedBondLine;
if (this.showHydrogenBonds) {
dashedBondLine = drawLine(this.viewer.originalAtoms, this.bondList, this.bondMap["dashedLines"], this.viewer.cutoffs, "dashed", atomColors);
}
const solidBondLine = drawLine(this.viewer.originalAtoms, this.bondList, this.bondMap["solidLines"], this.viewer.cutoffs, "solid", atomColors);
this.meshes = { stickBondMesh: stickBondMesh, stickCapBondMesh: bondMesh, stickCapBondCap: bondCap, dashedBondLine: dashedBondLine, solidBondLine: solidBondLine };
Object.values(this.meshes).forEach((mesh) => {
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/gui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,8 @@ test("Bond", async ({ page }) => {
});
await expect(page).toHaveScreenshot("Bond-delete-bond-pair.png");
});

test("ModelStyle", async ({ page }) => {
await page.goto("http://127.0.0.1:8080/tests/e2e/testModelStyle.html");
await expect(page).toHaveScreenshot("ModelStyle.png");
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/e2e/gui.spec.js-snapshots/Bond-frame-0-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/e2e/gui.spec.js-snapshots/Ops-add-atom-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/e2e/gui.spec.js-snapshots/Ops-replace-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/e2e/gui.spec.js-snapshots/Ops-translate-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions tests/e2e/testModelStyle.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>WEAS Test</title>
</head>
<body>
<div id="viewer" style="position: relative; width: 600px; height: 400px"></div>

<script type="module">
import * as weas from "../../dist/weas.mjs";

async function fetchFile(filename) {
const response = await fetch(`../../demo/datas/${filename}`);
if (!response.ok) {
throw new Error(`Failed to load file for structure: ${filename}`);
}
return await response.text();
}

let domElement = document.getElementById("viewer");

const guiConfig = {
legend: {
enabled: true,
position: "bottom-right", // Options: 'top-right', 'top-left', 'bottom-right', 'bottom-left'
},
};
// read atoms from file
const filename = "c2h6so.xyz";
fetchFile(filename).then((fileContent) => {
const atoms = weas.parseXYZ(fileContent);
let editor = new weas.WEAS({ domElement, guiConfig });
editor.avr.atoms = atoms;
editor.avr.modelStyle = 1;
editor.avr.selectedAtomsIndices = [2, 4, 6, 7];
editor.avr.modelStyle = 4;
editor.avr.selectedAtomsIndices = [3, 5, 8, 9];
editor.avr.modelStyle = 3;
editor.avr.selectedAtomsIndices = [];
editor.avr.bondManager.init();
editor.avr.drawModels();
editor.render();
window.editor = editor;
});
</script>
</body>
</html>

0 comments on commit 26743c1

Please sign in to comment.