# HG changeset patch
# User am@osimis.io
# Date 1535462806 -7200
# Node ID 3c190e2bb3af08310c1ce4f01668317606e15c39
# Parent 38b0ac8055b9939bfae1f45a212c98f8eb08019b
refactoring: ApplicationRunner + app hierarchy
diff -r 38b0ac8055b9 -r 3c190e2bb3af .hgignore
--- a/.hgignore Tue Aug 28 11:09:37 2018 +0200
+++ b/.hgignore Tue Aug 28 15:26:46 2018 +0200
@@ -4,3 +4,4 @@
Platforms/Wasm/build/
Platforms/Wasm/build-web/
Platforms/Wasm/ThirdPartyDownloads/
+Applications/Qt/archive/
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Generic/BasicNativeApplication.cpp
--- a/Applications/Generic/BasicNativeApplication.cpp Tue Aug 28 11:09:37 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,242 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- **/
-
-
-#if ORTHANC_ENABLE_NATIVE != 1
-#error this file shall be included only with the ORTHANC_ENABLE_NATIVE set to 1
-#endif
-
-#include "BasicNativeApplication.h"
-#include "BasicNativeApplicationContext.h"
-#include
-
-#include "../../Framework/Toolbox/MessagingToolbox.h"
-
-#include
-#include
-#include
-#include
-#include "../../Platforms/Generic/OracleWebService.h"
-
-namespace OrthancStone
-{
- // Anonymous namespace to avoid clashes against other compilation modules
- namespace
- {
- class LogStatusBar : public IStatusBar
- {
- public:
- virtual void ClearMessage()
- {
- }
-
- virtual void SetMessage(const std::string& message)
- {
- LOG(WARNING) << message;
- }
- };
- }
-
- int BasicNativeApplication::Execute(MessageBroker& broker,
- IBasicApplication& application,
- int argc,
- char* argv[])
- {
- /******************************************************************
- * Initialize all the subcomponents of Orthanc Stone
- ******************************************************************/
-
- Orthanc::Logging::Initialize();
- Orthanc::Toolbox::InitializeOpenSsl();
- Orthanc::HttpClient::GlobalInitialize();
-
- Initialize();
-
- /******************************************************************
- * Declare and parse the command-line options of the application
- ******************************************************************/
-
- boost::program_options::options_description options;
-
- { // generic options
- boost::program_options::options_description generic("Generic options");
- generic.add_options()
- ("help", "Display this help and exit")
- ("verbose", "Be verbose in logs")
- ("orthanc", boost::program_options::value()->default_value("http://localhost:8042/"),
- "URL to the Orthanc server")
- ("username", "Username for the Orthanc server")
- ("password", "Password for the Orthanc server")
- ("https-verify", boost::program_options::value()->default_value(true), "Check HTTPS certificates")
- ;
-
- options.add(generic);
- }
-
- // platform specific options
- DeclareCommandLineOptions(options);
-
- // application specific options
- application.DeclareStartupOptions(options);
-
- boost::program_options::variables_map parameters;
- bool error = false;
-
- try
- {
- boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
- options(options).run(), parameters);
- boost::program_options::notify(parameters);
- }
- catch (boost::program_options::error& e)
- {
- LOG(ERROR) << "Error while parsing the command-line arguments: " << e.what();
- error = true;
- }
-
-
- /******************************************************************
- * Configure the application with the command-line parameters
- ******************************************************************/
-
- if (error || parameters.count("help"))
- {
- std::cout << std::endl
- << "Usage: " << argv[0] << " [OPTION]..."
- << std::endl
- << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research."
- << std::endl << std::endl
- << "Demonstration application of Orthanc Stone using SDL."
- << std::endl;
-
- std::cout << options << "\n";
- return error ? -1 : 0;
- }
-
- if (parameters.count("https-verify") &&
- !parameters["https-verify"].as())
- {
- LOG(WARNING) << "Turning off verification of HTTPS certificates (unsafe)";
- Orthanc::HttpClient::ConfigureSsl(false, "");
- }
-
- if (parameters.count("verbose"))
- {
- Orthanc::Logging::EnableInfoLevel(true);
- }
-
- ParseCommandLineOptions(parameters);
-
-
- bool success = true;
- try
- {
- /****************************************************************
- * Initialize the connection to the Orthanc server
- ****************************************************************/
-
- Orthanc::WebServiceParameters webServiceParameters;
-
- if (parameters.count("orthanc"))
- {
- webServiceParameters.SetUrl(parameters["orthanc"].as());
- }
-
- if (parameters.count("username"))
- {
- webServiceParameters.SetUsername(parameters["username"].as());
- }
-
- if (parameters.count("password"))
- {
- webServiceParameters.SetPassword(parameters["password"].as());
- }
-
- LOG(WARNING) << "URL to the Orthanc REST API: " << webServiceParameters.GetUrl();
-
- {
- OrthancPlugins::OrthancHttpConnection orthanc(webServiceParameters);
- if (!MessagingToolbox::CheckOrthancVersion(orthanc))
- {
- LOG(ERROR) << "Your version of Orthanc is incompatible with Stone of Orthanc, please upgrade";
- throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
- }
- }
-
-
- /****************************************************************
- * Initialize the application
- ****************************************************************/
-
- LOG(WARNING) << "Creating the widgets of the application";
-
- LogStatusBar statusBar;
-
- BasicNativeApplicationContext context;
- Oracle oracle(4); // use 4 threads to download content
- OracleWebService webService(broker, oracle, webServiceParameters, context);
- context.SetWebService(webService);
-
- application.Initialize(&context, statusBar, parameters);
-
- {
- BasicNativeApplicationContext::GlobalMutexLocker locker(context);
- context.SetCentralWidget(application.GetCentralWidget());
- context.GetCentralViewport().SetStatusBar(statusBar);
- }
-
- std::string title = application.GetTitle();
- if (title.empty())
- {
- title = "Stone of Orthanc";
- }
-
- /****************************************************************
- * Run the application
- ****************************************************************/
-
- Run(context, title, argc, argv);
-
- /****************************************************************
- * Finalize the application
- ****************************************************************/
-
- LOG(WARNING) << "The application has stopped";
- application.Finalize();
- }
- catch (Orthanc::OrthancException& e)
- {
- LOG(ERROR) << "EXCEPTION: " << e.What();
- success = false;
- }
-
-
- /******************************************************************
- * Finalize all the subcomponents of Orthanc Stone
- ******************************************************************/
-
- Finalize();
- Orthanc::HttpClient::GlobalFinalize();
- Orthanc::Toolbox::FinalizeOpenSsl();
-
- return (success ? 0 : -1);
- }
-
-}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Generic/BasicNativeApplication.h
--- a/Applications/Generic/BasicNativeApplication.h Tue Aug 28 11:09:37 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- **/
-
-
-#pragma once
-
-#include "../IBasicApplication.h"
-
-#if ORTHANC_ENABLE_NATIVE != 1
-#error this file shall be included only with the ORTHANC_ENABLE_NATIVE set to 1
-#endif
-
-namespace OrthancStone
-{
- class BasicNativeApplicationContext;
-
- class BasicNativeApplication
- {
- public:
-
- int Execute(MessageBroker& broker,
- IBasicApplication& application,
- int argc,
- char* argv[]);
-
- virtual void Initialize() = 0;
- virtual void DeclareCommandLineOptions(boost::program_options::options_description& options) = 0;
- virtual void ParseCommandLineOptions(const boost::program_options::variables_map& parameters) = 0;
-
- virtual void Run(BasicNativeApplicationContext& context, const std::string& title, int argc, char* argv[]) = 0;
- virtual void Finalize() = 0;
- };
-
-}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Generic/BasicNativeApplicationRunner.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Generic/BasicNativeApplicationRunner.cpp Tue Aug 28 15:26:46 2018 +0200
@@ -0,0 +1,240 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ **/
+
+
+#if ORTHANC_ENABLE_NATIVE != 1
+#error this file shall be included only with the ORTHANC_ENABLE_NATIVE set to 1
+#endif
+
+#include "BasicNativeApplicationRunner.h"
+#include "BasicNativeApplicationContext.h"
+#include
+
+#include "../../Framework/Toolbox/MessagingToolbox.h"
+
+#include
+#include
+#include
+#include
+#include "../../Platforms/Generic/OracleWebService.h"
+
+namespace OrthancStone
+{
+ // Anonymous namespace to avoid clashes against other compilation modules
+ namespace
+ {
+ class LogStatusBar : public IStatusBar
+ {
+ public:
+ virtual void ClearMessage()
+ {
+ }
+
+ virtual void SetMessage(const std::string& message)
+ {
+ LOG(WARNING) << message;
+ }
+ };
+ }
+
+ int BasicNativeApplicationRunner::Execute(int argc,
+ char* argv[])
+ {
+ /******************************************************************
+ * Initialize all the subcomponents of Orthanc Stone
+ ******************************************************************/
+
+ Orthanc::Logging::Initialize();
+ Orthanc::Toolbox::InitializeOpenSsl();
+ Orthanc::HttpClient::GlobalInitialize();
+
+ Initialize();
+
+ /******************************************************************
+ * Declare and parse the command-line options of the application
+ ******************************************************************/
+
+ boost::program_options::options_description options;
+
+ { // generic options
+ boost::program_options::options_description generic("Generic options");
+ generic.add_options()
+ ("help", "Display this help and exit")
+ ("verbose", "Be verbose in logs")
+ ("orthanc", boost::program_options::value()->default_value("http://localhost:8042/"),
+ "URL to the Orthanc server")
+ ("username", "Username for the Orthanc server")
+ ("password", "Password for the Orthanc server")
+ ("https-verify", boost::program_options::value()->default_value(true), "Check HTTPS certificates")
+ ;
+
+ options.add(generic);
+ }
+
+ // platform specific options
+ DeclareCommandLineOptions(options);
+
+ // application specific options
+ application_.DeclareStartupOptions(options);
+
+ boost::program_options::variables_map parameters;
+ bool error = false;
+
+ try
+ {
+ boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
+ options(options).run(), parameters);
+ boost::program_options::notify(parameters);
+ }
+ catch (boost::program_options::error& e)
+ {
+ LOG(ERROR) << "Error while parsing the command-line arguments: " << e.what();
+ error = true;
+ }
+
+
+ /******************************************************************
+ * Configure the application with the command-line parameters
+ ******************************************************************/
+
+ if (error || parameters.count("help"))
+ {
+ std::cout << std::endl
+ << "Usage: " << argv[0] << " [OPTION]..."
+ << std::endl
+ << "Orthanc, lightweight, RESTful DICOM server for healthcare and medical research."
+ << std::endl << std::endl
+ << "Demonstration application of Orthanc Stone using SDL."
+ << std::endl;
+
+ std::cout << options << "\n";
+ return error ? -1 : 0;
+ }
+
+ if (parameters.count("https-verify") &&
+ !parameters["https-verify"].as())
+ {
+ LOG(WARNING) << "Turning off verification of HTTPS certificates (unsafe)";
+ Orthanc::HttpClient::ConfigureSsl(false, "");
+ }
+
+ if (parameters.count("verbose"))
+ {
+ Orthanc::Logging::EnableInfoLevel(true);
+ }
+
+ ParseCommandLineOptions(parameters);
+
+
+ bool success = true;
+ try
+ {
+ /****************************************************************
+ * Initialize the connection to the Orthanc server
+ ****************************************************************/
+
+ Orthanc::WebServiceParameters webServiceParameters;
+
+ if (parameters.count("orthanc"))
+ {
+ webServiceParameters.SetUrl(parameters["orthanc"].as());
+ }
+
+ if (parameters.count("username"))
+ {
+ webServiceParameters.SetUsername(parameters["username"].as());
+ }
+
+ if (parameters.count("password"))
+ {
+ webServiceParameters.SetPassword(parameters["password"].as());
+ }
+
+ LOG(WARNING) << "URL to the Orthanc REST API: " << webServiceParameters.GetUrl();
+
+ {
+ OrthancPlugins::OrthancHttpConnection orthanc(webServiceParameters);
+ if (!MessagingToolbox::CheckOrthancVersion(orthanc))
+ {
+ LOG(ERROR) << "Your version of Orthanc is incompatible with Stone of Orthanc, please upgrade";
+ throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol);
+ }
+ }
+
+
+ /****************************************************************
+ * Initialize the application
+ ****************************************************************/
+
+ LOG(WARNING) << "Creating the widgets of the application";
+
+ LogStatusBar statusBar;
+
+ BasicNativeApplicationContext context;
+ Oracle oracle(4); // use 4 threads to download content
+ OracleWebService webService(broker_, oracle, webServiceParameters, context);
+ context.SetWebService(webService);
+
+ application_.Initialize(&context, statusBar, parameters);
+
+ {
+ BasicNativeApplicationContext::GlobalMutexLocker locker(context);
+ context.SetCentralWidget(application_.GetCentralWidget());
+ context.GetCentralViewport().SetStatusBar(statusBar);
+ }
+
+ std::string title = application_.GetTitle();
+ if (title.empty())
+ {
+ title = "Stone of Orthanc";
+ }
+
+ /****************************************************************
+ * Run the application
+ ****************************************************************/
+
+ Run(context, title, argc, argv);
+
+ /****************************************************************
+ * Finalize the application
+ ****************************************************************/
+
+ LOG(WARNING) << "The application is stopping";
+ application_.Finalize();
+ }
+ catch (Orthanc::OrthancException& e)
+ {
+ LOG(ERROR) << "EXCEPTION: " << e.What();
+ success = false;
+ }
+
+
+ /******************************************************************
+ * Finalize all the subcomponents of Orthanc Stone
+ ******************************************************************/
+
+ Finalize();
+ Orthanc::HttpClient::GlobalFinalize();
+ Orthanc::Toolbox::FinalizeOpenSsl();
+
+ return (success ? 0 : -1);
+ }
+
+}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Generic/BasicNativeApplicationRunner.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Generic/BasicNativeApplicationRunner.h Tue Aug 28 15:26:46 2018 +0200
@@ -0,0 +1,58 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ **/
+
+
+#pragma once
+
+#include "../IBasicApplication.h"
+
+#if ORTHANC_ENABLE_NATIVE != 1
+#error this file shall be included only with the ORTHANC_ENABLE_NATIVE set to 1
+#endif
+
+namespace OrthancStone
+{
+ class BasicNativeApplicationContext;
+
+ class BasicNativeApplicationRunner
+ {
+ protected:
+ MessageBroker& broker_;
+ IBasicApplication& application_;
+ public:
+
+ BasicNativeApplicationRunner(MessageBroker& broker,
+ IBasicApplication& application)
+ : broker_(broker),
+ application_(application)
+ {
+ }
+ int Execute(int argc,
+ char* argv[]);
+
+ virtual void Initialize() = 0;
+ virtual void DeclareCommandLineOptions(boost::program_options::options_description& options) = 0;
+ virtual void ParseCommandLineOptions(const boost::program_options::variables_map& parameters) = 0;
+
+ virtual void Run(BasicNativeApplicationContext& context, const std::string& title, int argc, char* argv[]) = 0;
+ virtual void Finalize() = 0;
+ };
+
+}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Qt/BasicQtApplication.cpp
--- a/Applications/Qt/BasicQtApplication.cpp Tue Aug 28 11:09:37 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- **/
-
-
-#if ORTHANC_ENABLE_QT != 1
-#error this file shall be included only with the ORTHANC_ENABLE_QT set to 1
-#endif
-
-#include "BasicQtApplication.h"
-#include
-#include
-
-#include "../../Framework/Toolbox/MessagingToolbox.h"
-
-#include
-#include
-#include
-#include
-#include "../../Platforms/Generic/OracleWebService.h"
-#include "../../Applications/Samples/Qt/MainWindow.h"
-
-
-namespace OrthancStone
-{
- void BasicQtApplication::Initialize()
- {
- }
-
- void BasicQtApplication::DeclareCommandLineOptions(boost::program_options::options_description& options)
- {
- }
-
- void BasicQtApplication::Run(BasicNativeApplicationContext& context, const std::string& title, int argc, char* argv[])
- {
- context.Start();
-
- QApplication app(argc, argv);
- MainWindow window(context);
-
- window.show();
- app.exec();
-
- context.Stop();
- }
-
- void BasicQtApplication::Finalize()
- {
- }
-
-
-}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Qt/BasicQtApplication.h
--- a/Applications/Qt/BasicQtApplication.h Tue Aug 28 11:09:37 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- **/
-
-
-#pragma once
-
-#include "../Generic/BasicNativeApplication.h"
-
-#if ORTHANC_ENABLE_QT != 1
-#error this file shall be included only with the ORTHANC_ENABLE_QT set to 1
-#endif
-
-namespace OrthancStone
-{
- class BasicQtApplication : public BasicNativeApplication
- {
- public:
- virtual void Initialize();
- virtual void DeclareCommandLineOptions(boost::program_options::options_description& options);
- virtual void ParseCommandLineOptions(const boost::program_options::variables_map& parameters) {}
- virtual void Run(BasicNativeApplicationContext& context, const std::string& title, int argc, char* argv[]);
- virtual void Finalize();
- };
-
-}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Qt/BasicQtApplicationRunner.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Qt/BasicQtApplicationRunner.cpp Tue Aug 28 15:26:46 2018 +0200
@@ -0,0 +1,67 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ **/
+
+
+#if ORTHANC_ENABLE_QT != 1
+#error this file shall be included only with the ORTHANC_ENABLE_QT set to 1
+#endif
+
+#include "BasicQtApplicationRunner.h"
+#include
+#include
+
+#include "../../Framework/Toolbox/MessagingToolbox.h"
+
+#include
+#include
+#include
+#include
+#include "../../Platforms/Generic/OracleWebService.h"
+
+
+namespace OrthancStone
+{
+ void BasicQtApplicationRunner::Initialize()
+ {
+ }
+
+ void BasicQtApplicationRunner::DeclareCommandLineOptions(boost::program_options::options_description& options)
+ {
+ }
+
+ void BasicQtApplicationRunner::Run(BasicNativeApplicationContext& context, const std::string& title, int argc, char* argv[])
+ {
+ context.Start();
+
+ QApplication app(argc, argv);
+ InitializeMainWindow(context);
+
+ window_->show();
+ app.exec();
+
+ context.Stop();
+ }
+
+ void BasicQtApplicationRunner::Finalize()
+ {
+ }
+
+
+}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Qt/BasicQtApplicationRunner.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Qt/BasicQtApplicationRunner.h Tue Aug 28 15:26:46 2018 +0200
@@ -0,0 +1,55 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ **/
+
+
+#pragma once
+
+#include "../Generic/BasicNativeApplicationRunner.h"
+#include "QStoneMainWindow.h"
+
+#if ORTHANC_ENABLE_QT != 1
+#error this file shall be included only with the ORTHANC_ENABLE_QT set to 1
+#endif
+
+namespace OrthancStone
+{
+ class BasicQtApplicationRunner : public BasicNativeApplicationRunner
+ {
+ protected:
+ std::auto_ptr window_;
+
+ virtual void InitializeMainWindow(BasicNativeApplicationContext& context) = 0;
+ public:
+ BasicQtApplicationRunner(MessageBroker& broker,
+ IBasicApplication& application)
+ : BasicNativeApplicationRunner(broker, application)
+ {
+ }
+
+
+ virtual void Initialize();
+
+ virtual void DeclareCommandLineOptions(boost::program_options::options_description& options);
+ virtual void ParseCommandLineOptions(const boost::program_options::variables_map& parameters) {}
+ virtual void Run(BasicNativeApplicationContext& context, const std::string& title, int argc, char* argv[]);
+ virtual void Finalize();
+ };
+
+}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Qt/QStoneMainWindow.cpp
--- a/Applications/Qt/QStoneMainWindow.cpp Tue Aug 28 11:09:37 2018 +0200
+++ b/Applications/Qt/QStoneMainWindow.cpp Tue Aug 28 15:26:46 2018 +0200
@@ -20,20 +20,22 @@
#include "QStoneMainWindow.h"
-QStoneMainWindow::QStoneMainWindow(OrthancStone::BasicNativeApplicationContext& context, QWidget *parent) :
- QMainWindow(parent),
- context_(context)
-{
-}
-
-void QStoneMainWindow::SetCentralStoneWidget(QCairoWidget *centralWidget)
+namespace OrthancStone
{
- cairoCentralWidget_ = centralWidget;
- cairoCentralWidget_->SetContext(context_);
-}
+
+ QStoneMainWindow::QStoneMainWindow(BasicNativeApplicationContext& context, QWidget *parent) :
+ QMainWindow(parent),
+ context_(context)
+ {
+ }
-QStoneMainWindow::~QStoneMainWindow()
-{
+ void QStoneMainWindow::SetCentralStoneWidget(QCairoWidget *centralWidget)
+ {
+ cairoCentralWidget_ = centralWidget;
+ cairoCentralWidget_->SetContext(context_);
+ }
+
+ QStoneMainWindow::~QStoneMainWindow()
+ {
+ }
}
-
-
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Qt/QStoneMainWindow.h
--- a/Applications/Qt/QStoneMainWindow.h Tue Aug 28 11:09:37 2018 +0200
+++ b/Applications/Qt/QStoneMainWindow.h Tue Aug 28 15:26:46 2018 +0200
@@ -24,19 +24,22 @@
#include "QCairoWidget.h"
#include "../Generic/BasicNativeApplicationContext.h"
-class QStoneMainWindow : public QMainWindow
+namespace OrthancStone
{
- Q_OBJECT
+ class QStoneMainWindow : public QMainWindow
+ {
+ Q_OBJECT
-private:
- OrthancStone::BasicNativeApplicationContext& context_;
- QCairoWidget *cairoCentralWidget_;
+ private:
+ OrthancStone::BasicNativeApplicationContext& context_;
+ QCairoWidget *cairoCentralWidget_;
-protected: // you must inherit this class
- QStoneMainWindow(OrthancStone::BasicNativeApplicationContext& context, QWidget *parent = 0);
- void SetCentralStoneWidget(QCairoWidget* centralWidget);
-public:
- virtual ~QStoneMainWindow();
+ protected: // you must inherit this class
+ QStoneMainWindow(BasicNativeApplicationContext& context, QWidget *parent = 0);
+ void SetCentralStoneWidget(QCairoWidget* centralWidget);
+ public:
+ virtual ~QStoneMainWindow();
-};
+ };
+}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/Qt/MainWindow.cpp
--- a/Applications/Samples/Qt/MainWindow.cpp Tue Aug 28 11:09:37 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- **/
-
-#include "MainWindow.h"
-
-/**
- * Don't use "ui_MainWindow.h" instead of below, as
- * this makes CMake unable to detect when the UI file changes.
- **/
-#include
-
-MainWindow::MainWindow(OrthancStone::BasicNativeApplicationContext& context, QWidget *parent) :
- QStoneMainWindow(context, parent),
- ui_(new Ui::MainWindow)
-{
- ui_->setupUi(this);
- SetCentralStoneWidget(ui_->cairoCentralWidget);
-}
-
-MainWindow::~MainWindow()
-{
- delete ui_;
-}
-
-
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/Qt/MainWindow.h
--- a/Applications/Samples/Qt/MainWindow.h Tue Aug 28 11:09:37 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/**
- * Stone of Orthanc
- * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
- * Department, University Hospital of Liege, Belgium
- * Copyright (C) 2017-2018 Osimis S.A., Belgium
- *
- * This program is free software: you can redistribute it and/or
- * modify it under the terms of the GNU Affero General Public License
- * as published by the Free Software Foundation, either version 3 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- **/
-#pragma once
-
-#include "../../Qt/QCairoWidget.h"
-#include "../../Qt/QStoneMainWindow.h"
-
-namespace Ui
-{
- class MainWindow;
-}
-
-
-class MainWindow : public QStoneMainWindow
-{
- Q_OBJECT
-
-private:
- Ui::MainWindow *ui_;
-
-public:
- explicit MainWindow(OrthancStone::BasicNativeApplicationContext& context, QWidget *parent = 0);
- ~MainWindow();
-};
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/Qt/MainWindow.ui
--- a/Applications/Samples/Qt/MainWindow.ui Tue Aug 28 11:09:37 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-
-
- MainWindow
-
-
-
- 0
- 0
- 800
- 600
-
-
-
- Stone of Orthanc
-
-
- Qt::LeftToRight
-
-
-
-
- 0
- 0
-
-
-
- Qt::LeftToRight
-
-
-
- QLayout::SetDefaultConstraint
-
-
-
-
-
-
-
-
-
- 0
- 0
- 800
- 25
-
-
-
-
- Test
-
-
-
-
-
-
-
-
- QCairoWidget
- QGraphicsView
- QCairoWidget.h
-
-
-
-
-
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/Qt/SampleMainWindow.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Samples/Qt/SampleMainWindow.cpp Tue Aug 28 15:26:46 2018 +0200
@@ -0,0 +1,75 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ **/
+
+#include "SampleMainWindow.h"
+
+/**
+ * Don't use "ui_MainWindow.h" instead of below, as
+ * this makes CMake unable to detect when the UI file changes.
+ **/
+#include
+#include "../../Applications/Samples/SampleApplicationBase.h"
+
+namespace OrthancStone
+{
+ namespace Samples
+ {
+
+ SampleMainWindow::SampleMainWindow(OrthancStone::BasicNativeApplicationContext& context, OrthancStone::Samples::SampleApplicationBase& stoneSampleApplication, QWidget *parent) :
+ QStoneMainWindow(context, parent),
+ ui_(new Ui::SampleMainWindow),
+ stoneSampleApplication_(stoneSampleApplication)
+ {
+ ui_->setupUi(this);
+ SetCentralStoneWidget(ui_->cairoCentralWidget);
+
+ connect(ui_->toolButton1, &QToolButton::clicked, this, &SampleMainWindow::tool1Clicked);
+ connect(ui_->toolButton2, &QToolButton::clicked, this, &SampleMainWindow::tool2Clicked);
+ connect(ui_->pushButton1, &QPushButton::clicked, this, &SampleMainWindow::pushButton1Clicked);
+ connect(ui_->pushButton1, &QPushButton::clicked, this, &SampleMainWindow::pushButton2Clicked);
+ }
+
+ SampleMainWindow::~SampleMainWindow()
+ {
+ delete ui_;
+ }
+
+ void SampleMainWindow::tool1Clicked()
+ {
+ stoneSampleApplication_.OnTool1Clicked();
+ }
+
+ void SampleMainWindow::tool2Clicked()
+ {
+ stoneSampleApplication_.OnTool2Clicked();
+ }
+
+ void SampleMainWindow::pushButton1Clicked()
+ {
+ stoneSampleApplication_.OnPushButton1Clicked();
+ }
+
+ void SampleMainWindow::pushButton2Clicked()
+ {
+ stoneSampleApplication_.OnPushButton2Clicked();
+ }
+
+ }
+}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/Qt/SampleMainWindow.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Samples/Qt/SampleMainWindow.h Tue Aug 28 15:26:46 2018 +0200
@@ -0,0 +1,56 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ **/
+#pragma once
+
+#include "../../Qt/QCairoWidget.h"
+#include "../../Qt/QStoneMainWindow.h"
+
+namespace Ui
+{
+ class SampleMainWindow;
+}
+
+namespace OrthancStone
+{
+ namespace Samples
+ {
+
+ class SampleApplicationBase;
+
+ class SampleMainWindow : public QStoneMainWindow
+ {
+ Q_OBJECT
+
+ private:
+ Ui::SampleMainWindow* ui_;
+ SampleApplicationBase& stoneSampleApplication_;
+
+ public:
+ explicit SampleMainWindow(OrthancStone::BasicNativeApplicationContext& context, SampleApplicationBase& stoneSampleApplication, QWidget *parent = 0);
+ ~SampleMainWindow();
+
+ private slots:
+ void tool1Clicked();
+ void tool2Clicked();
+ void pushButton1Clicked();
+ void pushButton2Clicked();
+ };
+ }
+}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/Qt/SampleMainWindow.ui
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Samples/Qt/SampleMainWindow.ui Tue Aug 28 15:26:46 2018 +0200
@@ -0,0 +1,130 @@
+
+
+ SampleMainWindow
+
+
+
+ 0
+ 0
+ 903
+ 634
+
+
+
+
+ 500
+ 300
+
+
+
+
+ 500
+ 300
+
+
+
+ Stone of Orthanc
+
+
+ Qt::LeftToRight
+
+
+
+
+ 0
+ 0
+
+
+
+ Qt::LeftToRight
+
+
+
+ QLayout::SetDefaultConstraint
+
+
+
+
+
+ 0
+ 500
+
+
+
+
+
+
+
+
+ 0
+ 100
+
+
+
+
+ 16777215
+ 100
+
+
+
+
+
+
+ tool1
+
+
+
+
+
+
+ tool2
+
+
+
+
+
+
+ action1
+
+
+
+
+
+
+ action2
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 0
+ 903
+ 22
+
+
+
+
+ Test
+
+
+
+
+
+
+
+
+ QCairoWidget
+ QGraphicsView
+ QCairoWidget.h
+
+
+
+
+
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/Qt/SampleQtApplicationRunner.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Samples/Qt/SampleQtApplicationRunner.h Tue Aug 28 15:26:46 2018 +0200
@@ -0,0 +1,51 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2018 Osimis S.A., Belgium
+ *
+ * This program is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation, either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ **/
+
+
+#pragma once
+
+#include "../../Qt/BasicQtApplicationRunner.h"
+#include "SampleMainWindow.h"
+
+#if ORTHANC_ENABLE_QT != 1
+#error this file shall be included only with the ORTHANC_ENABLE_QT set to 1
+#endif
+
+namespace OrthancStone
+{
+ namespace Samples
+ {
+ class SampleQtApplicationRunner : public OrthancStone::BasicQtApplicationRunner
+ {
+ protected:
+ virtual void InitializeMainWindow(OrthancStone::BasicNativeApplicationContext& context)
+ {
+ window_.reset(new SampleMainWindow(context, dynamic_cast(application_)));
+ }
+ public:
+ SampleQtApplicationRunner(MessageBroker& broker,
+ SampleApplicationBase& application)
+ : OrthancStone::BasicQtApplicationRunner(broker, application)
+ {
+ }
+
+ };
+ }
+}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/SampleApplicationBase.h
--- a/Applications/Samples/SampleApplicationBase.h Tue Aug 28 11:09:37 2018 +0200
+++ b/Applications/Samples/SampleApplicationBase.h Tue Aug 28 15:26:46 2018 +0200
@@ -22,7 +22,6 @@
#pragma once
#include "../../Applications/IBasicApplication.h"
-#include "../../Framework/Viewport/WidgetViewport.h"
namespace OrthancStone
{
@@ -31,12 +30,34 @@
class SampleApplicationBase : public IBasicApplication
{
public:
+ virtual void Initialize(BasicApplicationContext* context,
+ IStatusBar& statusBar,
+ const boost::program_options::variables_map& parameters)
+ {
+ }
+
+
+
virtual std::string GetTitle() const
{
return "Stone of Orthanc - Sample";
}
- virtual void CustomInitialize() {}
+ virtual void OnPushButton1Clicked() {}
+ virtual void OnPushButton2Clicked() {}
+ virtual void OnTool1Clicked() {}
+ virtual void OnTool2Clicked() {}
+
+ virtual void GetButtonNames(std::string& pushButton1,
+ std::string& pushButton2,
+ std::string& tool1,
+ std::string& tool2
+ ) {
+ pushButton1 = "action1";
+ pushButton2 = "action2";
+ tool1 = "tool1";
+ tool2 = "tool2";
+ }
};
}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/SampleList.h
--- a/Applications/Samples/SampleList.h Tue Aug 28 11:09:37 2018 +0200
+++ b/Applications/Samples/SampleList.h Tue Aug 28 15:26:46 2018 +0200
@@ -2,35 +2,35 @@
#if ORTHANC_STONE_SAMPLE == 1
#include "EmptyApplication.h"
-typedef OrthancStone::Samples::EmptyApplication Application;
+typedef OrthancStone::Samples::EmptyApplication SampleApplication;
#elif ORTHANC_STONE_SAMPLE == 2
#include "TestPatternApplication.h"
-typedef OrthancStone::Samples::TestPatternApplication Application;
+typedef OrthancStone::Samples::TestPatternApplication SampleApplication;
#elif ORTHANC_STONE_SAMPLE == 3
#include "SingleFrameApplication.h"
-typedef OrthancStone::Samples::SingleFrameApplication Application;
+typedef OrthancStone::Samples::SingleFrameApplication SampleApplication;
#elif ORTHANC_STONE_SAMPLE == 4
#include "SingleVolumeApplication.h"
-typedef OrthancStone::Samples::SingleVolumeApplication Application;
+typedef OrthancStone::Samples::SingleVolumeApplication SampleApplication;
#elif ORTHANC_STONE_SAMPLE == 5
#include "BasicPetCtFusionApplication.h"
-typedef OrthancStone::Samples::BasicPetCtFusionApplication Application;
+typedef OrthancStone::Samples::BasicPetCtFusionApplication SampleApplication;
#elif ORTHANC_STONE_SAMPLE == 6
#include "SynchronizedSeriesApplication.h"
-typedef OrthancStone::Samples::SynchronizedSeriesApplication Application;
+typedef OrthancStone::Samples::SynchronizedSeriesApplication SampleApplication;
#elif ORTHANC_STONE_SAMPLE == 7
#include "LayoutPetCtFusionApplication.h"
-typedef OrthancStone::Samples::LayoutPetCtFusionApplication Application;
+typedef OrthancStone::Samples::LayoutPetCtFusionApplication SampleApplication;
#elif ORTHANC_STONE_SAMPLE == 8
#include "SimpleViewerApplication.h"
-typedef OrthancStone::Samples::SimpleViewerApplication Application;
+typedef OrthancStone::Samples::SimpleViewerApplication SampleApplication;
#else
#error Please set the ORTHANC_STONE_SAMPLE macro
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/SampleMainNative.cpp
--- a/Applications/Samples/SampleMainNative.cpp Tue Aug 28 11:09:37 2018 +0200
+++ b/Applications/Samples/SampleMainNative.cpp Tue Aug 28 15:26:46 2018 +0200
@@ -24,21 +24,21 @@
#include "../Sdl/BasicSdlApplication.h"
#endif
#if ORTHANC_ENABLE_QT==1
-#include "../Qt/BasicQtApplication.h"
+#include "Qt/SampleQtApplicationRunner.h"
#endif
#include "../../Framework/Messages/MessageBroker.h"
int main(int argc, char* argv[])
{
OrthancStone::MessageBroker broker;
- Application application(broker);
+ SampleApplication sampleStoneApplication(broker);
#if ORTHANC_ENABLE_SDL==1
OrthancStone::BasicSdlApplication sdlApplication;
- return sdlApplication.Execute(broker, application, argc, argv);
+ return sdlApplication.Execute(broker, sampleStoneApplication, argc, argv);
#endif
#if ORTHANC_ENABLE_QT==1
- OrthancStone::BasicQtApplication qtApplication;
- return qtApplication.Execute(broker, application, argc, argv);
+ OrthancStone::Samples::SampleQtApplicationRunner qtAppRunner(broker, sampleStoneApplication);
+ return qtAppRunner.Execute(argc, argv);
#endif
}
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/SampleMainWasm.cpp
--- a/Applications/Samples/SampleMainWasm.cpp Tue Aug 28 11:09:37 2018 +0200
+++ b/Applications/Samples/SampleMainWasm.cpp Tue Aug 28 15:26:46 2018 +0200
@@ -28,5 +28,5 @@
OrthancStone::IBasicApplication* CreateUserApplication(OrthancStone::MessageBroker& broker) {
- return new Application(broker);
+ return new SampleApplication(broker);
}
\ No newline at end of file
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/SimpleViewerApplication.h
--- a/Applications/Samples/SimpleViewerApplication.h Tue Aug 28 11:09:37 2018 +0200
+++ b/Applications/Samples/SimpleViewerApplication.h Tue Aug 28 15:26:46 2018 +0200
@@ -24,6 +24,7 @@
#include "SampleApplicationBase.h"
#include "../../Framework/Layers/OrthancFrameLayerSource.h"
+#include "../../Framework/Layers/CircleMeasureTracker.h"
#include "../../Framework/Layers/LineMeasureTracker.h"
#include "../../Framework/Widgets/LayerWidget.h"
#include "../../Framework/Widgets/LayoutWidget.h"
@@ -110,7 +111,14 @@
{
if (button == MouseButton_Left)
{
- return new LineMeasureTracker(statusBar, dynamic_cast(widget).GetSlice(), x, y, 255, 0, 0, 10);
+ if (application_.currentTool_ == Tools_LineMeasure)
+ {
+ return new LineMeasureTracker(statusBar, dynamic_cast(widget).GetSlice(), x, y, 255, 0, 0, 10);
+ }
+ else if (application_.currentTool_ == Tools_CircleMeasure)
+ {
+ return new CircleMeasureTracker(statusBar, dynamic_cast(widget).GetSlice(), x, y, 255, 0, 0, 10);
+ }
}
return NULL;
}
@@ -138,21 +146,6 @@
KeyboardModifiers modifiers,
IStatusBar* statusBar)
{
- // int scale = (modifiers & KeyboardModifiers_Control ? 10 : 1);
-
- // switch (direction)
- // {
- // case MouseWheelDirection_Up:
- // application_.OffsetSlice(-scale);
- // break;
-
- // case MouseWheelDirection_Down:
- // application_.OffsetSlice(scale);
- // break;
-
- // default:
- // break;
- // }
}
virtual void KeyPressed(WorldSceneWidget& widget,
@@ -172,7 +165,12 @@
}
};
+ enum Tools {
+ Tools_LineMeasure,
+ Tools_CircleMeasure
+ };
+ Tools currentTool_;
std::unique_ptr mainWidgetInteractor_;
std::unique_ptr thumbnailInteractor_;
LayoutWidget* mainLayout_;
@@ -186,18 +184,17 @@
OrthancStone::WidgetViewport* wasmViewport2_;
IStatusBar* statusBar_;
- unsigned int slice_;
std::unique_ptr smartLoader_;
std::unique_ptr orthancApiClient_;
public:
SimpleViewerApplication(MessageBroker& broker) :
IObserver(broker),
+ currentTool_(Tools_LineMeasure),
mainLayout_(NULL),
currentInstanceIndex_(0),
wasmViewport1_(NULL),
- wasmViewport2_(NULL),
- slice_(0)
+ wasmViewport2_(NULL)
{
DeclareIgnoredMessage(MessageType_Widget_ContentChanged);
DeclareHandledMessage(MessageType_Widget_GeometryChanged);
@@ -313,7 +310,7 @@
// if this is the first thumbnail loaded, load the first instance in the mainWidget
if (mainWidget_->GetLayerCount() == 0)
{
- mainWidget_->AddLayer(smartLoader_->GetFrame(instancesIdsPerSeriesId_[seriesId][0], 0));
+ mainWidget_->AddLayer(smartLoader_->GetFrame(instancesIdsPerSeriesId_[seriesId][0], 0));
}
}
}
@@ -362,10 +359,28 @@
}
#endif
+
+
void SelectSeriesInMainViewport(const std::string& seriesId)
{
mainWidget_->ReplaceLayer(0, smartLoader_->GetFrame(instancesIdsPerSeriesId_[seriesId][0], 0));
}
+
+ virtual void OnPushButton1Clicked() {}
+ virtual void OnPushButton2Clicked() {}
+ virtual void OnTool1Clicked() { currentTool_ = Tools_LineMeasure;}
+ virtual void OnTool2Clicked() { currentTool_ = Tools_CircleMeasure;}
+
+ virtual void GetButtonNames(std::string& pushButton1,
+ std::string& pushButton2,
+ std::string& tool1,
+ std::string& tool2
+ ) {
+ tool1 = "line";
+ tool2 = "circle";
+ pushButton1 = "action1";
+ pushButton2 = "action2";
+ }
};
diff -r 38b0ac8055b9 -r 3c190e2bb3af Applications/Samples/Web/index.html
--- a/Applications/Samples/Web/index.html Tue Aug 28 11:09:37 2018 +0200
+++ b/Applications/Samples/Web/index.html Tue Aug 28 15:26:46 2018 +0200
@@ -14,7 +14,7 @@