/* * Project: MoleCuilder * Description: creates and alters molecular systems * Copyright (C) 2010 University of Bonn. All rights reserved. * Please see the LICENSE file or "Copyright notice" in builder.cpp for details. */ /* * BondLengthTableAction.cpp * * Created on: May 9, 2010 * Author: heber */ // include config.h #ifdef HAVE_CONFIG_H #include #endif #include "Helpers/MemDebug.hpp" #include "Actions/CommandAction/BondLengthTableAction.hpp" #include "Actions/ActionRegistry.hpp" #include "bondgraph.hpp" #include "config.hpp" #include "Helpers/Log.hpp" #include "Helpers/Verbose.hpp" #include "World.hpp" #include #include using namespace std; #include "UIElements/UIFactory.hpp" #include "UIElements/Dialog.hpp" #include "Actions/ValueStorage.hpp" const char CommandBondLengthTableAction::NAME[] = "bond-table"; CommandBondLengthTableAction::CommandBondLengthTableAction() : Action(NAME) {} CommandBondLengthTableAction::~CommandBondLengthTableAction() {} void CommandBondLengthTable(std::string &BondGraphFileName) { ValueStorage::getInstance().setCurrentValue(CommandBondLengthTableAction::NAME, BondGraphFileName); ActionRegistry::getInstance().getActionByName(CommandBondLengthTableAction::NAME)->call(Action::NonInteractive); }; void CommandBondLengthTableAction::getParametersfromValueStorage() {}; Dialog* CommandBondLengthTableAction::fillDialog(Dialog *dialog) { ASSERT(dialog,"No Dialog given when filling action dialog"); dialog->queryString(NAME, ValueStorage::getInstance().getDescription(NAME)); return dialog; } Action::state_ptr CommandBondLengthTableAction::performCall() { ostringstream usage; string BondGraphFileName; ValueStorage::getInstance().queryCurrentValue(NAME, BondGraphFileName); DoLog(0) && (Log() << Verbose(0) << "Using " << BondGraphFileName << " as bond length table." << endl); config *configuration = World::getInstance().getConfig(); if (configuration->BG == NULL) { configuration->BG = new BondGraph(configuration->GetIsAngstroem()); if ((!BondGraphFileName.empty()) && (configuration->BG->LoadBondLengthTable(BondGraphFileName))) { DoLog(0) && (Log() << Verbose(0) << "Bond length table loaded successfully." << endl); return Action::success; } else { DoeLog(1) && (eLog()<< Verbose(1) << "Bond length table loading failed." << endl); return Action::failure; } } else { DoLog(0) && (Log() << Verbose(0) << "Bond length table already present." << endl); return Action::failure; } } Action::state_ptr CommandBondLengthTableAction::performUndo(Action::state_ptr _state) { // ParserLoadXyzState *state = assert_cast(_state.get()); return Action::failure; // string newName = state->mol->getName(); // state->mol->setName(state->lastName); // // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); } Action::state_ptr CommandBondLengthTableAction::performRedo(Action::state_ptr _state){ return Action::failure; } bool CommandBondLengthTableAction::canUndo() { return false; } bool CommandBondLengthTableAction::shouldUndo() { return false; } const string CommandBondLengthTableAction::getName() { return NAME; }