Changes in src/Legacy/oldmenu.cpp [42a101:112b09]
- File:
-
- 1 edited
-
src/Legacy/oldmenu.cpp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Legacy/oldmenu.cpp
r42a101 r112b09 6 6 * 7 7 */ 8 9 #include "Helpers/MemDebug.hpp" 8 10 9 11 #include "Legacy/oldmenu.hpp" … … 36 38 #include "Menu/DisplayMenuItem.hpp" 37 39 #include "Menu/SubMenuItem.hpp" 40 #include "Actions/MapOfActions.hpp" 38 41 #include "Actions/MethodAction.hpp" 39 42 #include "Actions/ErrorAction.hpp" … … 424 427 void oldmenu::RemoveAtoms(molecule *mol) 425 428 { 426 atom * first, *second;429 atom *second; 427 430 int axis; 428 431 double tmp1, tmp2; … … 447 450 break; 448 451 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 } 459 462 } 460 463 break; … … 466 469 Log() << Verbose(0) << "Upper boundary: "; 467 470 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)); 476 477 } 477 478 } … … 516 517 min[i] = 0.; 517 518 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; 522 521 tmp1 = 0.; 523 if (first != second) {524 x = first->x - second->x;522 if (first != (*iter)) { 523 x = first->x - (*iter)->x; 525 524 tmp1 = x.Norm(); 526 525 } 527 526 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; 529 528 } 530 529 for (int i=MAX_ELEMENTS;i--;) … … 609 608 Log() << Verbose(0) << "What's the desired bond order: "; 610 609 cin >> Order1; 611 if (mol-> first->next != mol->last) { // there are bonds610 if (mol->hasBondStructure()) { 612 611 start = clock(); 613 612 mol->FragmentMolecule(Order1, configuration); … … 755 754 Log() << Verbose(0) << "State the factor: "; 756 755 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 761 758 Elements = new const element *[count]; 762 759 vectors = new Vector *[count]; 763 760 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; 769 764 j++; 770 765 } … … 783 778 } 784 779 } 785 if (mol-> first->next != mol->last) // if connect matrix is present already, redo it780 if (mol->hasBondStructure()) 786 781 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL); 787 782 // free memory … … 909 904 molecule *srcmol = NULL, *destmol = NULL; 910 905 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")); 913 908 if(dialog->display()) { 914 909 molecules->SimpleAdd(srcmol, destmol); … … 923 918 molecule *srcmol = NULL, *destmol = NULL; 924 919 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")); 927 922 if(dialog->display()) { 928 923 molecules->EmbedMerge(destmol, srcmol); … … 1025 1020 return; 1026 1021 } 1027 atom *Walker = mol->start;1028 1022 1029 1023 // generate some KeySets 1030 1024 Log() << Verbose(0) << "Generating KeySets." << endl; 1031 KeySet TestSets[mol-> AtomCount+1];1025 KeySet TestSets[mol->getAtomCount()+1]; 1032 1026 i=1; 1033 while (Walker->next != mol->end) { 1034 Walker = Walker->next; 1027 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) { 1035 1028 for (int j=0;j<i;j++) { 1036 TestSets[j].insert( Walker->nr);1029 TestSets[j].insert((*iter)->nr); 1037 1030 } 1038 1031 i++; … … 1040 1033 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl; 1041 1034 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 } 1045 1043 } 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 } 1050 1046 1051 1047 // constructing Graph structure … … 1055 1051 // insert KeySets into Subgraphs 1056 1052 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++) { 1058 1054 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.))); 1059 1055 } 1060 1056 Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl; 1061 1057 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.))); 1063 1059 if (test2.second) { 1064 1060 Log() << Verbose(1) << "Insertion worked?!" << endl;
Note:
See TracChangeset
for help on using the changeset viewer.
