Skip to content
Snippets Groups Projects
Commit a61ba71f authored by Alexander Rose's avatar Alexander Rose
Browse files

handle mixed sizes in link visuals

parent 7061d575
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ export const BallAndStickParams = {
...IntraUnitLinkParams,
...InterUnitLinkParams,
unitKinds: PD.MultiSelect<UnitKind>(['atomic'], UnitKindOptions),
sizeFactor: PD.Numeric(0.3, { min: 0.01, max: 10, step: 0.01 }),
sizeFactor: PD.Numeric(0.2, { min: 0.01, max: 10, step: 0.01 }),
sizeAspectRatio: PD.Numeric(2/3, { min: 0.01, max: 3, step: 0.01 }),
visuals: PD.MultiSelect<BallAndStickVisualName>(['element-sphere', 'intra-link', 'inter-link'], BallAndStickVisualOptions),
}
......@@ -50,6 +50,6 @@ export const BallAndStickRepresentationProvider: StructureRepresentationProvider
getParams: getBallAndStickParams,
defaultValues: PD.getDefaultValues(BallAndStickParams),
defaultColorTheme: 'element-symbol',
defaultSizeTheme: 'uniform',
defaultSizeTheme: 'physical',
isApplicable: (structure: Structure) => structure.elementCount > 0
}
\ No newline at end of file
......@@ -43,7 +43,11 @@ function createInterUnitLinkCylinderMesh(ctx: VisualContext, structure: Structur
const b = bonds[edgeIndex]
location.unit = b.unitA
location.element = b.unitA.elements[b.indexA]
return theme.size.size(location) * sizeFactor * sizeAspectRatio
const sizeA = theme.size.size(location)
location.unit = b.unitB
location.element = b.unitB.elements[b.indexB]
const sizeB = theme.size.size(location)
return Math.min(sizeA, sizeB) * sizeFactor * sizeAspectRatio
},
ignore: ignoreHydrogens ? (edgeIndex: number) => {
const b = bonds[edgeIndex]
......
......@@ -63,7 +63,10 @@ function createIntraUnitLinkCylinderMesh(ctx: VisualContext, unit: Unit, structu
flags: (edgeIndex: number) => BitFlags.create(_flags[edgeIndex]),
radius: (edgeIndex: number) => {
location.element = elements[a[edgeIndex]]
return theme.size.size(location) * sizeFactor * sizeAspectRatio
const sizeA = theme.size.size(location)
location.element = elements[b[edgeIndex]]
const sizeB = theme.size.size(location)
return Math.min(sizeA, sizeB) * sizeFactor * sizeAspectRatio
},
ignore: ignoreHydrogens ? (edgeIndex: number) => {
return isHydrogen(unit, elements[a[edgeIndex]]) || isHydrogen(unit, elements[b[edgeIndex]])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment