MolAtomPtr MolCoord::getAtom(const LString &chain, ResidIndex resid, const LString &aname, char cConfID /*='\0'*/) const { MolResiduePtr pResid = getResidue(chain, resid); if (pResid.isnull()) return MolAtomPtr(); int id = pResid->getAtomID(aname, cConfID); if (id<0) return MolAtomPtr(); return getAtom(id); /* if (cConfID=='\0') { int id = pResid->getAtomID(aname); if (id<0) return MolAtomPtr(); return getAtom(id); } else { LString key = aname + ":" + cConfID; int id = pResid->getAtomID(key); if (id<0) return MolAtomPtr(); return getAtom(id); } */ }
void BallStickRenderer::drawRings(DisplayContext *pdl) { int i, j; MolCoordPtr pMol = getClientMol(); while (m_atoms.size()>0) { std::set<int>::iterator iter = m_atoms.begin(); int aid = *iter; m_atoms.erase(iter); MolAtomPtr pa = pMol->getAtom(aid); if (pa.isnull()) continue; MolResiduePtr pres = pa->getParentResidue(); ResiToppar *ptop = pres->getTopologyObj(); if (ptop==NULL) continue; // draw rings int nrings = ptop->getRingCount(); for (i=0; i<nrings; i++) { const ResiToppar::RingAtomArray *pmembs = ptop->getRing(i); std::list<int> ring_atoms; // completeness flag of the ring bool fcompl = true; for (j=0; j<pmembs->size(); j++) { LString nm = pmembs->at(j); int maid = pres->getAtomID(nm); if (maid<=0) { fcompl = false; break; } std::set<int>::const_iterator miter = m_atoms.find(maid); if (miter==m_atoms.end()) { if (aid!=maid) { fcompl = false; break; } else { ring_atoms.push_back(aid); continue; } } ring_atoms.push_back(*miter); } if (fcompl) drawRingImpl(ring_atoms, pdl); } // remove drawn ring members from m_atoms for (i=0; i<nrings; i++) { const ResiToppar::RingAtomArray *pmembs = ptop->getRing(i); for (j=0; j<pmembs->size(); j++) { LString nm = pmembs->at(j); int maid = pres->getAtomID(nm); if (maid<=0) continue; std::set<int>::iterator miter = m_atoms.find(maid); if (miter==m_atoms.end()) continue; m_atoms.erase(miter); } } } }