Mercurial > hg > orthanc-stone
comparison Framework/Layers/ILayerSource.h @ 251:192e6e349e69 am-2
first usage of new message system (in SDL only)
author | am@osimis.io |
---|---|
date | Mon, 02 Jul 2018 18:13:46 +0200 |
parents | e2fe9352f240 |
children | 40b21c1f8b8d |
comparison
equal
deleted
inserted
replaced
250:5e642859267e | 251:192e6e349e69 |
---|---|
11 * | 11 * |
12 * This program is distributed in the hope that it will be useful, but | 12 * This program is distributed in the hope that it will be useful, but |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Affero General Public License for more details. | 15 * Affero General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Affero General Public License | 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/>. | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | 19 **/ |
20 | 20 |
21 | 21 |
22 #pragma once | 22 #pragma once |
23 | 23 |
24 #include "ILayerRenderer.h" | 24 #include "ILayerRenderer.h" |
25 #include "../Toolbox/Slice.h" | 25 #include "../Toolbox/Slice.h" |
26 #include "../../Framework/Messages/IObservable.h" | |
27 #include "../../Framework/Messages/IMessage.h" | |
26 | 28 |
27 namespace OrthancStone | 29 namespace OrthancStone |
28 { | 30 { |
29 class ILayerSource : public boost::noncopyable | 31 class ILayerSource : public boost::noncopyable, public IObservable |
30 { | 32 { |
31 public: | 33 public: |
32 class IObserver : public boost::noncopyable | 34 struct SliceChangedMessage : public IMessage |
33 { | 35 { |
34 public: | 36 const Slice& slice; |
35 virtual ~IObserver() | 37 SliceChangedMessage(const Slice& slice) |
38 : IMessage(MessageType_SliceChanged), | |
39 slice(slice) | |
36 { | 40 { |
37 } | 41 } |
42 }; | |
38 | 43 |
39 // Triggered as soon as the source has enough information to | 44 struct LayerReadyMessage : public IMessage |
40 // answer to "GetExtent()" | 45 { |
41 virtual void NotifyGeometryReady(const ILayerSource& source) = 0; | 46 std::auto_ptr<ILayerRenderer>& layer; |
42 | 47 const CoordinateSystem3D& slice; |
43 virtual void NotifyGeometryError(const ILayerSource& source) = 0; | 48 bool isError; |
44 | |
45 // Triggered if the content of several slices in the source | |
46 // volume has changed | |
47 virtual void NotifyContentChange(const ILayerSource& source) = 0; | |
48 | 49 |
49 // Triggered if the content of some individual slice in the | 50 LayerReadyMessage(std::auto_ptr<ILayerRenderer>& layer, |
50 // source volume has changed | 51 const CoordinateSystem3D& slice, |
51 virtual void NotifySliceChange(const ILayerSource& source, | 52 bool isError) // TODO Shouldn't this be separate as NotifyLayerError? |
52 const Slice& slice) = 0; | 53 : IMessage(MessageType_LayerReady), |
53 | 54 layer(layer), |
54 // The layer must be deleted by the observer that releases the | 55 slice(slice), |
55 // std::auto_ptr | 56 isError(isError) |
56 virtual void NotifyLayerReady(std::auto_ptr<ILayerRenderer>& layer, | 57 { |
57 const ILayerSource& source, | 58 } |
58 const CoordinateSystem3D& slice, | |
59 bool isError) = 0; // TODO Shouldn't this be separate as NotifyLayerError? | |
60 }; | 59 }; |
60 | |
61 // class IObserver : public boost::noncopyable | |
62 // { | |
63 // public: | |
64 // virtual ~IObserver() | |
65 // { | |
66 // } | |
67 | |
68 // // Triggered as soon as the source has enough information to | |
69 // // answer to "GetExtent()" | |
70 // virtual void NotifyGeometryReady(const ILayerSource& source) = 0; | |
71 | |
72 // virtual void NotifyGeometryError(const ILayerSource& source) = 0; | |
73 | |
74 // // Triggered if the content of several slices in the source | |
75 // // volume has changed | |
76 // virtual void NotifyContentChange(const ILayerSource& source) = 0; | |
77 | |
78 // // Triggered if the content of some individual slice in the | |
79 // // source volume has changed | |
80 // virtual void NotifySliceChange(const ILayerSource& source, | |
81 // const Slice& slice) = 0; | |
82 | |
83 // // The layer must be deleted by the observer that releases the | |
84 // // std::auto_ptr | |
85 // virtual void NotifyLayerReady(std::auto_ptr<ILayerRenderer>& layer, | |
86 // const ILayerSource& source, | |
87 // const CoordinateSystem3D& slice, | |
88 // bool isError) = 0; // TODO Shouldn't this be separate as NotifyLayerError? | |
89 // }; | |
61 | 90 |
91 ILayerSource(MessageBroker& broker) | |
92 : IObservable(broker) | |
93 {} | |
94 | |
62 virtual ~ILayerSource() | 95 virtual ~ILayerSource() |
63 { | 96 { |
64 } | 97 } |
65 | 98 |
66 virtual void Register(IObserver& observer) = 0; | 99 // virtual void Register(IObserver& observer) = 0; |
67 | 100 |
68 virtual bool GetExtent(std::vector<Vector>& points, | 101 virtual bool GetExtent(std::vector<Vector>& points, |
69 const CoordinateSystem3D& viewportSlice) = 0; | 102 const CoordinateSystem3D& viewportSlice) = 0; |
70 | 103 |
71 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) = 0; | 104 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) = 0; |