source: molecuilder/src/Actions/AnalysisAction/PairCorrelationAction.cpp@ 2e06c4

Last change on this file since 2e06c4 was 2e06c4, checked in by Frederik Heber <heber@…>, 15 years ago

Added all commands defined in ParseCommandLineOptions() as Actions.

  • Actions are not yet used, except verbose, version and help.
  • Files are present and included in Makefile.am
  • not unit tests written so far
  • no action has been tested so far (except for MapOfActions)
  • structure introduced to to transition from ParseCommandLineOptions to actions.
  • program name and config file are fixed arguments.

Signed-off-by: Frederik Heber <heber@…>

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * PairCorrelationAction.cpp
3 *
4 * Created on: May 9, 2010
5 * Author: heber
6 */
7
8#include "Actions/AnalysisAction/PairCorrelationAction.hpp"
9#include "CommandLineParser.hpp"
10#include "analysis_correlation.hpp"
11#include "log.hpp"
12#include "element.hpp"
13#include "periodentafel.hpp"
14#include "World.hpp"
15
16#include <iostream>
17#include <string>
18
19using namespace std;
20
21#include "UIElements/UIFactory.hpp"
22#include "UIElements/Dialog.hpp"
23#include "Actions/MapOfActions.hpp"
24
25const char AnalysisPairCorrelationAction::NAME[] = "pair-correlation";
26
27AnalysisPairCorrelationAction::AnalysisPairCorrelationAction() :
28 Action(NAME)
29{}
30
31AnalysisPairCorrelationAction::~AnalysisPairCorrelationAction()
32{}
33
34Action::state_ptr AnalysisPairCorrelationAction::performCall() {
35 Dialog *dialog = UIFactory::getInstance().makeDialog();
36 int ranges[3] = {1, 1, 1};
37 double BinStart = 0.;
38 double BinEnd = 0.;
39 string outputname;
40 string binoutputname;
41 bool periodic;
42 ofstream output;
43 ofstream binoutput;
44 const element *elemental1;
45 const element *elemental2;
46
47 dialog->queryElement("elements", &elemental1, MapOfActions::getInstance().getDescription("elements"));
48 dialog->queryElement("elements", &elemental2, MapOfActions::getInstance().getDescription("elements"));
49 dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
50 dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
51 dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
52 dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
53 dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
54
55 if(dialog->display()) {
56 output.open(outputname.c_str());
57 binoutput.open(binoutputname.c_str());
58 PairCorrelationMap *correlationmap = NULL;
59 if (periodic)
60 correlationmap = PeriodicPairCorrelation(World::getInstance().getMolecules(), elemental1, elemental2, ranges);
61 else
62 correlationmap = PairCorrelation(World::getInstance().getMolecules(), elemental1, elemental2);
63 //OutputCorrelationToSurface(&output, correlationmap);
64 BinPairMap *binmap = BinData( correlationmap, 0.5, BinStart, BinEnd );
65 OutputCorrelation ( &binoutput, binmap );
66 output.close();
67 binoutput.close();
68 delete(binmap);
69 delete(correlationmap);
70 delete dialog;
71 return Action::success;
72 } else {
73 delete dialog;
74 return Action::failure;
75 }
76}
77
78Action::state_ptr AnalysisPairCorrelationAction::performUndo(Action::state_ptr _state) {
79// ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
80
81 return Action::failure;
82// string newName = state->mol->getName();
83// state->mol->setName(state->lastName);
84//
85// return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
86}
87
88Action::state_ptr AnalysisPairCorrelationAction::performRedo(Action::state_ptr _state){
89 return Action::failure;
90}
91
92bool AnalysisPairCorrelationAction::canUndo() {
93 return false;
94}
95
96bool AnalysisPairCorrelationAction::shouldUndo() {
97 return false;
98}
99
100const string AnalysisPairCorrelationAction::getName() {
101 return NAME;
102}
Note: See TracBrowser for help on using the repository browser.