source: src/Actions/GraphAction/PrintSelectedAtomsAsGraphStringAction.cpp@ 91c409

Candidate_v1.7.0 stable
Last change on this file since 91c409 was 5061d9, checked in by Frederik Heber <frederik.heber@…>, 5 years ago

Added action to print selected atoms as graph6 string.

  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[5061d9]1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 *
6 *
7 * This file is part of MoleCuilder.
8 *
9 * MoleCuilder is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * MoleCuilder is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/*
24 * PrintSelectedAtomsAsGraphStringAction.cpp
25 *
26 * Created on: Apr 2, 2021
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35//#include "CodePatterns/MemDebug.hpp"
36
37#include "CodePatterns/Log.hpp"
38#include "CodePatterns/Verbose.hpp"
39#include "World.hpp"
40#include "Graph/Graph6Writer.hpp"
41
42#include <iostream>
43#include <string>
44
45#include "PrintSelectedAtomsAsGraphStringAction.hpp"
46
47using namespace MoleCuilder;
48
49// and construct the stuff
50#include "PrintSelectedAtomsAsGraphStringAction.def"
51#include "Action_impl_pre.hpp"
52/** =========== define the function ====================== */
53ActionState::ptr GraphPrintSelectedAtomsAsGraphStringAction::performCall() {
54 const std::vector<const atom *> atoms = const_cast<const World &>(World::getInstance()).getSelectedAtoms();
55 if (atoms.empty()) {
56 STATUS("No atoms have been selected to print as graph6 string.");
57
58 return Action::success;
59 } else {
60 Graph6Writer writer(World::getConstInstance().getSelectedAtoms());
61 {
62 std::stringstream output;
63 writer.write_graph6(output);
64 LOG(0, "Graph6: " << output.str());
65 }
66 {
67 std::stringstream output;
68 writer.write_elementlist(output);
69 LOG(0, "Elements over nodes: " << output.str());
70 }
71 return Action::success;
72 }
73}
74
75ActionState::ptr GraphPrintSelectedAtomsAsGraphStringAction::performUndo(ActionState::ptr _state) {
76 return Action::success;
77}
78
79ActionState::ptr GraphPrintSelectedAtomsAsGraphStringAction::performRedo(ActionState::ptr _state){
80 return Action::success;
81}
82
83bool GraphPrintSelectedAtomsAsGraphStringAction::canUndo() {
84 return true;
85}
86
87bool GraphPrintSelectedAtomsAsGraphStringAction::shouldUndo() {
88 return true;
89}
90/** =========== end of function ====================== */
Note: See TracBrowser for help on using the repository browser.