source: src/Legacy/oldmenu.cpp@ 8540f0

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

Removed molecule::first, molecule::last.

  • molecule does not have a chained list of bonds.
  • we have to go through atoms and its bonds, by checking (*BondRunner)->leftatom against (*AtomRunner) we exclude the other half.
  • first,last were present in only a few structures.
  • new functions:
    • molecule::hasBondStructure() - replaces first->next != last construct
    • molecule::CountBonds() - replaces first->next->next == last (i.e. one bond present) and alikes.

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

  • Property mode set to 100644
File size: 42.5 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 *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 {
450 second = mol->AskAtom("Enter number of atom as reference point: ");
451 Log() << Verbose(0) << "Enter radius: ";
452 cin >> tmp1;
453 molecule::iterator runner;
454 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
455 runner = iter++;
456 if ((*runner)->x.DistanceSquared((*runner)->x) > tmp1*tmp1) // distance to first above radius ...
457 mol->RemoveAtom((*runner));
458 }
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 molecule::iterator runner;
469 for (molecule::iterator iter = mol->begin(); iter != mol->end(); ) {
470 runner = iter++;
471 if (((*runner)->x[axis] < tmp1) || ((*runner)->x[axis] > tmp2)) {// out of boundary ...
472 //Log() << Verbose(0) << "Atom " << *(*runner) << " with " << (*runner)->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
473 mol->RemoveAtom((*runner));
474 }
475 }
476 break;
477 };
478 //mol->Output();
479 choice = 'r';
480};
481
482/** Submenu for measuring out the atoms in the molecule.
483 * \param *periode periodentafel
484 * \param *mol molecule with all the atoms
485 */
486void oldmenu::MeasureAtoms(periodentafel *periode, molecule *mol, config *configuration)
487{
488 atom *first, *second, *third;
489 Vector x,y;
490 double min[256], tmp1, tmp2, tmp3;
491 int Z;
492 char choice; // menu choice char
493
494 Log() << Verbose(0) << "===========MEASURE ATOMS=========================" << endl;
495 Log() << Verbose(0) << " a - calculate bond length between one atom and all others" << endl;
496 Log() << Verbose(0) << " b - calculate bond length between two atoms" << endl;
497 Log() << Verbose(0) << " c - calculate bond angle" << endl;
498 Log() << Verbose(0) << " d - calculate principal axis of the system" << endl;
499 Log() << Verbose(0) << " e - calculate volume of the convex envelope" << endl;
500 Log() << Verbose(0) << " f - calculate temperature from current velocity" << endl;
501 Log() << Verbose(0) << " g - output all temperatures per step from velocities" << endl;
502 Log() << Verbose(0) << "all else - go back" << endl;
503 Log() << Verbose(0) << "===============================================" << endl;
504 Log() << Verbose(0) << "INPUT: ";
505 cin >> choice;
506
507 switch(choice) {
508 default:
509 Log() << Verbose(1) << "Not a valid choice." << endl;
510 break;
511 case 'a':
512 first = mol->AskAtom("Enter first atom: ");
513 for (int i=MAX_ELEMENTS;i--;)
514 min[i] = 0.;
515
516 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
517 Z = (*iter)->type->Z;
518 tmp1 = 0.;
519 if (first != (*iter)) {
520 x = first->x - (*iter)->x;
521 tmp1 = x.Norm();
522 }
523 if ((tmp1 != 0.) && ((min[Z] == 0.) || (tmp1 < min[Z]))) min[Z] = tmp1;
524 //Log() << Verbose(0) << "Bond length between Atom " << first->nr << " and " << ((*iter)->nr << ": " << tmp1 << " a.u." << endl;
525 }
526 for (int i=MAX_ELEMENTS;i--;)
527 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;
528 break;
529
530 case 'b':
531 first = mol->AskAtom("Enter first atom: ");
532 second = mol->AskAtom("Enter second atom: ");
533 for (int i=NDIM;i--;)
534 min[i] = 0.;
535 x = first->x - second->x;
536 tmp1 = x.Norm();
537 Log() << Verbose(1) << "Distance vector is " << x << "." << "/n"
538 << "Norm of distance is " << tmp1 << "." << endl;
539 break;
540
541 case 'c':
542 Log() << Verbose(0) << "Evaluating bond angle between three - first, central, last - atoms." << endl;
543 first = mol->AskAtom("Enter first atom: ");
544 second = mol->AskAtom("Enter central atom: ");
545 third = mol->AskAtom("Enter last atom: ");
546 tmp1 = tmp2 = tmp3 = 0.;
547 x = first->x - second->x;
548 y = third->x - second->x;
549 Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
550 Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
551 break;
552 case 'd':
553 Log() << Verbose(0) << "Evaluating prinicipal axis." << endl;
554 Log() << Verbose(0) << "Shall we rotate? [0/1]: ";
555 cin >> Z;
556 if ((Z >=0) && (Z <=1))
557 mol->PrincipalAxisSystem((bool)Z);
558 else
559 mol->PrincipalAxisSystem(false);
560 break;
561 case 'e':
562 {
563 Log() << Verbose(0) << "Evaluating volume of the convex envelope.";
564 class Tesselation *TesselStruct = NULL;
565 const LinkedCell *LCList = NULL;
566 LCList = new LinkedCell(mol, 10.);
567 FindConvexBorder(mol, TesselStruct, LCList, NULL);
568 double clustervolume = VolumeOfConvexEnvelope(TesselStruct, configuration);
569 Log() << Verbose(0) << "The tesselated surface area is " << clustervolume << "." << endl;\
570 delete(LCList);
571 delete(TesselStruct);
572 }
573 break;
574 case 'f':
575 mol->OutputTemperatureFromTrajectories((ofstream *)&cout, mol->MDSteps-1, mol->MDSteps);
576 break;
577 case 'g':
578 {
579 char filename[255];
580 Log() << Verbose(0) << "Please enter filename: " << endl;
581 cin >> filename;
582 Log() << Verbose(1) << "Storing temperatures in " << filename << "." << endl;
583 ofstream *output = new ofstream(filename, ios::trunc);
584 if (!mol->OutputTemperatureFromTrajectories(output, 0, mol->MDSteps))
585 Log() << Verbose(2) << "File could not be written." << endl;
586 else
587 Log() << Verbose(2) << "File stored." << endl;
588 output->close();
589 delete(output);
590 }
591 break;
592 }
593};
594
595/** Submenu for measuring out the atoms in the molecule.
596 * \param *mol molecule with all the atoms
597 * \param *configuration configuration structure for the to be written config files of all fragments
598 */
599void oldmenu::FragmentAtoms(molecule *mol, config *configuration)
600{
601 int Order1;
602 clock_t start, end;
603
604 Log() << Verbose(0) << "Fragmenting molecule with current connection matrix ..." << endl;
605 Log() << Verbose(0) << "What's the desired bond order: ";
606 cin >> Order1;
607 if (mol->hasBondStructure()) {
608 start = clock();
609 mol->FragmentMolecule(Order1, configuration);
610 end = clock();
611 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
612 } else
613 Log() << Verbose(0) << "Connection matrix has not yet been generated!" << endl;
614};
615
616/********************************************** Submenu routine **************************************/
617
618/** Submenu for manipulating atoms.
619 * \param *periode periodentafel
620 * \param *molecules list of molecules whose atoms are to be manipulated
621 */
622void oldmenu::ManipulateAtoms(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
623{
624 atom *first, *second;
625 molecule *mol = NULL;
626 Vector x,y,z,n; // coordinates for absolute point in cell volume
627 double *factor; // unit factor if desired
628 double bond, minBond;
629 char choice; // menu choice char
630 bool valid;
631
632 Log() << Verbose(0) << "=========MANIPULATE ATOMS======================" << endl;
633 Log() << Verbose(0) << "a - add an atom" << endl;
634 Log() << Verbose(0) << "r - remove an atom" << endl;
635 Log() << Verbose(0) << "b - scale a bond between atoms" << endl;
636 Log() << Verbose(0) << "u - change an atoms element" << endl;
637 Log() << Verbose(0) << "l - measure lengths, angles, ... for an atom" << endl;
638 Log() << Verbose(0) << "all else - go back" << endl;
639 Log() << Verbose(0) << "===============================================" << endl;
640 if (molecules->NumberOfActiveMolecules() > 1)
641 eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
642 Log() << Verbose(0) << "INPUT: ";
643 cin >> choice;
644
645 switch (choice) {
646 default:
647 Log() << Verbose(0) << "Not a valid choice." << endl;
648 break;
649
650 case 'a': // add atom
651 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
652 if ((*ListRunner)->ActiveFlag) {
653 mol = *ListRunner;
654 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
655 AddAtoms(periode, mol);
656 }
657 break;
658
659 case 'b': // scale a bond
660 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
661 if ((*ListRunner)->ActiveFlag) {
662 mol = *ListRunner;
663 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
664 Log() << Verbose(0) << "Scaling bond length between two atoms." << endl;
665 first = mol->AskAtom("Enter first (fixed) atom: ");
666 second = mol->AskAtom("Enter second (shifting) atom: ");
667 minBond = 0.;
668 for (int i=NDIM;i--;)
669 minBond += (first->x[i]-second->x[i])*(first->x[i] - second->x[i]);
670 minBond = sqrt(minBond);
671 Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
672 Log() << Verbose(0) << "Enter new bond length [a.u.]: ";
673 cin >> bond;
674 for (int i=NDIM;i--;) {
675 second->x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);
676 }
677 //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
678 //second->Output(second->type->No, 1);
679 }
680 break;
681
682 case 'c': // unit scaling of the metric
683 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
684 if ((*ListRunner)->ActiveFlag) {
685 mol = *ListRunner;
686 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
687 Log() << Verbose(0) << "Angstroem -> Bohrradius: 1.8897261\t\tBohrradius -> Angstroem: 0.52917721" << endl;
688 Log() << Verbose(0) << "Enter three factors: ";
689 factor = new double[NDIM];
690 cin >> factor[0];
691 cin >> factor[1];
692 cin >> factor[2];
693 valid = true;
694 mol->Scale((const double ** const)&factor);
695 delete[](factor);
696 }
697 break;
698
699 case 'l': // measure distances or angles
700 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
701 if ((*ListRunner)->ActiveFlag) {
702 mol = *ListRunner;
703 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
704 MeasureAtoms(periode, mol, configuration);
705 }
706 break;
707
708 case 'r': // remove atom
709 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
710 if ((*ListRunner)->ActiveFlag) {
711 mol = *ListRunner;
712 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
713 RemoveAtoms(mol);
714 }
715 break;
716
717 case 'u': // change an atom's element
718 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
719 if ((*ListRunner)->ActiveFlag) {
720 int Z;
721 mol = *ListRunner;
722 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
723 first = NULL;
724 do {
725 Log() << Verbose(0) << "Change the element of which atom: ";
726 cin >> Z;
727 } while ((first = mol->FindAtom(Z)) == NULL);
728 Log() << Verbose(0) << "New element by atomic number Z: ";
729 cin >> Z;
730 first->setType(Z);
731 Log() << Verbose(0) << "Atom " << first->nr << "'s element is " << first->type->name << "." << endl;
732 }
733 break;
734 }
735};
736
737void oldmenu::duplicateCell(MoleculeListClass *molecules, config *configuration) {
738 molecule *mol = NULL;
739 int axis,faktor,count,j;
740 atom *first = NULL;
741 const element **Elements;
742 Vector x,y;
743 Vector **vectors;
744
745 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
746 if ((*ListRunner)->ActiveFlag) {
747 mol = *ListRunner;
748 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
749 Log() << Verbose(0) << "State the axis [(+-)123]: ";
750 cin >> axis;
751 Log() << Verbose(0) << "State the factor: ";
752 cin >> faktor;
753 if (mol->getAtomCount() != 0) { // if there is more than none
754 count = mol->getAtomCount(); // is changed becausing of adding, thus has to be stored away beforehand
755 Elements = new const element *[count];
756 vectors = new Vector *[count];
757 j = 0;
758 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
759 Elements[j] = (*iter)->type;
760 vectors[j] = &(*iter)->x;
761 j++;
762 }
763 if (count != j)
764 eLog() << Verbose(1) << "AtomCount " << count << " is not equal to number of atoms in molecule " << j << "!" << endl;
765 x.Zero();
766 y.Zero();
767 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
768 for (int i=1;i<faktor;i++) { // then add this list with respective translation factor times
769 x += y; // per factor one cell width further
770 for (int k=count;k--;) { // go through every atom of the original cell
771 first = World::getInstance().createAtom(); // create a new body
772 first->x = (*vectors[k]) + x; // use coordinate of original atom
773 first->type = Elements[k]; // insert original element
774 mol->AddAtom(first); // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
775 }
776 }
777 if (mol->hasBondStructure())
778 mol->CreateAdjacencyList(mol->BondDistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
779 // free memory
780 delete[](Elements);
781 delete[](vectors);
782 // correct cell size
783 if (axis < 0) { // if sign was negative, we have to translate everything
784 x = y;
785 x.Scale(-(faktor-1));
786 mol->Translate(&x);
787 }
788 World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
789 }
790 }
791}
792
793/** Submenu for manipulating molecules.
794 * \param *periode periodentafel
795 * \param *molecules list of molecule to manipulate
796 */
797void oldmenu::ManipulateMolecules(periodentafel *periode, MoleculeListClass *molecules, config *configuration)
798{
799 Vector x,y,z,n; // coordinates for absolute point in cell volume
800 char choice; // menu choice char
801 molecule *mol = NULL;
802 MoleculeLeafClass *Subgraphs = NULL;
803
804 Log() << Verbose(0) << "=========MANIPULATE GLOBALLY===================" << endl;
805 Log() << Verbose(0) << "c - scale by unit transformation" << endl;
806 Log() << Verbose(0) << "d - duplicate molecule/periodic cell" << endl;
807 Log() << Verbose(0) << "f - fragment molecule many-body bond order style" << endl;
808 Log() << Verbose(0) << "g - center atoms in box" << endl;
809 Log() << Verbose(0) << "i - realign molecule" << endl;
810 Log() << Verbose(0) << "m - mirror all molecules" << endl;
811 Log() << Verbose(0) << "o - create connection matrix" << endl;
812 Log() << Verbose(0) << "t - translate molecule by vector" << endl;
813 Log() << Verbose(0) << "all else - go back" << endl;
814 Log() << Verbose(0) << "===============================================" << endl;
815 if (molecules->NumberOfActiveMolecules() > 1)
816 eLog() << Verbose(2) << "There is more than one molecule active! Atoms will be added to each." << endl;
817 Log() << Verbose(0) << "INPUT: ";
818 cin >> choice;
819
820 switch (choice) {
821 default:
822 Log() << Verbose(0) << "Not a valid choice." << endl;
823 break;
824
825 case 'd': // duplicate the periodic cell along a given axis, given times
826 duplicateCell(molecules, configuration);
827 break;
828
829 case 'f':
830 FragmentAtoms(mol, configuration);
831 break;
832
833 case 'g': // center the atoms
834 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
835 if ((*ListRunner)->ActiveFlag) {
836 mol = *ListRunner;
837 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
838 CenterAtoms(mol);
839 }
840 break;
841
842 case 'i': // align all atoms
843 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
844 if ((*ListRunner)->ActiveFlag) {
845 mol = *ListRunner;
846 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
847 AlignAtoms(periode, mol);
848 }
849 break;
850
851 case 'm': // mirror atoms along a given axis
852 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
853 if ((*ListRunner)->ActiveFlag) {
854 mol = *ListRunner;
855 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
856 MirrorAtoms(mol);
857 }
858 break;
859
860 case 'o': // create the connection matrix
861 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
862 if ((*ListRunner)->ActiveFlag) {
863 mol = *ListRunner;
864 double bonddistance;
865 clock_t start,end;
866 Log() << Verbose(0) << "What's the maximum bond distance: ";
867 cin >> bonddistance;
868 start = clock();
869 mol->CreateAdjacencyList(bonddistance, configuration->GetIsAngstroem(), &BondGraph::CovalentMinMaxDistance, NULL);
870 end = clock();
871 Log() << Verbose(0) << "Clocks for this operation: " << (end-start) << ", time: " << ((double)(end-start)/CLOCKS_PER_SEC) << "s." << endl;
872 }
873 break;
874
875 case 't': // translate all atoms
876 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
877 if ((*ListRunner)->ActiveFlag) {
878 mol = *ListRunner;
879 Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
880 Dialog *dialog = UIFactory::getInstance().makeDialog();
881 dialog->queryVector("Enter translation vector.",&x,World::getInstance().getDomain(),false);
882 if(dialog->display()){
883 mol->Center += x;
884 }
885 delete dialog;
886 }
887 break;
888 }
889 // Free all
890 if (Subgraphs != NULL) { // free disconnected subgraph list of DFS analysis was performed
891 while (Subgraphs->next != NULL) {
892 Subgraphs = Subgraphs->next;
893 delete(Subgraphs->previous);
894 }
895 delete(Subgraphs);
896 }
897};
898
899
900void oldmenu::SimpleAddMolecules(MoleculeListClass *molecules) {
901 molecule *srcmol = NULL, *destmol = NULL;
902 Dialog *dialog = UIFactory::getInstance().makeDialog();
903 dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
904 dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
905 if(dialog->display()) {
906 molecules->SimpleAdd(srcmol, destmol);
907 }
908 else {
909 Log() << Verbose(0) << "Adding of molecules canceled" << endl;
910 }
911 delete dialog;
912}
913
914void oldmenu::embeddMolecules(MoleculeListClass *molecules) {
915 molecule *srcmol = NULL, *destmol = NULL;
916 Dialog *dialog = UIFactory::getInstance().makeDialog();
917 dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
918 dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
919 if(dialog->display()) {
920 molecules->EmbedMerge(destmol, srcmol);
921 }
922 else {
923 Log() << Verbose(0) << "embedding of molecules canceled" << endl;
924 }
925
926
927}
928
929void oldmenu::multiMergeMolecules(MoleculeListClass *molecules) {
930 int nr;
931 molecule *mol = NULL;
932 do {
933 Log() << Verbose(0) << "Enter index of molecule to merge into: ";
934 cin >> nr;
935 mol = molecules->ReturnIndex(nr);
936 } while ((mol == NULL) && (nr != -1));
937 if (nr != -1) {
938 int N = molecules->ListOfMolecules.size()-1;
939 int *src = new int(N);
940 for(MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
941 if ((*ListRunner)->IndexNr != nr)
942 src[N++] = (*ListRunner)->IndexNr;
943 molecules->SimpleMultiMerge(mol, src, N);
944 delete[](src);
945 }
946}
947
948void oldmenu::simpleMergeMolecules(MoleculeListClass *molecules) {
949 int src, dest;
950 molecule *srcmol = NULL, *destmol = NULL;
951 {
952 do {
953 Log() << Verbose(0) << "Enter index of destination molecule: ";
954 cin >> dest;
955 destmol = molecules->ReturnIndex(dest);
956 } while ((destmol == NULL) && (dest != -1));
957 do {
958 Log() << Verbose(0) << "Enter index of source molecule to merge into: ";
959 cin >> src;
960 srcmol = molecules->ReturnIndex(src);
961 } while ((srcmol == NULL) && (src != -1));
962 if ((src != -1) && (dest != -1))
963 molecules->SimpleMerge(srcmol, destmol);
964 }
965}
966
967/** Submenu for merging molecules.
968 * \param *periode periodentafel
969 * \param *molecules list of molecules to add to
970 */
971void oldmenu::MergeMolecules(periodentafel *periode, MoleculeListClass *molecules)
972{
973 TextMenu *MergeMoleculesMenu = new TextMenu(Log() << Verbose(0), "Merge Molecules");
974
975 Action *simpleAddAction = new MethodAction("simpleAddAction",boost::bind(&oldmenu::SimpleAddMolecules,this,molecules),false);
976 new ActionMenuItem('a',"simple add of one molecule to another",MergeMoleculesMenu,simpleAddAction);
977
978 Action *embeddAction = new MethodAction("embeddAction",boost::bind(&oldmenu::embeddMolecules,this,molecules),false);
979 new ActionMenuItem('e',"embedding merge of two molecules",MergeMoleculesMenu,embeddAction);
980
981 Action *multiMergeAction = new MethodAction("multiMergeAction",boost::bind(&oldmenu::multiMergeMolecules,this,molecules),false);
982 new ActionMenuItem('m',"multi-merge of all molecules",MergeMoleculesMenu,multiMergeAction);
983
984 Action *scatterMergeAction = new ErrorAction("scatterMergeAction","Not Implemented yet",false);
985 new ActionMenuItem('s',"scatter merge of two molecules",MergeMoleculesMenu,scatterMergeAction);
986
987 Action *simpleMergeAction = new MethodAction("simpleMergeAction",boost::bind(&oldmenu::simpleMergeMolecules,this,molecules),false);
988 new ActionMenuItem('t',"simple merge of two molecules",MergeMoleculesMenu,simpleMergeAction);
989
990 Action *returnAction = new MethodAction("returnAction",boost::bind(&TextMenu::doQuit,MergeMoleculesMenu),false);
991 MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",MergeMoleculesMenu,returnAction);
992
993 MergeMoleculesMenu->addDefault(returnItem);
994
995 MergeMoleculesMenu->display();
996};
997
998
999/********************************************** Test routine **************************************/
1000
1001/** Is called always as option 'T' in the menu.
1002 * \param *molecules list of molecules
1003 */
1004void oldmenu::testroutine(MoleculeListClass *molecules)
1005{
1006 // the current test routine checks the functionality of the KeySet&Graph concept:
1007 // We want to have a multiindex (the KeySet) describing a unique subgraph
1008 int i, comp, counter=0;
1009
1010 // create a clone
1011 molecule *mol = NULL;
1012 if (molecules->ListOfMolecules.size() != 0) // clone
1013 mol = (molecules->ListOfMolecules.front())->CopyMolecule();
1014 else {
1015 eLog() << Verbose(0) << "I don't have anything to test on ... ";
1016 performCriticalExit();
1017 return;
1018 }
1019
1020 // generate some KeySets
1021 Log() << Verbose(0) << "Generating KeySets." << endl;
1022 KeySet TestSets[mol->getAtomCount()+1];
1023 i=1;
1024 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
1025 for (int j=0;j<i;j++) {
1026 TestSets[j].insert((*iter)->nr);
1027 }
1028 i++;
1029 }
1030 Log() << Verbose(0) << "Testing insertion of already present item in KeySets." << endl;
1031 KeySetTestPair test;
1032 molecule::const_iterator iter = mol->begin();
1033 if (iter != mol->end()) {
1034 test = TestSets[mol->getAtomCount()-1].insert((*iter)->nr);
1035 if (test.second) {
1036 Log() << Verbose(1) << "Insertion worked?!" << endl;
1037 } else {
1038 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*test.first) << "." << endl;
1039 }
1040 } else {
1041 eLog() << Verbose(1) << "No atoms to test double insertion." << endl;
1042 }
1043
1044 // constructing Graph structure
1045 Log() << Verbose(0) << "Generating Subgraph class." << endl;
1046 Graph Subgraphs;
1047
1048 // insert KeySets into Subgraphs
1049 Log() << Verbose(0) << "Inserting KeySets into Subgraph class." << endl;
1050 for (int j=0;j<mol->getAtomCount();j++) {
1051 Subgraphs.insert(GraphPair (TestSets[j],pair<int, double>(counter++, 1.)));
1052 }
1053 Log() << Verbose(0) << "Testing insertion of already present item in Subgraph." << endl;
1054 GraphTestPair test2;
1055 test2 = Subgraphs.insert(GraphPair (TestSets[mol->getAtomCount()],pair<int, double>(counter++, 1.)));
1056 if (test2.second) {
1057 Log() << Verbose(1) << "Insertion worked?!" << endl;
1058 } else {
1059 Log() << Verbose(1) << "Insertion rejected: Present object is " << (*(test2.first)).second.first << "." << endl;
1060 }
1061
1062 // show graphs
1063 Log() << Verbose(0) << "Showing Subgraph's contents, checking that it's sorted." << endl;
1064 Graph::iterator A = Subgraphs.begin();
1065 while (A != Subgraphs.end()) {
1066 Log() << Verbose(0) << (*A).second.first << ": ";
1067 KeySet::iterator key = (*A).first.begin();
1068 comp = -1;
1069 while (key != (*A).first.end()) {
1070 if ((*key) > comp)
1071 Log() << Verbose(0) << (*key) << " ";
1072 else
1073 Log() << Verbose(0) << (*key) << "! ";
1074 comp = (*key);
1075 key++;
1076 }
1077 Log() << Verbose(0) << endl;
1078 A++;
1079 }
1080 World::getInstance().destroyMolecule(mol);
1081};
1082
1083oldmenu::oldmenu()
1084{
1085 // TODO Auto-generated constructor stub
1086}
1087
1088oldmenu::~oldmenu()
1089{
1090 // TODO Auto-generated destructor stub
1091}
Note: See TracBrowser for help on using the repository browser.