| 1 | /*
|
|---|
| 2 | * CommandLineWindow.cpp
|
|---|
| 3 | *
|
|---|
| 4 | * Created on: May 8, 2010
|
|---|
| 5 | * Author: heber
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #include "Helpers/MemDebug.hpp"
|
|---|
| 9 |
|
|---|
| 10 | #include <boost/bind.hpp>
|
|---|
| 11 |
|
|---|
| 12 | #include "CommandLineUI/CommandLineWindow.hpp"
|
|---|
| 13 | #include "CommandLineUI/CommandLineStatusIndicator.hpp"
|
|---|
| 14 |
|
|---|
| 15 | #include "Actions/ActionRegistry.hpp"
|
|---|
| 16 | #include "Actions/AnalysisAction/PairCorrelationAction.hpp"
|
|---|
| 17 | #include "Actions/AnalysisAction/PairCorrelationToPointAction.hpp"
|
|---|
| 18 | #include "Actions/AnalysisAction/PairCorrelationToSurfaceAction.hpp"
|
|---|
| 19 | #include "Actions/AtomAction/AddAction.hpp"
|
|---|
| 20 | #include "Actions/AtomAction/ChangeElementAction.hpp"
|
|---|
| 21 | #include "Actions/AtomAction/RemoveAction.hpp"
|
|---|
| 22 | #include "Actions/CmdAction/BondLengthTableAction.hpp"
|
|---|
| 23 | #include "Actions/CmdAction/ElementDbAction.hpp"
|
|---|
| 24 | #include "Actions/CmdAction/FastParsingAction.hpp"
|
|---|
| 25 | #include "Actions/CmdAction/HelpAction.hpp"
|
|---|
| 26 | #include "Actions/CmdAction/VerboseAction.hpp"
|
|---|
| 27 | #include "Actions/CmdAction/VersionAction.hpp"
|
|---|
| 28 | #include "Actions/FragmentationAction/DepthFirstSearchAction.hpp"
|
|---|
| 29 | #include "Actions/FragmentationAction/SubgraphDissectionAction.hpp"
|
|---|
| 30 | #include "Actions/MoleculeAction/BondFileAction.hpp"
|
|---|
| 31 | #include "Actions/MoleculeAction/ChangeNameAction.hpp"
|
|---|
| 32 | #include "Actions/MoleculeAction/FillWithMoleculeAction.hpp"
|
|---|
| 33 | #include "Actions/MoleculeAction/LinearInterpolationofTrajectoriesAction.hpp"
|
|---|
| 34 | #include "Actions/MoleculeAction/SaveAdjacencyAction.hpp"
|
|---|
| 35 | #include "Actions/MoleculeAction/SaveBondsAction.hpp"
|
|---|
| 36 | #include "Actions/MoleculeAction/SaveTemperatureAction.hpp"
|
|---|
| 37 | #include "Actions/MoleculeAction/VerletIntegrationAction.hpp"
|
|---|
| 38 | #include "Actions/ParserAction/LoadXyzAction.hpp"
|
|---|
| 39 | #include "Actions/ParserAction/SaveXyzAction.hpp"
|
|---|
| 40 | #include "Actions/TesselationAction/ConvexEnvelopeAction.hpp"
|
|---|
| 41 | #include "Actions/TesselationAction/NonConvexEnvelopeAction.hpp"
|
|---|
| 42 | #include "Actions/WorldAction/AddEmptyBoundaryAction.hpp"
|
|---|
| 43 | #include "Actions/WorldAction/BoundInBoxAction.hpp"
|
|---|
| 44 | #include "Actions/WorldAction/CenterInBoxAction.hpp"
|
|---|
| 45 | #include "Actions/WorldAction/CenterOnEdgeAction.hpp"
|
|---|
| 46 | #include "Actions/WorldAction/ChangeBoxAction.hpp"
|
|---|
| 47 | #include "Actions/WorldAction/RemoveSphereOfAtomsAction.hpp"
|
|---|
| 48 | #include "Actions/WorldAction/RepeatBoxAction.hpp"
|
|---|
| 49 | #include "Actions/WorldAction/ScaleBoxAction.hpp"
|
|---|
| 50 | #include "Actions/WorldAction/SetDefaultNameAction.hpp"
|
|---|
| 51 | #include "Actions/WorldAction/SetGaussianBasisAction.hpp"
|
|---|
| 52 | #include "CommandLineParser.hpp"
|
|---|
| 53 |
|
|---|
| 54 | #include <iostream>
|
|---|
| 55 |
|
|---|
| 56 | using namespace std;
|
|---|
| 57 |
|
|---|
| 58 | // TODO: see what code can be moved to a base class for Graphic and CommandLine Windows
|
|---|
| 59 | CommandLineWindow::CommandLineWindow()
|
|---|
| 60 | {
|
|---|
| 61 | // create and register all command line callable actions
|
|---|
| 62 | populateAnalysisActions();
|
|---|
| 63 | populateAtomActions();
|
|---|
| 64 | populateCmdActions();
|
|---|
| 65 | populateFragmentationActions();
|
|---|
| 66 | populateMoleculeActions();
|
|---|
| 67 | populateParserActions();
|
|---|
| 68 | populateTesselationActions();
|
|---|
| 69 | populateWorldActions();
|
|---|
| 70 |
|
|---|
| 71 | // Add status indicators etc...
|
|---|
| 72 | statusIndicator = new CommandLineStatusIndicator();
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | CommandLineWindow::~CommandLineWindow()
|
|---|
| 76 | {
|
|---|
| 77 | // // go through all possible actions
|
|---|
| 78 | // for(std::map<const std::string,Action*>::iterator ActionRunner = ActionRegistry::getInstance().getBeginIter(); ActionRegistry::getInstance().getBeginIter() != ActionRegistry::getInstance().getEndIter(); ActionRunner = ActionRegistry::getInstance().getBeginIter()) {
|
|---|
| 79 | // ActionRegistry::getInstance().unregisterAction(ActionRunner->second);
|
|---|
| 80 | // delete(ActionRunner->second);
|
|---|
| 81 | // }
|
|---|
| 82 |
|
|---|
| 83 | delete statusIndicator;
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | void CommandLineWindow::display() {
|
|---|
| 87 | // go through all possible actions
|
|---|
| 88 | for(std::map<const std::string,Action*>::iterator ActionRunner = ActionRegistry::getInstance().getBeginIter(); ActionRunner != ActionRegistry::getInstance().getEndIter(); ActionRunner++) {
|
|---|
| 89 | // check whether action is present in command line
|
|---|
| 90 | if (CommandLineParser::getInstance().vm.count(ActionRunner->first)) {
|
|---|
| 91 | ActionRunner->second->call();
|
|---|
| 92 | }
|
|---|
| 93 | }
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | void CommandLineWindow::populateAnalysisActions()
|
|---|
| 97 | {
|
|---|
| 98 | new AnalysisPairCorrelationAction();
|
|---|
| 99 | new AnalysisPairCorrelationToPointAction();
|
|---|
| 100 | new AnalysisPairCorrelationToSurfaceAction();
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | void CommandLineWindow::populateAtomActions()
|
|---|
| 104 | {
|
|---|
| 105 | new AtomAddAction();
|
|---|
| 106 | new AtomChangeElementAction();
|
|---|
| 107 | new AtomRemoveAction();
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | void CommandLineWindow::populateCmdActions()
|
|---|
| 111 | {
|
|---|
| 112 | new CommandLineBondLengthTableAction();
|
|---|
| 113 | new CommandLineElementDbAction();
|
|---|
| 114 | new CommandLineFastParsingAction();
|
|---|
| 115 | new CommandLineHelpAction();
|
|---|
| 116 | new CommandLineVerboseAction();
|
|---|
| 117 | new CommandLineVersionAction();
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | void CommandLineWindow::populateFragmentationActions()
|
|---|
| 121 | {
|
|---|
| 122 | new FragmentationDepthFirstSearchAction();
|
|---|
| 123 | }
|
|---|
| 124 |
|
|---|
| 125 | void CommandLineWindow::populateMoleculeActions()
|
|---|
| 126 | {
|
|---|
| 127 | new MoleculeBondFileAction();
|
|---|
| 128 | new MoleculeChangeNameAction();
|
|---|
| 129 | new MoleculeFillWithMoleculeAction();
|
|---|
| 130 | new MoleculeLinearInterpolationofTrajectoriesAction();
|
|---|
| 131 | new MoleculeSaveAdjacencyAction();
|
|---|
| 132 | new MoleculeSaveBondsAction();
|
|---|
| 133 | new MoleculeSaveTemperatureAction();
|
|---|
| 134 | new MoleculeVerletIntegrationAction();
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | void CommandLineWindow::populateParserActions()
|
|---|
| 138 | {
|
|---|
| 139 | new ParserLoadXyzAction();
|
|---|
| 140 | new ParserSaveXyzAction();
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | void CommandLineWindow::populateTesselationActions()
|
|---|
| 144 | {
|
|---|
| 145 | new TesselationConvexEnvelopeAction();
|
|---|
| 146 | new TesselationNonConvexEnvelopeAction();
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | void CommandLineWindow::populateWorldActions()
|
|---|
| 150 | {
|
|---|
| 151 | new WorldAddEmptyBoundaryAction();
|
|---|
| 152 | new WorldBoundInBoxAction();
|
|---|
| 153 | new WorldCenterInBoxAction();
|
|---|
| 154 | new WorldCenterOnEdgeAction();
|
|---|
| 155 | new WorldChangeBoxAction();
|
|---|
| 156 | new WorldRemoveSphereOfAtomsAction();
|
|---|
| 157 | new WorldRepeatBoxAction();
|
|---|
| 158 | new WorldScaleBoxAction();
|
|---|
| 159 | new WorldSetDefaultNameAction();
|
|---|
| 160 | new WorldSetGaussianBasisAction();
|
|---|
| 161 | }
|
|---|