Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ParserAction/LoadXyzAction.cpp

    ra1e929 r112b09  
    88#include "Helpers/MemDebug.hpp"
    99
    10 using namespace std;
    11 
    1210#include "Actions/ParserAction/LoadXyzAction.hpp"
    1311#include "Parser/XyzParser.hpp"
    1412
    1513#include <iostream>
    16 #include <set>
    1714#include <string>
    18 #include <vector>
    1915
     16using namespace std;
    2017
    2118#include "UIElements/UIFactory.hpp"
     
    2421
    2522#include "atom.hpp"
    26 #include "log.hpp"
    2723#include "molecule.hpp"
    28 #include "verbose.hpp"
    29 #include "World.hpp"
    3024
    3125/****** ParserLoadXyzAction *****/
     
    4337//};
    4438
    45 const char ParserLoadXyzAction::NAME[] = "parse-xyz";
     39const char ParserLoadXyzAction::NAME[] = "LoadXyz";
    4640
    4741ParserLoadXyzAction::ParserLoadXyzAction() :
     
    5448Action::state_ptr ParserLoadXyzAction::performCall() {
    5549  string filename;
     50  XyzParser parser;
    5651  Dialog *dialog = UIFactory::getInstance().makeDialog();
    5752
    58   dialog->queryString(NAME,&filename, NAME);
     53  dialog->queryString("filename",&filename, "Filename of the xyz file");
    5954
    6055  if(dialog->display()) {
    61     DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
    6256    // parse xyz file
    6357    ifstream input;
    6458    input.open(filename.c_str());
    65     if (!input.fail()) {
    66       // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
    67       set <atom*> UniqueList;
    68       {
    69         vector<atom *> ListBefore = World::getInstance().getAllAtoms();
    70         for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner)
    71           UniqueList.insert(*runner);
    72       }
    73       XyzParser parser; // briefly instantiate a parser which is removed at end of focus
     59    if (!input.fail())
    7460      parser.load(&input);
    75       {
    76         vector<atom *> ListAfter = World::getInstance().getAllAtoms();
    77         pair< set<atom *>::iterator, bool > Inserter;
    78         if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed
    79           MoleculeListClass *molecules = World::getInstance().getMolecules();
    80           molecule *mol= NULL;
    81           if (molecules->ListOfMolecules.empty()) {
    82             mol = World::getInstance().createMolecule();
    83             molecules->insert(mol);
    84           } else {
    85             mol = *(molecules->ListOfMolecules.begin());
    86           }
    87           for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {
    88             Inserter = UniqueList.insert(*runner);
    89             if (Inserter.second) { // if not present, then new (just parsed) atom, add ...
    90               cout << "Adding new atom " << **runner << " to new mol." << endl;
    91               mol->AddAtom(*runner);
    92             }
    93           }
    94           mol->doCountAtoms();
    95         } else {
    96           cout << "No atoms parsed?" << endl;
    97         }
    98       }
    99     } else {
    100       DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
    101     }
    10261    input.close();
    10362  }
Note: See TracChangeset for help on using the changeset viewer.