Mercurial > hg > orthanc-stone
comparison Framework/Scene2DViewport/ViewportController.h @ 722:28b9e3a54200
Undo mechanism implemented (not connected to UI yet). Undo stack and measuring
tools are now handled by the ViewportController. Multi-touch does not crash
trackers anymore.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 21 May 2019 10:27:54 +0200 |
parents | af0aa0c149fa |
children | c0fcb2757b0a |
comparison
equal
deleted
inserted
replaced
721:af0aa0c149fa | 722:28b9e3a54200 |
---|---|
23 #include "PointerTypes.h" | 23 #include "PointerTypes.h" |
24 | 24 |
25 #include <Framework/Scene2D/Scene2D.h> | 25 #include <Framework/Scene2D/Scene2D.h> |
26 #include <Framework/Scene2D/PointerEvent.h> | 26 #include <Framework/Scene2D/PointerEvent.h> |
27 #include <Framework/Scene2DViewport/IFlexiblePointerTracker.h> | 27 #include <Framework/Scene2DViewport/IFlexiblePointerTracker.h> |
28 | |
29 #include <stack> | |
28 | 30 |
29 namespace OrthancStone | 31 namespace OrthancStone |
30 { | 32 { |
31 /** | 33 /** |
32 This object is responsible for hosting a scene, responding to messages from | 34 This object is responsible for hosting a scene, responding to messages from |
79 void SetSceneToCanvasTransform(const AffineTransform2D& transform); | 81 void SetSceneToCanvasTransform(const AffineTransform2D& transform); |
80 | 82 |
81 /** Forwarded to the underlying scene, and broadcasted to the observers */ | 83 /** Forwarded to the underlying scene, and broadcasted to the observers */ |
82 void FitContent(unsigned int canvasWidth, unsigned int canvasHeight); | 84 void FitContent(unsigned int canvasWidth, unsigned int canvasHeight); |
83 | 85 |
86 /** | |
87 Stores a command : | |
88 - this first trims the undo stack to keep the first numAppliedCommands_ | |
89 - then it adds the supplied command at the top of the undo stack | |
90 | |
91 In other words, when a new command is pushed, all the undone (and not | |
92 redone) commands are removed. | |
93 */ | |
94 void PushCommand(TrackerCommandPtr command); | |
95 | |
96 /** | |
97 Undoes the command at the top of the undo stack, or throws if there is no | |
98 command to undo. | |
99 You can check "CanUndo" first to protect against extraneous redo. | |
100 */ | |
101 void Undo(); | |
102 | |
103 /** | |
104 Redoes the command that is just above the last applied command in the undo | |
105 stack or throws if there is no command to redo. | |
106 You can check "CanRedo" first to protect against extraneous redo. | |
107 */ | |
108 void Redo(); | |
109 | |
110 /** selfexpl */ | |
111 bool CanUndo() const; | |
112 | |
113 /** selfexpl */ | |
114 bool CanRedo() const; | |
115 | |
116 /** Adds a new measure tool */ | |
117 void AddMeasureTool(MeasureToolPtr measureTool); | |
118 | |
119 /** Removes a measure tool or throws if it cannot be found */ | |
120 void RemoveMeasureTool(MeasureToolPtr measureTool); | |
121 | |
84 private: | 122 private: |
85 Scene2DPtr scene_; | 123 std::vector<TrackerCommandPtr> commandStack_; |
86 FlexiblePointerTrackerPtr tracker_; | 124 |
125 /** | |
126 This is always between >= 0 and <= undoStack_.size() and gives the | |
127 position where the controller is in the undo stack. | |
128 - If numAppliedCommands_ > 0, one can undo | |
129 - If numAppliedCommands_ < numAppliedCommands_.size(), one can redo | |
130 */ | |
131 size_t numAppliedCommands_; | |
132 std::vector<MeasureToolPtr> measureTools_; | |
133 Scene2DPtr scene_; | |
134 FlexiblePointerTrackerPtr tracker_; | |
87 }; | 135 }; |
88 } | 136 } |