Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Legacy/oldmenu.cpp

    r273382 r97ebf8  
    3535#include "Menu/DisplayMenuItem.hpp"
    3636#include "Menu/SubMenuItem.hpp"
     37#include "Actions/MapOfActions.hpp"
    3738#include "Actions/MethodAction.hpp"
    3839#include "Actions/ErrorAction.hpp"
     
    6162  char choice;  // menu choice char
    6263  bool valid;
     64  bool aborted;
    6365
    6466  Log() << Verbose(0) << "===========ADD ATOM============================" << endl;
     
    8082      case 'a': // absolute coordinates of atom
    8183      {
     84        Dialog *dialog = UIFactory::getInstance().makeDialog();
    8285        first = World::getInstance().createAtom();
    83         Dialog *dialog = UIFactory::getInstance().makeDialog();
    84         dialog->queryVector("Enter absolute coordinates.",&first->x,mol->cell_size, false);
    85         dialog->queryElement("Choose element for this atom",&first->type);
     86        dialog->queryVector("Please enter coordinates: ",&first->x,World::getInstance().getDomain(), false);
     87        dialog->queryElement("Please choose element: ",&first->type);
    8688        if(dialog->display()){
    8789          mol->AddAtom(first);  // add to molecule
    8890        }
    8991        else{
    90           // dialog was canceled... destroy the atom that was used
    9192          World::getInstance().destroyAtom(first);
    9293        }
    93         delete dialog;
    9494      }
    9595      break;
     
    9898        first = World::getInstance().createAtom();
    9999        valid = true;
     100        aborted = false;
    100101        do {
    101           Dialog *dialog = UIFactory::getInstance().makeDialog();
    102102          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
    103           dialog->queryVector("Enter reference coordinates.",&x,mol->cell_size,true);
    104           dialog->queryVector("Enter relative coordinates.",&first->x,mol->cell_size,false);
     103          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
     104          dialog->queryVector("Enter reference coordinates.",&x,World::getInstance().getDomain(), true);
     105          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
     106          if((aborted = !dialog->display())){
     107            continue;
     108          }
    105109          first->x += x;
    106           dialog->display();
    107           delete dialog;
    108         } while (!(valid = mol->CheckBounds(&first->x)));
    109         first->type = periode->AskElement();  // give type
    110         mol->AddAtom(first);  // add to molecule
     110        } while (!aborted && !(valid = mol->CheckBounds((const Vector *)&first->x)));
     111        if(!aborted){
     112          first->type = periode->AskElement();  // give type
     113          mol->AddAtom(first);  // add to molecule
     114        }
     115        else{
     116          World::getInstance().destroyAtom(first);
     117        }
    111118        break;
    112119
     
    117124        do {
    118125          if (!valid) eLog() << Verbose(2) << "Resulting position out of cell." << endl;
     126          auto_ptr<Dialog> dialog(UIFactory::getInstance().makeDialog());
    119127          second = mol->AskAtom("Enter atom number: ");
    120           Dialog *dialog = UIFactory::getInstance().makeDialog();
    121           dialog->queryVector("Enter relative coordinates.",&first->x,mol->cell_size,false);
     128          dialog->queryVector("Enter relative coordinates.",&first->x,World::getInstance().getDomain(), false);
    122129          dialog->display();
    123130          for (int i=NDIM;i--;) {
     
    326333    {
    327334      Dialog *dialog = UIFactory::getInstance().makeDialog();
    328       dialog->queryVector("Enter normal vector of mirror plane.",&n,mol->cell_size,false);
     335      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
    329336      dialog->display();
    330337      delete dialog;
     
    393400    {
    394401      Dialog *dialog = UIFactory::getInstance().makeDialog();
    395       dialog->queryVector("Enter normal vector of mirror plane.",&n,mol->cell_size,false);
     402      dialog->queryVector("Enter normal vector of mirror plane.",&n,World::getInstance().getDomain(),false);
    396403      dialog->display();
    397404      delete dialog;
     
    766773      x.Zero();
    767774      y.Zero();
    768       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
     775      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
    769776      for (int i=1;i<faktor;i++) {  // then add this list with respective translation factor times
    770777        x += y; // per factor one cell width further
     
    787794        mol->Translate(&x);
    788795      }
    789       mol->cell_size[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
     796      World::getInstance().getDomain()[(abs(axis) == 2) ? 2 : ((abs(axis) == 3) ? 5 : 0)] *= faktor;
    790797    }
    791798  }
     
    880887        Log() << Verbose(0) << "Current molecule is: " << mol->IndexNr << "\t" << mol->name << endl;
    881888        Dialog *dialog = UIFactory::getInstance().makeDialog();
    882         dialog->queryVector("Enter translation vector.",&x,mol->cell_size,false);
    883         dialog->display();
     889        dialog->queryVector("Enter translation vector.",&x,World::getInstance().getDomain(),false);
     890        if(dialog->display()){
     891          mol->Center += x;
     892        }
    884893        delete dialog;
    885         mol->Center += x;
    886894     }
    887895     break;
     
    901909  molecule *srcmol = NULL, *destmol = NULL;
    902910  Dialog *dialog = UIFactory::getInstance().makeDialog();
    903   dialog->queryMolecule("Enter index of destination molecule: ",&destmol, molecules);
    904   dialog->queryMolecule("Enter index of source molecule to add from: ",&srcmol, molecules);
     911  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     912  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    905913  if(dialog->display()) {
    906914    molecules->SimpleAdd(srcmol, destmol);
     
    915923  molecule *srcmol = NULL, *destmol = NULL;
    916924  Dialog *dialog = UIFactory::getInstance().makeDialog();
    917   dialog->queryMolecule("Enter index of matrix molecule (the variable one): ",&srcmol,molecules);
    918   dialog->queryMolecule("Enter index of molecule to merge into (the fixed one): ",&destmol,molecules);
     925  dialog->queryMolecule("molecule-by-id",&destmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     926  dialog->queryMolecule("molecule-by-id",&srcmol, MapOfActions::getInstance().getDescription("molecule-by-id"));
    919927  if(dialog->display()) {
    920928    molecules->EmbedMerge(destmol, srcmol);
Note: See TracChangeset for help on using the changeset viewer.