Mercurial > hg > orthanc-stone
comparison Samples/Common/RtViewerView.h @ 1404:3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 29 Apr 2020 22:06:24 +0200 |
parents | |
children | 5d7ee14dc1eb |
comparison
equal
deleted
inserted
replaced
1395:62dc0d737e7b | 1404:3e644f6fadd4 |
---|---|
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 #include <Framework/Viewport/IViewport.h> | |
22 | |
23 #include <Framework/Loaders/DicomStructureSetLoader.h> | |
24 #include <Framework/Loaders/OrthancMultiframeVolumeLoader.h> | |
25 #include <Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h> | |
26 #include <Framework/Loaders/ILoadersContext.h> | |
27 #include <Framework/Messages/IMessageEmitter.h> | |
28 #include <Framework/Messages/IObserver.h> | |
29 #include <Framework/Messages/ObserverBase.h> | |
30 #include <Framework/Oracle/OracleCommandExceptionMessage.h> | |
31 #include <Framework/Scene2DViewport/ViewportController.h> | |
32 | |
33 #include <Framework/Volumes/DicomVolumeImage.h> | |
34 #include <Framework/Volumes/VolumeSceneLayerSource.h> | |
35 | |
36 #include <boost/enable_shared_from_this.hpp> | |
37 #include <boost/thread.hpp> | |
38 #include <boost/noncopyable.hpp> | |
39 | |
40 namespace OrthancStone | |
41 { | |
42 class RtViewerApp; | |
43 | |
44 class RtViewerView : public ObserverBase<RtViewerView> | |
45 { | |
46 public: | |
47 RtViewerView(boost::weak_ptr<RtViewerApp> app, | |
48 const std::string& canvasId, | |
49 VolumeProjection projection) | |
50 : app_(app) | |
51 , currentPlane_(0) | |
52 , projection_(projection) | |
53 { | |
54 viewport_ = CreateViewport(canvasId); | |
55 FLOATING_INFOTEXT_LAYER_ZINDEX = 6; | |
56 FIXED_INFOTEXT_LAYER_ZINDEX = 7; | |
57 } | |
58 | |
59 /** | |
60 This method is called when the scene transform changes. It allows to | |
61 recompute the visual elements whose content depend upon the scene transform | |
62 */ | |
63 void OnSceneTransformChanged( | |
64 const ViewportController::SceneTransformChanged& message); | |
65 | |
66 /** | |
67 This method will ask the VolumeSceneLayerSource, that are responsible to | |
68 generated 2D content based on a volume and a cutting plane, to regenerate | |
69 it. This is required if the volume itself changes (during loading) or if | |
70 the cutting plane is changed | |
71 */ | |
72 void UpdateLayers(); | |
73 | |
74 void Refresh(); | |
75 | |
76 void TakeScreenshot( | |
77 const std::string& target, | |
78 unsigned int canvasWidth, | |
79 unsigned int canvasHeight); | |
80 | |
81 void Invalidate(); | |
82 void FitContent(); | |
83 void RetrieveGeometry(); | |
84 void PrepareViewport(); | |
85 void RegisterMessages(); | |
86 | |
87 #if ORTHANC_ENABLE_SDL == 1 | |
88 void EnableGLDebugOutput(); | |
89 #endif | |
90 | |
91 void CreateLayers(boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> ctLoader, | |
92 boost::shared_ptr<OrthancMultiframeVolumeLoader> doseLoader, | |
93 boost::shared_ptr<DicomVolumeImage> doseVolume, | |
94 boost::shared_ptr<DicomStructureSetLoader> rtstructLoader); | |
95 | |
96 boost::shared_ptr<IViewport> GetViewport() | |
97 { | |
98 return viewport_; | |
99 } | |
100 | |
101 private: | |
102 void SetInfoDisplayMessage(std::string key, std::string value); | |
103 boost::shared_ptr<RtViewerApp> GetApp(); | |
104 static boost::shared_ptr<IViewport> CreateViewport(const std::string& canvasId); | |
105 void DisplayInfoText(); | |
106 void HideInfoText(); | |
107 void DisplayFloatingCtrlInfoText(const PointerEvent& e); | |
108 | |
109 void SetCtVolumeSlicer(const boost::shared_ptr<IVolumeSlicer>& volume, | |
110 ILayerStyleConfigurator* style); | |
111 | |
112 void SetDoseVolumeSlicer(const boost::shared_ptr<IVolumeSlicer>& volume, | |
113 ILayerStyleConfigurator* style); | |
114 | |
115 void SetStructureSet(const boost::shared_ptr<DicomStructureSetLoader>& volume); | |
116 | |
117 private: | |
118 boost::weak_ptr<RtViewerApp> app_; | |
119 boost::shared_ptr<VolumeSceneLayerSource> ctVolumeLayerSource_, doseVolumeLayerSource_, structLayerSource_; | |
120 | |
121 // collection of cutting planes for this particular view | |
122 std::vector<OrthancStone::CoordinateSystem3D> planes_; | |
123 size_t currentPlane_; | |
124 | |
125 VolumeProjection projection_; | |
126 | |
127 std::map<std::string, std::string> infoTextMap_; | |
128 | |
129 int FLOATING_INFOTEXT_LAYER_ZINDEX; | |
130 int FIXED_INFOTEXT_LAYER_ZINDEX; | |
131 boost::shared_ptr<IViewport> viewport_; | |
132 }; | |
133 } |