source: src/Legacy/oldmenu.cpp@ 104524

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 104524 was 104524, checked in by Frederik Heber <heber@…>, 15 years ago

Changed PairCorrelationAction to incorporate all three cases and handled different parameters needed for each, changed queryElement to list of elements.

PairCorrelationAction:

queryElement:

Others:

  • Property mode set to 100644
File size: 42.7 KB
Line 
1/** \file menu.cpp
2 * The class in this file is responsible for displaying the menu and enabling choices.
3 *
4 * This class is currently being refactored. Functions were copied from builder.cpp and are
5 * to be imported into the menu class.
6 *
7 */
8
9#include "Legacy/oldmenu.hpp"
10#include "analysis_correlation.hpp"
11#include "World.hpp"
12#include "atom.hpp"
13#include "bond.hpp"
14#include "bondgraph.hpp"
15#include "boundary.hpp"
16#include "config.hpp"
17#include "element.hpp"
18#include "ellipsoid.hpp"
19#include "helpers.hpp"
20#include "leastsquaremin.hpp"
21#include "linkedcell.hpp"
22#include "log.hpp"
23#include "memoryusageobserverunittest.hpp"
24#include "molecule.hpp"
25#include "periodentafel.hpp"
26#include "vector_ops.hpp"
27#include "Plane.hpp"
28
29#include "UIElements/UIFactory.hpp"
30#include "UIElements/Dialog.hpp"
31#include "Menu/Menu.hpp"
32#include "Menu/TextMenu.hpp"
33#include "Menu/ActionMenuItem.hpp"
34#include "Menu/SeperatorItem.hpp"
35#include "Menu/DisplayMenuItem.hpp"
36#include "Menu/SubMenuItem.hpp"
37#include "Actions/MapOfActions.hpp"
38#include "Actions/MethodAction.hpp"
39#include "Actions/ErrorAction.hpp"
40#include "Views/StreamStringView.hpp"
41#include "Views/MethodStringView.hpp"
42
43
44#include <boost/bind.hpp>
45
46/* copied methods for refactoring */
47/*TODO: Move these methods inside menu class
48 * and restructure menu class*/
49
50/********************************************* Subsubmenu routine ************************************/
51
52/** Submenu for adding atoms to the molecule.
53 * \param *periode periodentafel
54 * \param *molecule molecules with atoms
55 */
56void oldmenu::AddAtoms(periodentafel *periode, molecule *mol)
57{
58 atom *first, *second, *third, *fourth;
59 Vector **atoms;
60 Vector x,y,z,n; // coordinates for absolute point in cell volume
61 double a,b,c;
62 char choice; // menu choice char
63 bool valid;
64 bool aborted;
65
66 Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
67 Log() << Verbose(0) << " a - state absolute coordinates of atom" << endl;
68 Log() << Verbose(0) << " b - state relative coordinates of atom wrt to reference point" << endl;
69 Log() << Verbose(0) << " c - state relative coordinates of atom wrt to already placed atom" << endl;
70 Log() << Verbose(0) << " d - state two atoms, two angles and a distance" << endl;
71 Log() << Verbose(0) << " e - least square distance position to a set of atoms" << endl;
72 Log() << Verbose(0) << "all else - go back" << endl;
73 Log() << Verbose(0) << "===============================================" << endl;
74 Log() << Verbose(0) << "Note: Specifiy angles in degrees not multiples of Pi!" << endl;
75 Log() << Verbose(0) << "INPUT: ";
76 cin >> choice;
77
78 switch (choice) {
79 default:
80 eLog() << Verbose(2) << "Not a valid choice." << endl;
81 break;
82 case 'a': // absolute coordinates of atom
83 {
84 Dialog *dialog = UIFactory::getInstance().makeDialog();
85 first = World::getInstance().createAtom();
86 std::vector<element *> elements;
87 dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false);
88 dialog->queryElement("Please choose element: ",&elements);
89 if(dialog->display()){
90 if (elements.size() == 1) {
91 first->type = elements.at(0);
92 mol->AddAtom(first); // add to molecule
93 } else {
94 DoeLog(1) && (eLog() << Verbose(1) << "Unequal to one element given for element of new atom." << endl);
95 }
96 }
97 else{
98 World::getInstance().destroyAtom(first);
99 }
100 }
101 break;
102
103 case 'b': // relative coordinates of atom wrt to reference point
104 first = World::getInstance().createAtom();
105 valid = true;
106 aborted = false;
107 do {
108 if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
109 auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
110 dialog->queryVector("Enter reference coordinates.",&x,World::getInstance().getDomain(), true);
111 dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
112 if((aborted = !dialog->display())){
113 continue;
114 }
115 first->x += x;
116 } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->x)));
117 if(!aborted){
118 first->type = periode->AskElement(); // give type
119 mol->AddAtom(first); // add to molecule
120 }
121 else{
122 World::getInstance().destroyAtom(first);
123 }
124 break;
125
126 case 'c': // relative coordinates of atom wrt to already placed atom
127 {
128 first = World::getInstance().createAtom();
129 valid = true;
130 do {
131 if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
132 auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
133 second = mol->AskAtom("Enter atom number: ");
134 dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
135 dialog->display();
136 for (int i=NDIM;i--;) {
137 first->x[i] += second->x[i];
138 }
139 } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
140 first->type = periode->AskElement(); // give type
141 mol->AddAtom(first); // add to molecule
142 }
143 break;
144
145 case 'd': // two atoms, two angles and a distance
146 first = World::getInstance().createAtom();
147 valid = true;
148 do {
149 if (!valid) {
150 eLog() << Verbose(2) << "Resulting coordinates out of cell - " << first->x << endl;
151 }
152 Log() << Verbose(0) << "First, we need two atoms, the first atom is the central, while the second is the outer one." << endl;
153 second = mol->AskAtom("Enter central atom: ");
154 third = mol->AskAtom("Enter second atom (specifying the axis for first angle): ");
155 fourth = mol->AskAtom("Enter third atom (specifying a plane for second angle): ");
156 a = ask_value("Enter distance between central (first) and new atom: ");
157 b = ask_value("Enter angle between new, first and second atom (degrees): ");
158 b *= M_PI/180.;
159 bound(&b, 0., 2.*M_PI);
160 c = ask_value("Enter second angle between new and normal vector of plane defined by first, second and third atom (degrees): ");
161 c *= M_PI/180.;
162 bound(&c, -M_PI, M_PI);
163 Log() << Verbose(0) << "radius: " << a << "\t phi: " << b*180./M_PI << "\t theta: " << c*180./M_PI << endl;
164/*
165 second->Output(1,1,(ofstream *)&cout);
166 third->Output(1,2,(ofstream *)&cout);
167 fourth->Output(1,3,(ofstream *)&cout);
168 n.MakeNormalvector((const vector *)&second->x, (const vector *)&third->x, (const vector *)&fourth->x);
169 x.Copyvector(&second->x);
170 x.SubtractVector(&third->x);
171 x.Copyvector(&fourth->x);
172 x.SubtractVector(&third->x);
173
174 if (!z.SolveSystem(&x,&y,&n, b, c, a)) {
175 Log() << Verbose(0) << "Failure solving self-dependent linear system!" << endl;
176 continue;
177 }
178 Log() << Verbose(0) << "resulting relative coordinates: ";
179 z.Output();
180 Log() << Verbose(0) << endl;
181 */
182 // calc axis vector
183 x= second->x - third->x;
184 x.Normalize();
185 Log() << Verbose(0) << "x: " << x << endl;
186 z = Plane(second->x,third->x,fourth->x).getNormal();
187 Log() << Verbose(0) << "z: " << z << endl;
188 y = Plane(x,z,0).getNormal();
189 Log() << Verbose(0) << "y: " << y << endl;
190
191 // rotate vector around first angle
192 first->x = x;
193 first->x = RotateVector(first->x,z,b - M_PI);
194 Log() << Verbose(0) << "Rotated vector: " << first->x << endl,
195 // remove the projection onto the rotation plane of the second angle
196 n = y;
197 n.Scale(first->x.ScalarProduct(y));
198 Log() << Verbose(0) << "N1: " << n << endl;
199 first->x -= n;
200 Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
201 n = z;
202 n.Scale(first->x.ScalarProduct(z));
203 Log() << Verbose(0) << "N2: " << n << endl;
204 first->x -= n;
205 Log() << Verbose(0) << "2nd subtracted vector: " << first->x << endl;
206
207 // rotate another vector around second angle
208 n = y;
209 n = RotateVector(n,x,c - M_PI);
210 Log() << Verbose(0) << "2nd Rotated vector: " << n << endl;
211
212 // add the two linear independent vectors
213 first->x += n;
214 first->x.Normalize();
215 first->x.Scale(a);
216 first->x += second->x;
217
218 Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
219 } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
220 first->type = periode->AskElement(); // give type
221 mol->AddAtom(first); // add to molecule
222 break;
223
224 case 'e': // least square distance position to a set of atoms
225 first = World::getInstance().createAtom();
226 atoms = new (Vector*[128]);
227 valid = true;
228 for(int i=128;i--;)
229 atoms[i] = NULL;
230 int i=0, j=0;
231 Log() << Verbose(0) << "Now we need at least three molecules.\n";
232 do {
233 Log() << Verbose(0) << "Enter " << i+1 << "th atom: ";
234 cin >> j;
235 if (j != -1) {
236 second = mol->FindAtom(j);
237 atoms[i++] = &(second->x);
238 }
239 } while ((j != -1) && (i<128));
240 if (i >= 2) {
241 LSQdistance(first->x,(const Vector **)atoms, i);
242
243 Log() << Verbose(0) << first->x;
244 first->type = periode->AskElement(); // give type
245 mol->AddAtom(first); // add to molecule
246 } else {
247 World::getInstance().destroyAtom(first);
248 Log() << Verbose(0) << "Please enter at least two vectors!\n";
249 }
250 break;
251 };
252};
253
254/** Submenu for centering the atoms in the molecule.
255 * \param *mol molecule with all the atoms
256 */
257void oldmenu::CenterAtoms(molecule *mol)
258{
259 Vector x, y, helper;
260 char choice; // menu choice char
261
262 Log() << Verbose(0) << "===========CENTER ATOMS=========================" << endl;
263 Log() << Verbose(0) << " a - on origin" << endl;
264 Log() << Verbose(0) << " b - on center of gravity" << endl;
265 Log() << Verbose(0) << " c - within box with additional boundary" << endl;
266 Log() << Verbose(0) << " d - within given simulation box" << endl;
267 Log() << Verbose(0) << "all else - go back" << endl;
268 Log() << Verbose(0) << "===============================================" << endl;
269 Log() << Verbose(0) << "INPUT: ";
270 cin >> choice;
271
272 switch (choice) {
273 default:
274 Log() << Verbose(0) << "Not a valid choice." << endl;
275 break;
276 case 'a':
277 Log() << Verbose(0) << "Centering atoms in config file on origin." << endl;
278 mol->CenterOrigin();
279 break;
280 case 'b':
281 Log() << Verbose(0) << "Centering atoms in config file on center of gravity." << endl;
282 mol->CenterPeriodic();
283 break;
284 case 'c':
285 Log() << Verbose(0) << "Centering atoms in config file within given additional boundary." << endl;
286 for (int i=0;i<NDIM;i++) {
287 Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
288 cin >> y[i];
289 }
290 mol->CenterEdge(&x); // make every coordinate positive
291 mol->Center += y; // translate by boundary
292 helper = (2*y)+x;
293 mol->SetBoxDimension(&helper); // update Box of atoms by boundary
294 break;
295 case 'd':
296 Log() << Verbose(1) << "Centering atoms in config file within given simulation box." << endl;
297 for (int i=0;i<NDIM;i++) {
298 Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
299 cin >> x[i];
300 }
301 // update Box of atoms by boundary
302 mol->SetBoxDimension(&x);
303 // center
304 mol->CenterInBox();
305 break;
306 }
307};
308
309/** Submenu for aligning the atoms in the molecule.
310 * \param *periode periodentafel
311 * \param *mol molecule with all the atoms
312 */
313void oldmenu::AlignAtoms(periodentafel *periode, molecule *mol)
314{
315 atom *first, *second, *third;
316 Vector x,n;
317 char choice; // menu choice char
318
319 Log() << Verbose(0) << "===========ALIGN ATOMS=========================" << endl;
320 Log() << Verbose(0) << " a - state three atoms defining align plane" << endl;
321 Log() << Verbose(0) << " b - state alignment vector" << endl;
322 Log() << Verbose(0) << " c - state two atoms in alignment direction" << endl;
323 Log() << Verbose(0) << " d - align automatically by least square fit" << endl;
324 Log() << Verbose(0) << "all else - go back" << endl;
325 Log() << Verbose(0) << "===============================================" << endl;
326 Log() << Verbose(0) << "INPUT: ";
327 cin >> choice;
328
329 switch (choice) {
330 default:
331 case 'a': // three atoms defining mirror plane
332 first = mol->AskAtom("Enter first atom: ");
333 second = mol->AskAtom("Enter second atom: ");
334 third = mol->AskAtom("Enter third atom: ");
335
336 n = Plane(first->x,second->x,third->x).getNormal();
337 break;
338 case 'b': // normal vector of mirror plane
339 {
340 Dialog *dialog = UIFactory::getInstance().makeDialog();
341 dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
342 dialog->display();
343 delete dialog;
344 n.Normalize();
345 }
346 break;
347
348 case 'c': // three atoms defining mirror plane
349 first = mol->AskAtom("Enter first atom: ");
350 second = mol->AskAtom("Enter second atom: ");
351
352 n = first->x - second->x;
353 n.Normalize();
354 break;
355 case 'd':
356 char shorthand[4];
357 Vector a;
358 struct lsq_params param;
359 do {
360 fprintf(stdout, "Enter the element of atoms to be chosen: ");
361 fscanf(stdin, "%3s", shorthand);
362 } while ((param.type = periode->FindElement(shorthand)) == NULL);
363 Log() << Verbose(0) << "Element is " << param.type->name << endl;
364 mol->GetAlignvector(&param);
365 for (int i=NDIM;i--;) {
366 x[i] = gsl_vector_get(param.x,i);
367 n[i] = gsl_vector_get(param.x,i+NDIM);
368 }
369 gsl_vector_free(param.x);
370 Log() << Verbose(0) << "Offset vector: " << x << endl;
371 n.Normalize();
372 break;
373 };
374 Log() << Verbose(0) << "Alignment vector: " << n << endl;
375 mol->Align(&n);
376};
377
378/** Submenu for mirroring the atoms in the molecule.
379 * \param *mol molecule with all the atoms
380 */
381void oldmenu::MirrorAtoms(molecule *mol)
382{
383 atom *first, *second, *third;
384 Vector n;
385 char choice; // menu choice char
386
387 Log() << Verbose(0) << "===========MIRROR ATOMS=========================" << endl;
388 Log() << Verbose(0) << " a - state three atoms defining mirror plane" << endl;
389 Log() << Verbose(0) << " b - state normal vector of mirror plane" << endl;
390 Log() << Verbose(0) << " c - state two atoms in normal direction" << endl;
391 Log() << Verbose(0) << "all else - go back" << endl;
392 Log() << Verbose(0) << "===============================================" << endl;
393 Log() << Verbose(0) << "INPUT: ";
394 cin >> choice;
395
396 switch (choice) {
397 default:
398 case 'a': // three atoms defining mirror plane
399 first = mol->AskAtom("Enter first atom: ");
400 second = mol->AskAtom("Enter second atom: ");
401 third = mol->AskAtom("Enter third atom: ");
402
403 n = Plane(first->x,second->x,third->x).getNormal();
404 break;
405 case 'b': // normal vector of mirror plane
406 {
407 Dialog *dialog = UIFactory::getInstance().makeDialog();
408 dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
409 dialog->display();
410 delete dialog;
411 n.Normalize();
412 }
413 break;
414
415 case 'c': // three atoms defining mirror plane
416 first = mol->AskAtom("Enter first atom: ");
417 second = mol->AskAtom("Enter second atom: ");
418
419 n = first->x - second->x;
420 n.Normalize();
421 break;
422 };
423 Log() << Verbose(0) << "Normal vector: " << n << endl;
424 mol->Mirror((const Vector *)&n);
425};
426
427/** Submenu for removing the atoms from the molecule.
428 * \param *mol molecule with all the atoms
429 */
430void oldmenu::RemoveAtoms(molecule *mol)
431{
432 atom *second;
433 int axis;
434 double tmp1, tmp2;
435 char choice; // menu choice char
436
437 Log() << Verbose(0) << "===========REMOVE ATOMS=========================" << endl;
438 Log() << Verbose(0) << " a - state atom for removal by number" << endl;
439 Log() << Verbose(0) << " b - keep only in radius around atom" << endl;
440 Log() << Verbose(0) << " c - remove this with one axis greater value" << endl;
441 Log() << Verbose(0) << "all else - go back" << endl;
442 Log() << Verbose(0) << "===============================================" << endl;
443 Log() << Verbose(0) << "INPUT: ";
444 cin >> choice;
445
446 switch (choice) {
447 default:
448 case 'a':
449 if (mol->RemoveAtom(mol->AskAtom("Enter number of atom within molecule: ")))
450 Log() << Verbose(1) << "Atom removed." << endl;
451 else
452 Log() << Verbose(1) << "Atom not found." << endl;
453 break;
454 case 'b':
455 {
456 second = mol->AskAtom("Enter number of atom as reference point: ");
457 Log() << Verbose(0) << "Enter radius: ";
458 cin >> tmp1;
459 molecule::iterator runner;
460 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
461 runner = iter++;
462 if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...
463 mol->RemoveAtom((*runner));
464 }
465 }
466 break;
467 case 'c':
468 Log() << Verbose(0) << "Which axis is it: ";
469 cin >> axis;
470 Log() << Verbose(0) << "Lower boundary: ";
471 cin >> tmp1;
472 Log() << Verbose(0) << "Upper boundary: ";
473 cin >> tmp2;
474 molecule::iterator runner;
475 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
476 runner = iter++;
477 if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...
478 //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
479 mol->RemoveAtom((*runner));
480 }
481 }
482 break;
483 };
484 //mol->Output();
485 choice = 'r';
486};
487
488/** Submenu for measuring out the atoms in the molecule.
489 * \param *periode periodentafel
490 * \param *mol molecule with all the atoms
491 */
492void oldmenu::MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
493{
494 atom *first, *second, *third;
495 Vector x,y;
496 double min[256], tmp1, tmp2, tmp3;
497 int Z;
498 char choice; // menu choice char
499
500 Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
501 Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
502 Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl;
503 Log() << Verbose(0) << " c - calculate bond angle" << endl;
504 Log() << Verbose(0) << " d - calculate principal axis of the system" << endl;
505 Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
506 Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl;
507 Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
508 Log() << Verbose(0) << "all else - go back" << endl;
509 Log() << Verbose(0) << "===============================================" << endl;
510 Log() << Verbose(0) << "INPUT: ";
511 cin >> choice;
512
513 switch(choice) {
514 default:
515 Log() << Verbose(1) << "Not a valid choice." << endl;
516 break;
517 case 'a':
518 first = mol->AskAtom("Enter first atom: ");
519 for (int i=MAX_ELEMENTS;i--;)
520 min[i] = 0.;
521
522 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
523 Z = (*iter)->type->Z;
524 tmp1 = 0.;
525 if (first != (*iter)) {
526 x = first->x - (*iter)->x;
527 tmp1 = x.Norm();
528 }
529 if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
530 //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;
531 }
532 for (int i=MAX_ELEMENTS;i--;)
533 if (min[i] != 0.) Log() << Verbose(0) << "Minimum Bond length between " << first->type->name << " Atom " << first->nr << " and next Ion of type " << (periode->FindElement(i))->name << ": " << min[i] << " a.u." << endl;
534 break;
535
536 case 'b':
537 first = mol->AskAtom("Enter first atom: ");
538 second = mol->AskAtom("Enter second atom: ");
539 for (int i=NDIM;i--;)
540 min[i] = 0.;
541 x = first->x - second->x;
542 tmp1 = x.Norm();
543 Log() << Verbose(1) << "Distance vector is " << x << "." << "/n"
544 << "Norm of distance is " << tmp1 << "." << endl;
545 break;
546
547 case 'c':
548 Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
549 first = mol->AskAtom("Enter first atom: ");
550 second = mol->AskAtom("Enter central atom: ");
551 third = mol->AskAtom("Enter last atom: ");
552 tmp1 = tmp2 = tmp3 = 0.;
553 x = first->x - second->x;
554 y = third->x - second->x;
555 Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
556 Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
557 break;
558 case 'd':
559 Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
560 Log() << Verbose(0) << "Shall we rotate? [0/1]: ";
561 cin >> Z;
562 if ((Z >=0) && (Z <=1))
563 mol->PrincipalAxisSystem((bool)Z);
564 else
565 mol->PrincipalAxisSystem(false);
566 break;
567 case 'e':
568 {
569 Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
570 class Tesselation *TesselStruct = NULL;
571 const LinkedCell *LCList = NULL;
572 LCList = new LinkedCell(mol, 10.);
573 FindConvexBorder(mol, TesselStruct, LCList, NULL);
574 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
575 Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\
576 delete(LCList);
577 delete(TesselStruct);
578 }
579 break;
580 case 'f':
581 mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps);
582 break;
583 case 'g':
584 {
585 char filename[255];
586 Log() << Verbose(0) << "Please enter filename: " << endl;
587 cin >> filename;
588 Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
589 ofstream *output = new ofstream(filename, ios::trunc);
590 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
591 Log() << Verbose(2) << "File could not be written." << endl;
592 else
593 Log() << Verbose(2) << "File stored." << endl;
594 output->close();
595 delete(output);
596 }
597 break;
598 }
599};
600
601/** Submenu for measuring out the atoms in the molecule.
602 * \param *mol molecule with all the atoms
603 * \param *configuration configuration structure for the to be written config files of all fragments
604 */
605void oldmenu::FragmentAtoms(molecule *mol, config *configuration)
606{
607 int Order1;
608 clock_t start, end;
609
610 Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
611 Log() << Verbose(0) << "What's the desired bond order: ";
612 cin >> Order1;
613 if (mol->hasBondStructure()) {
614 start = clock();
615 mol->FragmentMolecule(Order1, configuration);
616 end = clock();
617 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
618 } else
619 Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
620};
621
622/********************************************** Submenu routine **************************************/
623
624/** Submenu for manipulating atoms.
625 * \param *periode periodentafel
626 * \param *molecules list of molecules whose atoms are to be manipulated
627 */
628void oldmenu::ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
629{
630 atom *first, *second;
631 molecule *mol = NULL;
632 Vector x,y,z,n; // coordinates for absolute point in cell volume
633 double *factor; // unit factor if desired
634 double bond, minBond;
635 char choice; // menu choice char
636 bool valid;
637
638 Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl;
639 Log() << Verbose(0) << "a - add an atom" << endl;
640 Log() << Verbose(0) << "r - remove an atom" << endl;
641 Log() << Verbose(0) << "b - scale a bond between atoms" << endl;
642 Log() << Verbose(0) << "u - change an atoms element" << endl;
643 Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
644 Log() << Verbose(0) << "all else - go back" << endl;
645 Log() << Verbose(0) << "===============================================" << endl;
646 if (molecules->NumberOfActiveMolecules() > 1)
647 eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
648 Log() << Verbose(0) << "INPUT: ";
649 cin >> choice;
650
651 switch (choice) {
652 default:
653 Log() << Verbose(0) << "Not a valid choice." << endl;
654 break;
655
656 case 'a': // add atom
657 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
658 if ((*ListRunner)->ActiveFlag) {
659 mol = *ListRunner;
660 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
661 AddAtoms(periode, mol);
662 }
663 break;
664
665 case 'b': // scale a bond
666 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
667 if ((*ListRunner)->ActiveFlag) {
668 mol = *ListRunner;
669 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
670 Log() << Verbose(0) << "Scaling bond length between two atoms." << endl;
671 first = mol->AskAtom("Enter first (fixed) atom: ");
672 second = mol->AskAtom("Enter second (shifting) atom: ");
673 minBond = 0.;
674 for (int i=NDIM;i--;)
675 minBond += (first->x[i]-second->x[i])*(first->x[i] - second->x[i]);
676 minBond = sqrt(minBond);
677 Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
678 Log() << Verbose(0) << "Enter new bond length [a.u.]: ";
679 cin >> bond;
680 for (int i=NDIM;i--;) {
681 second->x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);
682 }
683 //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
684 //second->Output(second->type->No, 1);
685 }
686 break;
687
688 case 'c': // unit scaling of the metric
689 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
690 if ((*ListRunner)->ActiveFlag) {
691 mol = *ListRunner;
692 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
693 Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;
694 Log() << Verbose(0) << "Enter three factors: ";
695 factor = new double[NDIM];
696 cin >> factor[0];
697 cin >> factor[1];
698 cin >> factor[2];
699 valid = true;
700 mol->Scale((const double ** const)&factor);
701 delete[](factor);
702 }
703 break;
704
705 case 'l': // measure distances or angles
706 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
707 if ((*ListRunner)->ActiveFlag) {
708 mol = *ListRunner;
709 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
710 MeasureAtoms(periode, mol, configuration);
711 }
712 break;
713
714 case 'r': // remove atom
715 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
716 if ((*ListRunner)->ActiveFlag) {
717 mol = *ListRunner;
718 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
719 RemoveAtoms(mol);
720 }
721 break;
722
723 case 'u': // change an atom's element
724 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
725 if ((*ListRunner)->ActiveFlag) {
726 int Z;
727 mol = *ListRunner;
728 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
729 first = NULL;
730 do {
731 Log() << Verbose(0) << "Change the element of which atom: ";
732 cin >> Z;
733 } while ((first = mol->FindAtom(Z)) == NULL);
734 Log() << Verbose(0) << "New element by atomic number Z: ";
735 cin >> Z;
736 first->setType(Z);
737 Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
738 }
739 break;
740 }
741};
742
743void oldmenu::duplicateCell(MoleculeListClass *molecules, config *configuration) {
744 molecule *mol = NULL;
745 int axis,faktor,count,j;
746 atom *first = NULL;
747 const element **Elements;
748 Vector x,y;
749 Vector **vectors;
750
751 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
752 if ((*ListRunner)->ActiveFlag) {
753 mol = *ListRunner;
754 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
755 Log() << Verbose(0) << "State the axis [(+-)123]: ";
756 cin >> axis;
757 Log() << Verbose(0) << "State the factor: ";
758 cin >> faktor;
759 if (mol->getAtomCount() != 0) { // if there is more than none
760 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand
761 Elements = new const element *[count];
762 vectors = new Vector *[count];
763 j = 0;
764 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
765 Elements[j] = (*iter)->type;
766 vectors[j] = &(*iter)->x;
767 j++;
768 }
769 if (count != j)
770 eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
771 x.Zero();
772 y.Zero();
773 y[abs(axis)-1] = World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
774 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times
775 x += y; // per factor one cell width further
776 for (int k=count;k--;) { // go through every atom of the original cell
777 first = World::getInstance().createAtom(); // create a new body
778 first->x = (*vectors[k]) + x; // use coordinate of original atom
779 first->type = Elements[k]; // insert original element
780 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
781 }
782 }
783 if (mol->hasBondStructure())
784 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
785 // free memory
786 delete[](Elements);
787 delete[](vectors);
788 // correct cell size
789 if (axis < 0) { // if sign was negative, we have to translate everything
790 x = y;
791 x.Scale(-(faktor-1));
792 mol->Translate(&x);
793 }
794 World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
795 }
796 }
797}
798
799/** Submenu for manipulating molecules.
800 * \param *periode periodentafel
801 * \param *molecules list of molecule to manipulate
802 */
803void oldmenu::ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
804{
805 Vector x,y,z,n; // coordinates for absolute point in cell volume
806 char choice; // menu choice char
807 molecule *mol = NULL;
808 MoleculeLeafClass *Subgraphs = NULL;
809
810 Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl;
811 Log() << Verbose(0) << "c - scale by unit transformation" << endl;
812 Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;
813 Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;
814 Log() << Verbose(0) << "g - center atoms in box" << endl;
815 Log() << Verbose(0) << "i - realign molecule" << endl;
816 Log() << Verbose(0) << "m - mirror all molecules" << endl;
817 Log() << Verbose(0) << "o - create connection matrix" << endl;
818 Log() << Verbose(0) << "t - translate molecule by vector" << endl;
819 Log() << Verbose(0) << "all else - go back" << endl;
820 Log() << Verbose(0) << "===============================================" << endl;
821 if (molecules->NumberOfActiveMolecules() > 1)
822 eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
823 Log() << Verbose(0) << "INPUT: ";
824 cin >> choice;
825
826 switch (choice) {
827 default:
828 Log() << Verbose(0) << "Not a valid choice." << endl;
829 break;
830
831 case 'd': // duplicate the periodic cell along a given axis, given times
832 duplicateCell(molecules, configuration);
833 break;
834
835 case 'f':
836 FragmentAtoms(mol, configuration);
837 break;
838
839 case 'g': // center the atoms
840 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
841 if ((*ListRunner)->ActiveFlag) {
842 mol = *ListRunner;
843 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
844 CenterAtoms(mol);
845 }
846 break;
847
848 case 'i': // align all atoms
849 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
850 if ((*ListRunner)->ActiveFlag) {
851 mol = *ListRunner;
852 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
853 AlignAtoms(periode, mol);
854 }
855 break;
856
857 case 'm': // mirror atoms along a given axis
858 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
859 if ((*ListRunner)->ActiveFlag) {
860 mol = *ListRunner;
861 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
862 MirrorAtoms(mol);
863 }
864 break;
865
866 case 'o': // create the connection matrix
867 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
868 if ((*ListRunner)->ActiveFlag) {
869 mol = *ListRunner;
870 double bonddistance;
871 clock_t start,end;
872 Log() << Verbose(0) << "What's the maximum bond distance: ";
873 cin >> bonddistance;
874 start = clock();
875 mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
876 end = clock();
877 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
878 }
879 break;
880
881 case 't': // translate all atoms
882 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
883 if ((*ListRunner)->ActiveFlag) {
884 mol = *ListRunner;
885 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
886 Dialog *dialog = UIFactory::getInstance().makeDialog();
887 dialog->queryVector("Enter translation vector.",&x,World::getInstance().getDomain(),false);
888 if(dialog->display()){
889 mol->Center += x;
890 }
891 delete dialog;
892 }
893 break;
894 }
895 // Free all
896 if (Subgraphs != NULL) { // free disconnected subgraph list of DFS analysis was performed
897 while (Subgraphs->next != NULL) {
898 Subgraphs = Subgraphs->next;
899 delete(Subgraphs->previous);
900 }
901 delete(Subgraphs);
902 }
903};
904
905
906void oldmenu::SimpleAddMolecules(MoleculeListClass *molecules) {
907 molecule *srcmol = NULL, *destmol = NULL;
908 Dialog *dialog = UIFactory::getInstance().makeDialog();
909 dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
910 dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
911 if(dialog->display()) {
912 molecules->SimpleAdd(srcmol, destmol);
913 }
914 else {
915 Log() << Verbose(0) << "Adding of molecules canceled" << endl;
916 }
917 delete dialog;
918}
919
920void oldmenu::embeddMolecules(MoleculeListClass *molecules) {
921 molecule *srcmol = NULL, *destmol = NULL;
922 Dialog *dialog = UIFactory::getInstance().makeDialog();
923 dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
924 dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
925 if(dialog->display()) {
926 molecules->EmbedMerge(destmol, srcmol);
927 }
928 else {
929 Log() << Verbose(0) << "embedding of molecules canceled" << endl;
930 }
931
932
933}
934
935void oldmenu::multiMergeMolecules(MoleculeListClass *molecules) {
936 int nr;
937 molecule *mol = NULL;
938 do {
939 Log() << Verbose(0) << "Enter index of molecule to merge into: ";
940 cin >> nr;
941 mol = molecules->ReturnIndex(nr);
942 } while ((mol == NULL) && (nr != -1));
943 if (nr != -1) {
944 int N = molecules->ListOfMolecules.size()-1;
945 int *src = new int(N);
946 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
947 if ((*ListRunner)->IndexNr != nr)
948 src[N++] = (*ListRunner)->IndexNr;
949 molecules->SimpleMultiMerge(mol, src, N);
950 delete[](src);
951 }
952}
953
954void oldmenu::simpleMergeMolecules(MoleculeListClass *molecules) {
955 int src, dest;
956 molecule *srcmol = NULL, *destmol = NULL;
957 {
958 do {
959 Log() << Verbose(0) << "Enter index of destination molecule: ";
960 cin >> dest;
961 destmol = molecules->ReturnIndex(dest);
962 } while ((destmol == NULL) && (dest != -1));
963 do {
964 Log() << Verbose(0) << "Enter index of source molecule to merge into: ";
965 cin >> src;
966 srcmol = molecules->ReturnIndex(src);
967 } while ((srcmol == NULL) && (src != -1));
968 if ((src != -1) && (dest != -1))
969 molecules->SimpleMerge(srcmol, destmol);
970 }
971}
972
973/** Submenu for merging molecules.
974 * \param *periode periodentafel
975 * \param *molecules list of molecules to add to
976 */
977void oldmenu::MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)
978{
979 TextMenu *MergeMoleculesMenu = new TextMenu(Log() << Verbose(0), "Merge Molecules");
980
981 Action *simpleAddAction = new MethodAction("simpleAddAction",boost::bind(&oldmenu::SimpleAddMolecules,this,molecules),false);
982 new ActionMenuItem('a',"simple add of one molecule to another",MergeMoleculesMenu,simpleAddAction);
983
984 Action *embeddAction = new MethodAction("embeddAction",boost::bind(&oldmenu::embeddMolecules,this,molecules),false);
985 new ActionMenuItem('e',"embedding merge of two molecules",MergeMoleculesMenu,embeddAction);
986
987 Action *multiMergeAction = new MethodAction("multiMergeAction",boost::bind(&oldmenu::multiMergeMolecules,this,molecules),false);
988 new ActionMenuItem('m',"multi-merge of all molecules",MergeMoleculesMenu,multiMergeAction);
989
990 Action *scatterMergeAction = new ErrorAction("scatterMergeAction","Not Implemented yet",false);
991 new ActionMenuItem('s',"scatter merge of two molecules",MergeMoleculesMenu,scatterMergeAction);
992
993 Action *simpleMergeAction = new MethodAction("simpleMergeAction",boost::bind(&oldmenu::simpleMergeMolecules,this,molecules),false);
994 new ActionMenuItem('t',"simple merge of two molecules",MergeMoleculesMenu,simpleMergeAction);
995
996 Action *returnAction = new MethodAction("returnAction",boost::bind(&TextMenu::doQuit,MergeMoleculesMenu),false);
997 MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",MergeMoleculesMenu,returnAction);
998
999 MergeMoleculesMenu->addDefault(returnItem);
1000
1001 MergeMoleculesMenu->display();
1002};
1003
1004
1005/********************************************** Test routine **************************************/
1006
1007/** Is called always as option 'T' in the menu.
1008 * \param *molecules list of molecules
1009 */
1010void oldmenu::testroutine(MoleculeListClass *molecules)
1011{
1012 // the current test routine checks the functionality of the KeySet&Graph concept:
1013 // We want to have a multiindex (the KeySet) describing a unique subgraph
1014 int i, comp, counter=0;
1015
1016 // create a clone
1017 molecule *mol = NULL;
1018 if (molecules->ListOfMolecules.size() != 0) // clone
1019 mol = (molecules->ListOfMolecules.front())->CopyMolecule();
1020 else {
1021 eLog() << Verbose(0) << "I don't have anything to test on ... ";
1022 performCriticalExit();
1023 return;
1024 }
1025
1026 // generate some KeySets
1027 Log() << Verbose(0) << "Generating KeySets." << endl;
1028 KeySet TestSets[mol->getAtomCount()+1];
1029 i=1;
1030 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
1031 for (int j=0;j<i;j++) {
1032 TestSets[j].insert((*iter)->nr);
1033 }
1034 i++;
1035 }
1036 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
1037 KeySetTestPair test;
1038 molecule::const_iterator iter = mol->begin();
1039 if (iter != mol->end()) {
1040 test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr);
1041 if (test.second) {
1042 Log() << Verbose(1) << "Insertion worked?!" << endl;
1043 } else {
1044 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
1045 }
1046 } else {
1047 eLog() << Verbose(1) << "No atoms to test double insertion." << endl;
1048 }
1049
1050 // constructing Graph structure
1051 Log() << Verbose(0) << "Generating Subgraph class." << endl;
1052 Graph Subgraphs;
1053
1054 // insert KeySets into Subgraphs
1055 Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
1056 for (int j=0;j<mol->getAtomCount();j++) {
1057 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
1058 }
1059 Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
1060 GraphTestPair test2;
1061 test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
1062 if (test2.second) {
1063 Log() << Verbose(1) << "Insertion worked?!" << endl;
1064 } else {
1065 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
1066 }
1067
1068 // show graphs
1069 Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl;
1070 Graph::iterator A = Subgraphs.begin();
1071 while (A != Subgraphs.end()) {
1072 Log() << Verbose(0) << (*A).second.first << ": ";
1073 KeySet::iterator key = (*A).first.begin();
1074 comp = -1;
1075 while (key != (*A).first.end()) {
1076 if ((*key) > comp)
1077 Log() << Verbose(0) << (*key) << " ";
1078 else
1079 Log() << Verbose(0) << (*key) << "! ";
1080 comp = (*key);
1081 key++;
1082 }
1083 Log() << Verbose(0) << endl;
1084 A++;
1085 }
1086 World::getInstance().destroyMolecule(mol);
1087};
1088
1089oldmenu::oldmenu()
1090{
1091 // TODO Auto-generated constructor stub
1092}
1093
1094oldmenu::~oldmenu()
1095{
1096 // TODO Auto-generated destructor stub
1097}
Note: See TracBrowser for help on using the repository browser.