comparison Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp @ 1962:c6272d7bb6d9

display of orientation markers in Stone Web viewer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Oct 2022 19:12:29 +0200
parents d459477804bf
children 79fdc3b1f031
comparison
equal deleted inserted replaced
1961:cbf54cd28d59 1962:c6272d7bb6d9
1587 static const int LAYER_TEXTURE = 0; 1587 static const int LAYER_TEXTURE = 0;
1588 static const int LAYER_OVERLAY = 1; 1588 static const int LAYER_OVERLAY = 1;
1589 static const int LAYER_REFERENCE_LINES = 2; 1589 static const int LAYER_REFERENCE_LINES = 2;
1590 static const int LAYER_ANNOTATIONS_OSIRIX = 3; 1590 static const int LAYER_ANNOTATIONS_OSIRIX = 3;
1591 static const int LAYER_ANNOTATIONS_STONE = 4; 1591 static const int LAYER_ANNOTATIONS_STONE = 4;
1592 static const int LAYER_ORIENTATION_MARKERS = 5;
1592 1593
1593 1594
1594 class ICommand : public Orthanc::IDynamicObject 1595 class ICommand : public Orthanc::IDynamicObject
1595 { 1596 {
1596 private: 1597 private:
2228 } 2229 }
2229 } 2230 }
2230 2231
2231 StoneAnnotationsRegistry::GetInstance().Load(*stoneAnnotations_, instance.GetSopInstanceUid(), frameIndex); 2232 StoneAnnotationsRegistry::GetInstance().Load(*stoneAnnotations_, instance.GetSopInstanceUid(), frameIndex);
2232 2233
2234 // Orientation markers, new in Stone Web viewer 2.4
2235 std::unique_ptr<OrthancStone::MacroSceneLayer> orientationMarkers;
2236
2237 if (instance.GetGeometry().IsValid())
2238 {
2239 orientationMarkers.reset(new OrthancStone::MacroSceneLayer);
2240
2241 std::string top, bottom, left, right;
2242 instance.GetGeometry().GetOrientationMarkers(top, bottom, left, right);
2243
2244 std::unique_ptr<OrthancStone::TextSceneLayer> text;
2245
2246 text.reset(new OrthancStone::TextSceneLayer);
2247 text->SetText(top);
2248 text->SetPosition(pixelSpacingX * static_cast<double>(frame.GetWidth()) / 2.0, 0);
2249 text->SetAnchor(OrthancStone::BitmapAnchor_TopCenter);
2250 orientationMarkers->AddLayer(text.release());
2251
2252 text.reset(new OrthancStone::TextSceneLayer);
2253 text->SetText(bottom);
2254 text->SetPosition(pixelSpacingX * static_cast<double>(frame.GetWidth()) / 2.0,
2255 pixelSpacingY * static_cast<double>(frame.GetHeight()));
2256 text->SetAnchor(OrthancStone::BitmapAnchor_BottomCenter);
2257 orientationMarkers->AddLayer(text.release());
2258
2259 text.reset(new OrthancStone::TextSceneLayer);
2260 text->SetText(left);
2261 text->SetPosition(0, pixelSpacingY * static_cast<double>(frame.GetHeight()) / 2.0);
2262 text->SetAnchor(OrthancStone::BitmapAnchor_CenterLeft);
2263 orientationMarkers->AddLayer(text.release());
2264
2265 text.reset(new OrthancStone::TextSceneLayer);
2266 text->SetText(right);
2267 text->SetPosition(pixelSpacingX * static_cast<double>(frame.GetWidth()),
2268 pixelSpacingY * static_cast<double>(frame.GetHeight()) / 2.0);
2269 text->SetAnchor(OrthancStone::BitmapAnchor_CenterRight);
2270 orientationMarkers->AddLayer(text.release());
2271 }
2272
2273
2233 { 2274 {
2234 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock()); 2275 std::unique_ptr<OrthancStone::IViewport::ILock> lock(viewport_->Lock());
2235 2276
2236 OrthancStone::Scene2D& scene = lock->GetController().GetScene(); 2277 OrthancStone::Scene2D& scene = lock->GetController().GetScene();
2237 2278
2251 scene.SetLayer(LAYER_ANNOTATIONS_OSIRIX, annotationsOsiriX.release()); 2292 scene.SetLayer(LAYER_ANNOTATIONS_OSIRIX, annotationsOsiriX.release());
2252 } 2293 }
2253 else 2294 else
2254 { 2295 {
2255 scene.DeleteLayer(LAYER_ANNOTATIONS_OSIRIX); 2296 scene.DeleteLayer(LAYER_ANNOTATIONS_OSIRIX);
2297 }
2298
2299 if (orientationMarkers.get() != NULL)
2300 {
2301 scene.SetLayer(LAYER_ORIENTATION_MARKERS, orientationMarkers.release());
2302 }
2303 else
2304 {
2305 scene.DeleteLayer(LAYER_ORIENTATION_MARKERS);
2256 } 2306 }
2257 2307
2258 stoneAnnotations_->Render(scene); // Necessary for "FitContent()" to work 2308 stoneAnnotations_->Render(scene); // Necessary for "FitContent()" to work
2259 2309
2260 if (fitNextContent_) 2310 if (fitNextContent_)