Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add UniqueID label type #1548

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions avogadro/qtplugins/label/label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -147,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));
Expand All @@ -173,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) {
Expand Down Expand Up @@ -327,6 +333,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<float>());
Vector3ub color = interface.color;
Expand Down
Loading