void Viewer::drawSelected(GLObjectList const& objects, Vec const& cameraPosition) { if (!m_selectionHighlighting || objects.isEmpty()) return; // create a stencil of the highlighted region glClearStencil(0x4); glDisable(GL_LIGHTING); glClear(GL_STENCIL_BUFFER_BIT); glEnable(GL_STENCIL_TEST); glStencilFunc(GL_ALWAYS, 0x0, 0x4); glStencilMask(0x4); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); GLObjectList::const_iterator object; for (object = objects.begin(); object != objects.end(); ++object) { (*object)->draw(cameraPosition); } glStencilFunc(GL_EQUAL, 0x4, 0x4); glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); for (object = objects.begin(); object != objects.end(); ++object) { glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); (*object)->drawSelected(cameraPosition); } glDisable(GL_STENCIL_TEST); glDisable(GL_BLEND); glEnable(GL_LIGHTING); }
void Viewer::drawObjects(GLObjectList const& objects, Vec const& cameraPosition) { GLObjectList::const_iterator object; for (object = objects.begin(); object != objects.end(); ++object) { (*object)->draw(cameraPosition); } }
void Viewer::drawObjects(GLObjectList const& objects) { GLObjectList::const_iterator object; for (object = objects.begin(); object != objects.end(); ++object) { (*object)->draw(); } }
void Viewer::drawLabels(GLObjectList const& objects) { AtomList atomList; Layer::Atom* atom; Layer::Charge* charge; bool selectedOnly = (m_selectedObjects.count() > 0); GLObjectList::const_iterator object; for (object = objects.begin(); object!= objects.end(); ++object) { if ( (atom = qobject_cast<Layer::Atom*>(*object)) ) { atom->drawLabel(*this, m_labelType, s_labelFontMetrics); if ( !selectedOnly || atom->isSelected() ) atomList.append(atom); }else if ( (m_labelType == Layer::Atom::Charge) && (charge = qobject_cast<Layer::Charge*>(*object)) ) { charge->drawLabel(*this, s_labelFontMetrics); } } glDisable(GL_LIGHTING); qglColor(foregroundColor()); QString mesg = selectedOnly ? "Selection " : "Total "; AtomList::const_iterator iter; double value(0.0); if (m_labelType == Layer::Atom::Mass) { for (iter= atomList.begin(); iter != atomList.end(); ++iter) { value += (*iter)->getMass(); } mesg += "mass: " + QString::number(value,'f', 3); drawText(width()-s_labelFontMetrics.width(mesg), height()-10, mesg); }else if (m_labelType == Layer::Atom::Charge) { for (iter = atomList.begin(); iter != atomList.end(); ++iter) { value += (*iter)->getCharge(); } mesg += "charge: " + QString::number(value,'f', 2); drawText(width()-s_labelFontMetrics.width(mesg), height()-10, mesg); }else if (m_labelType == Layer::Atom::Spin) { for (iter = atomList.begin(); iter != atomList.end(); ++iter) { value += (*iter)->getSpin(); } mesg += "spin: " + QString::number(value,'f', 2); drawText(width()-s_labelFontMetrics.width(mesg), height()-10, mesg); } glEnable(GL_LIGHTING); }