Skip to content

Commit

Permalink
#2585 Change behaviour of "Show hydrogen labels" setting so the "on" …
Browse files Browse the repository at this point in the history
…value works the same way as "terminal and hetero"
  • Loading branch information
KonstantinEpam23 committed May 9, 2023
1 parent 528fd79 commit ef5f761
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/ketcher-core/src/application/render/restruct/reatom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export enum ShowHydrogenLabels {
Hetero = 'Hetero',
Terminal = 'Terminal',
TerminalAndHetero = 'Terminal and Hetero',
On = 'on'
On = 'on',
All = 'all'
}

class ReAtom extends ReObject {
Expand Down Expand Up @@ -513,7 +514,7 @@ function isLabelVisible(restruct, options, atom) {
const shouldBeVisible =
neighborsLength ||
options.carbonExplicitly ||
options.showHydrogenLabels === ShowHydrogenLabels.On ||
options.showHydrogenLabels === ShowHydrogenLabels.All ||
atom.a.alias ||
atom.a.isotope !== 0 ||
atom.a.radical !== 0 ||
Expand Down Expand Up @@ -549,12 +550,14 @@ function isLabelVisible(restruct, options, atom) {

function displayHydrogen(hydrogenLabels: ShowHydrogenLabels, atom: ReAtom) {
return (
hydrogenLabels === ShowHydrogenLabels.On ||
hydrogenLabels === ShowHydrogenLabels.All ||
(hydrogenLabels === ShowHydrogenLabels.Terminal &&
atom.a.neighbors.length < 2) ||
(hydrogenLabels === ShowHydrogenLabels.Hetero &&
atom.label?.text.toLowerCase() !== 'c') ||
(hydrogenLabels === ShowHydrogenLabels.TerminalAndHetero &&
([ShowHydrogenLabels.TerminalAndHetero, ShowHydrogenLabels.On].includes(
hydrogenLabels
) &&
(atom.a.neighbors.length < 2 || atom.label?.text.toLowerCase() !== 'c'))
)
}
Expand Down

0 comments on commit ef5f761

Please sign in to comment.