Mercurial > hg > orthanc-stone
annotate Framework/Scene2D/Internals/CompositorHelper.h @ 848:80829436ce0c am-mainline
starting to re-implement radiography editor with latest framework
author | Alain Mazy <alain@mazy.be> |
---|---|
date | Thu, 13 Jun 2019 16:47:02 +0200 |
parents | 266e2b0b9abc |
children | 6176917ef890 |
rev | line source |
---|---|
585 | 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 | |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
24 #include "../Scene2D.h" |
848
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
25 #include "../ScenePoint2D.h" |
841
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
602
diff
changeset
|
26 #include <boost/noncopyable.hpp> |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
602
diff
changeset
|
27 |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
602
diff
changeset
|
28 #include <map> |
266e2b0b9abc
better error reporting in DicomStructureSetLoader + fixed POST request logic
Benjamin Golinvaux <bgo@osimis.io>
parents:
602
diff
changeset
|
29 |
585 | 30 namespace OrthancStone |
31 { | |
848
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
32 class ICompositor |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
33 { |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
34 public: |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
35 virtual unsigned int GetWidth() const = 0; |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
36 virtual unsigned int GetHeight() const = 0; |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
37 virtual void Refresh() = 0; |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
38 |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
39 ScenePoint2D GetPixelCenterCoordinates(int x, int y) const |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
40 { |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
41 return ScenePoint2D( |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
42 static_cast<double>(x) + 0.5 - static_cast<double>(GetWidth()) / 2.0, |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
43 static_cast<double>(y) + 0.5 - static_cast<double>(GetHeight()) / 2.0); |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
44 } |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
45 |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
46 }; |
80829436ce0c
starting to re-implement radiography editor with latest framework
Alain Mazy <alain@mazy.be>
parents:
841
diff
changeset
|
47 |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
48 namespace Internals |
585 | 49 { |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
50 class CompositorHelper : protected Scene2D::IVisitor |
585 | 51 { |
52 public: | |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
53 class ILayerRenderer : public boost::noncopyable |
585 | 54 { |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
55 public: |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
56 virtual ~ILayerRenderer() |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
57 { |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
58 } |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
59 |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
60 virtual void Render(const AffineTransform2D& transform) = 0; |
585 | 61 |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
62 // "Update()" is only called if the type of the layer has not changed |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
63 virtual void Update(const ISceneLayer& layer) = 0; |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
64 }; |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
65 |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
66 class IRendererFactory : public boost::noncopyable |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
67 { |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
68 public: |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
69 virtual ~IRendererFactory() |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
70 { |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
71 } |
585 | 72 |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
73 virtual ILayerRenderer* Create(const ISceneLayer& layer) = 0; |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
74 }; |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
75 |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
76 private: |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
77 class Item; |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
78 |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
79 typedef std::map<int, Item*> Content; |
585 | 80 |
600
6129b1e5ba42
BasicScene SDL sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
593
diff
changeset
|
81 const Scene2D& scene_; |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
82 IRendererFactory& factory_; |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
83 Content content_; |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
84 AffineTransform2D sceneTransform_; |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
85 |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
86 protected: |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
87 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
|
88 uint64_t layerIdentifier, |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
89 int depth); |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
90 |
585 | 91 public: |
600
6129b1e5ba42
BasicScene SDL sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
593
diff
changeset
|
92 CompositorHelper(const Scene2D& scene, |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
93 IRendererFactory& factory) : |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
94 scene_(scene), |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
95 factory_(factory) |
585 | 96 { |
97 } | |
98 | |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
99 ~CompositorHelper(); |
585 | 100 |
593
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
101 void Refresh(unsigned int canvasWidth, |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
102 unsigned int canvasHeight); |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
103 }; |
6bf8f881fcb5
OpenGLBasicPolylineRenderer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
585
diff
changeset
|
104 } |
585 | 105 } |