Mercurial > hg > orthanc-stone
changeset 1535:301571299212
DefaultViewportInteractor::SetWindowingLayer()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Aug 2020 22:23:36 +0200 |
parents | 0443d04416d9 |
children | 7b326e5ee97b |
files | OrthancStone/Samples/Common/RtViewerApp.h OrthancStone/Samples/Common/RtViewerView.cpp OrthancStone/Samples/Common/RtViewerView.h OrthancStone/Samples/Sdl/RtViewer/RtViewerSdl.cpp OrthancStone/Samples/Sdl/SingleFrameViewer/SdlSimpleViewer.cpp OrthancStone/Samples/WebAssembly/RtViewer/RtViewerWasm.cpp OrthancStone/Sources/Scene2DViewport/ViewportController.cpp OrthancStone/Sources/Scene2DViewport/ViewportController.h |
diffstat | 8 files changed, 40 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancStone/Samples/Common/RtViewerApp.h Fri Aug 07 21:48:43 2020 +0200 +++ b/OrthancStone/Samples/Common/RtViewerApp.h Fri Aug 07 22:23:36 2020 +0200 @@ -73,7 +73,7 @@ public: void RunSdl(int argc, char* argv[]); void SdlRunLoop(const std::vector<boost::shared_ptr<OrthancStone::RtViewerView> >& views, - OrthancStone::IViewportInteractor& interactor); + OrthancStone::DefaultViewportInteractor& interactor); private: void ProcessOptions(int argc, char* argv[]); void HandleApplicationEvent(const SDL_Event& event);
--- a/OrthancStone/Samples/Common/RtViewerView.cpp Fri Aug 07 21:48:43 2020 +0200 +++ b/OrthancStone/Samples/Common/RtViewerView.cpp Fri Aug 07 22:23:36 2020 +0200 @@ -320,6 +320,8 @@ { ctVolumeLayerSource_->SetConfigurator(style); } + + ctLayer_ = depth; } void RtViewerView::SetDoseVolumeSlicer(const boost::shared_ptr<OrthancStone::IVolumeSlicer>& volume,
--- a/OrthancStone/Samples/Common/RtViewerView.h Fri Aug 07 21:48:43 2020 +0200 +++ b/OrthancStone/Samples/Common/RtViewerView.h Fri Aug 07 22:23:36 2020 +0200 @@ -51,6 +51,7 @@ : app_(app) , currentPlane_(0) , projection_(projection) + , ctLayer_(0) { viewport_ = CreateViewport(canvasId); FLOATING_INFOTEXT_LAYER_ZINDEX = 6; @@ -101,6 +102,11 @@ return viewport_; } + int GetCtLayerIndex() const + { + return ctLayer_; + } + private: void SetInfoDisplayMessage(std::string key, std::string value); boost::shared_ptr<RtViewerApp> GetApp(); @@ -132,5 +138,7 @@ int FLOATING_INFOTEXT_LAYER_ZINDEX; int FIXED_INFOTEXT_LAYER_ZINDEX; boost::shared_ptr<IViewport> viewport_; + + int ctLayer_; }; }
--- a/OrthancStone/Samples/Sdl/RtViewer/RtViewerSdl.cpp Fri Aug 07 21:48:43 2020 +0200 +++ b/OrthancStone/Samples/Sdl/RtViewer/RtViewerSdl.cpp Fri Aug 07 22:23:36 2020 +0200 @@ -245,7 +245,7 @@ } void RtViewerApp::SdlRunLoop(const std::vector<boost::shared_ptr<OrthancStone::RtViewerView> >& views, - OrthancStone::IViewportInteractor& interactor) + OrthancStone::DefaultViewportInteractor& interactor) { using namespace OrthancStone; @@ -373,6 +373,7 @@ switch (sdlEvent.type) { case SDL_MOUSEBUTTONDOWN: + interactor.SetWindowingLayer(view->GetCtLayerIndex()); lock->GetController().HandleMousePress(interactor, p, lock->GetCompositor().GetCanvasWidth(), lock->GetCompositor().GetCanvasHeight());
--- a/OrthancStone/Samples/Sdl/SingleFrameViewer/SdlSimpleViewer.cpp Fri Aug 07 21:48:43 2020 +0200 +++ b/OrthancStone/Samples/Sdl/SingleFrameViewer/SdlSimpleViewer.cpp Fri Aug 07 22:23:36 2020 +0200 @@ -143,6 +143,7 @@ application->LoadOrthancFrame(source, instanceId, frameIndex); OrthancStone::DefaultViewportInteractor interactor; + interactor.SetWindowingLayer(0); { int scancodeCount = 0;
--- a/OrthancStone/Samples/WebAssembly/RtViewer/RtViewerWasm.cpp Fri Aug 07 21:48:43 2020 +0200 +++ b/OrthancStone/Samples/WebAssembly/RtViewer/RtViewerWasm.cpp Fri Aug 07 22:23:36 2020 +0200 @@ -145,8 +145,6 @@ } StartLoaders(); - - DefaultViewportInteractor interactor; } }
--- a/OrthancStone/Sources/Scene2DViewport/ViewportController.cpp Fri Aug 07 21:48:43 2020 +0200 +++ b/OrthancStone/Sources/Scene2DViewport/ViewportController.cpp Fri Aug 07 22:23:36 2020 +0200 @@ -34,18 +34,18 @@ namespace OrthancStone { IFlexiblePointerTracker* DefaultViewportInteractor::CreateTracker( - boost::shared_ptr<IViewport> viewport, - const PointerEvent& event, - unsigned int viewportWidth, - unsigned int viewportHeight) + boost::shared_ptr<IViewport> viewport, + const PointerEvent& event, + unsigned int viewportWidth, + unsigned int viewportHeight) { switch (event.GetMouseButton()) { case MouseButton_Left: //return new RotateSceneTracker(viewport, event); - // Assumes that the layer whose windowing is controlled, is the one with index "0" - return new GrayscaleWindowingSceneTracker(viewport, 0, event, viewportWidth, viewportHeight); + return new GrayscaleWindowingSceneTracker( + viewport, windowingLayer_, event, viewportWidth, viewportHeight); case MouseButton_Middle: return new PanSceneTracker(viewport, event);
--- a/OrthancStone/Sources/Scene2DViewport/ViewportController.h Fri Aug 07 21:48:43 2020 +0200 +++ b/OrthancStone/Sources/Scene2DViewport/ViewportController.h Fri Aug 07 22:23:36 2020 +0200 @@ -51,7 +51,27 @@ // TODO - Move this to another file class DefaultViewportInteractor : public IViewportInteractor { + private: + // Index of the layer whose windowing is altered by clicking the + // left mouse button + int windowingLayer_; + public: + DefaultViewportInteractor() : + windowingLayer_(0) + { + } + + int GetWindowingLayer() const + { + return windowingLayer_; + } + + void SetWindowingLayer(int layerIndex) + { + windowingLayer_ = layerIndex; + } + virtual IFlexiblePointerTracker* CreateTracker(boost::shared_ptr<IViewport> viewport, const PointerEvent& event, unsigned int viewportWidth,