Mercurial > hg > orthanc-stone
annotate Framework/Scene2D/Scene2D.h @ 891:0aff28f15ea2
new abstraction: IViewport
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Jul 2019 18:18:42 +0200 |
parents | c0fcb2757b0a |
children | d10d2acb8a02 2d8ab34c8c91 |
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 | |
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 | |
21 | |
22 #pragma once | |
23 | |
24 #include "ISceneLayer.h" | |
25 #include "../Toolbox/AffineTransform2D.h" | |
736
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
700
diff
changeset
|
26 #include "../Messages/IObservable.h" |
c0fcb2757b0a
enforce relative includes
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
700
diff
changeset
|
27 #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
|
28 |
582 | 29 #include <map> |
30 | |
31 namespace OrthancStone | |
32 { | |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
699
diff
changeset
|
33 class Scene2D : public boost::noncopyable |
582 | 34 { |
35 public: | |
36 class IVisitor : public boost::noncopyable | |
37 { | |
38 public: | |
39 virtual ~IVisitor() | |
40 { | |
41 } | |
42 | |
43 virtual void Visit(const ISceneLayer& layer, | |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
44 uint64_t layerIdentifier, |
582 | 45 int depth) = 0; |
46 }; | |
47 | |
48 private: | |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
49 class Item; |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
50 |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
51 typedef std::map<int, Item*> Content; |
582 | 52 |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
53 Content content_; |
582 | 54 AffineTransform2D sceneToCanvas_; |
55 AffineTransform2D canvasToScene_; | |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
56 uint64_t layerCounter_; |
582 | 57 |
58 Scene2D(const Scene2D& other); | |
59 | |
60 public: | |
700
059e1fd05fd6
Introduced the ViewportController that sits between the application and the
Benjamin Golinvaux <bgo@osimis.io>
parents:
699
diff
changeset
|
61 Scene2D() : layerCounter_(0) |
582 | 62 { |
63 } | |
64 | |
65 ~Scene2D(); | |
66 | |
67 Scene2D* Clone() const | |
68 { | |
69 return new Scene2D(*this); | |
70 } | |
71 | |
72 void SetLayer(int depth, | |
73 ISceneLayer* layer); // Takes ownership | |
74 | |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
75 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
76 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
|
77 */ |
582 | 78 void DeleteLayer(int depth); |
79 | |
602
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
80 bool HasLayer(int depth) const; |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
81 |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
82 ISceneLayer& GetLayer(int depth) const; |
03c4b998fcd0
display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
600
diff
changeset
|
83 |
632
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
84 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
85 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
|
86 */ |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
87 int GetMinDepth() const; |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
88 |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
89 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
90 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
|
91 */ |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
92 int GetMaxDepth() const; |
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 /** |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
95 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
|
96 ownership to the caller |
500c3f70b6c2
- Added a ClearAllChains method to PolylineSceneLayer --> revision must change
Benjamin Golinvaux <bgo@osimis.io>
parents:
606
diff
changeset
|
97 */ |
606
d9c0a66304cb
Scene2D::ReleaseLayer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
602
diff
changeset
|
98 ISceneLayer* ReleaseLayer(int depth); |
d9c0a66304cb
Scene2D::ReleaseLayer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
602
diff
changeset
|
99 |
600
6129b1e5ba42
BasicScene SDL sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
582
diff
changeset
|
100 void Apply(IVisitor& visitor) const; |
582 | 101 |
102 const AffineTransform2D& GetSceneToCanvasTransform() const | |
103 { | |
104 return sceneToCanvas_; | |
105 } | |
106 | |
107 const AffineTransform2D& GetCanvasToSceneTransform() const | |
108 { | |
109 return canvasToScene_; | |
110 } | |
111 | |
112 void SetSceneToCanvasTransform(const AffineTransform2D& transform); | |
113 | |
114 void FitContent(unsigned int canvasWidth, | |
115 unsigned int canvasHeight); | |
116 }; | |
117 } |