Exemple #1
0
Data::GridDataList GridInfoDialog::getSelectedGrids()
{
   QTableWidget* table(m_dialog.gridTable);
   Data::GridDataList grids;

   QList<QTableWidgetItem*> items(table->selectedItems());
   QList<QTableWidgetItem*>::iterator iter;

   int row, col;
   for (iter = items.begin(); iter != items.end(); ++iter) {
       row = (*iter)->row();
       col = (*iter)->column();
       if (col == 0 && row >= 0 && row < m_gridDataList->size()) {
          grids.append((*m_gridDataList)[row]);
       }
   }

   return grids; 
}
bool MolecularOrbitals::processGridQueue(GridQueue const& gridQueue)
{
   // First obtain a list of the unique grid sizes
   std::set<Data::GridSize> sizes;
   GridQueue::const_iterator queued; 
   for (queued = gridQueue.begin(); queued != gridQueue.end(); ++queued) {
       sizes.insert(queued->second);    
   }

   // Second, determine what data is required for each grid size
   QLOG_TRACE() << "Computing data for" << gridQueue.size() <<"grids";
   QLOG_TRACE() << "There are" << sizes.size() << "different grid sizes";
   std::set<Data::GridSize>::iterator size;

   for (size = sizes.begin(); size != sizes.end(); ++size) {
       std::set<Data::SurfaceType> densities;
       std::set<Data::SurfaceType> alphaOrbitals;
       std::set<Data::SurfaceType> betaOrbitals;
       
       for (queued = gridQueue.begin(); queued != gridQueue.end(); ++queued) {
           if (queued->second == *size) {
              Data::SurfaceType type(queued->first);

              if (type.isDensity()) {
                 densities.insert(type);
              }else if (type.kind() == Data::SurfaceType::AlphaOrbital) {
                 alphaOrbitals.insert(type);
              }else if (type.kind() == Data::SurfaceType::BetaOrbital) {
                 betaOrbitals.insert(type); 
              }else  {
                 QLOG_WARN() << "Unknown Grid type found in processQueue";
              }
           }
       }

       if (densities.size() > 0) {
          QLOG_TRACE() << "Computing" << densities.size() << "density grids";
          Data::SurfaceType alpha(Data::SurfaceType::AlphaDensity);
          Data::GridData*   alphaGrid = new Data::GridData(*size, alpha);
          Data::SurfaceType beta(Data::SurfaceType::BetaDensity);
          Data::GridData*   betaGrid  = new Data::GridData(*size, beta);

          if (!computeDensityGrids(alphaGrid, betaGrid)) {
             // user canceled the action
             delete alphaGrid;
             delete betaGrid;
             return false;
          }

          m_availableGrids.append(alphaGrid);
          m_availableGrids.append(betaGrid);

          Data::GridData* spinGrid  = new Data::GridData(*alphaGrid);
          *spinGrid -= *betaGrid;
          spinGrid->setSurfaceType(Data::SurfaceType::SpinDensity);

          Data::GridData* totalGrid = new Data::GridData(*alphaGrid);
          *totalGrid += *betaGrid;
          totalGrid->setSurfaceType(Data::SurfaceType::TotalDensity);

          m_availableGrids.append(spinGrid);
          m_availableGrids.append(totalGrid);
       }

       Data::GridDataList grids;
       std::set<Data::SurfaceType>::iterator iter;
       for (iter = alphaOrbitals.begin(); iter != alphaOrbitals.end(); ++iter) {
           Data::GridData* grid = new Data::GridData(*size, *iter);
           grids.append(grid); 
       }

       if (grids.count() > 0) {
          QLOG_TRACE() << "Computing" << grids.size() << "alpha orbitals";
          if (computeOrbitalGrids(grids)) {
             m_availableGrids += grids;
          }else {
             for (int i = 0; i <  grids.size(); ++i) {
                 delete grids[i];
             }
             return false;
          }
       }

       grids.clear();
       for (iter = betaOrbitals.begin(); iter != betaOrbitals.end(); ++iter) {
           Data::GridData* grid = new Data::GridData(*size, *iter);
           grids.append(grid); 
       }

       if (grids.count() > 0) {
          QLOG_TRACE() << "Computing" << grids.size() << "beta orbitals";
          if (computeOrbitalGrids(grids)) {
             m_availableGrids += grids;
          }else {
             for (int i = 0; i <  grids.size(); ++i) {
                 delete grids[i];
             }
             return false;
          }
       }
       grids.clear();
   }

   return true;
}