[a2ab15] | 1 | /*
|
---|
| 2 | * CommandLineWindow.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: May 8, 2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[112b09] | 8 | #include "Helpers/MemDebug.hpp"
|
---|
| 9 |
|
---|
[a2ab15] | 10 | #include <boost/bind.hpp>
|
---|
| 11 |
|
---|
[5079a0] | 12 | #include "CommandLineUI/CommandLineWindow.hpp"
|
---|
| 13 | #include "CommandLineUI/CommandLineStatusIndicator.hpp"
|
---|
[a2ab15] | 14 |
|
---|
[4380af] | 15 | #include "Actions/ActionRegistry.hpp"
|
---|
[97ebf8] | 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"
|
---|
[d893f79] | 25 | #include "Actions/CmdAction/HelpAction.hpp"
|
---|
[97ebf8] | 26 | #include "Actions/CmdAction/VerboseAction.hpp"
|
---|
[50dfda] | 27 | #include "Actions/CmdAction/VersionAction.hpp"
|
---|
[97ebf8] | 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"
|
---|
[d893f79] | 38 | #include "Actions/ParserAction/LoadXyzAction.hpp"
|
---|
| 39 | #include "Actions/ParserAction/SaveXyzAction.hpp"
|
---|
[97ebf8] | 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"
|
---|
[4380af] | 52 | #include "CommandLineParser.hpp"
|
---|
[d893f79] | 53 |
|
---|
[a2ab15] | 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
|
---|
[d893f79] | 59 | CommandLineWindow::CommandLineWindow()
|
---|
[a2ab15] | 60 | {
|
---|
[d893f79] | 61 | // create and register all command line callable actions
|
---|
[97ebf8] | 62 | populateAnalysisActions();
|
---|
[50dfda] | 63 | populateAtomActions();
|
---|
| 64 | populateCmdActions();
|
---|
| 65 | populateFragmentationActions();
|
---|
| 66 | populateMoleculeActions();
|
---|
[d893f79] | 67 | populateParserActions();
|
---|
[50dfda] | 68 | populateTesselationActions();
|
---|
[97ebf8] | 69 | populateWorldActions();
|
---|
[a2ab15] | 70 |
|
---|
| 71 | // Add status indicators etc...
|
---|
| 72 | statusIndicator = new CommandLineStatusIndicator();
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | CommandLineWindow::~CommandLineWindow()
|
---|
| 76 | {
|
---|
[0fb9f6] | 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 | // }
|
---|
[97ebf8] | 82 |
|
---|
[a2ab15] | 83 | delete statusIndicator;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | void CommandLineWindow::display() {
|
---|
[4380af] | 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 | }
|
---|
[a2ab15] | 94 | }
|
---|
[d893f79] | 95 |
|
---|
[97ebf8] | 96 | void CommandLineWindow::populateAnalysisActions()
|
---|
| 97 | {
|
---|
| 98 | new AnalysisPairCorrelationAction();
|
---|
| 99 | new AnalysisPairCorrelationToPointAction();
|
---|
| 100 | new AnalysisPairCorrelationToSurfaceAction();
|
---|
| 101 | }
|
---|
| 102 |
|
---|
[50dfda] | 103 | void CommandLineWindow::populateAtomActions()
|
---|
| 104 | {
|
---|
[97ebf8] | 105 | new AtomAddAction();
|
---|
| 106 | new AtomChangeElementAction();
|
---|
| 107 | new AtomRemoveAction();
|
---|
[50dfda] | 108 | }
|
---|
| 109 |
|
---|
| 110 | void CommandLineWindow::populateCmdActions()
|
---|
[d893f79] | 111 | {
|
---|
[97ebf8] | 112 | new CommandLineBondLengthTableAction();
|
---|
| 113 | new CommandLineElementDbAction();
|
---|
| 114 | new CommandLineFastParsingAction();
|
---|
[e3ecc1a] | 115 | new CommandLineHelpAction();
|
---|
[97ebf8] | 116 | new CommandLineVerboseAction();
|
---|
[50dfda] | 117 | new CommandLineVersionAction();
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | void CommandLineWindow::populateFragmentationActions()
|
---|
| 121 | {
|
---|
[97ebf8] | 122 | new FragmentationDepthFirstSearchAction();
|
---|
[50dfda] | 123 | }
|
---|
| 124 |
|
---|
| 125 | void CommandLineWindow::populateMoleculeActions()
|
---|
| 126 | {
|
---|
[97ebf8] | 127 | new MoleculeBondFileAction();
|
---|
| 128 | new MoleculeChangeNameAction();
|
---|
| 129 | new MoleculeFillWithMoleculeAction();
|
---|
| 130 | new MoleculeLinearInterpolationofTrajectoriesAction();
|
---|
| 131 | new MoleculeSaveAdjacencyAction();
|
---|
| 132 | new MoleculeSaveBondsAction();
|
---|
| 133 | new MoleculeSaveTemperatureAction();
|
---|
| 134 | new MoleculeVerletIntegrationAction();
|
---|
[50dfda] | 135 | }
|
---|
| 136 |
|
---|
| 137 | void CommandLineWindow::populateParserActions()
|
---|
| 138 | {
|
---|
[d893f79] | 139 | new ParserLoadXyzAction();
|
---|
| 140 | new ParserSaveXyzAction();
|
---|
| 141 | }
|
---|
| 142 |
|
---|
[50dfda] | 143 | void CommandLineWindow::populateTesselationActions()
|
---|
| 144 | {
|
---|
[97ebf8] | 145 | new TesselationConvexEnvelopeAction();
|
---|
| 146 | new TesselationNonConvexEnvelopeAction();
|
---|
[50dfda] | 147 | }
|
---|
| 148 |
|
---|
[97ebf8] | 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 | }
|
---|