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 label editor to create custom labels #740
Conversation
Signed-off-by: Marc Prat Masó <marc.prat.maso@estudiantat.upc.edu>
Rendering::TextProperties::VCenter); | ||
tprop.setFontFamily(Rendering::TextProperties::SansSerif); | ||
|
||
tprop.setColorRgb(255, 255, 255); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we definitely want to let people pick colors for the labels. (Not per-label.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only in the label edit mode not the render display. But maybe white could be annoying if the background is white?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The white can be annoying for light-colored atoms (e.g., hydrogen)
|
||
void LabelEditor::save() | ||
{ | ||
m_molecule->beginMergeMode(tr("write Label")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Write Label" or maybe "Set Label" or "Create Label"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to "Create Label"
m_selected = (clickedObject.type == Rendering::AtomType); | ||
if (m_selected) { | ||
m_selectedAtom = m_molecule->atom(clickedObject.index); | ||
m_text = QString::fromUtf8(m_selectedAtom.label().c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QString::fromStdString() should also work, I think...
This Ubuntu failure just seems to be a timeout. (The test set seems to be failing on bond tests #735.) |
I'll test the UI on this. In the previous version, if you were showing the label display, it would look like you'd put a new label on top of the label display, which was weird. I think a user would expect clicking would offer a default (e.g., the "H3" or "C1" from the label display if nothing is set) so that text could be changed. The label engine probably needs to offer a popup menu / QComboBox with a few alternatives including "Custom Labels Only". |
This pull request has been mentioned on Avogadro Discussion. There might be relevant details there: https://discuss.avogadro.cc/t/atom-label-numbering-in-xyz-files/3608/3 |
Signed-off-by: Marc Prat Masó <marc.prat.maso@estudiantat.upc.edu>
We never had residue labels, but probably: Residue Labels:
I've definitely seen cases where people annotate 2-3 particular residues with labels. |
Here are the build results |
Let me know when you think this is ready to merge. The code looks good - just trying to get the UI / UX right. 😄 |
Signed-off-by: Marc Prat Masó <marc.prat.maso@estudiantat.upc.edu>
Here are the build results |
avogadro/qtplugins/label/label.cpp
Outdated
SLOT(residueLabelType(int))); | ||
index = residue->findData(int(residueOptions)); | ||
residue->model()->sort(0, Qt::AscendingOrder); | ||
form->addRow(QObject::tr("residue label:"), residue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tr("Residue Label:")
avogadro/qtplugins/label/label.cpp
Outdated
SLOT(atomLabelType(int))); | ||
int index = atom->findData(int(atomOptions)); | ||
atom->model()->sort(0, Qt::AscendingOrder); | ||
form->addRow(QObject::tr("Atom label:"), atom); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tr("Atom Label:")
I think there are two minor issues with the latest version.
|
avogadro/qtplugins/label/label.cpp
Outdated
if (i == 0) { | ||
atom->addItem(QObject::tr("None"), QVariant(LabelOptions::None)); | ||
} else { | ||
char val = 0x00; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use a string list. I know this works in English, but it won't work for translation in many languages.
QStringList options;
options << tr("None") << tr("Index") << tr("Element Symbol") << tr("Symbol + Index"); // etc
text += (text == "" ? "" : " / ") + atom.label(); | ||
} | ||
if (interface.atomOptions & LayerLabel::LabelOptions::Index) { | ||
text += (text == "" ? "" : " / ") + std::to_string(atom.index()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
atom.index() + 1
// most users expect Atom 1, Atom 2, etc. rather than starting at zero...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the "Select by Atom Index" is indexed at 0. I can change both elements to indexed at 1 if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think most users expect atom numbers to start at 1.
Signed-off-by: Marc Prat Masó <marc.prat.maso@estudiantat.upc.edu>
Though adding all the combinations looks noisy, if a user needs any of them it will be complex (and probably ugly). I can try a custom sort so it's more appealing or just remove them. |
Here are the build results |
Yes, I'd just remove them from the list. If users ask later, it's easy enough to add a few. But I'd rather go for "the most common" list now. It's the 80/20 or 90/10 rule .. maybe 20% of the options are used 80% of the time. It's always a challenge with our UI because it's used both by experts doing research as well as students doing molecular visualization. I figure most of the users are on the student end (so keep things simple). |
Signed-off-by: Marc Prat Masó <marc.prat.maso@estudiantat.upc.edu>
Here are the build results |
I think it's a great start. I might tweak the icon a bit (e.g., a letter in front of an atom). There's a lot of interest in scripts adding labels to atoms, so this is great. Need to add the atom labels to the property table too. |
Signed-off-by: Marc Prat Masó marc.prat.maso@estudiantat.upc.edu
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.