Mercurial > hg > orthanc-stone
annotate Framework/Layers/ILayerSource.h @ 253:8ff70c04c6df am-2
IObservable/IObserver now working in WASM too
author | am@osimis.io |
---|---|
date | Tue, 03 Jul 2018 10:48:47 +0200 |
parents | 40b21c1f8b8d |
children | 89d02de83c03 |
rev | line source |
---|---|
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Stone of Orthanc |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
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 |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
16 * |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 **/ |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 #pragma once |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "ILayerRenderer.h" |
77 | 25 #include "../Toolbox/Slice.h" |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
26 #include "../../Framework/Messages/IObservable.h" |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
27 #include "../../Framework/Messages/IMessage.h" |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 namespace OrthancStone |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
252 | 31 class ILayerSource : public IObservable |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 { |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 public: |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
34 struct SliceChangedMessage : public IMessage |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
35 { |
252 | 36 const Slice& slice_; |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
37 SliceChangedMessage(const Slice& slice) |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
38 : IMessage(MessageType_SliceChanged), |
252 | 39 slice_(slice) |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
40 { |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
41 } |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
42 }; |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
43 |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
44 struct LayerReadyMessage : public IMessage |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
252 | 46 std::auto_ptr<ILayerRenderer>& layer_; |
47 const CoordinateSystem3D& slice_; | |
48 bool isError_; | |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
49 |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
50 LayerReadyMessage(std::auto_ptr<ILayerRenderer>& layer, |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
51 const CoordinateSystem3D& slice, |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
52 bool isError) // TODO Shouldn't this be separate as NotifyLayerError? |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
53 : IMessage(MessageType_LayerReady), |
252 | 54 layer_(layer), |
55 slice_(slice), | |
56 isError_(isError) | |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 { |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 } |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
59 }; |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
61 // class IObserver : public boost::noncopyable |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
62 // { |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
63 // public: |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
64 // virtual ~IObserver() |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
65 // { |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
66 // } |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
67 |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
68 // // Triggered as soon as the source has enough information to |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
69 // // answer to "GetExtent()" |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
70 // virtual void NotifyGeometryReady(const ILayerSource& source) = 0; |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
71 |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
72 // virtual void NotifyGeometryError(const ILayerSource& source) = 0; |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
74 // // Triggered if the content of several slices in the source |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
75 // // volume has changed |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
76 // virtual void NotifyContentChange(const ILayerSource& source) = 0; |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
77 |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
78 // // Triggered if the content of some individual slice in the |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
79 // // source volume has changed |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
80 // virtual void NotifySliceChange(const ILayerSource& source, |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
81 // const Slice& slice) = 0; |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
82 |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
83 // // The layer must be deleted by the observer that releases the |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
84 // // std::auto_ptr |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
85 // virtual void NotifyLayerReady(std::auto_ptr<ILayerRenderer>& layer, |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
86 // const ILayerSource& source, |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
87 // const CoordinateSystem3D& slice, |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
88 // bool isError) = 0; // TODO Shouldn't this be separate as NotifyLayerError? |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
89 // }; |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
91 ILayerSource(MessageBroker& broker) |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
92 : IObservable(broker) |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
93 {} |
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
94 |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 virtual ~ILayerSource() |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 { |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 } |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 |
251
192e6e349e69
first usage of new message system (in SDL only)
am@osimis.io
parents:
135
diff
changeset
|
99 // virtual void Register(IObserver& observer) = 0; |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
97
d18dcc963930
separation of the renderers vs. viewport slice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
96
diff
changeset
|
101 virtual bool GetExtent(std::vector<Vector>& points, |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
102 const CoordinateSystem3D& viewportSlice) = 0; |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 |
110
53025eecbc95
renamed SliceGeometry as CoordinateSystem3D
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
97
diff
changeset
|
104 virtual void ScheduleLayerCreation(const CoordinateSystem3D& viewportSlice) = 0; |
65
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 }; |
885932a893de
OrthancFrameLayerSource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 } |