Mercurial > hg > orthanc-stone
diff Samples/Common/RtViewer.h @ 1393:27e0a00bd3e8
RtViewer SingleFrameViewer OK : wasm SDL single viewport
other viewports ongoing
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 29 Apr 2020 15:54:18 +0200 |
parents | dfb48f0794b1 |
children |
line wrap: on
line diff
--- a/Samples/Common/RtViewer.h Tue Apr 28 13:52:21 2020 +0200 +++ b/Samples/Common/RtViewer.h Wed Apr 29 15:54:18 2020 +0200 @@ -18,19 +18,18 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. **/ -#include <Framework/Viewport/SdlViewport.h> -#include <Framework/Loaders/GenericLoadersContext.h> +#include <Framework/Viewport/IViewport.h> + +#include <Framework/Loaders/DicomStructureSetLoader.h> +#include <Framework/Loaders/OrthancMultiframeVolumeLoader.h> +#include <Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h> +#include <Framework/Loaders/ILoadersContext.h> +#include <Framework/Messages/IMessageEmitter.h> #include <Framework/Messages/IObserver.h> -#include <Framework/Messages/IMessageEmitter.h> +#include <Framework/Messages/ObserverBase.h> #include <Framework/Oracle/OracleCommandExceptionMessage.h> #include <Framework/Scene2DViewport/ViewportController.h> #include <Framework/Volumes/DicomVolumeImage.h> -#include <Framework/Oracle/ThreadedOracle.h> -#include <Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h> -#include <Framework/Loaders/OrthancMultiframeVolumeLoader.h> -#include <Framework/Loaders/DicomStructureSetLoader.h> - -#include <Framework/Messages/ObserverBase.h> #include <boost/enable_shared_from_this.hpp> #include <boost/thread.hpp> @@ -88,6 +87,10 @@ void ProcessOptions(int argc, char* argv[]); void HandleApplicationEvent(const SDL_Event& event); #elif ORTHANC_ENABLE_WASM + public: + void RunWasm(); +#else +# error Either ORTHANC_ENABLE_SDL or ORTHANC_ENABLE_WASM must be enabled #endif public: @@ -95,6 +98,12 @@ void DisableTracker(); /** + Called by command-line option processing or when parsing the URL + parameters. + */ + void SetArgument(const std::string& key, const std::string& value); + + /** This method is called when the scene transform changes. It allows to recompute the visual elements whose content depend upon the scene transform */ @@ -136,56 +145,14 @@ private: void PrepareLoadersAndSlicers(); - - /** - Url of the Orthanc instance - Typically, in a native application (Qt, SDL), it will be an absolute URL like "http://localhost:8042". In - wasm on the browser, it could be an absolute URL, provided you do not have cross-origin problems, or a relative - URL. In our wasm samples, it is set to "..", because we set up either a reverse proxy or an Orthanc ServeFolders - plugin that serves the main web application from an URL like "http://localhost:8042/rtviewer" (with ".." leading - to the main Orthanc root URL) - */ - std::string orthancUrl_; - - /** - Orthanc ID of the CT series to load. Only used between startup and loading time. - */ - std::string ctSeriesId_; - - /** - Orthanc ID of the RTDOSE instance to load. Only used between startup and loading time. - */ - std::string doseInstanceId_; - - /** - Orthanc ID of the RTSTRUCT instance to load. Only used between startup and loading time. - */ - std::string rtStructInstanceId_; - - -#if ORTHANC_ENABLE_SDL - // if threaded (not wasm) - //IObservable oracleObservable_; - //ThreadedOracle oracle_; - //boost::shared_mutex mutex_; // to serialize messages from the ThreadedOracle -#elif ORTHANC_ENABLE_WASM - - -#endif - void SelectNextTool(); - /** - This returns a random point in the canvas part of the scene, but in - scene coordinates - */ - ScenePoint2D GetRandomPointInScene() const; + // argument handling + // SetArgument is above (public section) + std::map<std::string, std::string> arguments_; - boost::shared_ptr<IFlexiblePointerTracker> TrackerHitTest(const PointerEvent& e); - - boost::shared_ptr<IFlexiblePointerTracker> CreateSuitableTracker( - const SDL_Event& event, - const PointerEvent& e); + const std::string& GetArgument(const std::string& key) const; + bool HasArgument(const std::string& key) const; void TakeScreenshot( const std::string& target, @@ -224,6 +191,7 @@ const boost::shared_ptr<DicomStructureSetLoader>& volume); private: + void CreateViewport(); void DisplayFloatingCtrlInfoText(const PointerEvent& e); void DisplayInfoText(); void HideInfoText(); @@ -239,7 +207,8 @@ boost::shared_ptr<DicomStructureSetLoader> rtstructLoader_; /** encapsulates resources shared by loaders */ - boost::shared_ptr<GenericLoadersContext> loadersContext_; + boost::shared_ptr<ILoadersContext> loadersContext_; + boost::shared_ptr<VolumeSceneLayerSource> ctVolumeLayerSource_, doseVolumeLayerSource_, structLayerSource_; /** @@ -270,7 +239,7 @@ RtViewerGuiTool currentTool_; boost::shared_ptr<UndoStack> undoStack_; - boost::shared_ptr<SdlOpenGLViewport> viewport_; + boost::shared_ptr<IViewport> viewport_; }; }