[bcf653] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
| 4 | * Copyright (C) 2010 University of Bonn. All rights reserved.
|
---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[b9c847] | 8 | /*
|
---|
| 9 | * SetOutputFormatsAction.cpp
|
---|
| 10 | *
|
---|
| 11 | * Created on: May 8, 2010
|
---|
| 12 | * Author: heber
|
---|
| 13 | */
|
---|
| 14 |
|
---|
[bf3817] | 15 | // include config.h
|
---|
| 16 | #ifdef HAVE_CONFIG_H
|
---|
| 17 | #include <config.h>
|
---|
| 18 | #endif
|
---|
| 19 |
|
---|
[b9c847] | 20 | #include "Helpers/MemDebug.hpp"
|
---|
| 21 |
|
---|
| 22 | #include "Actions/WorldAction/SetOutputFormatsAction.hpp"
|
---|
[0430e3] | 23 | #include "Actions/ActionRegistry.hpp"
|
---|
[b9c847] | 24 | #include "Parser/ChangeTracker.hpp"
|
---|
| 25 | #include "Parser/FormatParserStorage.hpp"
|
---|
[952f38] | 26 | #include "Helpers/Log.hpp"
|
---|
| 27 | #include "Helpers/Verbose.hpp"
|
---|
[b9c847] | 28 | #include "World.hpp"
|
---|
| 29 |
|
---|
| 30 | #include <iostream>
|
---|
| 31 | #include <string>
|
---|
| 32 |
|
---|
| 33 | using namespace std;
|
---|
| 34 |
|
---|
| 35 | #include "UIElements/UIFactory.hpp"
|
---|
| 36 | #include "UIElements/Dialog.hpp"
|
---|
[861874] | 37 | #include "Actions/ValueStorage.hpp"
|
---|
[b9c847] | 38 |
|
---|
| 39 | const char WorldSetOutputFormatsAction::NAME[] = "set-output";
|
---|
| 40 |
|
---|
| 41 | WorldSetOutputFormatsAction::WorldSetOutputFormatsAction() :
|
---|
| 42 | Action(NAME)
|
---|
| 43 | {}
|
---|
| 44 |
|
---|
| 45 | WorldSetOutputFormatsAction::~WorldSetOutputFormatsAction()
|
---|
| 46 | {}
|
---|
| 47 |
|
---|
[a8f6ae] | 48 | void WorldSetOutputFormats(vector<std::string> &FormatList) {
|
---|
| 49 | ValueStorage::getInstance().setCurrentValue(WorldSetOutputFormatsAction::NAME, FormatList);
|
---|
| 50 | ActionRegistry::getInstance().getActionByName(WorldSetOutputFormatsAction::NAME)->call(Action::NonInteractive);
|
---|
| 51 | };
|
---|
| 52 |
|
---|
[0b2ce9] | 53 | void WorldSetOutputFormatsAction::getParametersfromValueStorage()
|
---|
| 54 | {};
|
---|
| 55 |
|
---|
[047878] | 56 | Dialog* WorldSetOutputFormatsAction::fillDialog(Dialog *dialog) {
|
---|
| 57 | ASSERT(dialog,"No Dialog given when filling action dialog");
|
---|
[ff22c5] | 58 |
|
---|
| 59 | dialog->queryStrings(NAME, ValueStorage::getInstance().getDescription(NAME));
|
---|
| 60 |
|
---|
| 61 | return dialog;
|
---|
| 62 | }
|
---|
| 63 |
|
---|
| 64 | Action::state_ptr WorldSetOutputFormatsAction::performCall() {
|
---|
[b9c847] | 65 | vector<std::string> FormatList;
|
---|
| 66 |
|
---|
[ff22c5] | 67 | ValueStorage::getInstance().queryCurrentValue(NAME, FormatList);
|
---|
| 68 |
|
---|
| 69 | for (vector<std::string>::iterator iter = FormatList.begin(); iter != FormatList.end(); ++iter) {
|
---|
| 70 | if (*iter == "mpqc") {
|
---|
| 71 | FormatParserStorage::getInstance().addMpqc();
|
---|
| 72 | DoLog(0) && (Log() << Verbose(0) << "Adding mpqc type to output." << endl);
|
---|
| 73 | } else if (*iter == "pcp") {
|
---|
| 74 | FormatParserStorage::getInstance().addPcp();
|
---|
| 75 | DoLog(0) && (Log() << Verbose(0) << "Adding pcp type to output." << endl);
|
---|
| 76 | } else if (*iter == "tremolo") {
|
---|
| 77 | FormatParserStorage::getInstance().addTremolo();
|
---|
| 78 | DoLog(0) && (Log() << Verbose(0) << "Adding tremolo type to output." << endl);
|
---|
| 79 | } else if (*iter == "xyz") {
|
---|
| 80 | FormatParserStorage::getInstance().addXyz();
|
---|
| 81 | DoLog(0) && (Log() << Verbose(0) << "Adding xyz type to output." << endl);
|
---|
| 82 | } else {
|
---|
[dde125] | 83 | DoeLog(1) && (eLog() << Verbose(1) << "Unknown format:" << *iter << endl);
|
---|
[b9c847] | 84 | }
|
---|
| 85 | }
|
---|
[ff22c5] | 86 | ChangeTracker::getInstance().saveStatus();
|
---|
| 87 | return Action::success;
|
---|
[b9c847] | 88 | }
|
---|
| 89 |
|
---|
| 90 | Action::state_ptr WorldSetOutputFormatsAction::performUndo(Action::state_ptr _state) {
|
---|
| 91 | // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
|
---|
| 92 |
|
---|
| 93 | return Action::failure;
|
---|
| 94 | // string newName = state->mol->getName();
|
---|
| 95 | // state->mol->setName(state->lastName);
|
---|
| 96 | //
|
---|
| 97 | // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | Action::state_ptr WorldSetOutputFormatsAction::performRedo(Action::state_ptr _state){
|
---|
| 101 | return Action::failure;
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | bool WorldSetOutputFormatsAction::canUndo() {
|
---|
| 105 | return false;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | bool WorldSetOutputFormatsAction::shouldUndo() {
|
---|
| 109 | return false;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | const string WorldSetOutputFormatsAction::getName() {
|
---|
| 113 | return NAME;
|
---|
| 114 | }
|
---|