Пример #1
0
void test7() {
  string smi = "c1ccccc1C";
#if 1
  Mol *m = SmilesToMol(smi);
  Mol::AromaticAtomIterator atomIt;
  Mol::AromaticAtomIterator beginP(m->beginAromaticAtoms());
  Mol::AromaticAtomIterator endP(m->endAromaticAtoms());
  unsigned int idx = 0;
  for (atomIt = beginP; atomIt != endP; atomIt++) {
    TEST_ASSERT((*atomIt)->getIdx() == idx);
    idx++;
  }
  TEST_ASSERT(idx == 6);

  atomIt = beginP;
  atomIt++;
  atomIt--;
  TEST_ASSERT((*atomIt)->getIdx() == 0);

  delete m;
  smi = "Cc1ccccc1";
  m = SmilesToMol(smi);
  beginP = m->beginAromaticAtoms();
  endP = m->endAromaticAtoms();
  idx = 0;
  for (atomIt = beginP; atomIt != endP; atomIt++) {
    TEST_ASSERT((*atomIt)->getIdx() == idx + 1);
    idx++;
  }
  TEST_ASSERT(idx == 6);
#endif
  BOOST_LOG(rdInfoLog) << "test7 done" << endl;
}
Пример #2
0
void MyFrame::OnReadFile (wxString filename)
{
   if (mol.ReadPdb((const char*)filename.mb_str(wxConvUTF8) )) {
       if ((mol.natm==0) && (mol.nhetatm!=0)) geoSettings.showHetatm=true;
       MyTab::EnableGeom();
       UpdateShadowmap();
       wxString name( mol.GetMolName(), wxConvUTF8 ); 
       SetTitle(  name.BeforeLast('.')+ _T(" - QuteMol") );
       m_tb->SetTitleText(name);
       geoSettings.Apply();

       // redo shaders, as texture size could have changed 
       cgSettings.UpdateShaders();

   } else {
      wxMessageBox(wxString::FromAscii(QAtom::lastReadError), _T(":-("), wxOK | wxICON_EXCLAMATION, this);
      m_tb->SetTitleText();
   }
   
  // remake shaders cos texture size could have changed...

   
   //theText->LoadFile(openFileDialog->GetFilename());
   //SetStatusText(GetCurrentFilename(), 0);      
}
Пример #3
0
Mol *read_atomic_coordinates(const char *file)
{
   long fpos;
   float x, y, z;
   int ord, natoms;

   free_dyna();

   if(find_string("Standard orientation")) {
      do {
         fpos = ftell(fp);
         natoms = addTrajectoryStep();
         } while(find_string("Standard orientation"));
   }
   else {
      rewind(fp);
      if(find_string("Z-Matrix orientation")) {
         do {
            fpos = ftell(fp);
            natoms = addTrajectoryStep();
         } while(find_string("Z-Matrix orientation"));
      }
      else {
           rewind(fp);
           if(find_string("Input orientation")) {
                do {
                 fpos = ftell(fp);
                 natoms = addTrajectoryStep();
                } while(find_string("Input orientation"));
           }
      }
   }

   Mol *mol = add_mol(file);
   dynamics.molecule = mol;
   dynamics.current = dynamics.ntotalsteps - 1;

   fseek(fp, fpos, SEEK_SET);

   if(!find_string("Coordinates (Angstroms)")) return 0;
   if(!find_string("-----")) return 0;

   fgets(line, 255, fp);
   do {
      if(flagG9803) {
      if(sscanf(line, "%*d %d %*d %f %f %f", &ord, &x, &y, &z) != 4) return 0;
      }
      else {
      if(sscanf(line, "%*d %d %f %f %f", &ord, &x, &y, &z) != 4) return 0;
      }
      if(ord >= 0) mol->AddNewAtom(ord, x, y, z);
      fgets(line, 255, fp);
   } while(!strstr(line, "------"));



   return mol;
}
Пример #4
0
AOgpu2::AOgpu2( Point3f dir, Mol &m, int ndir){
  
  shadowmap.computeAsTexture(dir, true, shadowAOCanvas );
  glFinish();
  
  moltextureCanvas.SetAsOutput();
  
  glDisable(GL_VERTEX_PROGRAM_ARB);
  glEnable(GL_FRAGMENT_PROGRAM_ARB);

  
  aogpu_settings.BindDrawAOShader();
  for (int i=0; i<3; i++) {
    glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, i, 
      matSM[0][i],matSM[1][i],matSM[2][i],matSM[3][i]
    );
    //printf("Sending %d (%f %f %f %f)\n", i, mat[0][i],mat[1][i],mat[2][i],mat[3][i]);
  }
  glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 3, dir[0],dir[1],dir[2], 4.0/ndir );
  glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 4, 
      0,stick_radius,0,0
  );

  m.DrawOnTexture();
  
  glDisable(GL_BLEND);
  
  glEnable(GL_VERTEX_PROGRAM_ARB);
  
};
Пример #5
0
void test5() {
  string smi = "CCCC";
  Mol *m = SmilesToMol(smi);
  Mol::BondIterator bondIt;
  unsigned int idx = 0;
  for (bondIt = m->beginBonds(); bondIt != m->endBonds(); bondIt++) {
    CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx");
    idx++;
  }
  CHECK_INVARIANT(idx == 3, "bad idx");
  idx = 0;
  for (bondIt = m->beginBonds(); bondIt != m->endBonds(); bondIt++) {
    CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx");
    idx++;
  }
  CHECK_INVARIANT(idx == 3, "bad idx");

  idx = 0;
  Mol::BondIterator beginP(m->beginBonds());
  Mol::BondIterator endP(m->endBonds());
  for (bondIt = beginP; bondIt != endP; bondIt++) {
    CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx");
    idx++;
  }
  CHECK_INVARIANT(idx == 3, "bad idx");

  BOOST_LOG(rdInfoLog) << "test5 done" << endl;
}
Пример #6
0
void GeoSettings::Apply(){
   if (mol.IsReady()) {
     if (mode==BALL_N_STICKS) {
       mol.SetBallAndSticks(stickRadius);
     }
     if (mode==LICORICE) {
       mol.SetLicorice(licoRadius);
     }
     if (mode==SPACE_FILL) mol.SetSpaceFill();
   }
   
   cgSettings.setGeoSettings(*this);
   cgSettings.UpdateShaders();
   
   UpdateShadowmap();
   
   mol.ResetAO();
}
Пример #7
0
void test8() {
  {
    string smi = "CC1CC2CC1C2";
    Mol *m = SmilesToMol(smi);
    QueryAtom *q = new QueryAtom();
    q->setQuery(makeAtomExplicitDegreeQuery(3));
    q->expandQuery(makeAtomRingBondCountQuery(2));
    unsigned int nSeen = 0;
    for (Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
         queryIt != m->endQueryAtoms(); ++queryIt) {
      TEST_ASSERT((*queryIt)->getIdx() == 1);
      nSeen++;
    }
    TEST_ASSERT(nSeen == 1);
    delete m;
    delete q;
  }

  BOOST_LOG(rdInfoLog) << "test8 done" << endl;
};
Пример #8
0
void MyFrame::OnIdle(wxIdleEvent& event){
  if (mol.DoingAO()) {
    m_tb->UpdateGearsIcon(true);
    if (mol.PrepareAOstep()) {
      m_canvas->SceneChanged();
      event.RequestMore(false); 
      m_tb->UpdateGearsIcon(false);
      return;
    }
    else event.RequestMore(true);      
  } else {
    event.RequestMore(false); 
    if (hardSettings.STILL_QUALITY!=hardSettings.MOVING_QUALITY)
    if (!m_canvas->shownHQ) {
      m_canvas->shownHQ=true;
      mustDoHQ=true;
      m_canvas->Refresh(false);
    }
    m_tb->UpdateGearsIcon(false);
  }
}
Пример #9
0
void test3() {
  string smi = "C1COCCNCOCNSCC1";
  unsigned char heteros[] = {2, 5, 7, 9, 10};

  Mol *m = SmilesToMol(smi);
  {
    unsigned int nSeen = 0;
    for (Mol::HeteroatomIterator heteroIt = m->beginHeteros();
         heteroIt != m->endHeteros(); heteroIt++) {
      CHECK_INVARIANT((*heteroIt)->getIdx() == heteros[nSeen], "bad hetero");
      nSeen++;
    }
  }
  {
    unsigned int nSeen = 0;
    for (Mol::HeteroatomIterator heteroIt = m->beginHeteros();
         heteroIt != m->endHeteros(); ++heteroIt) {
      CHECK_INVARIANT((*heteroIt)->getIdx() == heteros[nSeen], "bad hetero");
      nSeen++;
    }
  }
  {
    Mol::HeteroatomIterator heteroIt = m->beginHeteros();
    heteroIt++;
    heteroIt++;
    heteroIt--;
    CHECK_INVARIANT((*heteroIt)->getIdx() == heteros[1], "bad hetero");
    CHECK_INVARIANT((*--heteroIt)->getIdx() == heteros[0], "bad hetero");
    CHECK_INVARIANT((*heteroIt)->getIdx() == heteros[0], "bad hetero");
  }
  BOOST_LOG(rdInfoLog) << "test3 done" << endl;
};
Пример #10
0
void testIssue263() {
  string smi = "c1ccccc1C";
#if 1
  Mol *m = SmilesToMol(smi);
  Mol::AtomIterator atomIt;
  unsigned int idx = 0;
  for (atomIt = m->beginAtoms(); atomIt != m->endAtoms(); ++atomIt) {
    TEST_ASSERT((*atomIt)->getIdx() == idx);
    idx++;
  }
  TEST_ASSERT(idx == 7);

  Mol::BondIterator bondIt;
  idx = 0;
  for (bondIt = m->beginBonds(); bondIt != m->endBonds(); ++bondIt) {
    CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx");
    idx++;
  }
  CHECK_INVARIANT(idx == 7, "bad idx");

#endif
  BOOST_LOG(rdInfoLog) << "testIssue263 done" << endl;
}
Пример #11
0
AO::AO( Point3f _dir, Mol &m) {
  
  dir=_dir.Normalize();
  
  // orthonormal basis
  Point3f ax,ay,az=dir;
  ax=az^Point3f(1,0,0);
  if (ax.SquaredNorm()<0.1) ax=az^Point3f(0,1,0);
  ax=ax.Normalize();
  ay=(az^ax).Normalize();
  
  // project...
  m.Transform(ax,ay,az);
  
  
  int target=32; // 
  bufx=bufy=target;
  float bufscalex=target/(m.tx1-m.tx0);
  float bufscaley=target/(m.ty1-m.ty0);
  bufscale=(bufscalex<bufscaley)?bufscalex:bufscaley;
                
  m.ScaleTransl(bufscale);
  CubeMapSamp::Transform(ax,ay,az);
  
  printf("Scale=%f\n",bufscale);

  buf.resize(target*target,infty);
  
  for (int i=0; i<m.atom.size()-1; i++) {
    QAtom &a=m.atom[i];
    CheckAtom(a);
    RenderSphere( a.trp[0], a.trp[1], a.trp[2], a.trr );
    PrintBuffer();
  }
  
  
}
Пример #12
0
void test4() {
  string smi = "C1COCCNCOCNSCC1";
  unsigned int heteros1[] = {2, 7};

  Mol *m = SmilesToMol(smi);
  QueryAtom *q = new QueryAtom();
  q->setQuery(makeAtomNumQuery(8));
  {
    unsigned int nSeen = 0;
    for (Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
         queryIt != m->endQueryAtoms(); queryIt++) {
      CHECK_INVARIANT((*queryIt)->getIdx() == heteros1[nSeen], "bad query");
      nSeen++;
    }
  }
  {
    Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
    queryIt++;
    queryIt--;
    CHECK_INVARIANT((*queryIt)->getIdx() == heteros1[0], "bad query");
    CHECK_INVARIANT((*++queryIt)->getIdx() == heteros1[1], "bad query");
    CHECK_INVARIANT((*queryIt)->getIdx() == heteros1[1], "bad query");
  }
  {
    Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
    queryIt++;
    queryIt--;
    Mol::QueryAtomIterator queryIt2 = queryIt;
    CHECK_INVARIANT((*queryIt2)->getIdx() == heteros1[0], "bad query");
    CHECK_INVARIANT((*++queryIt2)->getIdx() == heteros1[1], "bad query");
    CHECK_INVARIANT((*queryIt2)->getIdx() == heteros1[1], "bad query");
  }
  smi = "CC(C)CC(C)CC(C)CC(C)C";
  unsigned int heteros2[] = {1, 4, 7, 10};
  m = SmilesToMol(smi);
  // m->debugMol(cout);
  q->setQuery(makeAtomImplicitValenceQuery(1));
  {
    unsigned int nSeen = 0;
    for (Mol::QueryAtomIterator queryIt = m->beginQueryAtoms(q);
         queryIt != m->endQueryAtoms(); ++queryIt) {
      CHECK_INVARIANT((*queryIt)->getIdx() == heteros2[nSeen], "bad query");
      nSeen++;
    }
  }
  BOOST_LOG(rdInfoLog) << "test4 done" << endl;
};
Пример #13
0
void TestGLCanvas::OnPaint( wxPaintEvent& event )
{


    /* must always be here */
    wxPaintDC dc(this);

#ifndef __WXMOTIF__
    if (!GetContext()) return;
#endif

    SetCurrent();

    if (!initdone) {
      static bool once=false;
      if (!once) {
        once=true; 
        int errcode=initGl();
        if (errcode!=ERRGL_OK){
          wxMessageBox(errorMSG(errcode), _T("Unrecoverable error: Problems initializing graphics"), wxOK | wxICON_EXCLAMATION, this);
          exit(0);
          }
        else initdone=true;
      }
    }
    
    if (!initdone) wxGLCanvas::OnPaint(event); else
    if (mol.IsReady()) { 
      if (mustDoHQ) {
        drawFrame( hardSettings.STILL_QUALITY );  
        shownHQ=true;
        mustDoHQ=false;
      } else {
        drawFrame( hardSettings.MOVING_QUALITY );  
        shownHQ=false;
      }
      SwapBuffers();  
    }  
    else {
      clearFrame();
      SwapBuffers();  
    }   
}
Пример #14
0
void test2() {
  string smi = "C1COC1";
  Mol *m = SmilesToMol(smi);
  Mol::BondIterator bondIt;

  unsigned int idx = 0;
  for (bondIt = m->beginBonds(); bondIt != m->endBonds(); bondIt++) {
    CHECK_INVARIANT((*bondIt)->getIdx() == idx, "bad idx");
    idx++;
  }
  bondIt = m->beginBonds();
  Mol::BondIterator bondIt2 = m->beginBonds();
  CHECK_INVARIANT(bondIt == bondIt2, "iterators don't compare equal");

  bondIt++;
  CHECK_INVARIANT((*bondIt)->getIdx() == 1, "bad idx");
  bondIt++;
  bondIt++;
  bondIt--;
  CHECK_INVARIANT((*bondIt)->getIdx() == 2, "bad idx");

  CHECK_INVARIANT(bondIt != bondIt2, "iterators don't compare different");

  bondIt--;
  --bondIt;
  CHECK_INVARIANT((*bondIt)->getIdx() == 0, "bad idx");
  CHECK_INVARIANT(bondIt == bondIt2, "iterator inequality failed");

  bondIt++;
  ++bondIt;
  CHECK_INVARIANT((*bondIt)->getIdx() == 2, "bad idx");

  // past the end stuff
  bondIt2 = m->endBonds();
  bondIt = m->beginBonds();
  bondIt--;

  BOOST_LOG(rdInfoLog) << "test2 done" << endl;
};
Пример #15
0
int InitQuteMol(const char * filename)
{
  
  CubeMapSamp::SetSize(CSIZE);
  OctaMapSamp::SetSize(CSIZE);

  if (filename==NULL) filename="porin.pdb";
   
  mol.ReadPdb(filename);
  cgSettings.SetDefaults();
  // initGl gets called from the GL canvas on startup.  It's not 
  // legal to call it before that time because the OpenGL context
  // does not exist yet.
    
  /*if (!initGl()) {
    printf("failed to initialize! :(\n");
    return 0;
  }*/

  //FillRandomTexture();
  //mol.DuplicateTexels(texture, TSIZE);
  //ReloadTexture(texture, bilinear);
  return 1;
}
Пример #16
0
// FOR HALOS
void prepareDepthTextureForCurrentViewpoint(){
  
  // Draw depth texture from current viewpoint
  
  haloCanvas.SetSameRes( mainCanvas );
  haloCanvas.SetAsOutput();
  
  if (use_accurate_halo)
    shadowSettingsAcc.BindShaders();
  else 
    shadowSettings.BindShaders();
    
    
  glClear( GL_DEPTH_BUFFER_BIT ) ; 
    
  mol.Draw();

  mainCanvas.SetAsOutput();  
  
  glActiveTextureARB(GL_TEXTURE1_ARB); 
  haloCanvas.SetAsTexture();
  glEnable(GL_TEXTURE_2D); 
  
}
Пример #17
0
void test1() {
  string smi = "CCOC";
  Mol *m = SmilesToMol(smi);
  Mol::AtomIterator atIt;

  unsigned int idx = 0;
  for (atIt = m->beginAtoms(); atIt != m->endAtoms(); atIt++) {
    CHECK_INVARIANT((*atIt)->getIdx() == idx, "bad idx");
    idx++;
  }
  atIt = m->beginAtoms();
  CHECK_INVARIANT((*(atIt + 2))->getIdx() == 2, "bad idx");

  atIt = m->beginAtoms();
  Mol::AtomIterator atIt2 = m->beginAtoms();
  CHECK_INVARIANT(atIt == atIt2, "iterators don't compare equal");

  atIt++;
  CHECK_INVARIANT((*atIt)->getIdx() == 1, "bad idx");
  atIt += 2;
  CHECK_INVARIANT((*atIt)->getIdx() == 3, "bad idx");
  atIt -= 1;
  CHECK_INVARIANT((*atIt)->getIdx() == 2, "bad idx");

  CHECK_INVARIANT(atIt != atIt2, "iterators don't compare different");
  CHECK_INVARIANT(atIt2 < atIt, "iterator inequality failed");
  CHECK_INVARIANT(atIt2 <= atIt, "iterator inequality failed");
  CHECK_INVARIANT(atIt > atIt2, "iterator inequality failed");
  CHECK_INVARIANT(atIt >= atIt2, "iterator inequality failed");

  atIt--;
  --atIt;
  CHECK_INVARIANT((*atIt)->getIdx() == 0, "bad idx");
  CHECK_INVARIANT(atIt == atIt2, "iterator inequality failed");

  atIt++;
  ++atIt;
  CHECK_INVARIANT((*atIt)->getIdx() == 2, "bad idx");

  atIt = m->beginAtoms();
  atIt = atIt + 2;
  atIt = atIt - 2;
  CHECK_INVARIANT((*atIt)->getIdx() == 0, "bad idx");

  atIt2 = m->beginAtoms();
  atIt2 += 2;
  CHECK_INVARIANT(atIt2 - atIt == 2, "subtraction failed");
  CHECK_INVARIANT(atIt - atIt2 == -2, "subtraction failed");

  // past the end stuff
  atIt2 = m->endAtoms();

  atIt = m->beginAtoms() + 10;
  CHECK_INVARIANT(atIt >= atIt2, "past-the-end failed");

  // this is whack
  atIt = m->beginAtoms();
  atIt -= 10;
  CHECK_INVARIANT(atIt >= atIt2, "past-the-end failed");

  BOOST_LOG(rdInfoLog) << "test1 done" << endl;
};
Пример #18
0
void TestGLCanvas::OnKeyDown( wxKeyEvent& event ){
  wxConsumeTrackBallEvent(event,true,track);
#ifdef __DARWIN__
	wxString path = wxStandardPaths::Get().GetResourcesDir() + "/presets/new.preset";
#else
	wxString path =  "presets\\new.preset";
#endif
  if (event.GetKeyCode() == WXK_F7 ) {
    cgSettings.Save(path.c_str());
  }

  if (event.GetKeyCode() == WXK_F6 ) {
    if (cgSettings.Load(path.c_str())) {
      MyTab::UpdateAll();
      
      cgSettings.ResetHalo();
      cgSettings.UpdateShaders();
      SceneChanged();
    }

  }

  if (event.GetKeyCode() == WXK_F5 ) {
    mol.PrepareAOSingleView();
    SceneChanged();
  }

  if (event.GetKeyCode() == WXK_F2 ) {
    static int status=0;
    status=(status+1) % 5;
    draw_balls = (status==0) || (status==1)  || (status==2) ; 
    draw_sticks = (status==0) || (status==1) || (status==3) || (status==4) ; 
    draw_wireframe_balls= (status==1)  ;
    draw_wireframe_sticks= (status==1)  || (status==3) ;
    
    SceneChanged();
  }
  
  if (event.GetKeyCode() == WXK_F1 ) {
    wxString text; 
    if (!mol.IsReady() ) text=wxT("(no molecule)");
    else {

      text=wxString( mol.GetMolName(), wxConvUTF8 ).BeforeLast('.') + 
           wxT("\n (file: \"")+wxString( mol.filename, wxConvUTF8 ) +wxT("\")\n\n");
      
      text=text+wxString::Format(wxT("%d atoms\n"),mol.atom.size());
      
      if (mol.sticks) {
        text=text+wxString::Format(wxT("%d bonds\n"),mol.bond.size());
      }
      
           
      text=text+wxString::Format(
        _T("\nUsing:\n Texture size = %dx%d\n Patch size=%dx%d"), 
        moltextureCanvas.GetHardRes(),
        moltextureCanvas.GetHardRes(),
        CSIZE,CSIZE
      );

      
    }       
    wxMessageBox(text, _T("QuteMol - file info"), wxOK | wxICON_INFORMATION, this);
  }

  if (event.GetKeyCode() == WXK_F6 ) {
    use_accurate_halo=!use_accurate_halo;
    SceneChanged();
  }
  
  // temp, should e set auto depending on dist
  if (event.GetKeyCode() == WXK_F2 ) {

    cgSettings.P_capping=!cgSettings.P_capping;
    cgSettings.UpdateShaders();
    SceneChanged();
  }
}
Пример #19
0
void MyFrame::OnSaveSnap (wxCommandEvent & event)
{
      
  int sx,sy;
  static const wxString FILETYPES = _T( 
     "PNG (lossless)|*.png|"
     "JPEG (lossy)|*.jpg|"
     "GIF animation|*.gif"
                  );
   wxFileDialog * saveSnapDialog =
       new wxFileDialog ( this,
                          wxString  (_T("Save a snapshot")),
                          wxString(), // def path
                          wxString(), 
                          FILETYPES,
                          wxSAVE | /*wxCHANGE_DIR |*/ wxOVERWRITE_PROMPT
                          );
                          
   static int lastFilterIndex=-1;
   
   if (lastFilterIndex==-1) lastFilterIndex=saveSnapDialog->GetFilterIndex();
   saveSnapDialog->SetFilterIndex( lastFilterIndex );
  
   wxString ext;   
   if (lastFilterIndex==1) ext=_T(".jpg"); 
   else if (lastFilterIndex==2) ext=_T(".gif"); 
   else ext=_T(".png");
   saveSnapDialog->SetFilename( wxString( mol.GetFilenameSnap(), wxConvUTF8 )+ ext );
   static wxString CANNOT_SAVE = _T("Could not save snap!\n\nYou might try setting\na lower resolution\nor removing AntiAliasing...");
   if (saveSnapDialog->ShowModal() == wxID_OK) 
   if ((new savesnapDialog(this,saveSnapDialog->GetFilterIndex()))->ShowModal() == wxID_OK )
   { 
      
      
      int jj=saveSnapDialog->GetFilterIndex();
      lastFilterIndex=jj;

      Byte* snap;
      int AAMult=(hardSettings.SNAP_ANTIALIAS)?2:1;
      bool useTransp=(hardSettings.PNG_TRANSPARENT==1) && (jj==0);
      if (jj!=2) {
        
        sx=sy=hardSettings.SNAP_SIZE*AAMult;
      
        if ((useTransp) && (cgSettings.UseHalo()>0)) {
          cgSettings.doingAlphaSnapshot=true;
          cgSettings.ResetHalo();
          cgSettings.UpdateShaders();
        }
      
        snap= GetSnapshot(sx,sy, useTransp );
      
        if (cgSettings.doingAlphaSnapshot) {
          cgSettings.doingAlphaSnapshot=false;
          cgSettings.ResetHalo();
          cgSettings.UpdateShaders();
        }      
        if (!snap) {
         wxMessageBox(CANNOT_SAVE, _T("OpenGL problems?"), wxOK | wxICON_EXCLAMATION, this);
         return;
        }
     } else sx=sy=hardSettings.GIF_SNAP_SIZE*AAMult;
     {
        
       wxString fn=saveSnapDialog->GetPath();
        
        // fix filename Extension
        //////////////////////////
        //wxString ext[3]={   _T("png"),   _T("jpg") ,  _T("png") };
        //wxString cext=fn.AfterLast('.');
        //if (cext.CmpNoCase(ext[0])||cext.CmpNoCase(ext[1])) fn=fn.BeforeLast('.');
        //fn=fn+_T('.')+ext[ jj ];
        
        switch (jj) {
          case 0:
          case 1: 
            if (!useTransp) {
              StartProgress("Saving snap!", 2);
              wxImage snapi(sx,sy,snap);
              if (AAMult!=1) snapi=snapi.Scale(sx/AAMult,sy/AAMult);
              UpdateProgress(1);
              wxBitmap(snapi.Mirror(false)).SaveFile(
                fn,
                (jj==0)?wxBITMAP_TYPE_PNG:wxBITMAP_TYPE_JPEG
              );
              UpdateProgress(2);
              EndProgress();
            }
            else {
              if (AAMult!=1) downsample2x2(snap, sx, sy);
              PNGSaveWithAlpha((const char*)fn.mb_str(wxConvUTF8),snap,sx/AAMult,sy/AAMult,1);
            };
           break;
          case 2: {
            GifWrapper gifw;
            int N;
            double totalTime;
            double subStepTime=0;
            double startTime;startTime=hardSettings.GIF_INITIAL_PAUSE/1000.0;
            if (hardSettings.GIF_ANIMATION_MODE==0) {
              N=hardSettings.GIF_ROT_N_FRAMES;
              totalTime=hardSettings.GIF_ROT_MSEC/1000.0;
            } 
            if (hardSettings.GIF_ANIMATION_MODE==1) {
              N=hardSettings.GIF_INSP_N_FRAMES;
              totalTime=hardSettings.GIF_INSP_MSEC/1000.0;
            } 
            if (hardSettings.GIF_ANIMATION_MODE==2) {
              N=hardSettings.GIF_6SIDES_N_FRAMES*6;
              totalTime=hardSettings.GIF_6SIDES_MSEC*6.0/1000.0;
              subStepTime=hardSettings.GIF_6SIDES_PAUSE/1000.0;
            } 
            
            StartProgress("Saving GIF", N);         
            for (int i=0; i<N; i++) {
              if (!UpdateProgress(i)) break;
              setAniStep(double(i)/N);
              snap = GetSnapshot(sx,sy, false);
              
              if (!snap) {
                 wxMessageBox(CANNOT_SAVE, _T("OpenGL problems?"), wxOK | wxICON_EXCLAMATION, this);
                 EndProgress();
                 return;
              }
              
              if (AAMult!=1) downsample2x2NoAlpha(snap, sx, sy);
              gifw.AddFrame(snap, sx/AAMult, sy/AAMult, 
                totalTime/N 
                + ( (i==0)?startTime:0) 
                + ( (i%(N/6)==0)?subStepTime:0) 
              ); 
            } 
            stopAni();
            gifw.Save( (const char*)fn.mb_str(wxConvUTF8) );
            EndProgress();
            } break;
        }
        
      }
   }
                  
}
Пример #20
0
void test4() {
  BOOST_LOG(rdErrorLog) << "---------------------- Test4" << std::endl;
  Mol m;

  Atom *a = new Atom(6);
  // we copy in addAtom, so this is safe
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  delete a;
  m.addBond(0, 1, Bond::SINGLE);
  m.addBond(1, 2, Bond::DOUBLE);
  m.addBond(2, 3, Bond::SINGLE);
  m.addBond(3, 4, Bond::DOUBLE);
  m.addBond(4, 5, Bond::SINGLE);
  m.addBond(5, 0, Bond::DOUBLE);
  m.addBond(5, 6, Bond::SINGLE);
  MolOps::sanitizeMol(m);

  ATOM_NULL_QUERY *aeq = makeAtomNullQuery();
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  BOOST_LOG(rdErrorLog) << "Done!" << std::endl;
}
Пример #21
0
void test1() {
  BOOST_LOG(rdErrorLog) << "---------------------- Test1" << std::endl;
  Mol qM;
  Mol m;

  Atom *a = new Atom(6);
  // we copy in addAtom, so this is safe
  m.addAtom(a);
  m.addAtom(a);
  delete a;
  m.addBond(0, 1, Bond::SINGLE);
  a = new Atom(8);
  m.addAtom(a);
  delete a;
  m.addBond(1, 2, Bond::DOUBLE);
  MolOps::sanitizeMol(m);

  QueryAtom *qA = new QueryAtom(6);
  CHECK_INVARIANT(qA->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(qA->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!qA->Match(m.getAtomWithIdx(2)), "");
  qA->expandQuery(makeAtomImplicitValenceQuery(3));
  CHECK_INVARIANT(qA->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(!qA->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!qA->Match(m.getAtomWithIdx(2)), "");

  qM.addAtom(qA);
  delete qA;
  qA = new QueryAtom(6);
  qA->expandQuery(makeAtomNumQuery(8), Queries::COMPOSITE_OR);
  qM.addAtom(qA);
  delete qA;
  qM.addAtom(new QueryAtom(8), true, true);
  // Atom::ATOM_SPTR qA(new QueryAtom(6));

  QueryBond *qB;
  qB = new QueryBond(Bond::UNSPECIFIED);
  qB->setOwningMol(qM);
  qB->setBeginAtomIdx(0);
  qB->setEndAtomIdx(1);

  CHECK_INVARIANT(qB->Match(m.getBondWithIdx(0)), "");
  CHECK_INVARIANT(qB->Match(m.getBondWithIdx(1)), "");
  qM.addBond(qB, true);
  qB = new QueryBond(Bond::DOUBLE);
  qB->setOwningMol(qM);
  qB->setBeginAtomIdx(1);
  qB->setEndAtomIdx(2);
  qM.addBond(qB, true);

  CHECK_INVARIANT(qM.getAtomWithIdx(0)->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(!qM.getAtomWithIdx(0)->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!qM.getAtomWithIdx(0)->Match(m.getAtomWithIdx(2)), "");
  CHECK_INVARIANT(qM.getAtomWithIdx(1)->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(qM.getAtomWithIdx(1)->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(qM.getAtomWithIdx(1)->Match(m.getAtomWithIdx(2)), "");
  CHECK_INVARIANT(!qM.getAtomWithIdx(2)->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(!qM.getAtomWithIdx(2)->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(qM.getAtomWithIdx(2)->Match(m.getAtomWithIdx(2)), "");

  CHECK_INVARIANT(qM.getBondWithIdx(0)->Match(m.getBondWithIdx(0)), "");
  CHECK_INVARIANT(qM.getBondWithIdx(0)->Match(m.getBondWithIdx(1)), "");
  CHECK_INVARIANT(!qM.getBondWithIdx(1)->Match(m.getBondWithIdx(0)), "");
  CHECK_INVARIANT(qM.getBondWithIdx(1)->Match(m.getBondWithIdx(1)), "");

  BOOST_LOG(rdErrorLog) << "Done!" << std::endl;
}
Пример #22
0
void test3() {
  BOOST_LOG(rdErrorLog) << "---------------------- Test3" << std::endl;
  Mol m;

  Atom *a = new Atom(6);
  // we copy in addAtom, so this is safe
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  delete a;
  m.addBond(0, 1, Bond::SINGLE);
  m.addBond(1, 2, Bond::DOUBLE);
  m.addBond(2, 3, Bond::SINGLE);
  m.addBond(3, 4, Bond::DOUBLE);
  m.addBond(4, 5, Bond::SINGLE);
  m.addBond(5, 0, Bond::DOUBLE);
  m.addBond(5, 6, Bond::SINGLE);
  MolOps::sanitizeMol(m);

  ATOM_EQUALS_QUERY *aeq = makeAtomExplicitDegreeQuery(3);
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;
  aeq = makeAtomExplicitDegreeQuery(2);
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  aeq = makeAtomHCountQuery(1);
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  aeq = makeAtomInNRingsQuery(1);
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  aeq = makeAtomInNRingsQuery(0);
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  aeq = makeAtomAromaticQuery();
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  aeq = makeAtomAliphaticQuery();
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  aeq = makeAtomInRingQuery();
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), "");
  aeq->setNegation(true);
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  aeq = makeAtomInRingOfSizeQuery(6);
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), "");
  aeq->setNegation(true);
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  aeq = makeAtomInRingOfSizeQuery(5);
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(!aeq->Match(m.getAtomWithIdx(6)), "");
  aeq->setNegation(true);
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(0)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(1)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(5)), "");
  CHECK_INVARIANT(aeq->Match(m.getAtomWithIdx(6)), "");
  delete aeq;

  BOND_EQUALS_QUERY *beq = makeBondIsInRingQuery();
  CHECK_INVARIANT(beq->Match(m.getBondWithIdx(0)), "");
  CHECK_INVARIANT(!beq->Match(m.getBondWithIdx(6)), "");
  CHECK_INVARIANT(beq->Match(m.getBondBetweenAtoms(0, 1)), "");
  CHECK_INVARIANT(beq->Match(m.getBondBetweenAtoms(1, 0)), "");
  CHECK_INVARIANT(!beq->Match(m.getBondBetweenAtoms(5, 6)), "");
  CHECK_INVARIANT(!beq->Match(m.getBondBetweenAtoms(6, 5)), "");

  BOOST_LOG(rdErrorLog) << "Done!" << std::endl;
}
Пример #23
0
void ResetColMode(){
  float tmp=mol.colMode;
  mol.colMode=-1;
  mol.SetColMode(tmp);
}
Пример #24
0
void SetColMode(float mode){
  mol.SetColMode(mode);
}
Пример #25
0
void MyFrame::ResetAO(){
  mol.ResetAO();
}
Пример #26
0
void test5() {
  BOOST_LOG(rdErrorLog) << "---------------------- Test5" << std::endl;
  Mol m;

  Atom *a = new Atom(6);
  // we copy in addAtom, so this is safe
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  delete a;
  m.addBond(0, 1, Bond::SINGLE);
  m.addBond(1, 2, Bond::DOUBLE);
  m.addBond(2, 3, Bond::SINGLE);
  m.addBond(3, 4, Bond::DOUBLE);
  m.addBond(4, 5, Bond::SINGLE);
  m.addBond(5, 0, Bond::DOUBLE);
  m.addBond(5, 6, Bond::SINGLE);
  MolOps::sanitizeMol(m);

  unsigned int valenceProd;
  valenceProd = queryAtomBondProduct(m.getAtomWithIdx(0));
  TEST_ASSERT(valenceProd == 1681);  // aromatic*aromatic = 41 * 41 = 1681
  valenceProd = queryAtomBondProduct(m.getAtomWithIdx(1));
  TEST_ASSERT(valenceProd == 1681);

  valenceProd = queryAtomBondProduct(m.getAtomWithIdx(5));
  TEST_ASSERT(valenceProd == 5043);

  valenceProd = queryAtomBondProduct(m.getAtomWithIdx(6));
  TEST_ASSERT(valenceProd == 3);

  valenceProd = queryAtomAllBondProduct(m.getAtomWithIdx(6));
  TEST_ASSERT(valenceProd == 81);

  BOOST_LOG(rdErrorLog) << "Done!" << std::endl;
}
Пример #27
0
void MyToolbar::UpdateGearsIcon(){
  UpdateGearsIcon( mol.DoingAO() );
}
Пример #28
0
void test2() {
  BOOST_LOG(rdErrorLog) << "---------------------- Test2" << std::endl;
  Mol qM;
  Mol m;

  Atom *a = new Atom(6);
  // we copy in addAtom, so this is safe
  m.addAtom(a);
  m.addAtom(a);
  m.addAtom(a);
  delete a;
  m.addBond(0, 1, Bond::TRIPLE);
  m.addBond(1, 2, Bond::SINGLE);
  a = new Atom(8);
  m.addAtom(a);
  delete a;
  m.addBond(2, 3, Bond::DOUBLE);
  MolOps::sanitizeMol(m);

  QueryBond *qB;
  qB = new QueryBond(Bond::SINGLE);

  CHECK_INVARIANT(!qB->Match(m.getBondWithIdx(0)), "");
  CHECK_INVARIANT(qB->Match(m.getBondWithIdx(1)), "");
  CHECK_INVARIANT(!qB->Match(m.getBondWithIdx(2)), "");

  BOND_EQUALS_QUERY *newQ = makeBondOrderEqualsQuery(Bond::DOUBLE);
  qB->expandQuery(newQ, Queries::COMPOSITE_OR);
  CHECK_INVARIANT(!qB->Match(m.getBondWithIdx(0)), "");
  CHECK_INVARIANT(qB->Match(m.getBondWithIdx(1)), "");
  CHECK_INVARIANT(qB->Match(m.getBondWithIdx(2)), "");

  BOOST_LOG(rdErrorLog) << "Done!" << std::endl;
}
Пример #29
0
void drawFrame() {
  
    cgSettings.MakeShaders();
    
    if (mol.DoingAO()) {
      // do at least one more step per rendering
      mol.PrepareAOstep(1);
      // continue until decent
      while (!mol.DecentAO()) mol.PrepareAOstep(1);  
    }

    /*if (cgSettings.UseHalo()>0) {
      // write depth in HaloTexture
      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, haloFrame);
    } else {
      // write depth in depthbuffer
      glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    }*/
  
  
  mainCanvas.SetAsOutput();
    
  if (cgSettings.doingAlphaSnapshot)    
    glClearColor( cgSettings.P_halo_col, cgSettings.P_halo_col, cgSettings.P_halo_col, 0.0f);
  else
    glClearColor( cgSettings.P_bg_color_R, cgSettings.P_bg_color_G, cgSettings.P_bg_color_B, 0.0f);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  
  
  
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  
  
  Point3f lightDir;
  
  if  ( cgSettings.P_sem_effect  // fixed light dir sem effect
//    || mol.sticks               // quick Hack: fixed light dir when bonds
    )
    lightDir= Point3f(0,0,1);
  else 
    lightDir=getDirFromTrackball(lightTrack);
    
  setLightDir( lightDir );

//  gluLookAt(0,0,-3,   0,0,0,   0,1,0);    original
//  gluLookAt(0,0,-3,   0,0,0,   0,1,0);    ok for tra

    if (mol.hasDefaultView())
        gluLookAt(0,0, 40,   0,0,0,   0,1,0);
    else
        gluLookAt(0,0,-40,   0,0,0,   0,1,0);
        
    if(MovingLightMode)
        drawLightDir();
    glColor3f(1,1,1);

    if (mol.hasDefaultView()) {
        float angle, axisX, axisY, axisZ;
        mol.getDefaultViewRotation(&angle, &axisX, &axisY, &axisZ);
        glRotatef(angle, axisX, axisY, axisZ);
    }


  if (1) {
    
    //track.center=Point3f(0, 0, 0);
    //track.radius= 1;
    //setProjection();

    if (aniStep>=0) // BH: Doesn't normally seem to be aniStep>=0
    {
      double extraRot=360.0*aniStep;
      
      // set extra rotation for GIF animation:
      switch (hardSettings.GIF_ANIMATION_MODE) {
       default:
       case 0: 
        glRotated(-hardSettings.GIF_ROT_SIDEVIEW_ANGLE,1,0,0);
        glRotated(extraRot,0,1,0);
        break;
       case 1:
        glRotated(-extraRot,0,0,1);
        glRotated(hardSettings.GIF_INSP_ANGLE,0,1,0);
        glRotated(extraRot,0,0,1);
        break;
       case 2:{
        double substep[6];
        for (int i=0; i<6; i++) {
          substep[i]=(aniStep*6-i)*90.0;
          if (substep[i]<0) substep[i]=0;
          if (substep[i]>90.0) substep[i]=90.0;
        }
        glRotated(-substep[5], 1,0,0);
        glRotated(-substep[4], 0,1,0);
        glRotated(-substep[3], 0,1,0);
        glRotated(-substep[2], 1,0,0);
        glRotated(-substep[1], 0,1,0);
        glRotated(-substep[0], 0,1,0);
        }break;
      }
    }

    setProjection( mainCanvas.GetVideoSize() );
    track.GetView();
    track.Apply(false); // Set to true to see the trackball itself.
    setProjection( mainCanvas.GetSoftRes() );
    
    if (cgSettings.P_use_shadowmap()) {
      shadowmap.computeAsTexture( getGlLightPos() , cgSettings.do_use_doubleshadow(), shadowmapCanvas);
      //shadowmap.computeAsTexture( Point3f(0,1,0) );
    }

    cgSettings.BindShaders();

    glEnable(GL_TEXTURE_2D);
    //glBindTexture(GL_TEXTURE_2D, molTexture);

    glActiveTextureARB(GL_TEXTURE1_ARB); 
    shadowmapCanvas.SetAsTexture();

    mol.Draw();
    //  shadowmap.m.DrawShadowmap(false);
  
    glDisable(GL_VERTEX_PROGRAM_ARB);
    glDisable(GL_FRAGMENT_PROGRAM_ARB);
    glDisable(GL_BLEND);
    
    if (cgSettings.UseHalo()>0) mol.DrawHalos();
  }

}
Пример #30
0
void Mol::Draw(){ 
  
    glPushMatrix();
    glScalef(1/r,1/r,1/r);
    glTranslatef(-px,-py,-pz);
    

    float x[4][4], scalef;
    glGetFloatv(GL_MODELVIEW_MATRIX, &(x[0][0]));
    
    glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, 0, 
      scalef=extractCurrentScaleFactor(x),0,0,0
    );
    
    /*
    glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 6, 
      1.0 / ( scalef*scalef) , 0,0,0
    );*/
/*    printf("ScaleFactor= %f, ShadowScaleFactor= %f\n",
    scalef, shadowScaleFactor  );*/


    glEnable(GL_VERTEX_PROGRAM_ARB);
    glEnable(GL_TEXTURE_2D);

    glActiveTextureARB(GL_TEXTURE0_ARB); 
    moltextureCanvas.SetAsTexture();
    
    if (cgSettings.P_shadowstrenght>0) {
      ShadowMap::GetCurrentPVMatrix();
      ShadowMap::FeedParameters();
    }
      
    for (int i=0; i<3; i++)
    glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, i, 
      x[i][0],x[i][1],x[i][2],0
    );
    
    glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 6, 
      mol.PredictAO(),0,0,0
    );

    if (draw_balls) {
      if (draw_wireframe_balls)  {
        glDisable(GL_FRAGMENT_PROGRAM_ARB);
        for (int i=0; i<atom.size(); i++)  {
          glColor3f(0,0,1);
          glBegin(GL_LINE_LOOP);
          atom[i].Draw();
          glEnd();
        }
      } else {
        glEnable(GL_VERTEX_PROGRAM_ARB);
        glEnable(GL_FRAGMENT_PROGRAM_ARB);
        //if (DL_atoms==666) glGenD
          
        glBegin(GL_QUADS);
        for (int i=0; i<atom.size(); i++)  atom[i].Draw();
        glEnd();
        
        glDisable(GL_VERTEX_PROGRAM_ARB);
        glDisable(GL_FRAGMENT_PROGRAM_ARB);
      }
    }

 
    if (draw_sticks) 
    if (sticks) {
      glEnable(GL_VERTEX_PROGRAM_ARB);
      glEnable(GL_FRAGMENT_PROGRAM_ARB);
      cgSettings.BindStickShaders();
      ShadowMap::FeedParameters();  
      for (int i=0; i<3; i++)
      glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, i, 
        x[i][0],x[i][1],x[i][2],0
      );
      
      /*
      glProgramEnvParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 6, 
        1.0 / ( scalef*scalef) , stick_radius,1.0 / ( scalef) ,0
      );*/
      
      glEnable(GL_TEXTURE_2D);
      
      glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, 0,  
        scalef, stick_radius,stick_radius*2,0  );     
      
      glColor3f(1,1,1);
      if (draw_wireframe_sticks) {
        glDisable(GL_FRAGMENT_PROGRAM_ARB);
        for (int i=0; i<bond.size(); i++)   {
          glColor3f(0,0.6,0.3);
          glBegin(GL_LINE_LOOP);
          bond[i].Draw();
          glEnd();
        }
      }
      else {
        glBegin(GL_QUADS);
        for (int i=0; i<bond.size(); i++) bond[i].Draw();
        glEnd();
      }
      cgSettings.BindShaders();
    }   
    
    glPopMatrix();
}