Mercurial > hg > orthanc-stone
comparison Framework/Widgets/SliceViewerWidget.h @ 388:20f149669c1f
renamed LayerWidget as SliceViewerWidget
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 09 Nov 2018 17:26:39 +0100 |
parents | Framework/Widgets/LayerWidget.h@e33659decec5 |
children | 17d54c028805 |
comparison
equal
deleted
inserted
replaced
387:a8b5cf760473 | 388:20f149669c1f |
---|---|
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-2018 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 "WorldSceneWidget.h" | |
25 #include "../Layers/ILayerSource.h" | |
26 #include "../Toolbox/Extent2D.h" | |
27 #include "../../Framework/Messages/IObserver.h" | |
28 | |
29 #include <map> | |
30 | |
31 namespace OrthancStone | |
32 { | |
33 class SliceViewerWidget : | |
34 public WorldSceneWidget, | |
35 public IObserver, | |
36 public IObservable | |
37 { | |
38 public: | |
39 typedef OriginMessage<MessageType_Widget_GeometryChanged, SliceViewerWidget> GeometryChangedMessage; | |
40 typedef OriginMessage<MessageType_Widget_ContentChanged, SliceViewerWidget> ContentChangedMessage; | |
41 | |
42 private: | |
43 class Scene; | |
44 | |
45 typedef std::map<const ILayerSource*, size_t> LayersIndex; | |
46 | |
47 bool started_; | |
48 LayersIndex layersIndex_; | |
49 std::vector<ILayerSource*> layers_; | |
50 std::vector<RenderStyle> styles_; | |
51 CoordinateSystem3D slice_; | |
52 std::auto_ptr<Scene> currentScene_; | |
53 std::auto_ptr<Scene> pendingScene_; | |
54 std::vector<bool> changedLayers_; | |
55 | |
56 bool LookupLayer(size_t& index /* out */, | |
57 const ILayerSource& layer) const; | |
58 | |
59 void GetLayerExtent(Extent2D& extent, | |
60 ILayerSource& source) const; | |
61 | |
62 void OnGeometryReady(const ILayerSource::GeometryReadyMessage& message); | |
63 | |
64 virtual void OnContentChanged(const ILayerSource::ContentChangedMessage& message); | |
65 | |
66 virtual void OnSliceChanged(const ILayerSource::SliceChangedMessage& message); | |
67 | |
68 virtual void OnLayerReady(const ILayerSource::LayerReadyMessage& message); | |
69 | |
70 virtual void OnLayerError(const ILayerSource::LayerErrorMessage& message); | |
71 | |
72 void ObserveLayer(ILayerSource& source); | |
73 | |
74 void ResetChangedLayers(); | |
75 | |
76 public: | |
77 SliceViewerWidget(MessageBroker& broker, | |
78 const std::string& name); | |
79 | |
80 virtual Extent2D GetSceneExtent(); | |
81 | |
82 protected: | |
83 virtual bool RenderScene(CairoContext& context, | |
84 const ViewportGeometry& view); | |
85 | |
86 void ResetPendingScene(); | |
87 | |
88 void UpdateLayer(size_t index, | |
89 ILayerRenderer* renderer, | |
90 const CoordinateSystem3D& slice); | |
91 | |
92 void InvalidateAllLayers(); | |
93 | |
94 void InvalidateLayer(size_t layer); | |
95 | |
96 public: | |
97 virtual ~SliceViewerWidget(); | |
98 | |
99 size_t AddLayer(ILayerSource* layer); // Takes ownership | |
100 | |
101 void ReplaceLayer(size_t layerIndex, ILayerSource* layer); // Takes ownership | |
102 | |
103 void RemoveLayer(size_t layerIndex); | |
104 | |
105 size_t GetLayerCount() const | |
106 { | |
107 return layers_.size(); | |
108 } | |
109 | |
110 const RenderStyle& GetLayerStyle(size_t layer) const; | |
111 | |
112 void SetLayerStyle(size_t layer, | |
113 const RenderStyle& style); | |
114 | |
115 void SetSlice(const CoordinateSystem3D& slice); | |
116 | |
117 const CoordinateSystem3D& GetSlice() const | |
118 { | |
119 return slice_; | |
120 } | |
121 | |
122 virtual bool HasAnimation() const | |
123 { | |
124 return true; | |
125 } | |
126 | |
127 virtual void DoAnimation(); | |
128 }; | |
129 } |