Mercurial > hg > orthanc-stone
comparison Samples/Common/RtViewer.h @ 1386:dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 27 Apr 2020 16:48:19 +0200 |
parents | ab871499ed30 |
children | 27e0a00bd3e8 |
comparison
equal
deleted
inserted
replaced
1385:ffe9beb7c5d3 | 1386:dfb48f0794b1 |
---|---|
34 | 34 |
35 #include <boost/enable_shared_from_this.hpp> | 35 #include <boost/enable_shared_from_this.hpp> |
36 #include <boost/thread.hpp> | 36 #include <boost/thread.hpp> |
37 #include <boost/noncopyable.hpp> | 37 #include <boost/noncopyable.hpp> |
38 | 38 |
39 #if ORTHANC_ENABLE_SDL | |
39 #include <SDL.h> | 40 #include <SDL.h> |
41 #endif | |
40 | 42 |
41 namespace OrthancStone | 43 namespace OrthancStone |
42 { | 44 { |
43 class OpenGLCompositor; | 45 class OpenGLCompositor; |
44 class IVolumeSlicer; | 46 class IVolumeSlicer; |
72 /** | 74 /** |
73 This application subclasses IMessageEmitter to use a mutex before forwarding Oracle messages (that | 75 This application subclasses IMessageEmitter to use a mutex before forwarding Oracle messages (that |
74 can be sent from multiple threads) | 76 can be sent from multiple threads) |
75 */ | 77 */ |
76 class RtViewerApp : public ObserverBase<RtViewerApp> | 78 class RtViewerApp : public ObserverBase<RtViewerApp> |
77 , public IMessageEmitter | |
78 { | 79 { |
79 public: | 80 public: |
80 | 81 |
81 | |
82 void PrepareScene(); | 82 void PrepareScene(); |
83 void Run(); | 83 |
84 #if ORTHANC_ENABLE_SDL | |
85 public: | |
86 void RunSdl(int argc, char* argv[]); | |
87 private: | |
88 void ProcessOptions(int argc, char* argv[]); | |
89 void HandleApplicationEvent(const SDL_Event& event); | |
90 #elif ORTHANC_ENABLE_WASM | |
91 #endif | |
92 | |
93 public: | |
84 void SetInfoDisplayMessage(std::string key, std::string value); | 94 void SetInfoDisplayMessage(std::string key, std::string value); |
85 void DisableTracker(); | 95 void DisableTracker(); |
86 | |
87 void HandleApplicationEvent(const SDL_Event& event); | |
88 | 96 |
89 /** | 97 /** |
90 This method is called when the scene transform changes. It allows to | 98 This method is called when the scene transform changes. It allows to |
91 recompute the visual elements whose content depend upon the scene transform | 99 recompute the visual elements whose content depend upon the scene transform |
92 */ | 100 */ |
101 */ | 109 */ |
102 void UpdateLayers(); | 110 void UpdateLayers(); |
103 | 111 |
104 void Refresh(); | 112 void Refresh(); |
105 | 113 |
114 #if 0 | |
106 virtual void EmitMessage(boost::weak_ptr<IObserver> observer, | 115 virtual void EmitMessage(boost::weak_ptr<IObserver> observer, |
107 const IMessage& message) ORTHANC_OVERRIDE | 116 const IMessage& message) ORTHANC_OVERRIDE |
108 { | 117 { |
109 try | 118 try |
110 { | 119 { |
115 { | 124 { |
116 LOG(ERROR) << "Exception while emitting a message: " << e.What(); | 125 LOG(ERROR) << "Exception while emitting a message: " << e.What(); |
117 throw; | 126 throw; |
118 } | 127 } |
119 } | 128 } |
129 #endif | |
120 | 130 |
121 static boost::shared_ptr<RtViewerApp> Create(); | 131 static boost::shared_ptr<RtViewerApp> Create(); |
122 void RegisterMessages(); | 132 void RegisterMessages(); |
123 | 133 |
124 protected: | 134 protected: |
125 RtViewerApp(); | 135 RtViewerApp(); |
126 | 136 |
127 private: | 137 private: |
128 #if 1 | 138 void PrepareLoadersAndSlicers(); |
139 | |
140 /** | |
141 Url of the Orthanc instance | |
142 Typically, in a native application (Qt, SDL), it will be an absolute URL like "http://localhost:8042". In | |
143 wasm on the browser, it could be an absolute URL, provided you do not have cross-origin problems, or a relative | |
144 URL. In our wasm samples, it is set to "..", because we set up either a reverse proxy or an Orthanc ServeFolders | |
145 plugin that serves the main web application from an URL like "http://localhost:8042/rtviewer" (with ".." leading | |
146 to the main Orthanc root URL) | |
147 */ | |
148 std::string orthancUrl_; | |
149 | |
150 /** | |
151 Orthanc ID of the CT series to load. Only used between startup and loading time. | |
152 */ | |
153 std::string ctSeriesId_; | |
154 | |
155 /** | |
156 Orthanc ID of the RTDOSE instance to load. Only used between startup and loading time. | |
157 */ | |
158 std::string doseInstanceId_; | |
159 | |
160 /** | |
161 Orthanc ID of the RTSTRUCT instance to load. Only used between startup and loading time. | |
162 */ | |
163 std::string rtStructInstanceId_; | |
164 | |
165 | |
166 #if ORTHANC_ENABLE_SDL | |
129 // if threaded (not wasm) | 167 // if threaded (not wasm) |
130 IObservable oracleObservable_; | 168 //IObservable oracleObservable_; |
131 ThreadedOracle oracle_; | 169 //ThreadedOracle oracle_; |
132 boost::shared_mutex mutex_; // to serialize messages from the ThreadedOracle | 170 //boost::shared_mutex mutex_; // to serialize messages from the ThreadedOracle |
171 #elif ORTHANC_ENABLE_WASM | |
172 | |
173 | |
133 #endif | 174 #endif |
134 | 175 |
135 void SelectNextTool(); | 176 void SelectNextTool(); |
136 | 177 |
137 /** | 178 /** |
157 //void Commit(boost::shared_ptr<TrackerCommand> cmd); | 198 //void Commit(boost::shared_ptr<TrackerCommand> cmd); |
158 void Undo(); | 199 void Undo(); |
159 void Redo(); | 200 void Redo(); |
160 | 201 |
161 | 202 |
162 void Handle(const DicomVolumeImage::GeometryReadyMessage& message); | 203 void HandleGeometryReady(const DicomVolumeImage::GeometryReadyMessage& message); |
163 void Handle(const OracleCommandExceptionMessage& message); | |
164 | 204 |
165 // TODO: wire this | 205 // TODO: wire this |
166 void HandleCTLoaded(const OrthancSeriesVolumeProgressiveLoader::VolumeImageReadyInHighQuality& message); | 206 void HandleCTLoaded(const OrthancSeriesVolumeProgressiveLoader::VolumeImageReadyInHighQuality& message); |
167 void HandleCTContentUpdated(const OrthancStone::DicomVolumeImage::ContentUpdatedMessage& message); | 207 void HandleCTContentUpdated(const OrthancStone::DicomVolumeImage::ContentUpdatedMessage& message); |
168 void HandleDoseLoaded(const OrthancStone::DicomVolumeImage::ContentUpdatedMessage& message); | 208 void HandleDoseLoaded(const OrthancStone::DicomVolumeImage::ContentUpdatedMessage& message); |
169 void HandleStructuresReady(const OrthancStone::DicomStructureSetLoader::StructuresReady& message); | 209 void HandleStructuresReady(const OrthancStone::DicomStructureSetLoader::StructuresReady& message); |
170 void HandleStructuresUpdated(const OrthancStone::DicomStructureSetLoader::StructuresUpdated& message); | 210 void HandleStructuresUpdated(const OrthancStone::DicomStructureSetLoader::StructuresUpdated& message); |
171 | 211 |
172 void SetCtVolume( | 212 void SetCtVolumeSlicer( |
173 int depth, | 213 int depth, |
174 const boost::shared_ptr<IVolumeSlicer>& volume, | 214 const boost::shared_ptr<IVolumeSlicer>& volume, |
175 ILayerStyleConfigurator* style); | 215 ILayerStyleConfigurator* style); |
176 | 216 |
177 void SetDoseVolume( | 217 void SetDoseVolumeSlicer( |
178 int depth, | 218 int depth, |
179 const boost::shared_ptr<IVolumeSlicer>& volume, | 219 const boost::shared_ptr<IVolumeSlicer>& volume, |
180 ILayerStyleConfigurator* style); | 220 ILayerStyleConfigurator* style); |
181 | 221 |
182 void SetStructureSet( | 222 void SetStructureSet( |
189 void HideInfoText(); | 229 void HideInfoText(); |
190 void RetrieveGeometry(); | 230 void RetrieveGeometry(); |
191 void FitContent(); | 231 void FitContent(); |
192 | 232 |
193 private: | 233 private: |
194 boost::shared_ptr<GenericLoadersContext> loadersContext_; | 234 boost::shared_ptr<DicomVolumeImage> ctVolume_; |
195 boost::shared_ptr<VolumeSceneLayerSource> ctVolumeLayerSource_, doseVolumeLayerSource_, structLayerSource_; | 235 boost::shared_ptr<DicomVolumeImage> doseVolume_; |
196 boost::shared_ptr<OrthancStone::IGeometryProvider> geometryProvider_; | 236 |
237 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> ctLoader_; | |
238 boost::shared_ptr<OrthancMultiframeVolumeLoader> doseLoader_; | |
239 boost::shared_ptr<DicomStructureSetLoader> rtstructLoader_; | |
240 | |
241 /** encapsulates resources shared by loaders */ | |
242 boost::shared_ptr<GenericLoadersContext> loadersContext_; | |
243 boost::shared_ptr<VolumeSceneLayerSource> ctVolumeLayerSource_, doseVolumeLayerSource_, structLayerSource_; | |
244 | |
245 /** | |
246 another interface to the ctLoader object (that also implements the IVolumeSlicer interface), that serves as the | |
247 reference for the geometry (position and dimensions of the volume + size of each voxel). It could be changed to be | |
248 the dose instead, but the CT is chosen because it usually has a better spatial resolution. | |
249 */ | |
250 boost::shared_ptr<OrthancStone::IGeometryProvider> geometryProvider_; | |
251 | |
252 // collection of cutting planes for this particular view | |
197 std::vector<OrthancStone::CoordinateSystem3D> planes_; | 253 std::vector<OrthancStone::CoordinateSystem3D> planes_; |
198 size_t currentPlane_; | 254 size_t currentPlane_; |
199 | 255 |
200 VolumeProjection projection_; | 256 VolumeProjection projection_; |
201 | 257 |