本文整理汇总了C++中AtomList::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ AtomList::clear方法的具体用法?C++ AtomList::clear怎么用?C++ AtomList::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AtomList
的用法示例。
在下文中一共展示了AtomList::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setConstraint
void ViewerModel::setConstraint()
{
int n(m_selectedObjects.size());
if (n < 1 || n > 4) {
displayMessage("Invalid number of atoms for constraint");
return;
}
// Check all the selected atoms belong to the same Molecule.
unsigned int findFlags(Layer::Parents | Layer::Visible);
MoleculeList parents(m_selectedObjects[0]->findLayers<Layer::Molecule>(findFlags));
if (parents.isEmpty()) return;
for (int i = 1; i < n; ++i) {
if (m_selectedObjects[i]->findLayers<Layer::Molecule>(findFlags) != parents) {
QString msg("Cannot enforce constraints between atoms in different molecules");
QMsgBox::warning(m_parent, "IQmol", msg);
return;
}
}
AtomList atoms;
Layer::Bond* bond;
if ( (n == 1) && (bond = qobject_cast<Layer::Bond*>(m_selectedObjects[0])) ) {
Layer::Atom* A(bond->beginAtom());
Layer::Atom* B(bond->endAtom());
if (A && B) atoms << A << B;
}else {
Layer::Atom* A;
for (int i = 0; i < n; ++i) {
if ((A = qobject_cast<Layer::Atom*>(m_selectedObjects[i]))) atoms << A;
}
if (atoms.size() != n) atoms.clear();
}
if (atoms.isEmpty()) {
displayMessage("Unable to set constraint");
return;
}
Layer::Molecule* molecule(parents.first());
Layer::Constraint* constraint(molecule->findMatchingConstraint(atoms));
if (constraint) {
constraint->configure();
if (constraint->accepted()) {
selectNone();
molecule->applyConstraint(constraint);
}
}else {
constraint = new Layer::Constraint(atoms);
constraint->configure();
if (constraint->accepted()) {
if (molecule->canAcceptConstraint(constraint)) {
selectNone();
molecule->addConstraint(constraint);
}else {
QMsgBox::information(0, "IQmol",
"A maximum of two scan coordinates are permitted");
delete constraint;
}
}else {
delete constraint;
}
}
}