Mercurial > hg > orthanc-stone
comparison Samples/Common/MeasureTools.h @ 632:500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
when calling it ==> BumpRevision has been added to base class
- Added some docs
= Added GetMinDepth + GetMaxDepth to Scene2D (to alleviate the need for app-
specific "Z depth registry" : clients may simply add a new layer on top or at
the bottom of the existing layer set.
- Added the line tracker measurement tools, commands and trackers. Generic base
classes + Line measure
- started work on the line measure handles
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Thu, 09 May 2019 10:41:31 +0200 |
parents | |
children | f939f449482c |
comparison
equal
deleted
inserted
replaced
618:0925b27e8750 | 632:500c3f70b6c2 |
---|---|
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 #pragma once | |
21 | |
22 #include <Framework/Scene2D/Scene2D.h> | |
23 #include <Framework/Scene2D/ScenePoint2D.h> | |
24 #include <Framework/Scene2D/PolylineSceneLayer.h> | |
25 #include <Framework/Scene2D/TextSceneLayer.h> | |
26 | |
27 #include <boost/shared_ptr.hpp> | |
28 | |
29 #include <vector> | |
30 #include <cmath> | |
31 | |
32 namespace OrthancStone | |
33 { | |
34 class MeasureTool | |
35 { | |
36 public: | |
37 virtual ~MeasureTool() {} | |
38 | |
39 /** | |
40 Enabled tools are rendered in the scene. | |
41 */ | |
42 void Enable(); | |
43 | |
44 /** | |
45 Disabled tools are not rendered in the scene. This is useful to be able | |
46 to use them as their own memento in command stacks (when a measure tool | |
47 creation command has been undone, the measure remains alive in the | |
48 command object but is disabled so that it can be redone later on easily) | |
49 */ | |
50 void Disable(); | |
51 | |
52 protected: | |
53 MeasureTool(Scene2D& scene) | |
54 : scene_(scene) | |
55 , enabled_(true) | |
56 { | |
57 } | |
58 | |
59 | |
60 | |
61 /** | |
62 This is the meat of the tool: this method must [create (if needed) and] | |
63 update the layers and their data according to the measure tool kind and | |
64 current state. This is repeatedly called during user interaction | |
65 */ | |
66 virtual void RefreshScene() = 0; | |
67 | |
68 | |
69 Scene2D& GetScene() | |
70 { | |
71 return scene_; | |
72 } | |
73 | |
74 /** | |
75 enabled_ is not accessible by subclasses because there is a state machine | |
76 that we do not wanna mess with | |
77 */ | |
78 bool IsEnabled() const | |
79 { | |
80 return enabled_; | |
81 } | |
82 | |
83 private: | |
84 Scene2D& scene_; | |
85 bool enabled_; | |
86 }; | |
87 | |
88 typedef boost::shared_ptr<MeasureTool> MeasureToolPtr; | |
89 | |
90 class LineMeasureTool : public MeasureTool | |
91 { | |
92 public: | |
93 LineMeasureTool(Scene2D& scene) | |
94 : MeasureTool(scene) | |
95 , layersCreated(false) | |
96 , polylineZIndex_(-1) | |
97 , textZIndex_(-1) | |
98 { | |
99 | |
100 } | |
101 | |
102 ~LineMeasureTool(); | |
103 | |
104 void SetStart(ScenePoint2D start); | |
105 void SetEnd(ScenePoint2D end); | |
106 void Set(ScenePoint2D start, ScenePoint2D end); | |
107 | |
108 private: | |
109 PolylineSceneLayer* GetPolylineLayer(); | |
110 TextSceneLayer* GetTextLayer(); | |
111 virtual void RefreshScene() ORTHANC_OVERRIDE; | |
112 void RemoveFromScene(); | |
113 | |
114 private: | |
115 ScenePoint2D start_; | |
116 ScenePoint2D end_; | |
117 bool layersCreated; | |
118 int polylineZIndex_; | |
119 int textZIndex_; | |
120 }; | |
121 | |
122 typedef boost::shared_ptr<LineMeasureTool> LineMeasureToolPtr; | |
123 typedef std::vector<MeasureToolPtr> MeasureToolList; | |
124 } | |
125 | |
126 |