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
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Affero General Public License for more details.
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 **/
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #pragma once
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "ISceneLayer.h"
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <map>
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 namespace OrthancStone
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 public:
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 class IVisitor : public boost::noncopyable
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 public:
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 virtual ~IVisitor()
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 }
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 int depth) = 0;
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 };
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
602
03c4b998fcd0 display scene positions in the basic sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 600
diff changeset
53 Content content_;
582
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 AffineTransform2D sceneToCanvas_;
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 Scene2D(const Scene2D& other);
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 }
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 ~Scene2D();
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 Scene2D* Clone() const
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 return new Scene2D(*this);
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 void SetLayer(int depth,
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 ISceneLayer* layer); // Takes ownership
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 void DeleteLayer(int depth);
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 const AffineTransform2D& GetSceneToCanvasTransform() const
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 return sceneToCanvas_;
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 }
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 const AffineTransform2D& GetCanvasToSceneTransform() const
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 return canvasToScene_;
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 void SetSceneToCanvasTransform(const AffineTransform2D& transform);
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 void FitContent(unsigned int canvasWidth,
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 unsigned int canvasHeight);
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 };
e36e69a380a5 Scene2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }