Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    r42a101 r112b09  
    66 *
    77 */
     8
     9#include "Helpers/MemDebug.hpp"
    810
    911#include "Legacy/oldmenu.hpp"
     
    3638#include "Menu/DisplayMenuItem.hpp"
    3739#include "Menu/SubMenuItem.hpp"
     40#include "Actions/MapOfActions.hpp"
    3841#include "Actions/MethodAction.hpp"
    3942#include "Actions/ErrorAction.hpp"
     
    424427void oldmenu::RemoveAtoms(molecule *mol)
    425428{
    426   atom *first, *second;
     429  atom *second;
    427430  int axis;
    428431  double tmp1, tmp2;
     
    447450      break;
    448451    case 'b':
    449       second = mol->AskAtom("Enter number of atom as reference point: ");
    450       Log() << Verbose(0) << "Enter radius: ";
    451       cin >> tmp1;
    452       first = mol->start;
    453       second = first->next;
    454       while(second != mol->end) {
    455         first = second;
    456         second = first->next;
    457         if (first->x.DistanceSquared(second->x) > tmp1*tmp1) // distance to first above radius ...
    458           mol->RemoveAtom(first);
     452      {
     453        second = mol->AskAtom("Enter number of atom as reference point: ");
     454        Log() << Verbose(0) << "Enter radius: ";
     455        cin >> tmp1;
     456        molecule::iterator runner;
     457        for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     458          runner = iter++;
     459          if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...
     460            mol->RemoveAtom((*runner));
     461        }
    459462      }
    460463      break;
     
    466469      Log() << Verbose(0) << "Upper boundary: ";
    467470      cin >> tmp2;
    468       first = mol->start;
    469       second = first->next;
    470       while(second != mol->end) {
    471         first = second;
    472         second = first->next;
    473         if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ...
    474           //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
    475           mol->RemoveAtom(first);
     471      molecule::iterator runner;
     472      for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
     473        runner = iter++;
     474        if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...
     475          //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
     476          mol->RemoveAtom((*runner));
    476477        }
    477478      }
     
    516517        min[i] = 0.;
    517518
    518       second = mol->start;
    519       while ((second->next != mol->end)) {
    520         second = second->next; // advance
    521         Z = second->type->Z;
     519      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     520        Z = (*iter)->type->Z;
    522521        tmp1 = 0.;
    523         if (first != second) {
    524           x = first->x - second->x;
     522        if (first != (*iter)) {
     523          x = first->x - (*iter)->x;
    525524          tmp1 = x.Norm();
    526525        }
    527526        if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
    528         //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << second->nr << ": " << tmp1 << " a.u." << endl;
     527        //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;
    529528      }
    530529      for (int i=MAX_ELEMENTS;i--;)
     
    609608  Log() << Verbose(0) << "What's the desired bond order: ";
    610609  cin >> Order1;
    611   if (mol->first->next != mol->last) {  // there are bonds
     610  if (mol->hasBondStructure()) {
    612611    start = clock();
    613612    mol->FragmentMolecule(Order1, configuration);
     
    755754    Log() << Verbose(0) << "State the factor: ";
    756755    cin >> faktor;
    757 
    758     mol->CountAtoms(); // recount atoms
    759     if (mol->AtomCount != 0) {  // if there is more than none
    760       count = mol->AtomCount;  // is changed becausing of adding, thus has to be stored away beforehand
     756    if (mol->getAtomCount() != 0) {  // if there is more than none
     757      count = mol->getAtomCount();  // is changed becausing of adding, thus has to be stored away beforehand
    761758      Elements = new const element *[count];
    762759      vectors = new Vector *[count];
    763760      j = 0;
    764       first = mol->start;
    765       while (first->next != mol->end) { // make a list of all atoms with coordinates and element
    766         first = first->next;
    767         Elements[j] = first->type;
    768         vectors[j] = &first->x;
     761      for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
     762        Elements[j] = (*iter)->type;
     763        vectors[j] = &(*iter)->x;
    769764        j++;
    770765      }
     
    783778        }
    784779      }
    785       if (mol->first->next != mol->last) // if connect matrix is present already, redo it
     780      if (mol->hasBondStructure())
    786781        mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
    787782      // free memory
     
    909904  molecule *srcmol = NULL, *destmol = NULL;
    910905  Dialog *dialog = UIFactory::getInstance().makeDialog();
    911   dialog->queryMolecule("Enter index of destination molecule: ",&destmol, molecules);
    912   dialog->queryMolecule("Enter index of source molecule to add from: ",&srcmol, molecules);
     906  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     907  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    913908  if(dialog->display()) {
    914909    molecules->SimpleAdd(srcmol, destmol);
     
    923918  molecule *srcmol = NULL, *destmol = NULL;
    924919  Dialog *dialog = UIFactory::getInstance().makeDialog();
    925   dialog->queryMolecule("Enter index of matrix molecule (the variable one): ",&srcmol,molecules);
    926   dialog->queryMolecule("Enter index of molecule to merge into (the fixed one): ",&destmol,molecules);
     920  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     921  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    927922  if(dialog->display()) {
    928923    molecules->EmbedMerge(destmol, srcmol);
     
    10251020    return;
    10261021  }
    1027   atom *Walker = mol->start;
    10281022
    10291023  // generate some KeySets
    10301024  Log() << Verbose(0) << "Generating KeySets." << endl;
    1031   KeySet TestSets[mol->AtomCount+1];
     1025  KeySet TestSets[mol->getAtomCount()+1];
    10321026  i=1;
    1033   while (Walker->next != mol->end) {
    1034     Walker = Walker->next;
     1027  for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    10351028    for (int j=0;j<i;j++) {
    1036       TestSets[j].insert(Walker->nr);
     1029      TestSets[j].insert((*iter)->nr);
    10371030    }
    10381031    i++;
     
    10401033  Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
    10411034  KeySetTestPair test;
    1042   test = TestSets[mol->AtomCount-1].insert(Walker->nr);
    1043   if (test.second) {
    1044     Log() << Verbose(1) << "Insertion worked?!" << endl;
     1035  molecule::const_iterator iter = mol->begin();
     1036  if (iter != mol->end()) {
     1037    test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr);
     1038    if (test.second) {
     1039      Log() << Verbose(1) << "Insertion worked?!" << endl;
     1040    } else {
     1041      Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
     1042    }
    10451043  } else {
    1046     Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
    1047   }
    1048   TestSets[mol->AtomCount].insert(mol->end->previous->nr);
    1049   TestSets[mol->AtomCount].insert(mol->end->previous->previous->previous->nr);
     1044    eLog() << Verbose(1) << "No atoms to test double insertion." << endl;
     1045  }
    10501046
    10511047  // constructing Graph structure
     
    10551051  // insert KeySets into Subgraphs
    10561052  Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
    1057   for (int j=0;j<mol->AtomCount;j++) {
     1053  for (int j=0;j<mol->getAtomCount();j++) {
    10581054    Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
    10591055  }
    10601056  Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
    10611057  GraphTestPair test2;
    1062   test2 = Subgraphs.insert(GraphPair (TestSets[mol->AtomCount],pair<int, double>(counter++, 1.)));
     1058  test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
    10631059  if (test2.second) {
    10641060    Log() << Verbose(1) << "Insertion worked?!" << endl;
Note: See TracChangeset for help on using the changeset viewer.