Mercurial > hg > orthanc-stone
comparison Framework/Widgets/LayerWidget.h @ 66:298f375dcb68 wasm
LayerWidget
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 17 May 2017 22:03:09 +0200 |
parents | |
children | f5f54ed8d307 |
comparison
equal
deleted
inserted
replaced
65:885932a893de | 66:298f375dcb68 |
---|---|
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 Osimis, 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 "WorldSceneWidget.h" | |
25 #include "../Layers/ILayerSource.h" | |
26 | |
27 #include <map> | |
28 | |
29 namespace OrthancStone | |
30 { | |
31 class LayerWidget : | |
32 public WorldSceneWidget, | |
33 public ILayerSource::IObserver // TODO move this as PImpl | |
34 { | |
35 private: | |
36 class Scene; | |
37 | |
38 typedef std::map<ILayerSource*, size_t> LayersIndex; | |
39 | |
40 bool started_; | |
41 LayersIndex layersIndex_; | |
42 std::vector<ILayerSource*> layers_; | |
43 std::vector<RenderStyle> styles_; | |
44 SliceGeometry slice_; | |
45 double sliceThickness_; | |
46 std::auto_ptr<Scene> currentScene_; | |
47 std::auto_ptr<Scene> pendingScene_; | |
48 | |
49 | |
50 bool LookupLayer(size_t& index /* out */, | |
51 ILayerSource& layer) const; | |
52 | |
53 | |
54 protected: | |
55 virtual void GetSceneExtent(double& x1, | |
56 double& y1, | |
57 double& x2, | |
58 double& y2); | |
59 | |
60 virtual bool RenderScene(CairoContext& context, | |
61 const ViewportGeometry& view); | |
62 | |
63 void ResetPendingScene(); | |
64 | |
65 void UpdateLayer(size_t index, | |
66 ILayerRenderer* renderer, | |
67 const SliceGeometry& slice); | |
68 | |
69 public: | |
70 LayerWidget(); | |
71 | |
72 virtual ~LayerWidget(); | |
73 | |
74 size_t AddLayer(ILayerSource* layer); // Takes ownership | |
75 | |
76 void SetLayerStyle(size_t layer, | |
77 const RenderStyle& style); | |
78 | |
79 void SetSlice(const SliceGeometry& slice, | |
80 double sliceThickness); | |
81 | |
82 virtual void NotifyGeometryReady(ILayerSource& source); | |
83 | |
84 virtual void NotifySourceChange(ILayerSource& source); | |
85 | |
86 virtual void NotifySliceChange(ILayerSource& source, | |
87 const SliceGeometry& slice); | |
88 | |
89 virtual void NotifyLayerReady(ILayerRenderer* renderer, | |
90 ILayerSource& source, | |
91 const SliceGeometry& viewportSlice); | |
92 | |
93 virtual void NotifyLayerError(ILayerSource& source, | |
94 const SliceGeometry& viewportSlice); | |
95 | |
96 virtual void Start(); | |
97 }; | |
98 } |