annotate Samples/Common/RtViewerView.cpp @ 1471:28c64c246312

working on a shared library
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 15 Jun 2020 12:57:54 +0200
parents 828a9b4ee1b7
children 1e381f2596d3
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
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
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
1457
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
30 #include "../../Framework/Oracle/GetOrthancWebViewerJpegCommand.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
31 #include "../../Framework/Scene2D/CairoCompositor.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
32 #include "../../Framework/Scene2D/ColorTextureSceneLayer.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
33 #include "../../Framework/Scene2D/GrayscaleStyleConfigurator.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
34 #include "../../Framework/Scene2D/LookupTableStyleConfigurator.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
35 #include "../../Framework/Scene2D/OpenGLCompositor.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
36 #include "../../Framework/Scene2D/PanSceneTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
37 #include "../../Framework/Scene2D/RotateSceneTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
38 #include "../../Framework/Scene2D/ZoomSceneTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
39 #include "../../Framework/Scene2DViewport/CreateAngleMeasureTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
40 #include "../../Framework/Scene2DViewport/CreateLineMeasureTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
41 #include "../../Framework/Scene2DViewport/IFlexiblePointerTracker.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
42 #include "../../Framework/Scene2DViewport/MeasureTool.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
43 #include "../../Framework/Scene2DViewport/PredeclaredTypes.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
44 #include "../../Framework/Scene2DViewport/UndoStack.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
45 #include "../../Framework/StoneException.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
46 #include "../../Framework/StoneInitialization.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
47 #include "../../Framework/Volumes/DicomVolumeImageMPRSlicer.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
48 #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
49
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
50 // Orthanc
1457
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
51 #include <Logging.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
52 #include <OrthancException.h>
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
53
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
54 // System
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
55 #include <boost/shared_ptr.hpp>
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
56 #include <boost/weak_ptr.hpp>
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
57 #include <boost/make_shared.hpp>
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 #include <stdio.h>
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
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
62 namespace OrthancStone
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 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
65 {
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
66 return app_.lock();
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
67 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
68
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
69 void RtViewerView::DisplayInfoText()
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
70 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
71 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
72 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
73 Scene2D& scene = controller.GetScene();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
74
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
75 // 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
76 OrthancStone::ICompositor& compositor = lock->GetCompositor();
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 std::stringstream msg;
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 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
81 kv != infoTextMap_.end(); ++kv)
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 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
84 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
85 std::string msgS = msg.str();
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 TextSceneLayer* layerP = NULL;
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
88 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
89 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
90 TextSceneLayer& layer = dynamic_cast<TextSceneLayer&>(
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
91 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
92 layerP = &layer;
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 else
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 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
97 layerP = layer.get();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
98 layer->SetColor(0, 255, 0);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
99 layer->SetFontIndex(1);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
100 layer->SetBorder(20);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
101 layer->SetAnchor(BitmapAnchor_TopLeft);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
102 //layer->SetPosition(0,0);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
103 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
104 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
105 // 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
106 layerP->SetText(msgS.c_str());
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
107 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
108 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
109 scene.GetCanvasToSceneTransform().Apply(cX, cY);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
110 layerP->SetPosition(cX, cY);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
111 lock->Invalidate();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
112 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
113
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
114 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
115 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
116 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
117 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
118 Scene2D& scene = controller.GetScene();
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 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
121
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
122 char buf[128];
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
123 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
124 p.GetX(), p.GetY(),
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
125 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
126
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
127 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
128 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
129 TextSceneLayer& layer =
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
130 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
131 layer.SetText(buf);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
132 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
133 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
134 else
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 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
137 layer->SetColor(0, 255, 0);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
138 layer->SetText(buf);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
139 layer->SetBorder(20);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
140 layer->SetAnchor(BitmapAnchor_BottomCenter);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
141 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
142 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
143 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
144 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
145
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
146 void RtViewerView::HideInfoText()
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
147 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
148 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
149 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
150 Scene2D& scene = controller.GetScene();
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 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
153 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
154
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
155 void RtViewerView::OnSceneTransformChanged(
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
156 const ViewportController::SceneTransformChanged& message)
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 DisplayInfoText();
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
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
161 void RtViewerView::Invalidate()
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
162 {
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
163 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
164 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
165 lock->Invalidate();
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
166 }
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
167
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
168 void RtViewerView::FitContent()
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
169 {
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
170 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
171 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
172 lock->Invalidate();
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
173 }
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
174
1406
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
175 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
176 {
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
177 if (!planes_.empty())
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 int next = 0;
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
180 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
181
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
182 if (temp < 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 next = 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 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
187 {
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
188 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
189 }
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
190 else
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 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
193 }
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
194 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
195
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
196 if (next != currentPlane_)
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
197 {
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
198 currentPlane_ = next;
5d7ee14dc1eb Mouse wheel handler is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1404
diff changeset
199 UpdateLayers();
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 }
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
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
204 void RtViewerView::RetrieveGeometry()
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
205 {
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
206 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
207
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
208 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
209 currentPlane_ = depth / 2;
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 planes_.resize(depth);
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 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
214 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
215 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
216 }
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 UpdateLayers();
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
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
221 void RtViewerView::UpdateLayers()
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
222 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
223 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
224
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
225 if (planes_.size() == 0)
1383
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 RetrieveGeometry();
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
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
230 if (currentPlane_ < planes_.size())
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 (ctVolumeLayerSource_.get() != NULL)
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 ctVolumeLayerSource_->Update(planes_[currentPlane_]);
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 if (doseVolumeLayerSource_.get() != NULL)
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 doseVolumeLayerSource_->Update(planes_[currentPlane_]);
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 if (structLayerSource_.get() != NULL)
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 structLayerSource_->Update(planes_[currentPlane_]);
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 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
245 lock->Invalidate();
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
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
248 void RtViewerView::PrepareViewport()
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
249 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
250 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
251 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
252 Scene2D& scene = controller.GetScene();
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
253 ICompositor& compositor = lock->GetCompositor();
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
254
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
255 // 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
256 // scaling.
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
257 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
258
1471
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
259 std::string ttf;
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
260 Orthanc::EmbeddedResources::GetFileResource(ttf, Orthanc::EmbeddedResources::UBUNTU_FONT);
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
261 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
262 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
263 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
264
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
265 void RtViewerView::SetInfoDisplayMessage(
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
266 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
267 {
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
268 if (value == "")
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
269 infoTextMap_.erase(key);
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
270 else
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
271 infoTextMap_[key] = value;
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
272 DisplayInfoText();
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
273 }
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
274
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
275 void RtViewerView::RegisterMessages()
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 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
278 ViewportController& controller = lock->GetController();
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
279 Scene2D& scene = controller.GetScene();
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
280 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
281 }
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
282
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
283 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
284 boost::shared_ptr<OrthancMultiframeVolumeLoader> doseLoader,
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
285 boost::shared_ptr<DicomVolumeImage> doseVolume,
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
286 boost::shared_ptr<DicomStructureSetLoader> rtstructLoader)
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
287 {
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
288 /**
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
289 Configure the CT
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
290 */
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
291 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
292 style->SetLinearInterpolation(true);
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
293
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
294 this->SetCtVolumeSlicer(ctLoader, style.release());
1386
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 {
1471
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
297 std::string lut;
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
298 Orthanc::EmbeddedResources::GetFileResource(lut, Orthanc::EmbeddedResources::COLORMAP_HOT);
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
299
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
300 std::unique_ptr<LookupTableStyleConfigurator> config(new LookupTableStyleConfigurator);
1471
28c64c246312 working on a shared library
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1458
diff changeset
301 config->SetLookupTable(lut);
1386
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 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
304 this->SetDoseVolumeSlicer(tmp, config.release());
1386
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
305 }
dfb48f0794b1 Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents: 1383
diff changeset
306
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
307 this->SetStructureSet(rtstructLoader);
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
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
310 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
311 OrthancStone::ILayerStyleConfigurator* style)
1383
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
312 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
313 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
314 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
315 Scene2D& scene = controller.GetScene();
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
316 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
317
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
318 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
319
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
320 if (style != NULL)
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 ctVolumeLayerSource_->SetConfigurator(style);
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
323 }
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
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
326 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
327 OrthancStone::ILayerStyleConfigurator* style)
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 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
330 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
331 Scene2D& scene = controller.GetScene();
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
332 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
333
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
334 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
335
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
336 if (style != NULL)
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
337 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
338 doseVolumeLayerSource_->SetConfigurator(style);
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 }
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
341
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
342 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
343 {
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
344 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
345 ViewportController& controller = lock->GetController();
ab871499ed30 SingleFrameViewer: refactored file locations + names to share files for RtViewer
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff changeset
346 Scene2D& scene = controller.GetScene();
1404
3e644f6fadd4 Three-viewport is now OK in SDL and Wasm
Benjamin Golinvaux <bgo@osimis.io>
parents: 1393
diff changeset
347 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
348
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
349 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
350 }
1457
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1433
diff changeset
351 }