Mercurial > hg > orthanc-stone
annotate Applications/Platforms/WebAssembly/WebAssemblyOracle.h @ 1774:95ece40bb298
DicomVolumeImageReslicer and DicomVolumeImageMPRSlicer behave identically on axial
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 12 May 2021 17:43:51 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
825 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1723
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
825 | 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. | |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1591
diff
changeset
|
16 * |
825 | 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 | |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1567
diff
changeset
|
24 #include "../../../OrthancStone/Sources/OrthancStone.h" |
1471
28c64c246312
working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1455
diff
changeset
|
25 |
825 | 26 #if !defined(ORTHANC_ENABLE_WASM) |
27 # error The macro ORTHANC_ENABLE_WASM must be defined | |
28 #endif | |
29 | |
30 #if ORTHANC_ENABLE_WASM != 1 | |
31 # error This file can only compiled for WebAssembly | |
32 #endif | |
33 | |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1567
diff
changeset
|
34 #include "../../../OrthancStone/Sources/Messages/IObservable.h" |
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1567
diff
changeset
|
35 #include "../../../OrthancStone/Sources/Messages/IMessageEmitter.h" |
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1567
diff
changeset
|
36 #include "../../../OrthancStone/Sources/Oracle/IOracle.h" |
825 | 37 |
1245
3d4dc87af04b
ParseDicomFromWadoCommand working in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1243
diff
changeset
|
38 #if ORTHANC_ENABLE_DCMTK == 1 |
1591
5887a4f8594b
moving platform-specific files out of the "OrthancStone" folder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1567
diff
changeset
|
39 # include "../../../OrthancStone/Sources/Toolbox/ParsedDicomCache.h" |
1245
3d4dc87af04b
ParseDicomFromWadoCommand working in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1243
diff
changeset
|
40 #endif |
3d4dc87af04b
ParseDicomFromWadoCommand working in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1243
diff
changeset
|
41 |
1567 | 42 #include <Compatibility.h> // For ORTHANC_OVERRIDE |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1299
diff
changeset
|
43 #include <WebServiceParameters.h> |
825 | 44 |
1488
7f16987131e1
Missing include + docs + public getter for volume geometry in multiframe loader
Benjamin Golinvaux <bgo@osimis.io>
parents:
1484
diff
changeset
|
45 #include <Enumerations.h> |
825 | 46 |
47 namespace OrthancStone | |
48 { | |
1484
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
49 class GetOrthancImageCommand; |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
50 class GetOrthancWebViewerJpegCommand; |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
51 class HttpCommand; |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
52 class OrthancRestApiCommand; |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
53 class ParseDicomFromWadoCommand; |
121d01aa328e
SeriesThumbnailsLoader working on raw dicom files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1471
diff
changeset
|
54 |
825 | 55 class WebAssemblyOracle : |
56 public IOracle, | |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
57 public IMessageEmitter |
825 | 58 { |
59 private: | |
60 typedef std::map<std::string, std::string> HttpHeaders; | |
61 | |
62 class TimeoutContext; | |
63 class FetchContext; | |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
64 class FetchCommand; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
65 |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
66 void SetOrthancUrl(FetchCommand& command, |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
67 const std::string& uri) const; |
825 | 68 |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
69 void Execute(boost::weak_ptr<IObserver> receiver, |
992
a9f5d0742e22
implementation of HttpCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
70 HttpCommand* command); |
a9f5d0742e22
implementation of HttpCommand in WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
831
diff
changeset
|
71 |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
72 void Execute(boost::weak_ptr<IObserver> receiver, |
825 | 73 OrthancRestApiCommand* command); |
74 | |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
75 void Execute(boost::weak_ptr<IObserver> receiver, |
825 | 76 GetOrthancImageCommand* command); |
77 | |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
78 void Execute(boost::weak_ptr<IObserver> receiver, |
825 | 79 GetOrthancWebViewerJpegCommand* command); |
1243
608983cc2512
removing unused logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1242
diff
changeset
|
80 |
608983cc2512
removing unused logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1242
diff
changeset
|
81 void Execute(boost::weak_ptr<IObserver> receiver, |
608983cc2512
removing unused logs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1242
diff
changeset
|
82 ParseDicomFromWadoCommand* command); |
825 | 83 |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
84 IObservable oracleObservable_; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
85 bool isLocalOrthanc_; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
86 std::string localOrthancRoot_; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
87 Orthanc::WebServiceParameters remoteOrthanc_; |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
88 |
1245
3d4dc87af04b
ParseDicomFromWadoCommand working in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1243
diff
changeset
|
89 #if ORTHANC_ENABLE_DCMTK == 1 |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
90 std::unique_ptr<ParsedDicomCache> dicomCache_; |
1245
3d4dc87af04b
ParseDicomFromWadoCommand working in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1243
diff
changeset
|
91 #endif |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
92 |
1723
81273beabc9f
refactoring: WebAssemblyOracle::ProcessFetchResult()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1678
diff
changeset
|
93 void ProcessFetchResult(boost::weak_ptr<IObserver>& receiver, |
81273beabc9f
refactoring: WebAssemblyOracle::ProcessFetchResult()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1678
diff
changeset
|
94 const std::string& answer, |
81273beabc9f
refactoring: WebAssemblyOracle::ProcessFetchResult()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1678
diff
changeset
|
95 const HttpHeaders& headers, |
81273beabc9f
refactoring: WebAssemblyOracle::ProcessFetchResult()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1678
diff
changeset
|
96 const IOracleCommand& command); |
81273beabc9f
refactoring: WebAssemblyOracle::ProcessFetchResult()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1678
diff
changeset
|
97 |
825 | 98 public: |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
99 WebAssemblyOracle() : |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
100 isLocalOrthanc_(false) |
825 | 101 { |
102 } | |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
103 |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
104 virtual void EmitMessage(boost::weak_ptr<IObserver> observer, |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
105 const IMessage& message) ORTHANC_OVERRIDE |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
106 { |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
107 oracleObservable_.EmitMessage(observer, message); |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
108 } |
825 | 109 |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
110 virtual bool Schedule(boost::shared_ptr<IObserver> receiver, |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
111 IOracleCommand* command) ORTHANC_OVERRIDE; |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
112 |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
113 IObservable& GetOracleObservable() |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
114 { |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
115 return oracleObservable_; |
825 | 116 } |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
117 |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
118 void SetLocalOrthanc(const std::string& root) |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
119 { |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
120 isLocalOrthanc_ = true; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
121 localOrthancRoot_ = root; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
122 } |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
123 |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
124 void SetRemoteOrthanc(const Orthanc::WebServiceParameters& orthanc) |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
125 { |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
126 isLocalOrthanc_ = false; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
127 remoteOrthanc_ = orthanc; |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
128 } |
1245
3d4dc87af04b
ParseDicomFromWadoCommand working in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1243
diff
changeset
|
129 |
3d4dc87af04b
ParseDicomFromWadoCommand working in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1243
diff
changeset
|
130 void SetDicomCacheSize(size_t size); |
1675
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
131 |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
132 class CachedInstanceAccessor : public boost::noncopyable |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
133 { |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
134 private: |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
135 #if ORTHANC_ENABLE_DCMTK == 1 |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
136 std::unique_ptr<ParsedDicomCache::Reader> reader_; |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
137 #endif |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
138 |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
139 public: |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
140 CachedInstanceAccessor(WebAssemblyOracle& oracle, |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
141 const std::string& sopInstanceUid); |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
142 |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
143 bool IsValid() const; |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
144 |
1678 | 145 #if ORTHANC_ENABLE_DCMTK == 1 |
1675
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
146 const Orthanc::ParsedDicomFile& GetDicom() const; |
1678 | 147 #endif |
1675
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
148 |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
149 size_t GetFileSize() const; |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
150 |
6fa05252b085
don't load low-quality image if the parsed dicom file is cached by the oracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
151 bool HasPixelData() const; |
1678 | 152 }; |
825 | 153 }; |
154 } |