Mercurial > hg > orthanc-stone
annotate Framework/Widgets/LayerWidget.h @ 284:38b0ac8055b9 am-2
Qt: catch and forward keyboard events
author | am@osimis.io |
---|---|
date | Tue, 28 Aug 2018 11:09:37 +0200 |
parents | f21ba2468570 |
children | 3897f9f28cfa |
rev | line source |
---|---|
66 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
135
e2fe9352f240
upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
121
diff
changeset
|
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium |
66 | 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. | |
267 | 16 * |
66 | 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 "WorldSceneWidget.h" | |
25 #include "../Layers/ILayerSource.h" | |
111
7665ccbf33db
rename Extent as Extent2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
26 #include "../Toolbox/Extent2D.h" |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
27 #include "../../Framework/Messages/IObserver.h" |
66 | 28 |
29 #include <map> | |
30 | |
31 namespace OrthancStone | |
32 { | |
33 class LayerWidget : | |
267 | 34 public WorldSceneWidget, |
35 public IObserver, | |
36 public IObservable | |
66 | 37 { |
38 private: | |
39 class Scene; | |
40 | |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
41 typedef std::map<const ILayerSource*, size_t> LayersIndex; |
66 | 42 |
43 bool started_; | |
44 LayersIndex layersIndex_; | |
45 std::vector<ILayerSource*> layers_; | |
46 std::vector<RenderStyle> styles_; | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
109
diff
changeset
|
47 CoordinateSystem3D slice_; |
66 | 48 std::auto_ptr<Scene> currentScene_; |
49 std::auto_ptr<Scene> pendingScene_; | |
103 | 50 std::vector<bool> changedLayers_; |
66 | 51 |
52 bool LookupLayer(size_t& index /* out */, | |
87
4a541cd4fa83
OrthancVolumeImageLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
86
diff
changeset
|
53 const ILayerSource& layer) const; |
85 | 54 |
111
7665ccbf33db
rename Extent as Extent2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
55 void GetLayerExtent(Extent2D& extent, |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
56 ILayerSource& source) const; |
77 | 57 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
58 void OnGeometryReady(const ILayerSource& source); |
90
64e60018943f
fix and observer refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
89
diff
changeset
|
59 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
60 virtual void OnContentChanged(const ILayerSource& source); |
77 | 61 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
62 virtual void OnSliceChanged(const ILayerSource& source, |
267 | 63 const Slice& slice); |
77 | 64 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
65 virtual void OnLayerReady(std::auto_ptr<ILayerRenderer>& renderer, |
267 | 66 const ILayerSource& source, |
67 const CoordinateSystem3D& slice, | |
68 bool isError); | |
77 | 69 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
70 |
103 | 71 void ResetChangedLayers(); |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
111
diff
changeset
|
72 |
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
111
diff
changeset
|
73 public: |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
268
diff
changeset
|
74 LayerWidget(MessageBroker& broker, const std::string& name); |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
75 |
268
5bd4161bf11b
removed constness of the observable when emitting a message
am@osimis.io
parents:
267
diff
changeset
|
76 virtual void HandleMessage(IObservable& from, const IMessage& message); |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
219
diff
changeset
|
77 |
111
7665ccbf33db
rename Extent as Extent2D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
110
diff
changeset
|
78 virtual Extent2D GetSceneExtent(); |
267 | 79 |
112
948f86e61e83
start of SliceLocationSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
111
diff
changeset
|
80 protected: |
66 | 81 virtual bool RenderScene(CairoContext& context, |
82 const ViewportGeometry& view); | |
83 | |
84 void ResetPendingScene(); | |
85 | |
86 void UpdateLayer(size_t index, | |
87 ILayerRenderer* renderer, | |
121
e66b2c757790
displaying rt-struct
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
119
diff
changeset
|
88 const CoordinateSystem3D& slice); |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
89 |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
90 void InvalidateAllLayers(); |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
91 |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
92 void InvalidateLayer(size_t layer); |
66 | 93 |
94 public: | |
271
46c5296d867e
OracleWebService and BasicSdlApplicationContext using the same global mutex
am@osimis.io
parents:
268
diff
changeset
|
95 virtual ~LayerWidget(); |
66 | 96 |
97 size_t AddLayer(ILayerSource* layer); // Takes ownership | |
98 | |
219 | 99 void ReplaceLayer(size_t layerIndex, ILayerSource* layer); // Takes ownership |
100 | |
89
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
101 size_t GetLayerCount() const |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
102 { |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
103 return layers_.size(); |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
104 } |
f244018a4e4b
BUGGY- trying to remove IVolumeSlicesObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
105 |
119
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
106 const RenderStyle& GetLayerStyle(size_t layer) const; |
ba83e38cf3ff
rendering of rt-dose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
112
diff
changeset
|
107 |
66 | 108 void SetLayerStyle(size_t layer, |
109 const RenderStyle& style); | |
110 | |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
109
diff
changeset
|
111 void SetSlice(const CoordinateSystem3D& slice); |
66 | 112 |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
109
diff
changeset
|
113 const CoordinateSystem3D& GetSlice() const |
85 | 114 { |
115 return slice_; | |
116 } | |
103 | 117 |
118 virtual bool HasUpdateContent() const | |
119 { | |
120 return true; | |
121 } | |
122 | |
123 virtual void UpdateContent(); | |
66 | 124 }; |
125 } |