Mercurial > hg > orthanc-stone
changeset 2384:83ea57ed2863 refactoring
merge
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Sun, 11 Oct 2026 09:56:59 +0200 |
| parents | a77e2bb865c1 (diff) 362a33965e11 (current diff) |
| children | bebd0583ebda |
| files | |
| diffstat | 3 files changed, 60 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.h Sat Oct 10 22:05:01 2026 +0200 +++ b/OrthancStone/Sources/Platforms/WebAssembly/WebAssemblyViewport.h Sun Oct 11 09:56:59 2026 +0200 @@ -58,7 +58,7 @@ std::string canvasId_; std::string canvasCssSelector_; std::unique_ptr<ICompositor> compositor_; - std::unique_ptr<ViewportController> controller_; + boost::shared_ptr<ViewportController> controller_; std::unique_ptr<IViewportInteractor> interactor_; bool enableEmscriptenMouseEvents_; unsigned int canvasWidth_;
--- a/OrthancStone/Sources/Scene2DViewport/ViewportController.cpp Sat Oct 10 22:05:01 2026 +0200 +++ b/OrthancStone/Sources/Scene2DViewport/ViewportController.cpp Sun Oct 11 09:56:59 2026 +0200 @@ -101,7 +101,7 @@ } std::vector<boost::shared_ptr<MeasureTool> > - ViewportController::HitTestMeasureTools(ScenePoint2D p) + ViewportController::HitTestMeasureTools(ScenePoint2D p) { std::vector<boost::shared_ptr<MeasureTool> > ret; @@ -143,7 +143,7 @@ ORTHANC_ASSERT(std::find(measureTools_.begin(), measureTools_.end(), measureTool) == measureTools_.end(), - "Duplicate measure tool"); + "Duplicate measure tool"); measureTools_.push_back(measureTool); } @@ -154,7 +154,7 @@ ORTHANC_ASSERT(std::find(measureTools_.begin(), measureTools_.end(), measureTool) != measureTools_.end(), - "Measure tool not found"); + "Measure tool not found"); measureTools_.erase( std::remove(measureTools_.begin(), measureTools_.end(), measureTool), measureTools_.end()); @@ -191,18 +191,6 @@ } - void ViewportController::InvalidateViewport() - { - boost::shared_ptr<IViewport> sharedViewport(viewport_.lock()); - - if (sharedViewport) - { - std::unique_ptr<IViewport::ILock> lock(sharedViewport->Lock()); - lock->Invalidate(); - } - } - - void ViewportController::HandleMousePress(IViewportInteractor& interactor, const PointerEvent& event, unsigned int viewportWidth, @@ -285,4 +273,55 @@ throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); } } + + + void ViewportController::InvalidateViewport() + { + boost::shared_ptr<IViewport> sharedViewport(viewport_.lock()); + + if (sharedViewport) + { + std::unique_ptr<IViewport::ILock> lock(sharedViewport->Lock()); + lock->Invalidate(); + } + } + + + void ViewportController::FitContent() + { + boost::shared_ptr<IViewport> sharedViewport(viewport_.lock()); + + if (sharedViewport) + { + std::unique_ptr<IViewport::ILock> lock(sharedViewport->Lock()); + if (lock->HasCompositor()) + { + lock->GetCompositor().FitContent(*scene_); + lock->Invalidate(); + + BroadcastMessage(SceneTransformChanged(*this)); + } + } + } + + + void ViewportController::GetCanvasSize(unsigned int& width, + unsigned int& height) + { + boost::shared_ptr<IViewport> sharedViewport(viewport_.lock()); + + if (sharedViewport) + { + std::unique_ptr<IViewport::ILock> lock(sharedViewport->Lock()); + if (lock->HasCompositor()) + { + width = lock->GetCompositor().GetCanvasWidth(); + height = lock->GetCompositor().GetCanvasHeight(); + return; + } + } + + width = 0; + height = 0; + } }
--- a/OrthancStone/Sources/Scene2DViewport/ViewportController.h Sat Oct 10 22:05:01 2026 +0200 +++ b/OrthancStone/Sources/Scene2DViewport/ViewportController.h Sun Oct 11 09:56:59 2026 +0200 @@ -193,6 +193,11 @@ void InvalidateViewport(); + void FitContent(); + + void GetCanvasSize(unsigned int& width, + unsigned int& height); + private: // The scene can be used by the higher-level objects (including the // measuring tools), possibly in their destructor, and so it must be
