Ignore:
Timestamp:
Jul 28, 2010, 9:21:14 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
400170, a7b777c
Parents:
7067bd6 (diff), 0430e3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'stable' into StructureRefactoring

Conflicts:

src/Makefile.am

Location:
src/Actions/ParserAction
Files:
4 edited

Legend:

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

    r7067bd6 r677e13  
    1111
    1212#include "Actions/ParserAction/LoadXyzAction.hpp"
     13#include "Actions/ActionRegistry.hpp"
    1314#include "Parser/XyzParser.hpp"
     15#include "atom.hpp"
     16#include "log.hpp"
     17#include "molecule.hpp"
     18#include "verbose.hpp"
     19#include "World.hpp"
    1420
    1521#include <iostream>
     
    1824#include <vector>
    1925
    20 
    2126#include "UIElements/UIFactory.hpp"
    2227#include "UIElements/Dialog.hpp"
    23 #include "Actions/MapOfActions.hpp"
    24 
    25 #include "atom.hpp"
    26 #include "log.hpp"
    27 #include "molecule.hpp"
    28 #include "verbose.hpp"
    29 #include "World.hpp"
     28#include "UIElements/ValueStorage.hpp"
    3029
    3130/****** ParserLoadXyzAction *****/
     
    5251{}
    5352
     53void ParserLoadXyz(std::string &filename) {
     54  ValueStorage::getInstance().setCurrentValue(ParserLoadXyzAction::NAME, filename);
     55  ActionRegistry::getInstance().getActionByName(ParserLoadXyzAction::NAME)->call(Action::NonInteractive);
     56};
     57
     58Dialog* ParserLoadXyzAction::createDialog() {
     59  Dialog *dialog = UIFactory::getInstance().makeDialog();
     60
     61  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     62
     63  return dialog;
     64}
     65
    5466Action::state_ptr ParserLoadXyzAction::performCall() {
    5567  string filename;
    56   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5768
    58   dialog->queryString(NAME,&filename, NAME);
     69  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5970
    60   if(dialog->display()) {
    61     DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
    62     // parse xyz file
    63     ifstream input;
    64     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);
     71  DoLog(1) && (Log() << Verbose(1) << "Parsing xyz file for new atoms." << endl);
     72  // parse xyz file
     73  ifstream input;
     74  input.open(filename.c_str());
     75  if (!input.fail()) {
     76    // TODO: Remove the insertion into molecule when saving does not depend on them anymore. Also, remove molecule.hpp include
     77    set <atom*> UniqueList;
     78    {
     79      vector<atom *> ListBefore = World::getInstance().getAllAtoms();
     80      for (vector<atom *>::iterator runner = ListBefore.begin();runner != ListBefore.end(); ++runner)
     81        UniqueList.insert(*runner);
     82    }
     83    XyzParser parser; // briefly instantiate a parser which is removed at end of focus
     84    parser.load(&input);
     85    {
     86      vector<atom *> ListAfter = World::getInstance().getAllAtoms();
     87      pair< set<atom *>::iterator, bool > Inserter;
     88      if (UniqueList.size() != ListAfter.size()) { // only create if new atoms have been parsed
     89        MoleculeListClass *molecules = World::getInstance().getMolecules();
     90        molecule *mol = World::getInstance().createMolecule();
     91        molecules->insert(mol);
     92        for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {
     93          Inserter = UniqueList.insert(*runner);
     94          if (Inserter.second) { // if not present, then new (just parsed) atom, add ...
     95            cout << "Adding new atom " << **runner << " to new mol." << endl;
     96            mol->AddAtom(*runner);
     97          }
     98        }
     99        mol->doCountAtoms();
     100      } else {
     101        cout << "No atoms parsed?" << endl;
    72102      }
    73       XyzParser parser; // briefly instantiate a parser which is removed at end of focus
    74       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 = World::getInstance().createMolecule();
    81           molecules->insert(mol);
    82           for (vector<atom *>::iterator runner = ListAfter.begin(); runner != ListAfter.end(); ++runner) {
    83             Inserter = UniqueList.insert(*runner);
    84             if (Inserter.second) { // if not present, then new (just parsed) atom, add ...
    85               cout << "Adding new atom " << **runner << " to new mol." << endl;
    86               mol->AddAtom(*runner);
    87             }
    88           }
    89           mol->doCountAtoms();
    90         } else {
    91           cout << "No atoms parsed?" << endl;
    92         }
    93       }
    94     } else {
    95       DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
    96103    }
    97     input.close();
     104  } else {
     105    DoeLog(1) && (eLog() << Verbose(1) << "Could not open file " << filename << "." << endl);
    98106  }
    99   delete dialog;
    100   return Action::failure;
     107  input.close();
     108  return Action::success;
    101109}
    102110
  • src/Actions/ParserAction/LoadXyzAction.hpp

    r7067bd6 r677e13  
    1212#include "Actions/Process.hpp"
    1313
     14void ParserLoadXyz(std::string &filename);
     15
    1416class ParserLoadXyzAction : public Action {
     17  friend void ParserLoadXyz(std::string &filename);
     18
    1519public:
    1620  ParserLoadXyzAction();
     
    2226  virtual const std::string getName();
    2327private:
     28  virtual Dialog * createDialog();
    2429  virtual Action::state_ptr performCall();
    2530  virtual Action::state_ptr performUndo(Action::state_ptr);
  • src/Actions/ParserAction/SaveXyzAction.cpp

    r7067bd6 r677e13  
    99
    1010#include "Actions/ParserAction/SaveXyzAction.hpp"
     11#include "Actions/ActionRegistry.hpp"
    1112#include "Parser/XyzParser.hpp"
     13#include "atom.hpp"
     14#include "molecule.hpp"
    1215
    1316#include <iostream>
     
    1821#include "UIElements/UIFactory.hpp"
    1922#include "UIElements/Dialog.hpp"
    20 #include "Actions/MapOfActions.hpp"
     23#include "UIElements/ValueStorage.hpp"
    2124
    22 #include "atom.hpp"
    23 #include "molecule.hpp"
    2425
    2526/****** ParserSaveXyzAction *****/
     
    4647{}
    4748
     49void ParserSaveXyz(std::string &filename) {
     50  ValueStorage::getInstance().setCurrentValue(ParserSaveXyzAction::NAME, filename);
     51  ActionRegistry::getInstance().getActionByName(ParserSaveXyzAction::NAME)->call(Action::NonInteractive);
     52};
     53
     54Dialog* ParserSaveXyzAction::createDialog() {
     55  Dialog *dialog = UIFactory::getInstance().makeDialog();
     56
     57  dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
     58
     59  return dialog;
     60}
     61
    4862Action::state_ptr ParserSaveXyzAction::performCall() {
    4963  string filename;
    5064  XyzParser parser;
    51   Dialog *dialog = UIFactory::getInstance().makeDialog();
    5265
    53   dialog->queryString("filename",&filename, "Filename of the xyz file");
     66  ValueStorage::getInstance().queryCurrentValue(NAME, filename);
    5467
    55   if(dialog->display()) {
    56     // store xyz file
    57     ofstream output;
    58     output.open(filename.c_str());
    59     if (!output.fail())
    60       parser.save(&output);
    61     output.close();
    62   }
    63   delete dialog;
     68  // store xyz file
     69  ofstream output;
     70  output.open(filename.c_str());
     71  if (!output.fail())
     72    parser.save(&output);
     73  output.close();
    6474  return Action::failure;
    6575}
  • src/Actions/ParserAction/SaveXyzAction.hpp

    r7067bd6 r677e13  
    1212#include "Actions/Process.hpp"
    1313
     14void ParserSaveXyz(std::string &filename);
     15
    1416class ParserSaveXyzAction : public Action {
     17  friend void ParserSaveXyz(std::string &filename);
     18
    1519public:
    1620  ParserSaveXyzAction();
     
    2226  virtual const std::string getName();
    2327private:
     28  virtual Dialog * createDialog();
    2429  virtual Action::state_ptr performCall();
    2530  virtual Action::state_ptr performUndo(Action::state_ptr);
Note: See TracChangeset for help on using the changeset viewer.