Mercurial > hg > orthanc-stone
annotate Samples/Common/RtViewerView.cpp @ 1463:182bf3106ee2
dos2unix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 12 Jun 2020 07:19:31 +0200 |
parents | 828a9b4ee1b7 |
children | 28c64c246312 |
rev | line source |
---|---|
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
1 /** |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
2 * Stone of Orthanc |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
6 * |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
11 * |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
16 * |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
19 **/ |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
20 |
1458
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
21 |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
22 // Sample app |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
23 #include "RtViewerView.h" |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
24 #include "RtViewerApp.h" |
1393
27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
Benjamin Golinvaux <bgo@osimis.io>
parents:
1392
diff
changeset
|
25 #include "SampleHelpers.h" |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
26 |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
27 // Stone of Orthanc |
1457 | 28 #include "../../Framework/Oracle/GetOrthancWebViewerJpegCommand.h" |
29 #include "../../Framework/Scene2D/CairoCompositor.h" | |
30 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h" | |
31 #include "../../Framework/Scene2D/GrayscaleStyleConfigurator.h" | |
32 #include "../../Framework/Scene2D/LookupTableStyleConfigurator.h" | |
33 #include "../../Framework/Scene2D/OpenGLCompositor.h" | |
34 #include "../../Framework/Scene2D/PanSceneTracker.h" | |
35 #include "../../Framework/Scene2D/RotateSceneTracker.h" | |
36 #include "../../Framework/Scene2D/ZoomSceneTracker.h" | |
37 #include "../../Framework/Scene2DViewport/CreateAngleMeasureTracker.h" | |
38 #include "../../Framework/Scene2DViewport/CreateLineMeasureTracker.h" | |
39 #include "../../Framework/Scene2DViewport/IFlexiblePointerTracker.h" | |
40 #include "../../Framework/Scene2DViewport/MeasureTool.h" | |
41 #include "../../Framework/Scene2DViewport/PredeclaredTypes.h" | |
42 #include "../../Framework/Scene2DViewport/UndoStack.h" | |
43 #include "../../Framework/StoneException.h" | |
44 #include "../../Framework/StoneInitialization.h" | |
45 #include "../../Framework/Volumes/DicomVolumeImageMPRSlicer.h" | |
46 #include "../../Framework/Volumes/VolumeSceneLayerSource.h" | |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
48 // Orthanc |
1457 | 49 #include <Logging.h> |
50 #include <OrthancException.h> | |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
51 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
52 // System |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
53 #include <boost/shared_ptr.hpp> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
54 #include <boost/weak_ptr.hpp> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
55 #include <boost/make_shared.hpp> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
56 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
57 #include <stdio.h> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
58 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
59 |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
60 namespace OrthancStone |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
61 { |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
62 boost::shared_ptr<RtViewerApp> RtViewerView::GetApp() |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
63 { |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
64 return app_.lock(); |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
65 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
66 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
67 void RtViewerView::DisplayInfoText() |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
68 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
69 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
70 ViewportController& controller = lock->GetController(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
71 Scene2D& scene = controller.GetScene(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
72 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
73 // do not try to use stuff too early! |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
74 OrthancStone::ICompositor& compositor = lock->GetCompositor(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
75 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
76 std::stringstream msg; |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
77 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
78 for (std::map<std::string, std::string>::const_iterator kv = infoTextMap_.begin(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
79 kv != infoTextMap_.end(); ++kv) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
80 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
81 msg << kv->first << " : " << kv->second << std::endl; |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
82 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
83 std::string msgS = msg.str(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
84 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
85 TextSceneLayer* layerP = NULL; |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
86 if (scene.HasLayer(FIXED_INFOTEXT_LAYER_ZINDEX)) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
87 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
88 TextSceneLayer& layer = dynamic_cast<TextSceneLayer&>( |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
89 scene.GetLayer(FIXED_INFOTEXT_LAYER_ZINDEX)); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
90 layerP = &layer; |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
91 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
92 else |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
93 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
94 std::unique_ptr<TextSceneLayer> layer(new TextSceneLayer); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
95 layerP = layer.get(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
96 layer->SetColor(0, 255, 0); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
97 layer->SetFontIndex(1); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
98 layer->SetBorder(20); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
99 layer->SetAnchor(BitmapAnchor_TopLeft); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
100 //layer->SetPosition(0,0); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
101 scene.SetLayer(FIXED_INFOTEXT_LAYER_ZINDEX, layer.release()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
102 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
103 // position the fixed info text in the upper right corner |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
104 layerP->SetText(msgS.c_str()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
105 double cX = compositor.GetCanvasWidth() * (-0.5); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
106 double cY = compositor.GetCanvasHeight() * (-0.5); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
107 scene.GetCanvasToSceneTransform().Apply(cX, cY); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
108 layerP->SetPosition(cX, cY); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
109 lock->Invalidate(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
110 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
111 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
112 void RtViewerView::DisplayFloatingCtrlInfoText(const PointerEvent& e) |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
113 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
114 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
115 ViewportController& controller = lock->GetController(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
116 Scene2D& scene = controller.GetScene(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
117 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
118 ScenePoint2D p = e.GetMainPosition().Apply(scene.GetCanvasToSceneTransform()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
119 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
120 char buf[128]; |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
121 sprintf(buf, "S:(%0.02f,%0.02f) C:(%0.02f,%0.02f)", |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
122 p.GetX(), p.GetY(), |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
123 e.GetMainPosition().GetX(), e.GetMainPosition().GetY()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
124 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
125 if (scene.HasLayer(FLOATING_INFOTEXT_LAYER_ZINDEX)) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
126 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
127 TextSceneLayer& layer = |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
128 dynamic_cast<TextSceneLayer&>(scene.GetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX)); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
129 layer.SetText(buf); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
130 layer.SetPosition(p.GetX(), p.GetY()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
131 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
132 else |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
133 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
134 std::unique_ptr<TextSceneLayer> layer(new TextSceneLayer); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
135 layer->SetColor(0, 255, 0); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
136 layer->SetText(buf); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
137 layer->SetBorder(20); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
138 layer->SetAnchor(BitmapAnchor_BottomCenter); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
139 layer->SetPosition(p.GetX(), p.GetY()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
140 scene.SetLayer(FLOATING_INFOTEXT_LAYER_ZINDEX, layer.release()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
141 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
142 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
143 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
144 void RtViewerView::HideInfoText() |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
145 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
146 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
147 ViewportController& controller = lock->GetController(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
148 Scene2D& scene = controller.GetScene(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
149 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
150 scene.DeleteLayer(FLOATING_INFOTEXT_LAYER_ZINDEX); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
151 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
152 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
153 void RtViewerView::OnSceneTransformChanged( |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
154 const ViewportController::SceneTransformChanged& message) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
155 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
156 DisplayInfoText(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
157 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
158 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
159 void RtViewerView::Invalidate() |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
160 { |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
161 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock()); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
162 lock->GetCompositor().FitContent(lock->GetController().GetScene()); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
163 lock->Invalidate(); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
164 } |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
165 |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
166 void RtViewerView::FitContent() |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
167 { |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
168 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock()); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
169 lock->GetCompositor().FitContent(lock->GetController().GetScene()); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
170 lock->Invalidate(); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
171 } |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
172 |
1406
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
173 void RtViewerView::Scroll(int delta) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
174 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
175 if (!planes_.empty()) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
176 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
177 int next = 0; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
178 int temp = static_cast<int>(currentPlane_) + delta; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
179 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
180 if (temp < 0) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
181 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
182 next = 0; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
183 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
184 else if (temp >= static_cast<int>(planes_.size())) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
185 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
186 next = static_cast<unsigned int>(planes_.size()) - 1; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
187 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
188 else |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
189 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
190 next = static_cast<size_t>(temp); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
191 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
192 LOG(INFO) << "RtViewerView::Scroll(" << delta << ") --> slice is now = " << next; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
193 |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
194 if (next != currentPlane_) |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
195 { |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
196 currentPlane_ = next; |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
197 UpdateLayers(); |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
198 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
199 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
200 } |
5d7ee14dc1eb
Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1404
diff
changeset
|
201 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
202 void RtViewerView::RetrieveGeometry() |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
203 { |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
204 const VolumeImageGeometry& geometry = GetApp()->GetMainGeometry(); |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
205 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
206 const unsigned int depth = geometry.GetProjectionDepth(projection_); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
207 currentPlane_ = depth / 2; |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
208 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
209 planes_.resize(depth); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
210 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
211 for (unsigned int z = 0; z < depth; z++) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
212 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
213 planes_[z] = geometry.GetProjectionSlice(projection_, z); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
214 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
215 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
216 UpdateLayers(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
217 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
218 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
219 void RtViewerView::UpdateLayers() |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
220 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
221 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
222 |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
223 if (planes_.size() == 0) |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
224 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
225 RetrieveGeometry(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
226 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
227 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
228 if (currentPlane_ < planes_.size()) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
229 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
230 if (ctVolumeLayerSource_.get() != NULL) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
231 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
232 ctVolumeLayerSource_->Update(planes_[currentPlane_]); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
233 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
234 if (doseVolumeLayerSource_.get() != NULL) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
235 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
236 doseVolumeLayerSource_->Update(planes_[currentPlane_]); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
237 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
238 if (structLayerSource_.get() != NULL) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
239 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
240 structLayerSource_->Update(planes_[currentPlane_]); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
241 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
242 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
243 lock->Invalidate(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
244 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
245 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
246 void RtViewerView::PrepareViewport() |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
247 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
248 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
249 ViewportController& controller = lock->GetController(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
250 Scene2D& scene = controller.GetScene(); |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
251 ICompositor& compositor = lock->GetCompositor(); |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
252 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
253 // False means we do NOT let a hi-DPI aware desktop managedr treat this as a legacy application that requires |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
254 // scaling. |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
255 controller.FitContent(compositor.GetCanvasWidth(), compositor.GetCanvasHeight()); |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
256 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
257 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
258 compositor.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
259 FONT_SIZE_0, Orthanc::Encoding_Latin1); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
260 compositor.SetFont(1, Orthanc::EmbeddedResources::UBUNTU_FONT, |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
261 FONT_SIZE_1, Orthanc::Encoding_Latin1); |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
262 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
263 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
264 void RtViewerView::SetInfoDisplayMessage( |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
265 std::string key, std::string value) |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
266 { |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
267 if (value == "") |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
268 infoTextMap_.erase(key); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
269 else |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
270 infoTextMap_[key] = value; |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
271 DisplayInfoText(); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
272 } |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
273 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
274 void RtViewerView::RegisterMessages() |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
275 { |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
276 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
277 ViewportController& controller = lock->GetController(); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
278 Scene2D& scene = controller.GetScene(); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
279 Register<ViewportController::SceneTransformChanged>(controller, &RtViewerView::OnSceneTransformChanged); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
280 } |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
281 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
282 void RtViewerView::CreateLayers(boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> ctLoader, |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
283 boost::shared_ptr<OrthancMultiframeVolumeLoader> doseLoader, |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
284 boost::shared_ptr<DicomVolumeImage> doseVolume, |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
285 boost::shared_ptr<DicomStructureSetLoader> rtstructLoader) |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
286 { |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
287 /** |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
288 Configure the CT |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
289 */ |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
290 std::auto_ptr<GrayscaleStyleConfigurator> style(new GrayscaleStyleConfigurator); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
291 style->SetLinearInterpolation(true); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
292 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
293 this->SetCtVolumeSlicer(ctLoader, style.release()); |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
294 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
295 { |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
296 std::unique_ptr<LookupTableStyleConfigurator> config(new LookupTableStyleConfigurator); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
297 config->SetLookupTable(Orthanc::EmbeddedResources::COLORMAP_HOT); |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
298 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
299 boost::shared_ptr<DicomVolumeImageMPRSlicer> tmp(new DicomVolumeImageMPRSlicer(doseVolume)); |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
300 this->SetDoseVolumeSlicer(tmp, config.release()); |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
301 } |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
302 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
303 this->SetStructureSet(rtstructLoader); |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
304 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
305 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
306 void RtViewerView::SetCtVolumeSlicer(const boost::shared_ptr<OrthancStone::IVolumeSlicer>& volume, |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
307 OrthancStone::ILayerStyleConfigurator* style) |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
308 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
309 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
310 ViewportController& controller = lock->GetController(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
311 Scene2D& scene = controller.GetScene(); |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
312 int depth = scene.GetMaxDepth() + 1; |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
313 |
1433
8635b333fa5b
[BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1406
diff
changeset
|
314 ctVolumeLayerSource_.reset(new OrthancStone::VolumeSceneLayerSource(viewport_, depth, volume)); |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
315 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
316 if (style != NULL) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
317 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
318 ctVolumeLayerSource_->SetConfigurator(style); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
319 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
320 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
321 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
322 void RtViewerView::SetDoseVolumeSlicer(const boost::shared_ptr<OrthancStone::IVolumeSlicer>& volume, |
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
323 OrthancStone::ILayerStyleConfigurator* style) |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
324 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
325 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
326 ViewportController& controller = lock->GetController(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
327 Scene2D& scene = controller.GetScene(); |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
328 int depth = scene.GetMaxDepth() + 1; |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
329 |
1433
8635b333fa5b
[BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1406
diff
changeset
|
330 doseVolumeLayerSource_.reset(new OrthancStone::VolumeSceneLayerSource(viewport_, depth, volume)); |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
331 |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
332 if (style != NULL) |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
333 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
334 doseVolumeLayerSource_->SetConfigurator(style); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
335 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
336 } |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
337 |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
338 void RtViewerView::SetStructureSet(const boost::shared_ptr<OrthancStone::DicomStructureSetLoader>& volume) |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
339 { |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
340 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
341 ViewportController& controller = lock->GetController(); |
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
342 Scene2D& scene = controller.GetScene(); |
1404
3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents:
1393
diff
changeset
|
343 int depth = scene.GetMaxDepth() + 1; |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
344 |
1433
8635b333fa5b
[BREAKING] VolumeSceneLayerSource now locks the viewport properly before using the scene. The ctor now accepts the viewport instead of a ref. to the scene. RtViewer sample has been adapted accordingly.
Benjamin Golinvaux <bgo@osimis.io>
parents:
1406
diff
changeset
|
345 structLayerSource_.reset(new OrthancStone::VolumeSceneLayerSource(viewport_, depth, volume)); |
1383
ab871499ed30
SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
346 } |
1457 | 347 } |