Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/Scene2D.h @ 1993:317a53d4fdc6
added magnifying glass
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 31 Oct 2022 22:19:57 +0100 |
parents | e8b9a2ba1df1 |
children | 07964689cb0b |
rev | line source |
---|---|
582 | 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 |
582 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
582 | 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
16 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
17 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
582 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #include "ISceneLayer.h" | |
27 #include "../Toolbox/AffineTransform2D.h" | |
736
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
700
diff
changeset
|
28 #include "../Messages/IObservable.h" |
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
700
diff
changeset
|
29 #include "../Messages/IMessage.h" |
654
462a5074f914
Turned the scene into an observable to be able to dynamically react to
Benjamin Golinvaux <bgo@osimis.io>
parents:
632
diff
changeset
|
30 |
582 | 31 #include <map> |
32 | |
33 namespace OrthancStone | |
34 { | |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
699
diff
changeset
|
35 class Scene2D : public boost::noncopyable |
582 | 36 { |
37 public: | |
38 class IVisitor : public boost::noncopyable | |
39 { | |
40 public: | |
41 virtual ~IVisitor() | |
42 { | |
43 } | |
44 | |
1211
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
45 virtual void Visit(const Scene2D& scene, |
d10d2acb8a02
compositors do not keep a reference to the scene anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
736
diff
changeset
|
46 const ISceneLayer& layer, |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
47 uint64_t layerIdentifier, |
582 | 48 int depth) = 0; |
49 }; | |
50 | |
51 private: | |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
52 class Item; |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
53 |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
54 typedef std::map<int, Item*> Content; |
582 | 55 |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
56 Content content_; |
582 | 57 AffineTransform2D sceneToCanvas_; |
58 AffineTransform2D canvasToScene_; | |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
59 uint64_t layerCounter_; |
582 | 60 |
61 Scene2D(const Scene2D& other); | |
62 | |
1989
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
63 void FitContent(const AffineTransform2D& forcedTransform, |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
64 unsigned int canvasWidth, |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
65 unsigned int canvasHeight); |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
66 |
582 | 67 public: |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
699
diff
changeset
|
68 Scene2D() : layerCounter_(0) |
582 | 69 { |
70 } | |
71 | |
72 ~Scene2D(); | |
73 | |
74 Scene2D* Clone() const | |
75 { | |
76 return new Scene2D(*this); | |
77 } | |
78 | |
1796
20a0aba0ede5
creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
79 ISceneLayer& SetLayer(int depth, |
20a0aba0ede5
creation of AnnotationsOverlay
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1739
diff
changeset
|
80 ISceneLayer* layer); // Takes ownership |
582 | 81 |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
82 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
83 Removes the layer at specified depth and deletes the underlying object |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
84 */ |
582 | 85 void DeleteLayer(int depth); |
86 | |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
87 bool HasLayer(int depth) const; |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
88 |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
89 ISceneLayer& GetLayer(int depth) const; |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
90 |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
91 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
92 Returns the minimum depth among all layers or 0 if there are no layers |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
93 */ |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
94 int GetMinDepth() const; |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
95 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
96 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
97 Returns the minimum depth among all layers or 0 if there are no layers |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
98 */ |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
99 int GetMaxDepth() const; |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
100 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
101 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
102 Removes the layer at specified depth and transfers the object |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
103 ownership to the caller |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
104 */ |
606
d9c0a66304cb
Scene2D::ReleaseLayer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
602
diff
changeset
|
105 ISceneLayer* ReleaseLayer(int depth); |
d9c0a66304cb
Scene2D::ReleaseLayer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
602
diff
changeset
|
106 |
600
6129b1e5ba42
BasicScene SDL sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
582
diff
changeset
|
107 void Apply(IVisitor& visitor) const; |
582 | 108 |
109 const AffineTransform2D& GetSceneToCanvasTransform() const | |
110 { | |
111 return sceneToCanvas_; | |
112 } | |
113 | |
114 const AffineTransform2D& GetCanvasToSceneTransform() const | |
115 { | |
116 return canvasToScene_; | |
117 } | |
118 | |
119 void SetSceneToCanvasTransform(const AffineTransform2D& transform); | |
120 | |
121 void FitContent(unsigned int canvasWidth, | |
122 unsigned int canvasHeight); | |
1374
1e4878ed1d77
added GetBoundingBox to Scene2D
Alain Mazy <alain@mazy.be>
parents:
1270
diff
changeset
|
123 |
1e4878ed1d77
added GetBoundingBox to Scene2D
Alain Mazy <alain@mazy.be>
parents:
1270
diff
changeset
|
124 void GetBoundingBox(Extent2D& target) const; |
1989
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
125 |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
126 void RotateViewport(double angle, |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
127 unsigned int canvasWidth, |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
128 unsigned int canvasHeight); |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
129 |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
130 void FlipViewportX(unsigned int canvasWidth, |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
131 unsigned int canvasHeight); |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
132 |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
133 void FlipViewportY(unsigned int canvasWidth, |
e8b9a2ba1df1
Added left/right rotation buttons
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1871
diff
changeset
|
134 unsigned int canvasHeight); |
582 | 135 }; |
136 } |