source: src/Actions/WorldAction/InputAction.cpp@ 9cd807

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
Last change on this file since 9cd807 was bf3817, checked in by Frederik Heber <heber@…>, 14 years ago

Added ifdef HAVE_CONFIG and config.h include to each and every cpp file.

  • is now topmost in front of MemDebug.hpp (and any other).
  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * InputAction.cpp
3 *
4 * Created on: May 8, 2010
5 * Author: heber
6 */
7
8// include config.h
9#ifdef HAVE_CONFIG_H
10#include <config.h>
11#endif
12
13#include "Helpers/MemDebug.hpp"
14
15#include "Actions/WorldAction/InputAction.hpp"
16#include "Actions/ActionRegistry.hpp"
17#include "Helpers/Log.hpp"
18#include "molecule.hpp"
19#include "Parser/FormatParserStorage.hpp"
20#include "Parser/PcpParser.hpp"
21#include "Helpers/Verbose.hpp"
22#include "World.hpp"
23
24#include <iostream>
25#include <string>
26
27using namespace std;
28
29#include "UIElements/UIFactory.hpp"
30#include "UIElements/Dialog.hpp"
31#include "Actions/ValueStorage.hpp"
32
33const char WorldInputAction::NAME[] = "input";
34
35WorldInputAction::WorldInputAction() :
36 Action(NAME)
37{}
38
39WorldInputAction::~WorldInputAction()
40{}
41
42void WorldInput(std::string &filename) {
43 ValueStorage::getInstance().setCurrentValue(WorldInputAction::NAME, filename);
44 ActionRegistry::getInstance().getActionByName(WorldInputAction::NAME)->call(Action::NonInteractive);
45};
46
47Dialog* WorldInputAction::fillDialog(Dialog *dialog) {
48 ASSERT(dialog,"No Dialog given when filling action dialog");
49
50 dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME));
51
52 return dialog;
53}
54
55Action::state_ptr WorldInputAction::performCall() {
56 MoleculeListClass *molecules = World::getInstance().getMolecules();
57 molecule *mol = NULL;
58 std::string filename;
59 std::ifstream test;
60
61 ValueStorage::getInstance().queryCurrentValue(NAME, filename);
62
63 DoLog(0) && (Log() << Verbose(0) << "Config file given." << endl);
64 if (filename.find('.') != string::npos) {
65 std::string FilenamePrefix = filename.substr(0,filename.find_last_of('.'));
66 std::string FilenameSuffix = filename.substr(filename.find_last_of('.')+1, filename.length());
67 DoLog(1) && (Log() << Verbose(1) << "Setting config file name prefix to " << FilenamePrefix << "." << endl);
68 test.open(filename.c_str());
69 if (test == NULL) {
70 DoLog(1) && (Log() << Verbose(1) << "Specified config file " << filename << " not found." << endl);
71 } else {
72 DoLog(1) && (Log() << Verbose(1) << "Specified config file found, parsing ... ");
73 FormatParserStorage::getInstance().get((std::istream &)test, FilenameSuffix);
74 test.close();
75 }
76 FormatParserStorage::getInstance().SetOutputPrefixForAll(FilenamePrefix);
77 // set mol to first active molecule
78 if (molecules->ListOfMolecules.size() != 0) {
79 for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
80 if ((*ListRunner)->ActiveFlag) {
81 mol = *ListRunner;
82 break;
83 }
84 }
85 if (mol == NULL) {
86 mol = World::getInstance().createMolecule();
87 mol->ActiveFlag = true;
88 molecules->insert(mol);
89 }
90 mol->SetNameFromFilename(filename.substr(0,filename.find('.')).c_str());
91 } else {
92 DoeLog(1) && (eLog() << Verbose(1) << "Input file does not have a suffix, cannot recognize format." << endl);
93 }
94 return Action::success;
95}
96
97Action::state_ptr WorldInputAction::performUndo(Action::state_ptr _state) {
98// ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
99
100 return Action::failure;
101// string newName = state->mol->getName();
102// state->mol->setName(state->lastName);
103//
104// return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
105}
106
107Action::state_ptr WorldInputAction::performRedo(Action::state_ptr _state){
108 return Action::failure;
109}
110
111bool WorldInputAction::canUndo() {
112 return false;
113}
114
115bool WorldInputAction::shouldUndo() {
116 return false;
117}
118
119const string WorldInputAction::getName() {
120 return NAME;
121}
Note: See TracBrowser for help on using the repository browser.