Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/SaveAdjacencyAction.cpp

    r112b09 r047878  
    99
    1010#include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
     12#include "bondgraph.hpp"
     13#include "config.hpp"
     14#include "log.hpp"
     15#include "molecule.hpp"
     16#include "verbose.hpp"
     17#include "World.hpp"
     18
    1119
    1220#include <iostream>
     
    1826#include "UIElements/UIFactory.hpp"
    1927#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
    21 
    22 #include "atom.hpp"
    23 #include "bondgraph.hpp"
    24 #include "config.hpp"
    25 #include "defs.hpp"
    26 #include "log.hpp"
    27 #include "molecule.hpp"
    28 #include "vector.hpp"
    29 #include "verbose.hpp"
    30 #include "World.hpp"
     28#include "UIElements/ValueStorage.hpp"
    3129
    3230/****** MoleculeSaveAdjacencyAction *****/
     
    5351{}
    5452
     53void MoleculeSaveAdjacency(std::string &adjacencyfile) {
     54  ValueStorage::getInstance().setCurrentValue(MoleculeSaveAdjacencyAction::NAME, adjacencyfile);
     55  ActionRegistry::getInstance().getActionByName(MoleculeSaveAdjacencyAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* MoleculeSaveAdjacencyAction::fillDialog(Dialog *dialog) {
     59  ASSERT(dialog,"No Dialog given when filling action dialog");
     60
     61  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     62
     63  return dialog;
     64}
     65
    5566Action::state_ptr MoleculeSaveAdjacencyAction::performCall() {
    5667  string filename;
    57   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5868  molecule *mol = NULL;
    5969
    60   dialog->queryString(NAME, &filename, MapOfActions::getInstance().getDescription(NAME));
    61   dialog->queryMolecule("molecule-by-id", &mol, MapOfActions::getInstance().getDescription("molecule-by-id"));
     70  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    6271
    63   if(dialog->display()) {
     72  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
     73    mol = iter->second;
    6474    DoLog(0) && (Log() << Verbose(0) << "Storing adjacency to path " << filename << "." << endl);
    6575    World::getInstance().getConfig()->BG->ConstructBondGraph(mol);
    6676    // TODO: sollte stream nicht filename benutzen, besser fuer unit test
    67     char outputname[MAXSTRINGSIZE];
    68     strcpy(outputname, filename.c_str());
    69     mol->StoreAdjacencyToFile(NULL, outputname);
    70     delete dialog;
    71     return Action::success;
     77    mol->StoreAdjacencyToFile(filename);
    7278  }
    73   delete dialog;
    74   return Action::failure;
     79  return Action::success;
    7580}
    7681
Note: See TracChangeset for help on using the changeset viewer.