From 54ca3090c72ee962f0af36de9abbd6094acc5f63 Mon Sep 17 00:00:00 2001 From: Thomas Sander Date: Sun, 4 Aug 2024 19:29:06 +0200 Subject: [PATCH] some small fixes --- .../fx/viewer3d/V3DMolecule.java | 17 +++--- .../render/MoleculeArchitect.java | 60 ++++++++++++------- 2 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/openmolecules/fx/viewer3d/V3DMolecule.java b/src/main/java/org/openmolecules/fx/viewer3d/V3DMolecule.java index 3ccb95c..57bea51 100755 --- a/src/main/java/org/openmolecules/fx/viewer3d/V3DMolecule.java +++ b/src/main/java/org/openmolecules/fx/viewer3d/V3DMolecule.java @@ -398,6 +398,9 @@ public BondRotationHelper getBondRotationHelper() { return mBondRotationHelper; } + private boolean isSurface(Node node) { + return node instanceof MeshView && !(node instanceof Cone); + } /** * @return center of gravity in local coordinate system @@ -467,16 +470,16 @@ public void setHydrogenMode(MoleculeArchitect.HydrogenMode mode) { * @param constructionMode one of the MoleculeArchitect.CONSTRUCTION_MODE... options * @param hydrogenMode one of the MoleculeArchitect.HYDROGEN_MODE... options */ - public void setMode(MoleculeArchitect.ConstructionMode constructionMode, - MoleculeArchitect.HydrogenMode hydrogenMode) { + public void setMode(MoleculeArchitect.ConstructionMode constructionMode, MoleculeArchitect.HydrogenMode hydrogenMode) { if (constructionMode != mConstructionMode || hydrogenMode != mHydrogenMode) { mConstructionMode = constructionMode; mHydrogenMode = hydrogenMode; for (int i=getChildren().size()-1; i>=0; i--) - if (!(getChildren().get(i) instanceof MeshView)) + if (!isSurface(getChildren().get(i))) getChildren().remove(i); + V3DMoleculeBuilder builder = new V3DMoleculeBuilder(this); builder.setConstructionMode(constructionMode); builder.setHydrogenMode(hydrogenMode); @@ -492,7 +495,7 @@ public void setMode(MoleculeArchitect.ConstructionMode constructionMode, public void reconstruct() { for (int i=getChildren().size()-1; i>=0; i--) - if (!(getChildren().get(i) instanceof MeshView)) + if (!isSurface(getChildren().get(i))) getChildren().remove(i); V3DMoleculeBuilder builder = new V3DMoleculeBuilder(this); builder.setConstructionMode(mConstructionMode); @@ -1107,7 +1110,7 @@ public void updateAppearance(Node node) { if (!(node instanceof Shape3D)) return; - if (node instanceof MeshView && !(node instanceof Cone)) + if (isSurface(node)) return; Shape3D shape = (Shape3D)node; @@ -1158,7 +1161,7 @@ public void updateAppearance(Node node) { } private Material getHiliteMaterial(Shape3D shape) { - if (shape instanceof MeshView) { + if (isSurface(shape)) { NodeDetail detail = (NodeDetail)shape.getUserData(); if (detail.getMaterial().getDiffuseColor().getOpacity() == 1.0) return sSolidHighlightedMaterial; @@ -1171,7 +1174,7 @@ private Material getHiliteMaterial(Shape3D shape) { } private PhongMaterial getOverrideMaterial(Shape3D shape) { - if (!(shape instanceof MeshView)) { + if (!isSurface(shape)) { NodeDetail detail = (NodeDetail)shape.getUserData(); if (detail != null && detail.getMaterial() == V3DMoleculeBuilder.getMaterial(MoleculeArchitect.getAtomARGB(1))) diff --git a/src/main/java/org/openmolecules/render/MoleculeArchitect.java b/src/main/java/org/openmolecules/render/MoleculeArchitect.java index 05f1d8e..66dd627 100755 --- a/src/main/java/org/openmolecules/render/MoleculeArchitect.java +++ b/src/main/java/org/openmolecules/render/MoleculeArchitect.java @@ -58,8 +58,8 @@ public enum ColorMode {ATOMIC_NO, WIRES;} private static final int CONNECTION_POINT_COLOR = 0xFFCCCA90; // changed from 0xFFFF1493 to make it less look like oxygen private static final int COLOR_NONE = 0x00000000; // don't draw objects with this color - private final static int[] ATOM_ARGB = { CONNECTION_POINT_COLOR, - COLOR_NONE, 0xFFD9FFFF, 0xFFCC80FF, 0xFFC2FF00, 0xFFFFB5B5, // ?, H,He,Li, Be,B + private final static int[] ATOM_ARGB = { COLOR_NONE, + 0xFFFFFFFF, 0xFFD9FFFF, 0xFFCC80FF, 0xFFC2FF00, 0xFFFFB5B5, // ?, H,He,Li, Be,B 0xFF909090, 0xFF3050F8, 0xFFFF0D0D, 0xFF90E050, 0xFFB3E3F5, 0xFFAB5CF2, // C, N, O, F,Ne,Na 0xFF8AFF00, 0xFFBFA6A6, 0xFFF0C8A0, 0xFFFF8000, 0xFFFFFF30, 0xFF1FF01F, // Mg,Al,Si, P, S,Cl 0xFF80D1E3, 0xFF8F40D4, 0xFF3DFF00, 0xFFE6E6E6, 0xFFBFC2C7, 0xFFA6A6AB, // Ar, K,Ca,Sc,Ti, V @@ -186,16 +186,17 @@ && includeAtom(mMol.getBondAtom(1, bond))) buildBond(bond); for (int atom=fromAtom; atom