Index: src/Legacy/oldmenu.cpp
===================================================================
--- src/Legacy/oldmenu.cpp	(revision ead4e6027f420d4abbcb4f74854b4daa8dad64ea)
+++ src/Legacy/oldmenu.cpp	(revision 72e7faca3bcf25ab3ecf4cbdb09c889f2985787f)
@@ -24,4 +24,6 @@
 #include "molecule.hpp"
 #include "periodentafel.hpp"
+#include "vector_ops.hpp"
+#include "Plane.hpp"
 
 #include "UIElements/UIFactory.hpp"
@@ -77,10 +79,19 @@
       break;
       case 'a': // absolute coordinates of atom
-        Log() << Verbose(0) << "Enter absolute coordinates." << endl;
+      {
         first = World::getInstance().createAtom();
-        first->x.AskPosition(mol->cell_size, false);
-        first->type = periode->AskElement();  // give type
-        mol->AddAtom(first);  // add to molecule
-        break;
+        Dialog *dialog = UIFactory::getInstance().makeDialog();
+        dialog->queryVector("Enter absolute coordinates.",&first->x,mol->cell_size, false);
+        dialog->queryElement("Choose element for this atom",&first->type);
+        if(dialog->display()){
+          mol->AddAtom(first);  // add to molecule
+        }
+        else{
+          // dialog was canceled... destroy the atom that was used
+          World::getInstance().destroyAtom(first);
+        }
+        delete dialog;
+      }
+      break;
 
       case 'b': // relative coordinates of atom wrt to reference point
@@ -88,12 +99,12 @@
         valid = true;
         do {
+          Dialog *dialog = UIFactory::getInstance().makeDialog();
           if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
-          Log() << Verbose(0) << "Enter reference coordinates." << endl;
-          x.AskPosition(mol->cell_size, true);
-          Log() << Verbose(0) << "Enter relative coordinates." << endl;
-          first->x.AskPosition(mol->cell_size, false);
-          first->x.AddVector((const Vector *)&x);
-          Log() << Verbose(0) << "\n";
-        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
+          dialog->queryVector("Enter reference coordinates.",&x,mol->cell_size,true);
+          dialog->queryVector("Enter relative coordinates.",&first->x,mol->cell_size,false);
+          first->x.AddVector(&x);
+          dialog->display();
+          delete dialog;
+        } while (!(valid = mol->CheckBounds(&first->x)));
         first->type = periode->AskElement();  // give type
         mol->AddAtom(first);  // add to molecule
@@ -101,4 +112,5 @@
 
       case 'c': // relative coordinates of atom wrt to already placed atom
+      {
         first = World::getInstance().createAtom();
         valid = true;
@@ -106,13 +118,15 @@
           if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
           second = mol->AskAtom("Enter atom number: ");
-          Log() << Verbose(0) << "Enter relative coordinates." << endl;
-          first->x.AskPosition(mol->cell_size, false);
+          Dialog *dialog = UIFactory::getInstance().makeDialog();
+          dialog->queryVector("Enter relative coordinates.",&first->x,mol->cell_size,false);
+          dialog->display();
           for (int i=NDIM;i--;) {
-            first->x.x[i] += second->x.x[i];
+            first->x[i] += second->x[i];
           }
         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
         first->type = periode->AskElement();  // give type
         mol->AddAtom(first);  // add to molecule
-        break;
+      }
+      break;
 
     case 'd': // two atoms, two angles and a distance
@@ -157,48 +171,30 @@
           x.SubtractVector(&third->x);
           x.Normalize();
-          Log() << Verbose(0) << "x: ",
-          x.Output();
-          Log() << Verbose(0) << endl;
-          z.MakeNormalVector(&second->x,&third->x,&fourth->x);
-          Log() << Verbose(0) << "z: ",
-          z.Output();
-          Log() << Verbose(0) << endl;
-          y.MakeNormalVector(&x,&z);
-          Log() << Verbose(0) << "y: ",
-          y.Output();
-          Log() << Verbose(0) << endl;
+          Log() << Verbose(0) << "x: " << x << endl;
+          z = Plane(second->x,third->x,fourth->x).getNormal();
+          Log() << Verbose(0) << "z: " << z << endl;
+          y = Plane(x,z,0).getNormal();
+          Log() << Verbose(0) << "y: " << y << endl;
 
           // rotate vector around first angle
           first->x.CopyVector(&x);
-          first->x.RotateVector(&z,b - M_PI);
-          Log() << Verbose(0) << "Rotated vector: ",
-          first->x.Output();
-          Log() << Verbose(0) << endl;
+          first->x = RotateVector(first->x,z,b - M_PI);
+          Log() << Verbose(0) << "Rotated vector: " << first->x << endl,
           // remove the projection onto the rotation plane of the second angle
           n.CopyVector(&y);
           n.Scale(first->x.ScalarProduct(&y));
-          Log() << Verbose(0) << "N1: ",
-          n.Output();
-          Log() << Verbose(0) << endl;
+          Log() << Verbose(0) << "N1: " << n << endl;
           first->x.SubtractVector(&n);
-          Log() << Verbose(0) << "Subtracted vector: ",
-          first->x.Output();
-          Log() << Verbose(0) << endl;
+          Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
           n.CopyVector(&z);
           n.Scale(first->x.ScalarProduct(&z));
-          Log() << Verbose(0) << "N2: ",
-          n.Output();
-          Log() << Verbose(0) << endl;
+          Log() << Verbose(0) << "N2: " << n << endl;
           first->x.SubtractVector(&n);
-          Log() << Verbose(0) << "2nd subtracted vector: ",
-          first->x.Output();
-          Log() << Verbose(0) << endl;
+          Log() << Verbose(0) << "2nd subtracted vector: " << first->x << endl;
 
           // rotate another vector around second angle
           n.CopyVector(&y);
-          n.RotateVector(&x,c - M_PI);
-          Log() << Verbose(0) << "2nd Rotated vector: ",
-          n.Output();
-          Log() << Verbose(0) << endl;
+          n = RotateVector(n,x,c - M_PI);
+          Log() << Verbose(0) << "2nd Rotated vector: " << n << endl;
 
           // add the two linear independent vectors
@@ -208,7 +204,5 @@
           first->x.AddVector(&second->x);
 
-          Log() << Verbose(0) << "resulting coordinates: ";
-          first->x.Output();
-          Log() << Verbose(0) << endl;
+          Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
         first->type = periode->AskElement();  // give type
@@ -233,7 +227,7 @@
         } while ((j != -1) && (i<128));
         if (i >= 2) {
-          first->x.LSQdistance((const Vector **)atoms, i);
-
-          first->x.Output();
+          LSQdistance(first->x,(const Vector **)atoms, i);
+
+          Log() << Verbose(0) << first->x;
           first->type = periode->AskElement();  // give type
           mol->AddAtom(first);  // add to molecule
@@ -280,5 +274,5 @@
       for (int i=0;i<NDIM;i++) {
         Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
-        cin >> y.x[i];
+        cin >> y[i];
       }
       mol->CenterEdge(&x);  // make every coordinate positive
@@ -293,5 +287,5 @@
       for (int i=0;i<NDIM;i++) {
         Log() << Verbose(0) << "Enter axis " << i << " boundary: ";
-        cin >> x.x[i];
+        cin >> x[i];
       }
       // update Box of atoms by boundary
@@ -330,11 +324,16 @@
       third = mol->AskAtom("Enter third atom: ");
 
-      n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
+      n = Plane(first->x,second->x,third->x).getNormal();
       break;
     case 'b': // normal vector of mirror plane
-      Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
-      n.AskPosition(mol->cell_size,0);
+    {
+      Dialog *dialog = UIFactory::getInstance().makeDialog();
+      dialog->queryVector("Enter normal vector of mirror plane.",&n,mol->cell_size,false);
+      dialog->display();
+      delete dialog;
       n.Normalize();
-      break;
+    }
+    break;
+
     case 'c': // three atoms defining mirror plane
       first = mol->AskAtom("Enter first atom: ");
@@ -356,17 +355,13 @@
       mol->GetAlignvector(&param);
       for (int i=NDIM;i--;) {
-        x.x[i] = gsl_vector_get(param.x,i);
-        n.x[i] = gsl_vector_get(param.x,i+NDIM);
+        x[i] = gsl_vector_get(param.x,i);
+        n[i] = gsl_vector_get(param.x,i+NDIM);
       }
       gsl_vector_free(param.x);
-      Log() << Verbose(0) << "Offset vector: ";
-      x.Output();
-      Log() << Verbose(0) << endl;
+      Log() << Verbose(0) << "Offset vector: " << x << endl;
       n.Normalize();
       break;
   };
-  Log() << Verbose(0) << "Alignment vector: ";
-  n.Output();
-  Log() << Verbose(0) << endl;
+  Log() << Verbose(0) << "Alignment vector: " << n << endl;
   mol->Align(&n);
 };
@@ -397,11 +392,16 @@
       third = mol->AskAtom("Enter third atom: ");
 
-      n.MakeNormalVector((const Vector *)&first->x,(const Vector *)&second->x,(const Vector *)&third->x);
+      n = Plane(first->x,second->x,third->x).getNormal();
       break;
     case 'b': // normal vector of mirror plane
-      Log() << Verbose(0) << "Enter normal vector of mirror plane." << endl;
-      n.AskPosition(mol->cell_size,0);
+    {
+      Dialog *dialog = UIFactory::getInstance().makeDialog();
+      dialog->queryVector("Enter normal vector of mirror plane.",&n,mol->cell_size,false);
+      dialog->display();
+      delete dialog;
       n.Normalize();
-      break;
+    }
+    break;
+
     case 'c': // three atoms defining mirror plane
       first = mol->AskAtom("Enter first atom: ");
@@ -413,7 +413,5 @@
       break;
   };
-  Log() << Verbose(0) << "Normal vector: ";
-  n.Output();
-  Log() << Verbose(0) << endl;
+  Log() << Verbose(0) << "Normal vector: " << n << endl;
   mol->Mirror((const Vector *)&n);
 };
@@ -471,5 +469,5 @@
         first = second;
         second = first->next;
-        if ((first->x.x[axis] < tmp1) || (first->x.x[axis] > tmp2)) {// out of boundary ...
+        if ((first->x[axis] < tmp1) || (first->x[axis] > tmp2)) {// out of boundary ...
           //Log() << Verbose(0) << "Atom " << *first << " with " << first->x.x[axis] << " on axis " << axis << " is out of bounds [" << tmp1 << "," << tmp2 << "]." << endl;
           mol->RemoveAtom(first);
@@ -541,7 +539,6 @@
       x.SubtractVector((const Vector *)&second->x);
       tmp1 = x.Norm();
-      Log() << Verbose(1) << "Distance vector is ";
-      x.Output();
-      Log() << Verbose(0) << "." << endl << "Norm of distance is " << tmp1 << "." << endl;
+      Log() << Verbose(1) << "Distance vector is " << x << "." << "/n"
+            << "Norm of distance is " << tmp1 << "." << endl;
       break;
 
@@ -676,5 +673,5 @@
         minBond = 0.;
         for (int i=NDIM;i--;)
-          minBond += (first->x.x[i]-second->x.x[i])*(first->x.x[i] - second->x.x[i]);
+          minBond += (first->x[i]-second->x[i])*(first->x[i] - second->x[i]);
         minBond = sqrt(minBond);
         Log() << Verbose(0) << "Current Bond length between " << first->type->name << " Atom " << first->nr << " and " << second->type->name << " Atom " << second->nr << ": " << minBond << " a.u." << endl;
@@ -682,5 +679,5 @@
         cin >> bond;
         for (int i=NDIM;i--;) {
-          second->x.x[i] -= (second->x.x[i]-first->x.x[i])/minBond*(minBond-bond);
+          second->x[i] -= (second->x[i]-first->x[i])/minBond*(minBond-bond);
         }
         //Log() << Verbose(0) << "New coordinates of Atom " << second->nr << " are: ";
@@ -778,5 +775,5 @@
       x.Zero();
       y.Zero();
-      y.x[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
+      y[abs(axis)-1] = mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] * abs(axis)/axis; // last term is for sign, first is for magnitude
       for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
         x.AddVector(&y); // per factor one cell width further
@@ -893,6 +890,8 @@
         mol = *ListRunner;
         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        Log() << Verbose(0) << "Enter translation vector." << endl;
-        x.AskPosition(mol->cell_size,0);
+        Dialog *dialog = UIFactory::getInstance().makeDialog();
+        dialog->queryVector("Enter translation vector.",&x,mol->cell_size,false);
+        dialog->display();
+        delete dialog;
         mol->Center.AddVector((const Vector *)&x);
      }
