[97ebf8] | 1 | /*
|
---|
| 2 | * BondLengthTableAction.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: May 9, 2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #include "Actions/CmdAction/BondLengthTableAction.hpp"
|
---|
[a3fded] | 9 | #include "bondgraph.hpp"
|
---|
[97ebf8] | 10 | #include "config.hpp"
|
---|
| 11 | #include "log.hpp"
|
---|
| 12 | #include "verbose.hpp"
|
---|
| 13 | #include "World.hpp"
|
---|
| 14 |
|
---|
| 15 | #include <iostream>
|
---|
| 16 | #include <string>
|
---|
| 17 |
|
---|
| 18 | using namespace std;
|
---|
| 19 |
|
---|
| 20 | #include "UIElements/UIFactory.hpp"
|
---|
| 21 | #include "UIElements/Dialog.hpp"
|
---|
| 22 | #include "Actions/MapOfActions.hpp"
|
---|
| 23 |
|
---|
| 24 | const char CommandLineBondLengthTableAction::NAME[] = "bond-table";
|
---|
| 25 |
|
---|
| 26 | CommandLineBondLengthTableAction::CommandLineBondLengthTableAction() :
|
---|
| 27 | Action(NAME)
|
---|
| 28 | {}
|
---|
| 29 |
|
---|
| 30 | CommandLineBondLengthTableAction::~CommandLineBondLengthTableAction()
|
---|
| 31 | {}
|
---|
| 32 |
|
---|
| 33 | Action::state_ptr CommandLineBondLengthTableAction::performCall() {
|
---|
| 34 | ostringstream usage;
|
---|
| 35 | string BondGraphFileName;
|
---|
| 36 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
| 37 |
|
---|
| 38 | config *configuration = World::getInstance().getConfig();
|
---|
| 39 | dialog->queryString(NAME, &BondGraphFileName, MapOfActions::getInstance().getDescription(NAME));
|
---|
| 40 |
|
---|
| 41 | if(dialog->display()) {
|
---|
[39af9f] | 42 | DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl);
|
---|
[97ebf8] | 43 | delete dialog;
|
---|
| 44 | } else {
|
---|
| 45 | delete dialog;
|
---|
[39af9f] | 46 | return Action::failure;
|
---|
[97ebf8] | 47 | }
|
---|
| 48 |
|
---|
| 49 | if (configuration->BG == NULL) {
|
---|
| 50 | configuration->BG = new BondGraph(configuration->GetIsAngstroem());
|
---|
| 51 | if ((!BondGraphFileName.empty()) && (configuration->BG->LoadBondLengthTable(BondGraphFileName))) {
|
---|
| 52 | DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl);
|
---|
| 53 | return Action::success;
|
---|
| 54 | } else {
|
---|
| 55 | DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl);
|
---|
| 56 | return Action::failure;
|
---|
| 57 | }
|
---|
| 58 | } else {
|
---|
| 59 | DoLog(0) && (Log() << Verbose(0) << "Bond length table already present." << endl);
|
---|
| 60 | return Action::failure;
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | Action::state_ptr CommandLineBondLengthTableAction::performUndo(Action::state_ptr _state) {
|
---|
| 65 | // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
|
---|
| 66 |
|
---|
| 67 | return Action::failure;
|
---|
| 68 | // string newName = state->mol->getName();
|
---|
| 69 | // state->mol->setName(state->lastName);
|
---|
| 70 | //
|
---|
| 71 | // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | Action::state_ptr CommandLineBondLengthTableAction::performRedo(Action::state_ptr _state){
|
---|
| 75 | return Action::failure;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | bool CommandLineBondLengthTableAction::canUndo() {
|
---|
| 79 | return false;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | bool CommandLineBondLengthTableAction::shouldUndo() {
|
---|
| 83 | return false;
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | const string CommandLineBondLengthTableAction::getName() {
|
---|
| 87 | return NAME;
|
---|
| 88 | }
|
---|