in packages/ketcher-core/src/application/render/restruct/reatom.ts [766:816]
function isLabelVisible(restruct, options, atom: ReAtom) {
const isAttachmentPointAtom = Boolean(atom.a.attachmentPoints);
const isCarbon = atom.a.label.toLowerCase() === 'c';
const visibleTerminal =
options.showHydrogenLabels !== ShowHydrogenLabels.Off &&
options.showHydrogenLabels !== ShowHydrogenLabels.Hetero;
const neighborsLength =
atom.a.neighbors.length === 0 ||
(atom.a.neighbors.length < 2 && visibleTerminal);
if (isAttachmentPointAtom && isCarbon) {
return false;
}
const shouldBeVisible =
neighborsLength ||
options.carbonExplicitly ||
options.showHydrogenLabels === ShowHydrogenLabels.On ||
atom.a.alias ||
atom.a.isotope !== null ||
atom.a.radical !== 0 ||
atom.a.charge !== null ||
atom.a.explicitValence >= 0 ||
atom.a.atomList !== null ||
atom.a.rglabel !== null ||
(atom.a.badConn && options.showValenceWarnings) ||
atom.a.label.toLowerCase() !== 'c';
if (shouldBeVisible) return true;
if (atom.a.neighbors.length === 2) {
const nei1 = atom.a.neighbors[0];
const nei2 = atom.a.neighbors[1];
const hb1 = restruct.molecule.halfBonds.get(nei1);
const hb2 = restruct.molecule.halfBonds.get(nei2);
const bond1 = restruct.bonds.get(hb1.bid);
const bond2 = restruct.bonds.get(hb2.bid);
const sameNotStereo =
bond1.b.type === bond2.b.type &&
bond1.b.stereo === Bond.PATTERN.STEREO.NONE &&
bond2.b.stereo === Bond.PATTERN.STEREO.NONE;
if (sameNotStereo && Math.abs(Vec2.cross(hb1.dir, hb2.dir)) < 0.2) {
return true;
}
}
return false;
}