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