Browse Source

added PhysicalSizeTheme.scale

David Sehnal 5 years ago
parent
commit
1f7ffabef9

+ 1 - 1
src/mol-repr/structure/visual/label-text.ts

@@ -148,7 +148,7 @@ function createElementText(ctx: VisualContext, structure: Structure, theme: Them
     const { label_atom_id, label_alt_id } = StructureProperties.atom;
     const { cumulativeUnitElementCount } = serialMapping;
 
-    const sizeTheme = PhysicalSizeTheme({}, {});
+    const sizeTheme = PhysicalSizeTheme({}, { scale: 1 });
 
     const count = structure.elementCount;
     const { elementScale } = props;

+ 2 - 2
src/mol-repr/structure/visual/util/common.ts

@@ -175,7 +175,7 @@ export function getUnitConformationAndRadius(structure: Structure, unit: Unit, p
     const boundary = unit === rootUnit ? unit.boundary : getBoundary(position);
 
     const l = StructureElement.Location.create(structure, rootUnit);
-    const sizeTheme = PhysicalSizeTheme({}, {});
+    const sizeTheme = PhysicalSizeTheme({}, { scale: 1 });
     const radius = (index: number) => {
         l.element = index as ElementIndex;
         return sizeTheme.size(l);
@@ -186,7 +186,7 @@ export function getUnitConformationAndRadius(structure: Structure, unit: Unit, p
 
 export function getStructureConformationAndRadius(structure: Structure, ignoreHydrogens: boolean, traceOnly: boolean) {
     const l = StructureElement.Location.create(structure);
-    const sizeTheme = PhysicalSizeTheme({}, {});
+    const sizeTheme = PhysicalSizeTheme({}, { scale: 1 });
 
     let xs: ArrayLike<number>;
     let ys: ArrayLike<number>;

+ 8 - 4
src/mol-theme/size/physical.ts

@@ -14,7 +14,9 @@ import { ThemeDataContext } from '../../mol-theme/theme';
 const DefaultSize = 1;
 const Description = 'Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres.';
 
-export const PhysicalSizeThemeParams = {};
+export const PhysicalSizeThemeParams = {
+    scale: PD.Numeric(1, { min: 0.1, max: 5, step: 0.1 })
+};
 export type PhysicalSizeThemeParams = typeof PhysicalSizeThemeParams
 export function getPhysicalSizeThemeParams(ctx: ThemeDataContext) {
     return PhysicalSizeThemeParams; // TODO return copy
@@ -35,14 +37,16 @@ export function getPhysicalRadius(unit: Unit, element: ElementIndex): number {
  * i.e. vdw for atoms and radius for coarse spheres
  */
 export function PhysicalSizeTheme(ctx: ThemeDataContext, props: PD.Values<PhysicalSizeThemeParams>): SizeTheme<PhysicalSizeThemeParams> {
+    const scale = props.scale === void 0 ? 1 : props.scale;
+
     function size(location: Location): number {
         let size: number;
         if (StructureElement.Location.is(location)) {
-            size = getPhysicalRadius(location.unit, location.element);
+            size = scale * getPhysicalRadius(location.unit, location.element);
         } else if (Bond.isLocation(location)) {
-            size = getPhysicalRadius(location.aUnit, location.aUnit.elements[location.aIndex]);
+            size = scale * getPhysicalRadius(location.aUnit, location.aUnit.elements[location.aIndex]);
         } else {
-            size = DefaultSize;
+            size = scale * DefaultSize;
         }
         return size;
     }