Index: src/Legacy/oldmenu.cpp
===================================================================
--- src/Legacy/oldmenu.cpp	(revision 5f612eea044e919bffc18a83cd7ddd35f981c765)
+++ src/Legacy/oldmenu.cpp	(revision 8cbb9792c39564b3033f03b7e9dc61143585d5f4)
@@ -24,4 +24,6 @@
 #include "molecule.hpp"
 #include "periodentafel.hpp"
+#include "vector_ops.hpp"
+#include "Plane.hpp"
 
 #include "UIElements/UIFactory.hpp"
@@ -59,4 +61,5 @@
   char choice;  // menu choice char
   bool valid;
+  bool aborted;
 
   Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
@@ -77,42 +80,59 @@
       break;
       case 'a': // absolute coordinates of atom
-        Log() << Verbose(0) << "Enter absolute coordinates." << endl;
+      {
+        Dialog *dialog = UIFactory::getInstance().makeDialog();
         first = World::getInstance().createAtom();
-        first->x.AskPosition(World::getInstance().getDomain(), false);
-        first->type = periode->AskElement();  // give type
-        mol->AddAtom(first);  // add to molecule
+        dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false);
+        dialog->queryElement("Please choose element: ",&first->type);
+        if(dialog->display()){
+          mol->AddAtom(first);  // add to molecule
+        }
+        else{
+          World::getInstance().destroyAtom(first);
+        }
+      }
+      break;
+
+      case 'b': // relative coordinates of atom wrt to reference point
+        first = World::getInstance().createAtom();
+        valid = true;
+        aborted = false;
+        do {
+          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
+          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
+          dialog->queryVector("Enter reference coordinates.",&x,World::getInstance().getDomain(), true);
+          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
+          if((aborted = !dialog->display())){
+            continue;
+          }
+          first->x += x;
+        } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->x)));
+        if(!aborted){
+          first->type = periode->AskElement();  // give type
+          mol->AddAtom(first);  // add to molecule
+        }
+        else{
+          World::getInstance().destroyAtom(first);
+        }
         break;
 
-      case 'b': // relative coordinates of atom wrt to reference point
+      case 'c': // relative coordinates of atom wrt to already placed atom
+      {
         first = World::getInstance().createAtom();
         valid = true;
         do {
           if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
-          Log() << Verbose(0) << "Enter reference coordinates." << endl;
-          x.AskPosition(World::getInstance().getDomain(), true);
-          Log() << Verbose(0) << "Enter relative coordinates." << endl;
-          first->x.AskPosition(World::getInstance().getDomain(), false);
-          first->x.AddVector((const Vector *)&x);
-          Log() << Verbose(0) << "\n";
-        } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
-        first->type = periode->AskElement();  // give type
-        mol->AddAtom(first);  // add to molecule
-        break;
-
-      case 'c': // relative coordinates of atom wrt to already placed atom
-        first = World::getInstance().createAtom();
-        valid = true;
-        do {
-          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
+          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
           second = mol->AskAtom("Enter atom number: ");
-          Log() << Verbose(0) << "Enter relative coordinates." << endl;
-          first->x.AskPosition(World::getInstance().getDomain(), false);
+          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), 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
@@ -154,61 +174,40 @@
           */
           // calc axis vector
-          x.CopyVector(&second->x);
-          x.SubtractVector(&third->x);
+          x= second->x - 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 = x;
+          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;
-          first->x.SubtractVector(&n);
-          Log() << Verbose(0) << "Subtracted vector: ",
-          first->x.Output();
-          Log() << Verbose(0) << endl;
-          n.CopyVector(&z);
-          n.Scale(first->x.ScalarProduct(&z));
-          Log() << Verbose(0) << "N2: ",
-          n.Output();
-          Log() << Verbose(0) << endl;
-          first->x.SubtractVector(&n);
-          Log() << Verbose(0) << "2nd subtracted vector: ",
-          first->x.Output();
-          Log() << Verbose(0) << endl;
+          n = y;
+          n.Scale(first->x.ScalarProduct(y));
+          Log() << Verbose(0) << "N1: " << n << endl;
+          first->x -= n;
+          Log() << Verbose(0) << "Subtracted vector: " << first->x << endl;
+          n = z;
+          n.Scale(first->x.ScalarProduct(z));
+          Log() << Verbose(0) << "N2: " << n << endl;
+          first->x -= n;
+          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 = y;
+          n = RotateVector(n,x,c - M_PI);
+          Log() << Verbose(0) << "2nd Rotated vector: " << n << endl;
 
           // add the two linear independent vectors
-          first->x.AddVector(&n);
+          first->x += n;
           first->x.Normalize();
           first->x.Scale(a);
-          first->x.AddVector(&second->x);
-
-          Log() << Verbose(0) << "resulting coordinates: ";
-          first->x.Output();
-          Log() << Verbose(0) << endl;
+          first->x += second->x;
+
+          Log() << Verbose(0) << "resulting coordinates: " << first->x << endl;
         } while (!(valid = mol->CheckBounds((const Vector *)&first->x)));
         first->type = periode->AskElement();  // give type
@@ -233,7 +232,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,11 +279,9 @@
       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
-      mol->Center.AddVector(&y); // translate by boundary
-      helper.CopyVector(&y);
-      helper.Scale(2.);
-      helper.AddVector(&x);
+      mol->Center += y; // translate by boundary
+      helper = (2*y)+x;
       mol->SetBoxDimension(&helper);  // update Box of atoms by boundary
       break;
@@ -293,5 +290,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,17 +327,21 @@
       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(World::getInstance().getDomain(),0);
+    {
+      Dialog *dialog = UIFactory::getInstance().makeDialog();
+      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
+      dialog->display();
+      delete dialog;
       n.Normalize();
-      break;
+    }
+    break;
+
     case 'c': // three atoms defining mirror plane
       first = mol->AskAtom("Enter first atom: ");
       second = mol->AskAtom("Enter second atom: ");
 
-      n.CopyVector((const Vector *)&first->x);
-      n.SubtractVector((const Vector *)&second->x);
+      n = first->x - second->x;
       n.Normalize();
       break;
@@ -356,17 +357,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,23 +394,25 @@
       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(World::getInstance().getDomain(),0);
+    {
+      Dialog *dialog = UIFactory::getInstance().makeDialog();
+      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
+      dialog->display();
+      delete dialog;
       n.Normalize();
-      break;
+    }
+    break;
+
     case 'c': // three atoms defining mirror plane
       first = mol->AskAtom("Enter first atom: ");
       second = mol->AskAtom("Enter second atom: ");
 
-      n.CopyVector((const Vector *)&first->x);
-      n.SubtractVector((const Vector *)&second->x);
+      n = first->x - second->x;
       n.Normalize();
       break;
   };
-  Log() << Verbose(0) << "Normal vector: ";
-  n.Output();
-  Log() << Verbose(0) << endl;
+  Log() << Verbose(0) << "Normal vector: " << n << endl;
   mol->Mirror((const Vector *)&n);
 };
@@ -455,5 +454,5 @@
         first = second;
         second = first->next;
-        if (first->x.DistanceSquared((const Vector *)&second->x) > tmp1*tmp1) // distance to first above radius ...
+        if (first->x.DistanceSquared(second->x) > tmp1*tmp1) // distance to first above radius ...
           mol->RemoveAtom(first);
       }
@@ -471,5 +470,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);
@@ -522,6 +521,5 @@
         tmp1 = 0.;
         if (first != second) {
-          x.CopyVector((const Vector *)&first->x);
-          x.SubtractVector((const Vector *)&second->x);
+          x = first->x - second->x;
           tmp1 = x.Norm();
         }
@@ -538,10 +536,8 @@
       for (int i=NDIM;i--;)
         min[i] = 0.;
-      x.CopyVector((const Vector *)&first->x);
-      x.SubtractVector((const Vector *)&second->x);
+      x = first->x - 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;
 
@@ -552,10 +548,8 @@
       third  = mol->AskAtom("Enter last atom: ");
       tmp1 = tmp2 = tmp3 = 0.;
-      x.CopyVector((const Vector *)&first->x);
-      x.SubtractVector((const Vector *)&second->x);
-      y.CopyVector((const Vector *)&third->x);
-      y.SubtractVector((const Vector *)&second->x);
+      x = first->x - second->x;
+      y = third->x - second->x;
       Log() << Verbose(0) << "Bond angle between first atom Nr." << first->nr << ", central atom Nr." << second->nr << " and last atom Nr." << third->nr << ": ";
-      Log() << Verbose(0) << (acos(x.ScalarProduct((const Vector *)&y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
+      Log() << Verbose(0) << (acos(x.ScalarProduct(y)/(y.Norm()*x.Norm()))/M_PI*180.) << " degrees" << endl;
       break;
     case 'd':
@@ -676,5 +670,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 +676,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,11 +772,10 @@
       x.Zero();
       y.Zero();
-      y.x[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
+      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
       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
+        x += y; // per factor one cell width further
         for (int k=count;k--;) { // go through every atom of the original cell
           first = World::getInstance().createAtom(); // create a new body
-          first->x.CopyVector(vectors[k]);  // use coordinate of original atom
-          first->x.AddVector(&x);     // translate the coordinates
+          first->x = (*vectors[k]) + x;  // use coordinate of original atom
           first->type = Elements[k];  // insert original element
           mol->AddAtom(first);        // and add to the molecule (which increments ElementsInMolecule, AtomCount, ...)
@@ -796,6 +789,5 @@
       // correct cell size
       if (axis < 0) { // if sign was negative, we have to translate everything
-        x.Zero();
-        x.AddVector(&y);
+        x = y;
         x.Scale(-(faktor-1));
         mol->Translate(&x);
@@ -893,7 +885,10 @@
         mol = *ListRunner;
         Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
-        Log() << Verbose(0) << "Enter translation vector." << endl;
-        x.AskPosition(World::getInstance().getDomain(),0);
-        mol->Center.AddVector((const Vector *)&x);
+        Dialog *dialog = UIFactory::getInstance().makeDialog();
+        dialog->queryVector("Enter translation vector.",&x,World::getInstance().getDomain(),false);
+        if(dialog->display()){
+          mol->Center += x;
+        }
+        delete dialog;
      }
      break;
