source: src/Legacy/oldmenu.cpp@ 112b09

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 112b09 was 112b09, checked in by Tillmann Crueger <crueger@…>, 15 years ago

Added #include "Helpers/MemDebug.hpp" to all .cpp files

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