Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AtomAction/AddAction.cpp

    r112b09 rf0a3ec  
    66 */
    77
    8 #include "Helpers/MemDebug.hpp"
    9 
    108#include "Actions/AtomAction/AddAction.hpp"
    11 #include "CommandLineParser.hpp"
    129#include "atom.hpp"
    1310#include "element.hpp"
    1411#include "log.hpp"
    15 #include "periodentafel.hpp"
     12#include "molecule.hpp"
    1613#include "vector.hpp"
    1714#include "verbose.hpp"
     
    3835Action::state_ptr AtomAddAction::performCall() {
    3936  Dialog *dialog = UIFactory::getInstance().makeDialog();
    40   int Z = -1;
     37  std::vector<element *> elements;
    4138  Vector position;
    4239
    43   dialog->queryInt(NAME, &Z, MapOfActions::getInstance().getDescription(NAME));
     40  dialog->queryElement(NAME, &elements, MapOfActions::getInstance().getDescription(NAME));
    4441  dialog->queryVector("position", &position, World::getInstance().getDomain(), true, MapOfActions::getInstance().getDescription("position"));
     42  cout << "pre-dialog" << endl;
    4543
    4644  if(dialog->display()) {
     45    cout << "post-dialog" << endl;
    4746    delete dialog;
    48     atom * first = World::getInstance().createAtom();
    49     first->type = World::getInstance().getPeriode()->FindElement(Z);
    50     first->x = position;
    51     if (first->type != NULL) {
     47    if (elements.size() == 1) {
     48      atom * first = World::getInstance().createAtom();
     49      first->type = *(elements.begin());
     50      first->x = position;
    5251      DoLog(1) && (Log() << Verbose(1) << "Adding new atom with element " << first->type->name << " at " << (first->x) << "." << endl);
     52      // TODO: remove when all of World's atoms are stored.
     53      std::vector<molecule *> molecules = World::getInstance().getAllMolecules();
     54      if (!molecules.empty()) {
     55        std::vector<molecule *>::iterator iter = molecules.begin();
     56        (*iter)->AddAtom(first);
     57      }
    5358      return Action::success;
    5459    } else {
    5560      DoeLog(1) && (eLog()<< Verbose(1) << "Could not find the specified element." << endl);
    56       World::getInstance().destroyAtom(first);
    5761      return Action::failure;
    5862    }
Note: See TracChangeset for help on using the changeset viewer.