Mercurial > hg > orthanc-stone
diff Applications/Sdl/SdlStoneApplicationRunner.cpp @ 385:6cc3ce74dc05
using message broker in widgets
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 07 Nov 2018 20:49:41 +0100 |
parents | faccc4b07b92 |
children | b70e9be013e4 |
line wrap: on
line diff
--- a/Applications/Sdl/SdlStoneApplicationRunner.cpp Wed Nov 07 16:17:02 2018 +0100 +++ b/Applications/Sdl/SdlStoneApplicationRunner.cpp Wed Nov 07 20:49:41 2018 +0100 @@ -24,16 +24,18 @@ #endif #include "SdlStoneApplicationRunner.h" -#include <boost/program_options.hpp> #include "../../Framework/Toolbox/MessagingToolbox.h" +#include "../../Platforms/Generic/OracleWebService.h" #include "SdlEngine.h" #include <Core/Logging.h> #include <Core/HttpClient.h> #include <Core/Toolbox.h> +#include <Core/OrthancException.h> #include <Plugins/Samples/Common/OrthancHttpConnection.h> -#include "../../Platforms/Generic/OracleWebService.h" + +#include <boost/program_options.hpp> namespace OrthancStone { @@ -42,6 +44,7 @@ SdlWindow::GlobalInitialize(); } + void SdlStoneApplicationRunner::DeclareCommandLineOptions(boost::program_options::options_description& options) { boost::program_options::options_description sdl("SDL options"); @@ -54,6 +57,7 @@ options.add(sdl); } + void SdlStoneApplicationRunner::ParseCommandLineOptions(const boost::program_options::variables_map& parameters) { if (!parameters.count("width") || @@ -85,10 +89,13 @@ { LOG(WARNING) << "OpenGL is disabled, enable it with option \"--opengl=on\" for best performance"; } - } - void SdlStoneApplicationRunner::Run(NativeStoneApplicationContext& context, const std::string& title, int argc, char* argv[]) + + void SdlStoneApplicationRunner::Run(NativeStoneApplicationContext& context, + const std::string& title, + int argc, + char* argv[]) { /************************************************************** * Run the application inside a SDL window @@ -97,11 +104,16 @@ LOG(WARNING) << "Starting the application"; SdlWindow window(title.c_str(), width_, height_, enableOpenGl_); - SdlEngine sdl(window, context); + SdlEngine sdl(window, context, broker_); { NativeStoneApplicationContext::GlobalMutexLocker locker(context); - context.GetCentralViewport().Register(sdl); // (*) + + locker.GetCentralViewport().RegisterObserverCallback( + new Callable<SdlEngine, IViewport::ViewportChangedMessage> + (sdl, &SdlEngine::OnViewportChanged)); + + //context.GetCentralViewport().Register(sdl); // (*) } context.Start(); @@ -115,13 +127,14 @@ // update thread started by "context.Start()" would call a // destructed object (the "SdlEngine" is deleted with the // lexical scope). + + // TODO Is this still true with message broker? context.Stop(); } + void SdlStoneApplicationRunner::Finalize() { SdlWindow::GlobalFinalize(); } - - }