From a22ede85115a384aa0c2a4d372dc2826a3198d0e Mon Sep 17 00:00:00 2001 From: Ivan Mitrichev Date: Sat, 23 Dec 2023 22:09:58 +0300 Subject: [PATCH 1/2] add UniqueID label type If UniqueID label type is chosen, atoms are numbered from zero, in contrast to index, where atoms are human-numbered from unity. UniqueID mode is needed e.g. for chemists working with Orca quantum chemistry software. It is common to specify atoms in Orca input file (e.g., for a forming bond in a TS search), and Orca counts from zero. Signed-off-by: Ivan Mitrichev --- avogadro/qtplugins/label/label.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/avogadro/qtplugins/label/label.cpp b/avogadro/qtplugins/label/label.cpp index aac9a29fa2..dbb9d017bd 100644 --- a/avogadro/qtplugins/label/label.cpp +++ b/avogadro/qtplugins/label/label.cpp @@ -66,7 +66,8 @@ struct LayerLabel : Core::LayerData Index = 0x01, Name = 0x02, Custom = 0x04, - Ordinal = 0x08 + Ordinal = 0x08, + UniqueID = 0x16 }; unsigned short atomOptions; unsigned short residueOptions; @@ -327,6 +328,9 @@ void Label::processAtom(const Core::Molecule& molecule, std::string(Elements::symbol(atomicNumber) + std::to_string(atomCount[atomicNumber])); } + if (interface.atomOptions & LayerLabel::LabelOptions::UniqueID) { + text += (text == "" ? "" : " / ") + std::to_string(atom.index()); + } if (text != "") { const Vector3f pos(atom.position3d().cast()); Vector3ub color = interface.color; From 9b49f5369d7a7f594c8a9528b28808a9cce1d3d2 Mon Sep 17 00:00:00 2001 From: Ivan Mitrichev Date: Mon, 25 Dec 2023 00:03:09 +0300 Subject: [PATCH 2/2] Update label.cpp (setupWidget) add UniqueID variant to atom labels list in setupWidget() Signed-off-by: Ivan Mitrichev --- avogadro/qtplugins/label/label.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/avogadro/qtplugins/label/label.cpp b/avogadro/qtplugins/label/label.cpp index dbb9d017bd..a91f196343 100644 --- a/avogadro/qtplugins/label/label.cpp +++ b/avogadro/qtplugins/label/label.cpp @@ -148,7 +148,7 @@ struct LayerLabel : Core::LayerData auto* atom = new QComboBox; atom->setObjectName("atom"); - char elements[] = { None, Index, Name, Custom, Ordinal }; + char elements[] = { None, Index, Name, Custom, Ordinal, UniqueID }; for (char option : elements) { if (option == 0) { atom->addItem(QObject::tr("None"), QVariant(LabelOptions::None)); @@ -174,6 +174,11 @@ struct LayerLabel : Core::LayerData : QObject::tr("El.&No.")); val |= LabelOptions::Ordinal; } + if (option & LabelOptions::UniqueID) { + text << ((text.size() == 0) ? QObject::tr("Unique ID") + : QObject::tr("Un.ID")); + val |= LabelOptions::UniqueID; + } QString join = QObject::tr(", "); atom->addItem(text.join(join), QVariant(val)); if (val == atomOptions) {