comparison Framework/Scene2DViewport/MeasureTools.h @ 703:d4d6c5b502b5

Merging refactor-viewport-controller
author Benjamin Golinvaux <bgo@osimis.io>
date Sun, 19 May 2019 16:31:56 +0200
parents 059e1fd05fd6
children 28b9e3a54200
comparison
equal deleted inserted replaced
696:75deb0acd632 703:d4d6c5b502b5
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-2019 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 <Framework/Scene2DViewport/PointerTypes.h>
24 #include <Framework/Scene2DViewport/ViewportController.h>
25
26 #include <Framework/Scene2D/Scene2D.h>
27 #include <Framework/Scene2D/ScenePoint2D.h>
28 #include <Framework/Scene2D/PolylineSceneLayer.h>
29 #include <Framework/Scene2D/TextSceneLayer.h>
30
31 #include <boost/shared_ptr.hpp>
32 #include <boost/weak_ptr.hpp>
33
34 #include <vector>
35 #include <cmath>
36
37 namespace OrthancStone
38 {
39 class MeasureTool : public IObserver
40 {
41 public:
42 virtual ~MeasureTool();
43
44 /**
45 Enabled tools are rendered in the scene.
46 */
47 void Enable();
48
49 /**
50 Disabled tools are not rendered in the scene. This is useful to be able
51 to use them as their own memento in command stacks (when a measure tool
52 creation command has been undone, the measure remains alive in the
53 command object but is disabled so that it can be redone later on easily)
54 */
55 void Disable();
56
57 /**
58 This method is called when the scene transform changes. It allows to
59 recompute the visual elements whose content depend upon the scene transform
60 */
61 void OnSceneTransformChanged(
62 const ViewportController::SceneTransformChanged& message);
63
64 protected:
65 MeasureTool(MessageBroker& broker, ViewportControllerWPtr controllerW);
66
67 /**
68 This is the meat of the tool: this method must [create (if needed) and]
69 update the layers and their data according to the measure tool kind and
70 current state. This is repeatedly called during user interaction
71 */
72 virtual void RefreshScene() = 0;
73
74 ViewportControllerPtr GetController();
75 Scene2DPtr GetScene();
76
77 /**
78 enabled_ is not accessible by subclasses because there is a state machine
79 that we do not wanna mess with
80 */
81 bool IsEnabled() const;
82
83 private:
84 ViewportControllerWPtr controllerW_;
85 bool enabled_;
86 };
87 }
88
89
90 extern void TrackerSample_SetInfoDisplayMessage(
91 std::string key, std::string value);