comparison OrthancStone/Sources/Scene2DViewport/UndoStack.h @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Scene2DViewport/UndoStack.h@2d8ab34c8c91
children 4fb8fdf03314
comparison
equal deleted inserted replaced
1511:9dfeee74c1e6 1512:244ad1e4e76a
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21 #pragma once
22
23 #include <boost/shared_ptr.hpp>
24
25 #include <vector>
26
27 namespace OrthancStone
28 {
29 class MeasureCommand;
30
31 class UndoStack
32 {
33 public:
34 UndoStack();
35
36 /**
37 Stores a command :
38 - this first trims the undo stack to keep the first numAppliedCommands_
39 - then it adds the supplied command at the top of the undo stack
40
41 In other words, when a new command is pushed, all the undone (and not
42 redone) commands are removed.
43 */
44 void PushCommand(boost::shared_ptr<MeasureCommand> command);
45
46 /**
47 Undoes the command at the top of the undo stack, or throws if there is no
48 command to undo.
49 You can check "CanUndo" first to protect against extraneous redo.
50 */
51 void Undo();
52
53 /**
54 Redoes the command that is just above the last applied command in the undo
55 stack or throws if there is no command to redo.
56 You can check "CanRedo" first to protect against extraneous redo.
57 */
58 void Redo();
59
60 /** selfexpl */
61 bool CanUndo() const;
62
63 /** selfexpl */
64 bool CanRedo() const;
65
66 private:
67 std::vector<boost::shared_ptr<MeasureCommand> > commandStack_;
68
69 /**
70 This is always between >= 0 and <= undoStack_.size() and gives the
71 position where the controller is in the undo stack.
72 - If numAppliedCommands_ > 0, one can undo
73 - If numAppliedCommands_ < numAppliedCommands_.size(), one can redo
74 */
75 size_t numAppliedCommands_;
76 };
77 }