| 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * PointCorrelationAction.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: May 9, 2010
|
|---|
| 12 | * Author: heber
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 21 |
|
|---|
| 22 | #include "Analysis/analysis_correlation.hpp"
|
|---|
| 23 | #include "CodePatterns/Verbose.hpp"
|
|---|
| 24 | #include "CodePatterns/Log.hpp"
|
|---|
| 25 | #include "Element/element.hpp"
|
|---|
| 26 | #include "Element/periodentafel.hpp"
|
|---|
| 27 | #include "LinearAlgebra/Vector.hpp"
|
|---|
| 28 | #include "molecule.hpp"
|
|---|
| 29 | #include "World.hpp"
|
|---|
| 30 |
|
|---|
| 31 | #include <cmath>
|
|---|
| 32 | #include <iostream>
|
|---|
| 33 | #include <string>
|
|---|
| 34 |
|
|---|
| 35 | #include "Actions/AnalysisAction/PointCorrelationAction.hpp"
|
|---|
| 36 |
|
|---|
| 37 | using namespace MoleCuilder;
|
|---|
| 38 |
|
|---|
| 39 | // and construct the stuff
|
|---|
| 40 | #include "PointCorrelationAction.def"
|
|---|
| 41 | #include "Action_impl_pre.hpp"
|
|---|
| 42 |
|
|---|
| 43 | /** =========== define the function ====================== */
|
|---|
| 44 | Action::state_ptr AnalysisPointCorrelationAction::performCall() {
|
|---|
| 45 | int ranges[3] = {1, 1, 1};
|
|---|
| 46 | ofstream output;
|
|---|
| 47 | ofstream binoutput;
|
|---|
| 48 | string type;
|
|---|
| 49 | BinPairMap *binmap = NULL;
|
|---|
| 50 |
|
|---|
| 51 | // execute action
|
|---|
| 52 | output.open(params.outputname.get().string().c_str());
|
|---|
| 53 | binoutput.open(params.binoutputname.get().string().c_str());
|
|---|
| 54 | cout << "Point to correlate to is " << params.Point.get() << endl;
|
|---|
| 55 | CorrelationToPointMap *correlationmap = NULL;
|
|---|
| 56 | for(std::vector<const element *>::const_iterator iter = params.elements.get().begin(); iter != params.elements.get().end(); ++iter)
|
|---|
| 57 | cout << "element is " << (*iter)->getSymbol() << endl;
|
|---|
| 58 | std::vector<molecule*> molecules = World::getInstance().getSelectedMolecules();
|
|---|
| 59 | if (params.periodic.get())
|
|---|
| 60 | correlationmap = PeriodicCorrelationToPoint(molecules, params.elements.get(), ¶ms.Point.get(), ranges);
|
|---|
| 61 | else
|
|---|
| 62 | correlationmap = CorrelationToPoint(molecules, params.elements.get(), ¶ms.Point.get());
|
|---|
| 63 | OutputCorrelationMap<CorrelationToPointMap>(&output, correlationmap, OutputCorrelationToPoint_Header, OutputCorrelationToPoint_Value);
|
|---|
| 64 | binmap = BinData( correlationmap, params.BinWidth.get(), params.BinStart.get(), params.BinEnd.get() );
|
|---|
| 65 | OutputCorrelationMap<BinPairMap> ( &binoutput, binmap, OutputCorrelation_Header, OutputCorrelation_Value );
|
|---|
| 66 | delete(binmap);
|
|---|
| 67 | delete(correlationmap);
|
|---|
| 68 | output.close();
|
|---|
| 69 | binoutput.close();
|
|---|
| 70 | return Action::success;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | Action::state_ptr AnalysisPointCorrelationAction::performUndo(Action::state_ptr _state) {
|
|---|
| 74 | return Action::success;
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | Action::state_ptr AnalysisPointCorrelationAction::performRedo(Action::state_ptr _state){
|
|---|
| 78 | return Action::success;
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | bool AnalysisPointCorrelationAction::canUndo() {
|
|---|
| 82 | return true;
|
|---|
| 83 | }
|
|---|
| 84 |
|
|---|
| 85 | bool AnalysisPointCorrelationAction::shouldUndo() {
|
|---|
| 86 | return true;
|
|---|
| 87 | }
|
|---|
| 88 | /** =========== end of function ====================== */
|
|---|