Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/AnnotationsSceneLayer.h @ 1879:b4486f43394a
reorganization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 Jan 2022 09:06:31 +0100 |
parents | 7053b8a0aaec |
children | 5a434f5889f8 |
rev | line source |
---|---|
1804 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1871
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
7053b8a0aaec
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1870
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
1804 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU Lesser General Public License | |
10 * as published by the Free Software Foundation, either version 3 of | |
11 * the License, or (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 * Lesser General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU Lesser General Public | |
19 * License along with this program. If not, see | |
20 * <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #include "../Messages/IObservable.h" | |
25 #include "Scene2D.h" | |
26 #include "../Scene2DViewport/IFlexiblePointerTracker.h" | |
27 | |
28 namespace OrthancStone | |
29 { | |
30 class AnnotationsSceneLayer : public IObservable | |
31 { | |
32 public: | |
33 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, AnnotationAddedMessage, AnnotationsSceneLayer); | |
34 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, AnnotationRemovedMessage, AnnotationsSceneLayer); | |
1809
79a5838739a6
starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1806
diff
changeset
|
35 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, AnnotationChangedMessage, AnnotationsSceneLayer); |
1804 | 36 |
37 enum Tool | |
38 { | |
39 Tool_Edit, | |
40 Tool_None, | |
41 Tool_Segment, | |
42 Tool_Angle, | |
43 Tool_Circle, | |
1809
79a5838739a6
starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1806
diff
changeset
|
44 Tool_Remove |
1804 | 45 }; |
1821
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1817
diff
changeset
|
46 |
1804 | 47 private: |
48 class GeometricPrimitive; | |
49 class Handle; | |
50 class Segment; | |
51 class Circle; | |
52 class Arc; | |
53 class Text; | |
54 | |
55 class Annotation; | |
56 class SegmentAnnotation; | |
57 class AngleAnnotation; | |
58 class CircleAnnotation; | |
59 | |
60 class EditPrimitiveTracker; | |
61 class CreateSegmentOrCircleTracker; | |
62 class CreateAngleTracker; | |
1809
79a5838739a6
starting the integration of AnnotationsSceneLayer into Stone Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1806
diff
changeset
|
63 class RemoveTracker; |
1804 | 64 |
65 typedef std::set<GeometricPrimitive*> GeometricPrimitives; | |
66 typedef std::set<Annotation*> Annotations; | |
67 typedef std::set<size_t> SubLayers; | |
68 | |
69 Tool activeTool_; | |
70 size_t macroLayerIndex_; | |
71 size_t polylineSubLayer_; | |
72 GeometricPrimitives primitives_; | |
73 Annotations annotations_; | |
74 SubLayers subLayersToRemove_; | |
1821
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1817
diff
changeset
|
75 Units units_; |
1804 | 76 |
77 void AddAnnotation(Annotation* annotation); | |
78 | |
79 void DeleteAnnotation(Annotation* annotation); | |
80 | |
81 void DeletePrimitive(GeometricPrimitive* primitive); | |
82 | |
83 void TagSubLayerToRemove(size_t subLayerIndex); | |
84 | |
85 public: | |
1817 | 86 explicit AnnotationsSceneLayer(size_t macroLayerIndex); |
1804 | 87 |
88 ~AnnotationsSceneLayer() | |
89 { | |
90 Clear(); | |
91 } | |
92 | |
93 void Clear(); | |
94 | |
95 void SetActiveTool(Tool tool) | |
96 { | |
97 activeTool_ = tool; | |
98 } | |
99 | |
100 Tool GetActiveTool() const | |
101 { | |
102 return activeTool_; | |
103 } | |
104 | |
1821
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1817
diff
changeset
|
105 void SetUnits(Units units); |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1817
diff
changeset
|
106 |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1817
diff
changeset
|
107 Units GetUnits() const |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1817
diff
changeset
|
108 { |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1817
diff
changeset
|
109 return units_; |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1817
diff
changeset
|
110 } |
36430d73e36c
introducing measure units in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1817
diff
changeset
|
111 |
1806
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
112 void AddSegmentAnnotation(const ScenePoint2D& p1, |
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
113 const ScenePoint2D& p2); |
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
114 |
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
115 void AddCircleAnnotation(const ScenePoint2D& p1, |
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
116 const ScenePoint2D& p2); |
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
117 |
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
118 void AddAngleAnnotation(const ScenePoint2D& p1, |
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
119 const ScenePoint2D& p2, |
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
120 const ScenePoint2D& p3); |
0840a25c6d41
removed hard-coded test in AnnotationsSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1804
diff
changeset
|
121 |
1804 | 122 void Render(Scene2D& scene); |
123 | |
124 bool ClearHover(); | |
125 | |
126 bool SetMouseHover(const ScenePoint2D& p /* expressed in canvas coordinates */, | |
127 const Scene2D& scene); | |
128 | |
129 IFlexiblePointerTracker* CreateTracker(const ScenePoint2D& p /* expressed in canvas coordinates */, | |
130 const Scene2D& scene); | |
131 | |
132 void Serialize(Json::Value& target) const; | |
133 | |
134 void Unserialize(const Json::Value& serialized); | |
135 }; | |
136 } |