/// <summary> /// Hide the repeated atoms and bonds of a multiple group. We hide al atoms that /// belong to the group unless they are defined in the parent atom list. Any /// bond to those atoms that is not a crossing bond or one connecting atoms in /// the parent list is hidden. /// </summary> /// <param name="container">molecule</param> /// <param name="sgroup">multiple group display shortcut</param> private static void HideMultipleParts(IAtomContainer container, Sgroup sgroup) { var crossing = sgroup.Bonds; var atoms = sgroup.Atoms; var parentAtoms = (ICollection <IAtom>)sgroup.GetValue(SgroupKey.CtabParentAtomList); foreach (var bond in container.Bonds) { if (parentAtoms.Contains(bond.Begin) && parentAtoms.Contains(bond.End)) { continue; } if (atoms.Contains(bond.Begin) || atoms.Contains(bond.End)) { StandardGenerator.Hide(bond); } } foreach (var atom in atoms) { if (!parentAtoms.Contains(atom)) { StandardGenerator.Hide(atom); } } foreach (var bond in crossing) { StandardGenerator.Unhide(bond); } }
/// <summary> /// Hide the atoms and bonds of a contracted abbreviation. If the abbreviations is attached /// we remap the attachment symbol to display the name. If there are no attachments the symbol /// we be added later ({@see #generateSgroups}). /// </summary> /// <param name="container">molecule</param> /// <param name="sgroup">abbreviation group display shortcut</param> private static void ContractAbbreviation(IAtomContainer container, IDictionary <IAtom, string> symbolRemap, Sgroup sgroup) { var crossing = sgroup.Bonds; var atoms = sgroup.Atoms; // only do 0,1 attachments for now if (crossing.Count > 1) { return; } foreach (var atom in atoms) { StandardGenerator.Hide(atom); } foreach (var bond in container.Bonds) { if (atoms.Contains(bond.Begin) || atoms.Contains(bond.End)) { StandardGenerator.Hide(bond); } } foreach (var bond in crossing) { StandardGenerator.Unhide(bond); var a1 = bond.Begin; var a2 = bond.End; StandardGenerator.Unhide(a1); if (atoms.Contains(a1)) { symbolRemap[a1] = sgroup.Subscript; } StandardGenerator.Unhide(a2); if (atoms.Contains(a2)) { symbolRemap[a2] = sgroup.Subscript; } } }