comparison OrthancStone/Sources/Scene2D/Scene2D.h @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Scene2D/Scene2D.h@6ea4062c1a0d
children 4fb8fdf03314
comparison
equal deleted inserted replaced
1511:9dfeee74c1e6 1512:244ad1e4e76a
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-2020 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
22 #pragma once
23
24 #include "ISceneLayer.h"
25 #include "../Toolbox/AffineTransform2D.h"
26 #include "../Messages/IObservable.h"
27 #include "../Messages/IMessage.h"
28
29 #include <map>
30
31 namespace OrthancStone
32 {
33 class Scene2D : public boost::noncopyable
34 {
35 public:
36 class IVisitor : public boost::noncopyable
37 {
38 public:
39 virtual ~IVisitor()
40 {
41 }
42
43 virtual void Visit(const Scene2D& scene,
44 const ISceneLayer& layer,
45 uint64_t layerIdentifier,
46 int depth) = 0;
47 };
48
49 private:
50 class Item;
51
52 typedef std::map<int, Item*> Content;
53
54 Content content_;
55 AffineTransform2D sceneToCanvas_;
56 AffineTransform2D canvasToScene_;
57 uint64_t layerCounter_;
58
59 Scene2D(const Scene2D& other);
60
61 public:
62 Scene2D() : layerCounter_(0)
63 {
64 }
65
66 ~Scene2D();
67
68 Scene2D* Clone() const
69 {
70 return new Scene2D(*this);
71 }
72
73 void SetLayer(int depth,
74 ISceneLayer* layer); // Takes ownership
75
76 /**
77 Removes the layer at specified depth and deletes the underlying object
78 */
79 void DeleteLayer(int depth);
80
81 bool HasLayer(int depth) const;
82
83 ISceneLayer& GetLayer(int depth) const;
84
85 /**
86 Returns the minimum depth among all layers or 0 if there are no layers
87 */
88 int GetMinDepth() const;
89
90 /**
91 Returns the minimum depth among all layers or 0 if there are no layers
92 */
93 int GetMaxDepth() const;
94
95 /**
96 Removes the layer at specified depth and transfers the object
97 ownership to the caller
98 */
99 ISceneLayer* ReleaseLayer(int depth);
100
101 void Apply(IVisitor& visitor) const;
102
103 const AffineTransform2D& GetSceneToCanvasTransform() const
104 {
105 return sceneToCanvas_;
106 }
107
108 const AffineTransform2D& GetCanvasToSceneTransform() const
109 {
110 return canvasToScene_;
111 }
112
113 void SetSceneToCanvasTransform(const AffineTransform2D& transform);
114
115 void FitContent(unsigned int canvasWidth,
116 unsigned int canvasHeight);
117
118 void GetBoundingBox(Extent2D& target) const;
119 };
120 }