# HG changeset patch # User Sebastien Jodogne # Date 1666890749 -7200 # Node ID c6272d7bb6d99a6a5372a2e4cac0d55b1cfd1a78 # Parent cbf54cd28d59a19985a403ffc5385eba8c43219f display of orientation markers in Stone Web viewer diff -r cbf54cd28d59 -r c6272d7bb6d9 Applications/StoneWebViewer/NEWS --- a/Applications/StoneWebViewer/NEWS Thu Oct 27 18:43:20 2022 +0200 +++ b/Applications/StoneWebViewer/NEWS Thu Oct 27 19:12:29 2022 +0200 @@ -1,6 +1,7 @@ Pending changes in the mainline =============================== +* Display of orientation markers * New configuration options: - "ShowInfoPanelAtStartup" to control the info panel at startup - "ShowUserPreferencesButton" to show the button for setting preferences diff -r cbf54cd28d59 -r c6272d7bb6d9 Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp --- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Oct 27 18:43:20 2022 +0200 +++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp Thu Oct 27 19:12:29 2022 +0200 @@ -1589,6 +1589,7 @@ static const int LAYER_REFERENCE_LINES = 2; static const int LAYER_ANNOTATIONS_OSIRIX = 3; static const int LAYER_ANNOTATIONS_STONE = 4; + static const int LAYER_ORIENTATION_MARKERS = 5; class ICommand : public Orthanc::IDynamicObject @@ -2230,6 +2231,46 @@ StoneAnnotationsRegistry::GetInstance().Load(*stoneAnnotations_, instance.GetSopInstanceUid(), frameIndex); + // Orientation markers, new in Stone Web viewer 2.4 + std::unique_ptr orientationMarkers; + + if (instance.GetGeometry().IsValid()) + { + orientationMarkers.reset(new OrthancStone::MacroSceneLayer); + + std::string top, bottom, left, right; + instance.GetGeometry().GetOrientationMarkers(top, bottom, left, right); + + std::unique_ptr text; + + text.reset(new OrthancStone::TextSceneLayer); + text->SetText(top); + text->SetPosition(pixelSpacingX * static_cast(frame.GetWidth()) / 2.0, 0); + text->SetAnchor(OrthancStone::BitmapAnchor_TopCenter); + orientationMarkers->AddLayer(text.release()); + + text.reset(new OrthancStone::TextSceneLayer); + text->SetText(bottom); + text->SetPosition(pixelSpacingX * static_cast(frame.GetWidth()) / 2.0, + pixelSpacingY * static_cast(frame.GetHeight())); + text->SetAnchor(OrthancStone::BitmapAnchor_BottomCenter); + orientationMarkers->AddLayer(text.release()); + + text.reset(new OrthancStone::TextSceneLayer); + text->SetText(left); + text->SetPosition(0, pixelSpacingY * static_cast(frame.GetHeight()) / 2.0); + text->SetAnchor(OrthancStone::BitmapAnchor_CenterLeft); + orientationMarkers->AddLayer(text.release()); + + text.reset(new OrthancStone::TextSceneLayer); + text->SetText(right); + text->SetPosition(pixelSpacingX * static_cast(frame.GetWidth()), + pixelSpacingY * static_cast(frame.GetHeight()) / 2.0); + text->SetAnchor(OrthancStone::BitmapAnchor_CenterRight); + orientationMarkers->AddLayer(text.release()); + } + + { std::unique_ptr lock(viewport_->Lock()); @@ -2255,6 +2296,15 @@ scene.DeleteLayer(LAYER_ANNOTATIONS_OSIRIX); } + if (orientationMarkers.get() != NULL) + { + scene.SetLayer(LAYER_ORIENTATION_MARKERS, orientationMarkers.release()); + } + else + { + scene.DeleteLayer(LAYER_ORIENTATION_MARKERS); + } + stoneAnnotations_->Render(scene); // Necessary for "FitContent()" to work if (fitNextContent_)