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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
582
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "ISceneLayer.h"
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include <map>
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 namespace OrthancStone
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 public:
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 class IVisitor : public boost::noncopyable
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 public:
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 virtual ~IVisitor()
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 }
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 int depth) = 0;
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 };
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 600
diff changeset
56 Content content_;
582
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 AffineTransform2D sceneToCanvas_;
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 Scene2D(const Scene2D& other);
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 }
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ~Scene2D();
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 Scene2D* Clone() const
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 return new Scene2D(*this);
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 }
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 void DeleteLayer(int depth);
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 const AffineTransform2D& GetSceneToCanvasTransform() const
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 return sceneToCanvas_;
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 const AffineTransform2D& GetCanvasToSceneTransform() const
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 return canvasToScene_;
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 void SetSceneToCanvasTransform(const AffineTransform2D& transform);
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 void FitContent(unsigned int canvasWidth,
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 };
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }