source: src/Legacy/oldmenu.cpp@ 97ebf8

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 97ebf8 was 97ebf8, checked in by Frederik Heber <heber@…>, 15 years ago

Added all commands defined in ParseCommandLineOptions() as Actions.

  • Actions are not yet used, except verbose, version and help.
  • Files are present and included in Makefile.am
  • not unit tests written so far
  • no action has been tested so far (except for MapOfActions)
  • structure introduced to to transition from ParseCommandLineOptions to actions.
  • program name and config file are fixed arguments.

Signed-off-by: Frederik Heber <heber@…>

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