diff Applications/Samples/CtPetDoseStructFusion/CtPetDoseStructFusionApplication.h @ 540:7428c5dfa5df ct-pet-dose-struct

Initial commit non working app
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 19 Mar 2019 16:29:07 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Applications/Samples/CtPetDoseStructFusion/CtPetDoseStructFusionApplication.h	Tue Mar 19 16:29:07 2019 +0100
@@ -0,0 +1,170 @@
+/**
+ * Stone of Orthanc
+ * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
+ * Department, University Hospital of Liege, Belgium
+ * Copyright (C) 2017-2019 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 <http://www.gnu.org/licenses/>.
+ **/
+
+
+#pragma once
+
+ /*
+ This header contains the command definitions for the sample applications
+ */
+#include "Applications/Samples/StoneSampleCommands_generated.hpp"
+using namespace StoneSampleCommands;
+
+#include "Applications/IStoneApplication.h"
+
+#include "Framework/Layers/CircleMeasureTracker.h"
+#include "Framework/Layers/LineMeasureTracker.h"
+#include "Framework/Widgets/SliceViewerWidget.h"
+#include "Framework/Widgets/LayoutWidget.h"
+#include "Framework/Messages/IObserver.h"
+#include "Framework/SmartLoader.h"
+
+#if ORTHANC_ENABLE_WASM==1
+#include "Platforms/Wasm/WasmPlatformApplicationAdapter.h"
+#include "Platforms/Wasm/Defaults.h"
+#endif
+
+#if ORTHANC_ENABLE_QT==1
+#include "Qt/CtPetDoseStructFusionMainWindow.h"
+#endif
+
+#include <Core/Images/Font.h>
+#include <Core/Logging.h>
+
+#include "ThumbnailInteractor.h"
+#include "MainWidgetInteractor.h"
+#include "AppStatus.h"
+#include "Messages.h"
+
+using namespace OrthancStone;
+
+
+namespace CtPetDoseStructFusion
+{
+
+  class CtPetDoseStructFusionApplication
+    : public IStoneApplication
+    , public IObserver
+    , public IObservable
+    , public StoneSampleCommands::IHandler
+  {
+  public:
+
+    struct StatusUpdatedMessage : public BaseMessage<CtPetDoseStructFusionMessageType_AppStatusUpdated>
+    {
+      const AppStatus& status_;
+
+      StatusUpdatedMessage(const AppStatus& status)
+        : BaseMessage(),
+          status_(status)
+      {
+      }
+    };
+
+  private:
+    Tool                                currentTool_;
+
+    std::auto_ptr<MainWidgetInteractor> mainWidgetInteractor_;
+    std::auto_ptr<ThumbnailInteractor>  thumbnailInteractor_;
+    LayoutWidget*                       mainLayout_;
+    LayoutWidget*                       thumbnailsLayout_;
+    SliceViewerWidget*                  mainWidget_;
+    std::vector<SliceViewerWidget*>     thumbnails_;
+    std::map<std::string, std::vector<std::string> > instancesIdsPerSeriesId_;
+    std::map<std::string, Json::Value>  seriesTags_;
+    unsigned int                        currentInstanceIndex_;
+    OrthancStone::WidgetViewport*       wasmViewport1_;
+    OrthancStone::WidgetViewport*       wasmViewport2_;
+
+    IStatusBar*                         statusBar_;
+    std::auto_ptr<SmartLoader>          smartLoader_;
+
+    Orthanc::Font                       font_;
+
+  public:
+    CtPetDoseStructFusionApplication(MessageBroker& broker) :
+      IObserver(broker),
+      IObservable(broker),
+      currentTool_(StoneSampleCommands::Tool_LineMeasure),
+      mainLayout_(NULL),
+      currentInstanceIndex_(0),
+      wasmViewport1_(NULL),
+      wasmViewport2_(NULL)
+    {
+      font_.LoadFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16);
+    }
+
+    virtual void Finalize() {}
+    virtual IWidget* GetCentralWidget() {return mainLayout_;}
+
+    virtual void DeclareStartupOptions(boost::program_options::options_description& options);
+    virtual void Initialize(StoneApplicationContext* context,
+                            IStatusBar& statusBar,
+                            const boost::program_options::variables_map& parameters);
+
+    void OnStudyListReceived(const OrthancApiClient::JsonResponseReadyMessage& message);
+
+    void OnStudyReceived(const OrthancApiClient::JsonResponseReadyMessage& message);
+
+    void OnSeriesReceived(const OrthancApiClient::JsonResponseReadyMessage& message);
+
+    void LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId);
+
+    void SelectStudy(const std::string& studyId);
+
+    void OnWidgetGeometryChanged(const SliceViewerWidget::GeometryChangedMessage& message);
+
+    void SelectSeriesInMainViewport(const std::string& seriesId);
+
+
+    Tool GetCurrentTool() const
+    {
+      return currentTool_;
+    }
+
+    const Orthanc::Font& GetFont() const
+    {
+      return font_;
+    }
+
+    // ExecuteAction method was empty (its body was a single "TODO" comment)
+    virtual bool Handle(const SelectTool& value) ORTHANC_OVERRIDE;
+    virtual bool Handle(const Action& value) ORTHANC_OVERRIDE;
+
+    template<typename T>
+    bool ExecuteCommand(const T& cmd)
+    {
+      std::string cmdStr = StoneSampleCommands::StoneSerialize(cmd);
+      return StoneSampleCommands::StoneDispatchToHandler(cmdStr, this);
+    }
+
+    virtual std::string GetTitle() const {return "CtPetDoseStructFusion";}
+
+#if ORTHANC_ENABLE_WASM==1
+    virtual void InitializeWasm();
+#endif
+
+#if ORTHANC_ENABLE_QT==1
+    virtual QStoneMainWindow* CreateQtMainWindow();
+#endif
+  };
+
+
+}