comparison Applications/Samples/Common/RtViewerView.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/RtViewerView.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 #include "../../Sources/Volumes/VolumeSceneLayerSource.h"
36
37 #include <boost/enable_shared_from_this.hpp>
38 #include <boost/thread.hpp>
39 #include <boost/noncopyable.hpp>
40
41 namespace OrthancStone
42 {
43 class RtViewerApp;
44
45 class RtViewerView : public ObserverBase<RtViewerView>
46 {
47 public:
48 RtViewerView(boost::weak_ptr<RtViewerApp> app,
49 const std::string& canvasId,
50 VolumeProjection projection)
51 : app_(app)
52 , currentPlane_(0)
53 , projection_(projection)
54 , ctLayer_(0)
55 {
56 viewport_ = CreateViewport(canvasId);
57 FLOATING_INFOTEXT_LAYER_ZINDEX = 6;
58 FIXED_INFOTEXT_LAYER_ZINDEX = 7;
59 }
60
61 /**
62 This method is called when the scene transform changes. It allows to
63 recompute the visual elements whose content depend upon the scene transform
64 */
65 void OnSceneTransformChanged(
66 const ViewportController::SceneTransformChanged& message);
67
68 /**
69 This method will ask the VolumeSceneLayerSource, that are responsible to
70 generated 2D content based on a volume and a cutting plane, to regenerate
71 it. This is required if the volume itself changes (during loading) or if
72 the cutting plane is changed
73 */
74 void UpdateLayers();
75
76 void Refresh();
77
78 void TakeScreenshot(
79 const std::string& target,
80 unsigned int canvasWidth,
81 unsigned int canvasHeight);
82
83 void Scroll(int delta);
84
85 void Invalidate();
86 void FitContent();
87 void RetrieveGeometry();
88 void PrepareViewport();
89 void RegisterMessages();
90
91 #if ORTHANC_ENABLE_SDL == 1
92 void EnableGLDebugOutput();
93 #endif
94
95 void CreateLayers(boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> ctLoader,
96 boost::shared_ptr<OrthancMultiframeVolumeLoader> doseLoader,
97 boost::shared_ptr<DicomVolumeImage> doseVolume,
98 boost::shared_ptr<DicomStructureSetLoader> rtstructLoader);
99
100 boost::shared_ptr<IViewport> GetViewport()
101 {
102 return viewport_;
103 }
104
105 int GetCtLayerIndex() const
106 {
107 return ctLayer_;
108 }
109
110 private:
111 void SetInfoDisplayMessage(std::string key, std::string value);
112 boost::shared_ptr<RtViewerApp> GetApp();
113 boost::shared_ptr<IViewport> CreateViewport(const std::string& canvasId);
114 void DisplayInfoText();
115 void HideInfoText();
116 void DisplayFloatingCtrlInfoText(const PointerEvent& e);
117
118 void SetCtVolumeSlicer(const boost::shared_ptr<IVolumeSlicer>& volume,
119 ILayerStyleConfigurator* style);
120
121 void SetDoseVolumeSlicer(const boost::shared_ptr<IVolumeSlicer>& volume,
122 ILayerStyleConfigurator* style);
123
124 void SetStructureSet(const boost::shared_ptr<DicomStructureSetLoader>& volume);
125
126 private:
127 boost::weak_ptr<RtViewerApp> app_;
128 boost::shared_ptr<VolumeSceneLayerSource> ctVolumeLayerSource_, doseVolumeLayerSource_, structLayerSource_;
129
130 // collection of cutting planes for this particular view
131 std::vector<OrthancStone::CoordinateSystem3D> planes_;
132 size_t currentPlane_;
133
134 VolumeProjection projection_;
135
136 std::map<std::string, std::string> infoTextMap_;
137
138 int FLOATING_INFOTEXT_LAYER_ZINDEX;
139 int FIXED_INFOTEXT_LAYER_ZINDEX;
140 boost::shared_ptr<IViewport> viewport_;
141
142 int ctLayer_;
143 };
144 }