Mercurial > hg > orthanc-stone
annotate Applications/Platforms/WebAssembly/WebAssemblyOracle.h @ 1719:9a1f79d21a3f
added buttons to go to the first and last frames
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 01 Dec 2020 10:42:45 +0100 |
parents | 1393e3393a0b |
children | 81273beabc9f |
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 | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
992
diff
changeset
|
5 * Copyright (C) 2017-2020 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 |
825 | 93 public: |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
94 WebAssemblyOracle() : |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
95 isLocalOrthanc_(false) |
825 | 96 { |
97 } | |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
98 |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
99 virtual void EmitMessage(boost::weak_ptr<IObserver> observer, |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
100 const IMessage& message) ORTHANC_OVERRIDE |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
101 { |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
102 oracleObservable_.EmitMessage(observer, message); |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
103 } |
825 | 104 |
1229
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
105 virtual bool Schedule(boost::shared_ptr<IObserver> receiver, |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
106 IOracleCommand* command) ORTHANC_OVERRIDE; |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
107 |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
108 IObservable& GetOracleObservable() |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
109 { |
b9f2a111c5b9
fix compilation of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1076
diff
changeset
|
110 return oracleObservable_; |
825 | 111 } |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
112 |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
113 void SetLocalOrthanc(const std::string& root) |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
114 { |
1242
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
115 isLocalOrthanc_ = true; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
116 localOrthancRoot_ = root; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
117 } |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
118 |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
119 void SetRemoteOrthanc(const Orthanc::WebServiceParameters& orthanc) |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
120 { |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
121 isLocalOrthanc_ = false; |
b9b5d4378874
working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1229
diff
changeset
|
122 remoteOrthanc_ = orthanc; |
831
d71cf8504159
handling of GET arguments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
825
diff
changeset
|
123 } |
1245
3d4dc87af04b
ParseDicomFromWadoCommand working in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1243
diff
changeset
|
124 |
3d4dc87af04b
ParseDicomFromWadoCommand working in wasm
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1243
diff
changeset
|
125 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
|
126 |
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
|
127 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
|
128 { |
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
|
129 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
|
130 #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
|
131 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
|
132 #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
|
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 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
|
135 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
|
136 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
|
137 |
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 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
|
139 |
1678 | 140 #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
|
141 const Orthanc::ParsedDicomFile& GetDicom() const; |
1678 | 142 #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
|
143 |
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 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
|
145 |
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 bool HasPixelData() const; |
1678 | 147 }; |
825 | 148 }; |
149 } |