Mercurial > hg > orthanc-stone
comparison Samples/WebAssembly/RtViewer/RtViewerWasm.cpp @ 1404:3e644f6fadd4
Three-viewport is now OK in SDL and Wasm
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 29 Apr 2020 22:06:24 +0200 |
parents | 27e0a00bd3e8 |
children | 5d7ee14dc1eb |
comparison
equal
deleted
inserted
replaced
1395:62dc0d737e7b | 1404:3e644f6fadd4 |
---|---|
16 * | 16 * |
17 * You should have received a copy of the GNU Affero General Public License | 17 * You should have received a copy of the GNU Affero General Public License |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | 19 **/ |
20 | 20 |
21 #include "RtViewer.h" | 21 #include "RtViewerApp.h" |
22 #include "RtViewerView.h" | |
22 #include "SampleHelpers.h" | 23 #include "SampleHelpers.h" |
23 | 24 |
24 // Stone of Orthanc includes | 25 // Stone of Orthanc includes |
25 #include <Framework/Loaders/WebAssemblyLoadersContext.h> | 26 #include <Framework/Loaders/WebAssemblyLoadersContext.h> |
26 //#include <Framework/OpenGL/WebAssemblyOpenGLContext.h> | 27 //#include <Framework/OpenGL/WebAssemblyOpenGLContext.h> |
72 DISPATCH_JAVASCRIPT_EVENT("StoneException"); \ | 73 DISPATCH_JAVASCRIPT_EVENT("StoneException"); \ |
73 } | 74 } |
74 | 75 |
75 namespace OrthancStone | 76 namespace OrthancStone |
76 { | 77 { |
77 void RtViewerApp::CreateViewport() | 78 boost::shared_ptr<IViewport> RtViewerView::CreateViewport( |
79 const std::string& canvasId) | |
78 { | 80 { |
79 viewport_ = WebGLViewport::Create("mycanvas1"); | 81 return WebGLViewport::Create(canvasId); |
80 } | 82 } |
81 | 83 |
82 void RtViewerApp::TakeScreenshot(const std::string& target, | 84 void RtViewerView::TakeScreenshot(const std::string& target, |
83 unsigned int canvasWidth, | 85 unsigned int canvasWidth, |
84 unsigned int canvasHeight) | 86 unsigned int canvasHeight) |
85 { | 87 { |
86 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); | 88 throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented); |
87 } | 89 } |
88 | 90 |
89 | 91 |
90 void RtViewerApp::RunWasm() | 92 void RtViewerApp::RunWasm() |
91 { | 93 { |
92 { | |
93 std::unique_ptr<IViewport::ILock> lock(viewport_->Lock()); | |
94 ViewportController& controller = lock->GetController(); | |
95 Scene2D& scene = controller.GetScene(); | |
96 ICompositor& compositor = lock->GetCompositor(); | |
97 | |
98 controller.FitContent(compositor.GetCanvasWidth(), compositor.GetCanvasHeight()); | |
99 | |
100 compositor.SetFont(0, Orthanc::EmbeddedResources::UBUNTU_FONT, | |
101 FONT_SIZE_0, Orthanc::Encoding_Latin1); | |
102 compositor.SetFont(1, Orthanc::EmbeddedResources::UBUNTU_FONT, | |
103 FONT_SIZE_1, Orthanc::Encoding_Latin1); | |
104 } | |
105 | |
106 loadersContext_.reset(new OrthancStone::WebAssemblyLoadersContext(1, 4, 1)); | 94 loadersContext_.reset(new OrthancStone::WebAssemblyLoadersContext(1, 4, 1)); |
107 | 95 |
108 // we are in WASM --> downcast to concrete type | 96 // we are in WASM --> downcast to concrete type |
109 boost::shared_ptr<WebAssemblyLoadersContext> loadersContext = | 97 boost::shared_ptr<WebAssemblyLoadersContext> loadersContext = |
110 boost::dynamic_pointer_cast<WebAssemblyLoadersContext>(loadersContext_); | 98 boost::dynamic_pointer_cast<WebAssemblyLoadersContext>(loadersContext_); |
114 else | 102 else |
115 loadersContext->SetLocalOrthanc(".."); | 103 loadersContext->SetLocalOrthanc(".."); |
116 | 104 |
117 loadersContext->SetDicomCacheSize(128 * 1024 * 1024); // 128MB | 105 loadersContext->SetDicomCacheSize(128 * 1024 * 1024); // 128MB |
118 | 106 |
119 PrepareLoadersAndSlicers(); | 107 CreateLoaders(); |
108 | |
109 CreateView("RtViewer_Axial", VolumeProjection_Axial); | |
110 CreateView("RtViewer_Coronal", VolumeProjection_Coronal); | |
111 CreateView("RtViewer_Sagittal", VolumeProjection_Sagittal); | |
112 | |
113 for (size_t i = 0; i < views_.size(); ++i) | |
114 { | |
115 views_[i]->PrepareViewport(); | |
116 } | |
117 | |
118 StartLoaders(); | |
120 | 119 |
121 DefaultViewportInteractor interactor; | 120 DefaultViewportInteractor interactor; |
122 } | 121 } |
123 } | 122 } |
124 | 123 |