annotate Applications/Samples/Common/RtViewerView.cpp @ 1770:073484e33bee

fix offset of textures
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 May 2021 10:53:37 +0200
parents 226718777702
children 3889ae96d2e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1680
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
1383
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
1471
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
27 #include <EmbeddedResources.h>
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
28
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
29 // Stone of Orthanc
1542
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
30 #include "../../../OrthancStone/Sources/Oracle/GetOrthancWebViewerJpegCommand.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
31 #include "../../../OrthancStone/Sources/Scene2D/CairoCompositor.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
32 #include "../../../OrthancStone/Sources/Scene2D/ColorTextureSceneLayer.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
33 #include "../../../OrthancStone/Sources/Scene2D/GrayscaleStyleConfigurator.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
34 #include "../../../OrthancStone/Sources/Scene2D/LookupTableStyleConfigurator.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
35 #include "../../../OrthancStone/Sources/Scene2D/OpenGLCompositor.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
36 #include "../../../OrthancStone/Sources/Scene2D/PanSceneTracker.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
37 #include "../../../OrthancStone/Sources/Scene2D/RotateSceneTracker.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
38 #include "../../../OrthancStone/Sources/Scene2D/ZoomSceneTracker.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
39 #include "../../../OrthancStone/Sources/Scene2DViewport/CreateAngleMeasureTracker.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
40 #include "../../../OrthancStone/Sources/Scene2DViewport/CreateLineMeasureTracker.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
41 #include "../../../OrthancStone/Sources/Scene2DViewport/IFlexiblePointerTracker.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
42 #include "../../../OrthancStone/Sources/Scene2DViewport/MeasureTool.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
43 #include "../../../OrthancStone/Sources/Scene2DViewport/PredeclaredTypes.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
44 #include "../../../OrthancStone/Sources/Scene2DViewport/UndoStack.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
45 #include "../../../OrthancStone/Sources/StoneException.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
46 #include "../../../OrthancStone/Sources/StoneInitialization.h"
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
47 #include "../../../OrthancStone/Sources/Volumes/DicomVolumeImageMPRSlicer.h"
1770
073484e33bee fix offset of textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
48 #include "../../../OrthancStone/Sources/Volumes/DicomVolumeImageReslicer.h"
1542
6e0da8370270 fixing paths
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1538
diff changeset
49 #include "../../../OrthancStone/Sources/Volumes/VolumeSceneLayerSource.h"
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
50
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
51 // Orthanc
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1501
diff changeset
52 #include <Compatibility.h> // For std::unique_ptr<>
1457
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
53 #include <Logging.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
54 #include <OrthancException.h>
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
55
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
56 // System
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
57 #include <boost/shared_ptr.hpp>
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
58 #include <boost/weak_ptr.hpp>
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
59 #include <boost/make_shared.hpp>
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
60
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
61 #include <stdio.h>
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
62
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
63
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
64 namespace OrthancStone
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
65 {
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
66 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
67 {
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
68 return app_.lock();
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
69 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
71 void RtViewerView::DisplayInfoText()
1383
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 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
74 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 Scene2D& scene = controller.GetScene();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
76
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
77 // do not try to use stuff too early!
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
78 const ICompositor& compositor = lock->GetCompositor();
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
79
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
80 std::stringstream msg;
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
81
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
82 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
83 kv != infoTextMap_.end(); ++kv)
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 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
86 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
87 std::string msgS = msg.str();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
89 TextSceneLayer* layerP = NULL;
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 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
91 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
92 TextSceneLayer& layer = dynamic_cast<TextSceneLayer&>(
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
93 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
94 layerP = &layer;
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
95 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
96 else
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
97 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 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
99 layerP = layer.get();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 layer->SetColor(0, 255, 0);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 layer->SetFontIndex(1);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 layer->SetBorder(20);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 layer->SetAnchor(BitmapAnchor_TopLeft);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
104 //layer->SetPosition(0,0);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 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
106 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 // 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
108 layerP->SetText(msgS.c_str());
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
109 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
110 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
111 scene.GetCanvasToSceneTransform().Apply(cX, cY);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112 layerP->SetPosition(cX, cY);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113 lock->Invalidate();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
114 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
115
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
116 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
117 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 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
119 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
120 Scene2D& scene = controller.GetScene();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
121
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 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
123
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
124 char buf[128];
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 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
126 p.GetX(), p.GetY(),
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 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
128
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 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
130 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
131 TextSceneLayer& layer =
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 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
133 layer.SetText(buf);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 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
135 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
136 else
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
137 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 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
139 layer->SetColor(0, 255, 0);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140 layer->SetText(buf);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141 layer->SetBorder(20);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
142 layer->SetAnchor(BitmapAnchor_BottomCenter);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
143 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
144 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
145 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
146 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
148 void RtViewerView::HideInfoText()
1383
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 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
151 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
152 Scene2D& scene = controller.GetScene();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
153
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154 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
155 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
157 void RtViewerView::OnSceneTransformChanged(
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
158 const ViewportController::SceneTransformChanged& message)
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
159 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
160 DisplayInfoText();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
161 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
162
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
163 void RtViewerView::Invalidate()
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
164 {
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
165 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
166 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
167 lock->Invalidate();
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
168 }
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
169
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
170 void RtViewerView::FitContent()
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
171 {
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
172 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
173 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
174 lock->Invalidate();
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
175 }
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
176
1406
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
177 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
178 {
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
179 if (!planes_.empty())
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
180 {
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
181 int next = 0;
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
182 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
183
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
184 if (temp < 0)
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 = 0;
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 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
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<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
191 }
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
192 else
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 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
195 }
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
196 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
197
1501
1e381f2596d3 fix warnings
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1471
diff changeset
198 if (next != static_cast<int>(currentPlane_))
1406
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 currentPlane_ = next;
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
201 UpdateLayers();
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
202 }
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
203 }
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
204 }
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
205
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
206 void RtViewerView::RetrieveGeometry()
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
207 {
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
208 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
209
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
210 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
211 currentPlane_ = depth / 2;
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_.resize(depth);
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 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
216 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
217 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
218 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
219
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
220 UpdateLayers();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
221 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
223 void RtViewerView::UpdateLayers()
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 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
226
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
227 if (planes_.size() == 0)
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
228 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
229 RetrieveGeometry();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
230 }
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 if (currentPlane_ < planes_.size())
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 (ctVolumeLayerSource_.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 ctVolumeLayerSource_->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 (doseVolumeLayerSource_.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 doseVolumeLayerSource_->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 if (structLayerSource_.get() != NULL)
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
243 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
244 structLayerSource_->Update(planes_[currentPlane_]);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
245 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
246 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
247 lock->Invalidate();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
248 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
249
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
250 void RtViewerView::PrepareViewport()
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
251 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock());
1594
74ed691f9c64 fix initial rendering of MPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
253
74ed691f9c64 fix initial rendering of MPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
254 /**
74ed691f9c64 fix initial rendering of MPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
255 * The method "RefreshCanvasSize()" must be used before the first
74ed691f9c64 fix initial rendering of MPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
256 * rendering, or when the layout of the HTML page changes, which
74ed691f9c64 fix initial rendering of MPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
257 * does not trigger the "emscripten_set_resize_callback()" event
74ed691f9c64 fix initial rendering of MPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
258 **/
74ed691f9c64 fix initial rendering of MPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
259 lock->RefreshCanvasSize();
74ed691f9c64 fix initial rendering of MPR sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1573
diff changeset
260
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
261 ViewportController& controller = lock->GetController();
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
262 ICompositor& compositor = lock->GetCompositor();
1383
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 // 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
265 // scaling.
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
266 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
267
1471
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
268 std::string ttf;
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
269 Orthanc::EmbeddedResources::GetFileResource(ttf, Orthanc::EmbeddedResources::UBUNTU_FONT);
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
270 compositor.SetFont(0, ttf, FONT_SIZE_0, Orthanc::Encoding_Latin1);
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
271 compositor.SetFont(1, ttf, 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
272 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
273
1573
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1542
diff changeset
274 void RtViewerView::SetInfoDisplayMessage(const std::string& key,
32e0c007789d cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1542
diff changeset
275 const std::string& value)
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
276 {
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
277 if (value == "")
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
278 infoTextMap_.erase(key);
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
279 else
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
280 infoTextMap_[key] = value;
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
281 DisplayInfoText();
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
282 }
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
283
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
284 void RtViewerView::RegisterMessages()
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
285 {
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
286 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
287 ViewportController& controller = lock->GetController();
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
288 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
289 }
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
290
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
291 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
292 boost::shared_ptr<OrthancMultiframeVolumeLoader> doseLoader,
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
293 boost::shared_ptr<DicomVolumeImage> doseVolume,
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
294 boost::shared_ptr<DicomStructureSetLoader> rtstructLoader)
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
295 {
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
296 /**
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
297 Configure the CT
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
298 */
1507
169adf9090a6 replacing deprecated std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1501
diff changeset
299 std::unique_ptr<GrayscaleStyleConfigurator> style(new GrayscaleStyleConfigurator);
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
300 style->SetLinearInterpolation(true);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
301
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
302 this->SetCtVolumeSlicer(ctLoader, style.release());
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
303
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
304 {
1471
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
305 std::string lut;
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
306 Orthanc::EmbeddedResources::GetFileResource(lut, Orthanc::EmbeddedResources::COLORMAP_HOT);
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
307
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
308 std::unique_ptr<LookupTableStyleConfigurator> config(new LookupTableStyleConfigurator);
1471
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
309 config->SetLookupTable(lut);
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
310
1768
226718777702 fix DicomVolumeImageMPRSlicer::Slice::CreateSceneLayer() for opposite normals
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1739
diff changeset
311 boost::shared_ptr<IVolumeSlicer> tmp(new DicomVolumeImageMPRSlicer(doseVolume));
1770
073484e33bee fix offset of textures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1768
diff changeset
312 //boost::shared_ptr<IVolumeSlicer> tmp(new DicomVolumeImageReslicer(doseVolume));
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
313 this->SetDoseVolumeSlicer(tmp, config.release());
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
314 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
315
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
316 this->SetStructureSet(rtstructLoader);
1383
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
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
319 void RtViewerView::SetCtVolumeSlicer(const boost::shared_ptr<IVolumeSlicer>& volume,
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
320 ILayerStyleConfigurator* style)
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
321 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
322 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
323 ViewportController& controller = lock->GetController();
1680
03afa09cfcf1 running the tests of the Orthanc Framework in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1640
diff changeset
324 const Scene2D& scene = controller.GetScene();
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
325 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
326
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
327 ctVolumeLayerSource_.reset(new VolumeSceneLayerSource(viewport_, depth, volume));
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
328
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
329 if (style != NULL)
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
330 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
331 ctVolumeLayerSource_->SetConfigurator(style);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
332 }
1535
301571299212 DefaultViewportInteractor::SetWindowingLayer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
333
301571299212 DefaultViewportInteractor::SetWindowingLayer()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
334 ctLayer_ = depth;
1383
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
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
337 void RtViewerView::SetDoseVolumeSlicer(const boost::shared_ptr<IVolumeSlicer>& volume,
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
338 ILayerStyleConfigurator* style)
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();
1680
03afa09cfcf1 running the tests of the Orthanc Framework in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1640
diff changeset
342 const 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
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
345 doseVolumeLayerSource_.reset(new 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
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
347 if (style != NULL)
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
348 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
349 doseVolumeLayerSource_->SetConfigurator(style);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
350 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
351 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
352
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
353 void RtViewerView::SetStructureSet(const boost::shared_ptr<DicomStructureSetLoader>& volume)
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
354 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
355 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
356 ViewportController& controller = lock->GetController();
1680
03afa09cfcf1 running the tests of the Orthanc Framework in WebAssembly
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1640
diff changeset
357 const Scene2D& scene = controller.GetScene();
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
358 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
359
1640
52b8b96cb55f cleaning namespaces
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1594
diff changeset
360 structLayerSource_.reset(new VolumeSceneLayerSource(viewport_, depth, volume));
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
361 }
1457
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
362 }