comparison Framework/Widgets/LayerWidget.h @ 247:3d523c9a8f0d am

trying to use boost::signals2 even more.
author am@osimis.io
date Mon, 02 Jul 2018 12:32:02 +0200
parents 26e3bfe30e66
children
comparison
equal deleted inserted replaced
246:5470b15f7cf2 247:3d523c9a8f0d
22 #pragma once 22 #pragma once
23 23
24 #include "WorldSceneWidget.h" 24 #include "WorldSceneWidget.h"
25 #include "../Layers/ILayerSource.h" 25 #include "../Layers/ILayerSource.h"
26 #include "../Toolbox/Extent2D.h" 26 #include "../Toolbox/Extent2D.h"
27 #include <boost/enable_shared_from_this.hpp>
27 28
28 #include <map> 29 #include <map>
29 30
30 namespace OrthancStone 31 namespace OrthancStone
31 { 32 {
32 class LayerWidget : 33 class LayerWidget :
33 public WorldSceneWidget, 34 public WorldSceneWidget,
34 private ILayerSource::IObserver 35 public ILayerSource::IObserver,
36 public boost::enable_shared_from_this<ILayerSource::IObserver>
37 //public boost::enable_shared_from_this<LayerWidget>
38
35 { 39 {
36 private: 40 private:
37 class Scene; 41 class Scene;
38 42
39 typedef std::map<const ILayerSource*, size_t> LayersIndex; 43 typedef std::map<const ILayerSource*, size_t> LayersIndex;
40 44
41 bool started_; 45 bool started_;
42 LayersIndex layersIndex_; 46 LayersIndex layersIndex_;
43 std::vector<ILayerSource*> layers_; 47 std::vector<boost::shared_ptr<ILayerSource>> layers_;
44 std::vector<RenderStyle> styles_; 48 std::vector<RenderStyle> styles_;
45 CoordinateSystem3D slice_; 49 CoordinateSystem3D slice_;
46 std::auto_ptr<Scene> currentScene_; 50 std::auto_ptr<Scene> currentScene_;
47 std::auto_ptr<Scene> pendingScene_; 51 std::auto_ptr<Scene> pendingScene_;
48 std::vector<bool> changedLayers_; 52 std::vector<bool> changedLayers_;
60 virtual void NotifyContentChange(const ILayerSource& source); 64 virtual void NotifyContentChange(const ILayerSource& source);
61 65
62 virtual void NotifySliceChange(const ILayerSource& source, 66 virtual void NotifySliceChange(const ILayerSource& source,
63 const Slice& slice); 67 const Slice& slice);
64 68
65 virtual void NotifyLayerReady(std::auto_ptr<ILayerRenderer>& renderer, 69 virtual void NotifyLayerReady(boost::shared_ptr<ILayerRenderer> renderer,
66 const ILayerSource& source, 70 const ILayerSource& source,
67 const CoordinateSystem3D& slice, 71 const CoordinateSystem3D& slice,
68 bool isError); 72 bool isError);
69 73
70 void ResetChangedLayers(); 74 void ResetChangedLayers();
77 const ViewportGeometry& view); 81 const ViewportGeometry& view);
78 82
79 void ResetPendingScene(); 83 void ResetPendingScene();
80 84
81 void UpdateLayer(size_t index, 85 void UpdateLayer(size_t index,
82 ILayerRenderer* renderer, 86 boost::shared_ptr<ILayerRenderer> renderer,
83 const CoordinateSystem3D& slice); 87 const CoordinateSystem3D& slice);
84 88
85 void InvalidateAllLayers(); 89 void InvalidateAllLayers();
86 90
87 void InvalidateLayer(size_t layer); 91 void InvalidateLayer(size_t layer);
89 public: 93 public:
90 LayerWidget(); 94 LayerWidget();
91 95
92 virtual ~LayerWidget(); 96 virtual ~LayerWidget();
93 97
94 size_t AddLayer(ILayerSource* layer); // Takes ownership 98 size_t AddLayer(boost::shared_ptr<ILayerSource> layer);
95 99
96 void ReplaceLayer(size_t layerIndex, ILayerSource* layer); // Takes ownership 100 void ReplaceLayer(size_t layerIndex, boost::shared_ptr<ILayerSource> layer); // Takes ownership
97 101
98 size_t GetLayerCount() const 102 size_t GetLayerCount() const
99 { 103 {
100 return layers_.size(); 104 return layers_.size();
101 } 105 }