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