[d02e07] | 1 | /*
|
---|
| 2 | * PointCorrelationAction.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: May 9, 2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "Helpers/MemDebug.hpp"
|
---|
| 9 |
|
---|
| 10 | #include "Actions/AnalysisAction/PointCorrelationAction.hpp"
|
---|
| 11 | #include "analysis_correlation.hpp"
|
---|
| 12 | #include "boundary.hpp"
|
---|
| 13 | #include "linkedcell.hpp"
|
---|
| 14 | #include "verbose.hpp"
|
---|
| 15 | #include "log.hpp"
|
---|
| 16 | #include "element.hpp"
|
---|
| 17 | #include "molecule.hpp"
|
---|
| 18 | #include "periodentafel.hpp"
|
---|
| 19 | #include "vector.hpp"
|
---|
| 20 | #include "World.hpp"
|
---|
| 21 |
|
---|
| 22 | #include <iostream>
|
---|
| 23 | #include <string>
|
---|
| 24 |
|
---|
| 25 | using namespace std;
|
---|
| 26 |
|
---|
| 27 | #include "UIElements/UIFactory.hpp"
|
---|
| 28 | #include "UIElements/Dialog.hpp"
|
---|
[9d33ba] | 29 | #include "UIElements/ValueStorage.hpp"
|
---|
[d02e07] | 30 |
|
---|
| 31 | const char AnalysisPointCorrelationAction::NAME[] = "point-correlation";
|
---|
| 32 |
|
---|
| 33 | AnalysisPointCorrelationAction::AnalysisPointCorrelationAction() :
|
---|
| 34 | Action(NAME)
|
---|
| 35 | {}
|
---|
| 36 |
|
---|
| 37 | AnalysisPointCorrelationAction::~AnalysisPointCorrelationAction()
|
---|
| 38 | {}
|
---|
| 39 |
|
---|
| 40 | Dialog* AnalysisPointCorrelationAction::createDialog() {
|
---|
| 41 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
| 42 |
|
---|
[9d33ba] | 43 | dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
|
---|
| 44 | dialog->queryElement("elements", ValueStorage::getInstance().getDescription("elements"));
|
---|
| 45 | dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
|
---|
| 46 | dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
|
---|
| 47 | dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
|
---|
| 48 | dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
|
---|
| 49 | dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
|
---|
| 50 | dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
|
---|
[d02e07] | 51 |
|
---|
| 52 | return dialog;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | Action::state_ptr AnalysisPointCorrelationAction::performCall() {
|
---|
| 56 | int ranges[3] = {1, 1, 1};
|
---|
| 57 | double BinEnd = 0.;
|
---|
| 58 | double BinStart = 0.;
|
---|
| 59 | double BinWidth = 0.;
|
---|
| 60 | molecule *Boundary = NULL;
|
---|
| 61 | string outputname;
|
---|
| 62 | string binoutputname;
|
---|
| 63 | bool periodic;
|
---|
| 64 | ofstream output;
|
---|
| 65 | ofstream binoutput;
|
---|
| 66 | std::vector< element *> elements;
|
---|
| 67 | string type;
|
---|
| 68 | Vector Point;
|
---|
| 69 | BinPairMap *binmap = NULL;
|
---|
| 70 | MoleculeListClass *molecules = World::getInstance().getMolecules();
|
---|
| 71 |
|
---|
| 72 | // obtain information
|
---|
[9d33ba] | 73 | ValueStorage::getInstance().queryCurrentValue("position", Point);
|
---|
| 74 | ValueStorage::getInstance().queryCurrentValue("elements", elements);
|
---|
| 75 | ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
|
---|
| 76 | ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
|
---|
| 77 | ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
|
---|
| 78 | ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
|
---|
| 79 | ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
|
---|
| 80 | ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
|
---|
[d02e07] | 81 |
|
---|
| 82 | // execute action
|
---|
| 83 | output.open(outputname.c_str());
|
---|
| 84 | binoutput.open(binoutputname.c_str());
|
---|
| 85 | cout << "Point to correlate to is " << Point << endl;
|
---|
| 86 | CorrelationToPointMap *correlationmap = NULL;
|
---|
| 87 | if (periodic)
|
---|
| 88 | correlationmap = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
|
---|
| 89 | else
|
---|
| 90 | correlationmap = CorrelationToPoint(molecules, elements, &Point);
|
---|
| 91 | OutputCorrelationToPoint(&output, correlationmap);
|
---|
| 92 | binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
|
---|
| 93 | OutputCorrelation ( &binoutput, binmap );
|
---|
| 94 | delete(binmap);
|
---|
| 95 | delete(correlationmap);
|
---|
| 96 | output.close();
|
---|
| 97 | binoutput.close();
|
---|
| 98 | return Action::success;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | Action::state_ptr AnalysisPointCorrelationAction::performUndo(Action::state_ptr _state) {
|
---|
| 102 | return Action::success;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | Action::state_ptr AnalysisPointCorrelationAction::performRedo(Action::state_ptr _state){
|
---|
| 106 | return Action::success;
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | bool AnalysisPointCorrelationAction::canUndo() {
|
---|
| 110 | return true;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | bool AnalysisPointCorrelationAction::shouldUndo() {
|
---|
| 114 | return true;
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | const string AnalysisPointCorrelationAction::getName() {
|
---|
| 118 | return NAME;
|
---|
| 119 | }
|
---|