source: src/Legacy/oldmenu.cpp@ e6317b

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

Broken: Merge commit 'Gitosis/stable' into stable

Conflicts:

molecuilder/src/Actions/AnalysisAction/PairCorrelationToPointAction.cpp
molecuilder/src/Actions/AnalysisAction/PairCorrelationToSurfaceAction.cpp
molecuilder/src/Makefile.am

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