746
|
1 /**
|
|
2 * Stone of Orthanc
|
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
|
|
4 * Department, University Hospital of Liege, Belgium
|
|
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium
|
|
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.
|
|
16 *
|
|
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
|
|
24 #include "../Messages/IMessageEmitter.h"
|
|
25 #include "OracleCommandWithPayload.h"
|
|
26
|
|
27 #include <Core/Images/ImageAccessor.h>
|
|
28
|
|
29 #include <map>
|
|
30
|
|
31 namespace OrthancStone
|
|
32 {
|
|
33 class GetOrthancWebViewerJpegCommand : public OracleCommandWithPayload
|
|
34 {
|
|
35 public:
|
|
36 typedef std::map<std::string, std::string> HttpHeaders;
|
|
37
|
|
38 class SuccessMessage : public OriginMessage<GetOrthancWebViewerJpegCommand>
|
|
39 {
|
|
40 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
|
|
41
|
|
42 private:
|
|
43 std::auto_ptr<Orthanc::ImageAccessor> image_;
|
|
44
|
|
45 public:
|
|
46 SuccessMessage(const GetOrthancWebViewerJpegCommand& command,
|
|
47 Orthanc::ImageAccessor* image); // Takes ownership
|
|
48
|
|
49 const Orthanc::ImageAccessor& GetImage() const
|
|
50 {
|
|
51 return *image_;
|
|
52 }
|
|
53 };
|
|
54
|
|
55 private:
|
|
56 std::string instanceId_;
|
|
57 unsigned int frame_;
|
|
58 unsigned int quality_;
|
|
59 HttpHeaders headers_;
|
|
60 unsigned int timeout_;
|
|
61 Orthanc::PixelFormat expectedFormat_;
|
|
62
|
|
63 public:
|
|
64 GetOrthancWebViewerJpegCommand();
|
|
65
|
|
66 virtual Type GetType() const
|
|
67 {
|
|
68 return Type_GetOrthancWebViewerJpeg;
|
|
69 }
|
|
70
|
|
71 void SetExpectedPixelFormat(Orthanc::PixelFormat format)
|
|
72 {
|
|
73 expectedFormat_ = format;
|
|
74 }
|
|
75
|
|
76 void SetInstance(const std::string& instanceId)
|
|
77 {
|
|
78 instanceId_ = instanceId;
|
|
79 }
|
|
80
|
|
81 void SetFrame(unsigned int frame)
|
|
82 {
|
|
83 frame_ = frame;
|
|
84 }
|
|
85
|
|
86 void SetQuality(unsigned int quality);
|
|
87
|
|
88 void SetHttpHeader(const std::string& key,
|
|
89 const std::string& value)
|
|
90 {
|
|
91 headers_[key] = value;
|
|
92 }
|
|
93
|
|
94 Orthanc::PixelFormat GetExpectedPixelFormat() const
|
|
95 {
|
|
96 return expectedFormat_;
|
|
97 }
|
|
98
|
|
99 const std::string& GetInstanceId() const
|
|
100 {
|
|
101 return instanceId_;
|
|
102 }
|
|
103
|
|
104 unsigned int GetFrame() const
|
|
105 {
|
|
106 return frame_;
|
|
107 }
|
|
108
|
|
109 unsigned int GetQuality() const
|
|
110 {
|
|
111 return quality_;
|
|
112 }
|
|
113
|
|
114 const HttpHeaders& GetHttpHeaders() const
|
|
115 {
|
|
116 return headers_;
|
|
117 }
|
|
118
|
|
119 void SetTimeout(unsigned int seconds)
|
|
120 {
|
|
121 timeout_ = seconds;
|
|
122 }
|
|
123
|
|
124 unsigned int GetTimeout() const
|
|
125 {
|
|
126 return timeout_;
|
|
127 }
|
|
128
|
|
129 std::string GetUri() const;
|
|
130
|
|
131 void ProcessHttpAnswer(IMessageEmitter& emitter,
|
|
132 const IObserver& receiver,
|
|
133 const std::string& answer) const;
|
|
134 };
|
|
135 }
|