comparison Applications/Samples/Common/RtViewerApp.h @ 1538:d1806b4e4839

moving OrthancStone/Samples/ as Applications/Samples/
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Aug 2020 13:24:38 +0200
parents OrthancStone/Samples/Common/RtViewerApp.h@301571299212
children 6e0da8370270
comparison
equal deleted inserted replaced
1537:de8cf5859e84 1538:d1806b4e4839
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-2020 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 "../../Sources/Loaders/DicomStructureSetLoader.h"
25 #include "../../Sources/Loaders/ILoadersContext.h"
26 #include "../../Sources/Loaders/OrthancMultiframeVolumeLoader.h"
27 #include "../../Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.h"
28 #include "../../Sources/Messages/IMessageEmitter.h"
29 #include "../../Sources/Messages/IObserver.h"
30 #include "../../Sources/Messages/ObserverBase.h"
31 #include "../../Sources/Oracle/OracleCommandExceptionMessage.h"
32 #include "../../Sources/Scene2DViewport/ViewportController.h"
33 #include "../../Sources/Viewport/IViewport.h"
34 #include "../../Sources/Volumes/DicomVolumeImage.h"
35
36 #include <boost/enable_shared_from_this.hpp>
37 #include <boost/thread.hpp>
38 #include <boost/noncopyable.hpp>
39
40 #if ORTHANC_ENABLE_SDL
41 #include <SDL.h>
42 #endif
43
44 namespace OrthancStone
45 {
46 class OpenGLCompositor;
47 class IVolumeSlicer;
48 class ILayerStyleConfigurator;
49 class DicomStructureSetLoader;
50 class IOracle;
51 class ThreadedOracle;
52 class VolumeSceneLayerSource;
53 class SdlOpenGLViewport;
54 class RtViewerView;
55
56 static const unsigned int FONT_SIZE_0 = 32;
57 static const unsigned int FONT_SIZE_1 = 24;
58
59 class Scene2D;
60 class UndoStack;
61
62 /**
63 This application subclasses IMessageEmitter to use a mutex before forwarding Oracle messages (that
64 can be sent from multiple threads)
65 */
66 class RtViewerApp : public ObserverBase<RtViewerApp>
67 {
68 public:
69
70 void PrepareScene();
71
72 #if ORTHANC_ENABLE_SDL
73 public:
74 void RunSdl(int argc, char* argv[]);
75 void SdlRunLoop(const std::vector<boost::shared_ptr<OrthancStone::RtViewerView> >& views,
76 OrthancStone::DefaultViewportInteractor& interactor);
77 private:
78 void ProcessOptions(int argc, char* argv[]);
79 void HandleApplicationEvent(const SDL_Event& event);
80 #elif ORTHANC_ENABLE_WASM
81 public:
82 void RunWasm();
83 #else
84 # error Either ORTHANC_ENABLE_SDL or ORTHANC_ENABLE_WASM must be enabled
85 #endif
86
87 public:
88 void DisableTracker();
89
90 /**
91 Called by command-line option processing or when parsing the URL
92 parameters.
93 */
94 void SetArgument(const std::string& key, const std::string& value);
95
96 const VolumeImageGeometry& GetMainGeometry();
97
98 static boost::shared_ptr<RtViewerApp> Create();
99
100 void CreateView(const std::string& canvasId, VolumeProjection projection);
101
102 protected:
103 RtViewerApp();
104
105 private:
106 void CreateLoaders();
107 void StartLoaders();
108 void SelectNextTool();
109
110 // argument handling
111 // SetArgument is above (public section)
112 std::map<std::string, std::string> arguments_;
113
114 std::string GetArgument(const std::string& key) const;
115 bool HasArgument(const std::string& key) const;
116
117 /**
118 This adds the command at the top of the undo stack
119 */
120 //void Commit(boost::shared_ptr<TrackerCommand> cmd);
121 void Undo();
122 void Redo();
123
124 void HandleGeometryReady(const DicomVolumeImage::GeometryReadyMessage& message);
125
126 // TODO: wire this
127 void HandleCTLoaded(const OrthancSeriesVolumeProgressiveLoader::VolumeImageReadyInHighQuality& message);
128 void HandleCTContentUpdated(const OrthancStone::DicomVolumeImage::ContentUpdatedMessage& message);
129 void HandleDoseLoaded(const OrthancStone::DicomVolumeImage::ContentUpdatedMessage& message);
130 void HandleStructuresReady(const OrthancStone::DicomStructureSetLoader::StructuresReady& message);
131 void HandleStructuresUpdated(const OrthancStone::DicomStructureSetLoader::StructuresUpdated& message);
132
133
134 private:
135 void RetrieveGeometry();
136 void FitContent();
137 void InvalidateAllViewports();
138 void UpdateLayersInAllViews();
139
140 private:
141 boost::shared_ptr<DicomVolumeImage> ctVolume_;
142 boost::shared_ptr<DicomVolumeImage> doseVolume_;
143
144 std::vector<boost::shared_ptr<RtViewerView> > views_;
145
146 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> ctLoader_;
147 boost::shared_ptr<OrthancMultiframeVolumeLoader> doseLoader_;
148 boost::shared_ptr<DicomStructureSetLoader> rtstructLoader_;
149
150 /** encapsulates resources shared by loaders */
151 boost::shared_ptr<ILoadersContext> loadersContext_;
152
153 /**
154 another interface to the ctLoader object (that also implements the IVolumeSlicer interface), that serves as the
155 reference for the geometry (position and dimensions of the volume + size of each voxel). It could be changed to be
156 the dose instead, but the CT is chosen because it usually has a better spatial resolution.
157 */
158 boost::shared_ptr<OrthancStone::IGeometryProvider> geometryProvider_;
159
160
161 boost::shared_ptr<IFlexiblePointerTracker> activeTracker_;
162
163 boost::shared_ptr<UndoStack> undoStack_;
164 };
165
166 }
167
168
169