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