[d02e07] | 1 | /*
|
---|
| 2 | * PointCorrelationAction.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: May 9, 2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[bf3817] | 8 | // include config.h
|
---|
| 9 | #ifdef HAVE_CONFIG_H
|
---|
| 10 | #include <config.h>
|
---|
| 11 | #endif
|
---|
| 12 |
|
---|
[d02e07] | 13 | #include "Helpers/MemDebug.hpp"
|
---|
| 14 |
|
---|
| 15 | #include "Actions/AnalysisAction/PointCorrelationAction.hpp"
|
---|
[0430e3] | 16 | #include "Actions/ActionRegistry.hpp"
|
---|
[d02e07] | 17 | #include "analysis_correlation.hpp"
|
---|
| 18 | #include "boundary.hpp"
|
---|
| 19 | #include "linkedcell.hpp"
|
---|
[952f38] | 20 | #include "Helpers/Verbose.hpp"
|
---|
| 21 | #include "Helpers/Log.hpp"
|
---|
[d02e07] | 22 | #include "element.hpp"
|
---|
| 23 | #include "molecule.hpp"
|
---|
| 24 | #include "periodentafel.hpp"
|
---|
[57f243] | 25 | #include "LinearAlgebra/Vector.hpp"
|
---|
[d02e07] | 26 | #include "World.hpp"
|
---|
| 27 |
|
---|
| 28 | #include <iostream>
|
---|
| 29 | #include <string>
|
---|
| 30 |
|
---|
| 31 | using namespace std;
|
---|
| 32 |
|
---|
| 33 | #include "UIElements/UIFactory.hpp"
|
---|
| 34 | #include "UIElements/Dialog.hpp"
|
---|
[861874] | 35 | #include "Actions/ValueStorage.hpp"
|
---|
[d02e07] | 36 |
|
---|
| 37 | const char AnalysisPointCorrelationAction::NAME[] = "point-correlation";
|
---|
| 38 |
|
---|
| 39 | AnalysisPointCorrelationAction::AnalysisPointCorrelationAction() :
|
---|
| 40 | Action(NAME)
|
---|
| 41 | {}
|
---|
| 42 |
|
---|
| 43 | AnalysisPointCorrelationAction::~AnalysisPointCorrelationAction()
|
---|
| 44 | {}
|
---|
| 45 |
|
---|
[b31cfa] | 46 | void AnalysisPointCorrelation(std::vector< element *> &elements, Vector &position, double BinStart, double BinWidth, double BinEnd, string &outputname, string &binoutputname, bool periodic) {
|
---|
| 47 | ValueStorage::getInstance().setCurrentValue("elements", elements);
|
---|
| 48 | ValueStorage::getInstance().setCurrentValue("position", position);
|
---|
| 49 | ValueStorage::getInstance().setCurrentValue("bin-start", BinStart);
|
---|
| 50 | ValueStorage::getInstance().setCurrentValue("bin-width", BinWidth);
|
---|
| 51 | ValueStorage::getInstance().setCurrentValue("bin-end", BinEnd);
|
---|
| 52 | ValueStorage::getInstance().setCurrentValue("output-file", outputname);
|
---|
| 53 | ValueStorage::getInstance().setCurrentValue("bin-output-file", binoutputname);
|
---|
| 54 | ValueStorage::getInstance().setCurrentValue("periodic", periodic);
|
---|
| 55 | ActionRegistry::getInstance().getActionByName(AnalysisPointCorrelationAction::NAME)->call(Action::NonInteractive);
|
---|
| 56 | };
|
---|
| 57 |
|
---|
[047878] | 58 | Dialog* AnalysisPointCorrelationAction::fillDialog(Dialog *dialog) {
|
---|
| 59 | ASSERT(dialog,"No Dialog given when filling action dialog");
|
---|
[d02e07] | 60 |
|
---|
[9d33ba] | 61 | dialog->queryVector("position", false, ValueStorage::getInstance().getDescription("position"));
|
---|
[e65de8] | 62 | dialog->queryElements("elements", ValueStorage::getInstance().getDescription("elements"));
|
---|
[9d33ba] | 63 | dialog->queryDouble("bin-start", ValueStorage::getInstance().getDescription("bin-start"));
|
---|
| 64 | dialog->queryDouble("bin-width", ValueStorage::getInstance().getDescription("bin-width"));
|
---|
| 65 | dialog->queryDouble("bin-end", ValueStorage::getInstance().getDescription("bin-end"));
|
---|
| 66 | dialog->queryString("output-file", ValueStorage::getInstance().getDescription("output-file"));
|
---|
| 67 | dialog->queryString("bin-output-file", ValueStorage::getInstance().getDescription("bin-output-file"));
|
---|
| 68 | dialog->queryBoolean("periodic", ValueStorage::getInstance().getDescription("periodic"));
|
---|
[d02e07] | 69 |
|
---|
| 70 | return dialog;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | Action::state_ptr AnalysisPointCorrelationAction::performCall() {
|
---|
| 74 | int ranges[3] = {1, 1, 1};
|
---|
| 75 | double BinEnd = 0.;
|
---|
| 76 | double BinStart = 0.;
|
---|
| 77 | double BinWidth = 0.;
|
---|
| 78 | string outputname;
|
---|
| 79 | string binoutputname;
|
---|
| 80 | bool periodic;
|
---|
| 81 | ofstream output;
|
---|
| 82 | ofstream binoutput;
|
---|
[e5c0a1] | 83 | std::vector<const element *> elements;
|
---|
[d02e07] | 84 | string type;
|
---|
| 85 | Vector Point;
|
---|
| 86 | BinPairMap *binmap = NULL;
|
---|
| 87 |
|
---|
| 88 | // obtain information
|
---|
[9d33ba] | 89 | ValueStorage::getInstance().queryCurrentValue("position", Point);
|
---|
| 90 | ValueStorage::getInstance().queryCurrentValue("elements", elements);
|
---|
| 91 | ValueStorage::getInstance().queryCurrentValue("bin-start", BinStart);
|
---|
| 92 | ValueStorage::getInstance().queryCurrentValue("bin-width", BinWidth);
|
---|
| 93 | ValueStorage::getInstance().queryCurrentValue("bin-end", BinEnd);
|
---|
| 94 | ValueStorage::getInstance().queryCurrentValue("output-file", outputname);
|
---|
| 95 | ValueStorage::getInstance().queryCurrentValue("bin-output-file", binoutputname);
|
---|
| 96 | ValueStorage::getInstance().queryCurrentValue("periodic", periodic);
|
---|
[d02e07] | 97 |
|
---|
| 98 | // execute action
|
---|
| 99 | output.open(outputname.c_str());
|
---|
| 100 | binoutput.open(binoutputname.c_str());
|
---|
| 101 | cout << "Point to correlate to is " << Point << endl;
|
---|
| 102 | CorrelationToPointMap *correlationmap = NULL;
|
---|
[e5c0a1] | 103 | for(std::vector<const element *>::iterator iter = elements.begin(); iter != elements.end(); ++iter)
|
---|
[2fe971] | 104 | cout << "element is " << (*iter)->getSymbol() << endl;
|
---|
[e65de8] | 105 | std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
|
---|
[d02e07] | 106 | if (periodic)
|
---|
| 107 | correlationmap = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
|
---|
| 108 | else
|
---|
| 109 | correlationmap = CorrelationToPoint(molecules, elements, &Point);
|
---|
| 110 | OutputCorrelationToPoint(&output, correlationmap);
|
---|
| 111 | binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
|
---|
| 112 | OutputCorrelation ( &binoutput, binmap );
|
---|
| 113 | delete(binmap);
|
---|
| 114 | delete(correlationmap);
|
---|
| 115 | output.close();
|
---|
| 116 | binoutput.close();
|
---|
| 117 | return Action::success;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | Action::state_ptr AnalysisPointCorrelationAction::performUndo(Action::state_ptr _state) {
|
---|
| 121 | return Action::success;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | Action::state_ptr AnalysisPointCorrelationAction::performRedo(Action::state_ptr _state){
|
---|
| 125 | return Action::success;
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | bool AnalysisPointCorrelationAction::canUndo() {
|
---|
| 129 | return true;
|
---|
| 130 | }
|
---|
| 131 |
|
---|
| 132 | bool AnalysisPointCorrelationAction::shouldUndo() {
|
---|
| 133 | return true;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | const string AnalysisPointCorrelationAction::getName() {
|
---|
| 137 | return NAME;
|
---|
| 138 | }
|
---|