예제 #1
0
파일: Viewer.C 프로젝트: baneofblabs/IQmol
void Viewer::drawObjects(GLObjectList const& objects, Vec const& cameraPosition)
{
   GLObjectList::const_iterator object;
   for (object = objects.begin(); object != objects.end(); ++object) {
       (*object)->draw(cameraPosition);
   }
}
예제 #2
0
파일: Viewer.C 프로젝트: baneofblabs/IQmol
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);
}
예제 #3
0
파일: Viewer.C 프로젝트: gechen/IQmol
void Viewer::drawObjects(GLObjectList const& objects)
{
   GLObjectList::const_iterator object;
   for (object = objects.begin(); object != objects.end(); ++object) {
       (*object)->draw();
   }
}
예제 #4
0
파일: Viewer.C 프로젝트: baneofblabs/IQmol
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);
}
예제 #5
0
파일: Viewer.C 프로젝트: baneofblabs/IQmol
void Viewer::displayGeometricParameter(GLObjectList const& selection)
{
   QString msg;
   Layer::Atom *a, *b, *c, *d;
   Layer::Bond *bond;

   switch (selection.size()) {
      case 0:
         return;
         break;
      case 1: 
         if ( (bond = qobject_cast<Layer::Bond*>(selection[0])) ) {
             QChar ch(0x00c5);
             msg = "Bond length: " + QString::number(bond->length(), 'f', 5) + " " + ch;
         }else if ( (a = qobject_cast<Layer::Atom*>(selection[0])) ) {
             msg = a->getAtomicSymbol() + " atom";
         }
         break;

      case 2:
         if ( (a = qobject_cast<Layer::Atom*>(selection[0])) &&
              (b = qobject_cast<Layer::Atom*>(selection[1])) ) {
            QChar ch(0x00c5);
            msg = "Distance: " + QString::number(Layer::Atom::distance(a,b), 'f', 5) + " " + ch;
         }
         break;

      case 3:
         if ( (a = qobject_cast<Layer::Atom*>(selection[0])) &&
              (b = qobject_cast<Layer::Atom*>(selection[1])) &&
              (c = qobject_cast<Layer::Atom*>(selection[2])) ) {
            QChar ch(0x00b0);
            msg = "Angle: " + QString::number(Layer::Atom::angle(a,b,c), 'f', 5) + " " + ch;
         }
         break;

      case 4:
         if ( (a = qobject_cast<Layer::Atom*>(selection[0])) &&
              (b = qobject_cast<Layer::Atom*>(selection[1])) &&
              (c = qobject_cast<Layer::Atom*>(selection[2])) &&
              (d = qobject_cast<Layer::Atom*>(selection[3])) ) {
            QChar ch(0x00b0);
            msg = "Torsion: " + QString::number(Layer::Atom::torsion(a,b,c,d), 'f', 3) + " " + ch;
         }
         break;

      default:
         break;
   }

   displayMessage(msg); 
}