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"
|
---|
29 | #include "Actions/MapOfActions.hpp"
|
---|
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 | int ranges[3] = {1, 1, 1};
|
---|
43 | double BinEnd = 0.;
|
---|
44 | double BinStart = 0.;
|
---|
45 | double BinWidth = 0.;
|
---|
46 | molecule *Boundary = NULL;
|
---|
47 | string outputname;
|
---|
48 | string binoutputname;
|
---|
49 | bool periodic;
|
---|
50 | ofstream output;
|
---|
51 | ofstream binoutput;
|
---|
52 | std::vector< element *> elements;
|
---|
53 | string type;
|
---|
54 | Vector Point;
|
---|
55 | BinPairMap *binmap = NULL;
|
---|
56 |
|
---|
57 | dialog->queryVector("position", &Point, false, MapOfActions::getInstance().getDescription("position"));
|
---|
58 | dialog->queryElement("elements", &elements, MapOfActions::getInstance().getDescription("elements"));
|
---|
59 | dialog->queryDouble("bin-start", &BinStart, MapOfActions::getInstance().getDescription("bin-start"));
|
---|
60 | dialog->queryDouble("bin-width", &BinWidth, MapOfActions::getInstance().getDescription("bin-width"));
|
---|
61 | dialog->queryDouble("bin-end", &BinEnd, MapOfActions::getInstance().getDescription("bin-end"));
|
---|
62 | dialog->queryString("output-file", &outputname, MapOfActions::getInstance().getDescription("output-file"));
|
---|
63 | dialog->queryString("bin-output-file", &binoutputname, MapOfActions::getInstance().getDescription("bin-output-file"));
|
---|
64 | dialog->queryBoolean("periodic", &periodic, MapOfActions::getInstance().getDescription("periodic"));
|
---|
65 |
|
---|
66 | return dialog;
|
---|
67 | }
|
---|
68 |
|
---|
69 | Action::state_ptr AnalysisPointCorrelationAction::performCall() {
|
---|
70 | int ranges[3] = {1, 1, 1};
|
---|
71 | double BinEnd = 0.;
|
---|
72 | double BinStart = 0.;
|
---|
73 | double BinWidth = 0.;
|
---|
74 | molecule *Boundary = NULL;
|
---|
75 | string outputname;
|
---|
76 | string binoutputname;
|
---|
77 | bool periodic;
|
---|
78 | ofstream output;
|
---|
79 | ofstream binoutput;
|
---|
80 | std::vector< element *> elements;
|
---|
81 | string type;
|
---|
82 | Vector Point;
|
---|
83 | BinPairMap *binmap = NULL;
|
---|
84 | MoleculeListClass *molecules = World::getInstance().getMolecules();
|
---|
85 |
|
---|
86 | // obtain information
|
---|
87 | MapOfActions::getInstance().queryCurrentValue("position", Point);
|
---|
88 | MapOfActions::getInstance().queryCurrentValue("elements", elements);
|
---|
89 | MapOfActions::getInstance().queryCurrentValue("bin-start", BinStart);
|
---|
90 | MapOfActions::getInstance().queryCurrentValue("bin-width", BinWidth);
|
---|
91 | MapOfActions::getInstance().queryCurrentValue("bin-end", BinEnd);
|
---|
92 | MapOfActions::getInstance().queryCurrentValue("output-file", outputname);
|
---|
93 | MapOfActions::getInstance().queryCurrentValue("bin-output-file", binoutputname);
|
---|
94 | MapOfActions::getInstance().queryCurrentValue("periodic", periodic);
|
---|
95 |
|
---|
96 | // execute action
|
---|
97 | output.open(outputname.c_str());
|
---|
98 | binoutput.open(binoutputname.c_str());
|
---|
99 | cout << "Point to correlate to is " << Point << endl;
|
---|
100 | CorrelationToPointMap *correlationmap = NULL;
|
---|
101 | if (periodic)
|
---|
102 | correlationmap = PeriodicCorrelationToPoint(molecules, elements, &Point, ranges);
|
---|
103 | else
|
---|
104 | correlationmap = CorrelationToPoint(molecules, elements, &Point);
|
---|
105 | OutputCorrelationToPoint(&output, correlationmap);
|
---|
106 | binmap = BinData( correlationmap, BinWidth, BinStart, BinEnd );
|
---|
107 | OutputCorrelation ( &binoutput, binmap );
|
---|
108 | delete(binmap);
|
---|
109 | delete(correlationmap);
|
---|
110 | output.close();
|
---|
111 | binoutput.close();
|
---|
112 | return Action::success;
|
---|
113 | }
|
---|
114 |
|
---|
115 | Action::state_ptr AnalysisPointCorrelationAction::performUndo(Action::state_ptr _state) {
|
---|
116 | return Action::success;
|
---|
117 | }
|
---|
118 |
|
---|
119 | Action::state_ptr AnalysisPointCorrelationAction::performRedo(Action::state_ptr _state){
|
---|
120 | return Action::success;
|
---|
121 | }
|
---|
122 |
|
---|
123 | bool AnalysisPointCorrelationAction::canUndo() {
|
---|
124 | return true;
|
---|
125 | }
|
---|
126 |
|
---|
127 | bool AnalysisPointCorrelationAction::shouldUndo() {
|
---|
128 | return true;
|
---|
129 | }
|
---|
130 |
|
---|
131 | const string AnalysisPointCorrelationAction::getName() {
|
---|
132 | return NAME;
|
---|
133 | }
|
---|