Mercurial > hg > orthanc-stone
comparison 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 |
comparison
equal
deleted
inserted
replaced
538:9d124a81c34a | 540:7428c5dfa5df |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2019 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 /* | |
25 This header contains the command definitions for the sample applications | |
26 */ | |
27 #include "Applications/Samples/StoneSampleCommands_generated.hpp" | |
28 using namespace StoneSampleCommands; | |
29 | |
30 #include "Applications/IStoneApplication.h" | |
31 | |
32 #include "Framework/Layers/CircleMeasureTracker.h" | |
33 #include "Framework/Layers/LineMeasureTracker.h" | |
34 #include "Framework/Widgets/SliceViewerWidget.h" | |
35 #include "Framework/Widgets/LayoutWidget.h" | |
36 #include "Framework/Messages/IObserver.h" | |
37 #include "Framework/SmartLoader.h" | |
38 | |
39 #if ORTHANC_ENABLE_WASM==1 | |
40 #include "Platforms/Wasm/WasmPlatformApplicationAdapter.h" | |
41 #include "Platforms/Wasm/Defaults.h" | |
42 #endif | |
43 | |
44 #if ORTHANC_ENABLE_QT==1 | |
45 #include "Qt/CtPetDoseStructFusionMainWindow.h" | |
46 #endif | |
47 | |
48 #include <Core/Images/Font.h> | |
49 #include <Core/Logging.h> | |
50 | |
51 #include "ThumbnailInteractor.h" | |
52 #include "MainWidgetInteractor.h" | |
53 #include "AppStatus.h" | |
54 #include "Messages.h" | |
55 | |
56 using namespace OrthancStone; | |
57 | |
58 | |
59 namespace CtPetDoseStructFusion | |
60 { | |
61 | |
62 class CtPetDoseStructFusionApplication | |
63 : public IStoneApplication | |
64 , public IObserver | |
65 , public IObservable | |
66 , public StoneSampleCommands::IHandler | |
67 { | |
68 public: | |
69 | |
70 struct StatusUpdatedMessage : public BaseMessage<CtPetDoseStructFusionMessageType_AppStatusUpdated> | |
71 { | |
72 const AppStatus& status_; | |
73 | |
74 StatusUpdatedMessage(const AppStatus& status) | |
75 : BaseMessage(), | |
76 status_(status) | |
77 { | |
78 } | |
79 }; | |
80 | |
81 private: | |
82 Tool currentTool_; | |
83 | |
84 std::auto_ptr<MainWidgetInteractor> mainWidgetInteractor_; | |
85 std::auto_ptr<ThumbnailInteractor> thumbnailInteractor_; | |
86 LayoutWidget* mainLayout_; | |
87 LayoutWidget* thumbnailsLayout_; | |
88 SliceViewerWidget* mainWidget_; | |
89 std::vector<SliceViewerWidget*> thumbnails_; | |
90 std::map<std::string, std::vector<std::string> > instancesIdsPerSeriesId_; | |
91 std::map<std::string, Json::Value> seriesTags_; | |
92 unsigned int currentInstanceIndex_; | |
93 OrthancStone::WidgetViewport* wasmViewport1_; | |
94 OrthancStone::WidgetViewport* wasmViewport2_; | |
95 | |
96 IStatusBar* statusBar_; | |
97 std::auto_ptr<SmartLoader> smartLoader_; | |
98 | |
99 Orthanc::Font font_; | |
100 | |
101 public: | |
102 CtPetDoseStructFusionApplication(MessageBroker& broker) : | |
103 IObserver(broker), | |
104 IObservable(broker), | |
105 currentTool_(StoneSampleCommands::Tool_LineMeasure), | |
106 mainLayout_(NULL), | |
107 currentInstanceIndex_(0), | |
108 wasmViewport1_(NULL), | |
109 wasmViewport2_(NULL) | |
110 { | |
111 font_.LoadFromResource(Orthanc::EmbeddedResources::FONT_UBUNTU_MONO_BOLD_16); | |
112 } | |
113 | |
114 virtual void Finalize() {} | |
115 virtual IWidget* GetCentralWidget() {return mainLayout_;} | |
116 | |
117 virtual void DeclareStartupOptions(boost::program_options::options_description& options); | |
118 virtual void Initialize(StoneApplicationContext* context, | |
119 IStatusBar& statusBar, | |
120 const boost::program_options::variables_map& parameters); | |
121 | |
122 void OnStudyListReceived(const OrthancApiClient::JsonResponseReadyMessage& message); | |
123 | |
124 void OnStudyReceived(const OrthancApiClient::JsonResponseReadyMessage& message); | |
125 | |
126 void OnSeriesReceived(const OrthancApiClient::JsonResponseReadyMessage& message); | |
127 | |
128 void LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId); | |
129 | |
130 void SelectStudy(const std::string& studyId); | |
131 | |
132 void OnWidgetGeometryChanged(const SliceViewerWidget::GeometryChangedMessage& message); | |
133 | |
134 void SelectSeriesInMainViewport(const std::string& seriesId); | |
135 | |
136 | |
137 Tool GetCurrentTool() const | |
138 { | |
139 return currentTool_; | |
140 } | |
141 | |
142 const Orthanc::Font& GetFont() const | |
143 { | |
144 return font_; | |
145 } | |
146 | |
147 // ExecuteAction method was empty (its body was a single "TODO" comment) | |
148 virtual bool Handle(const SelectTool& value) ORTHANC_OVERRIDE; | |
149 virtual bool Handle(const Action& value) ORTHANC_OVERRIDE; | |
150 | |
151 template<typename T> | |
152 bool ExecuteCommand(const T& cmd) | |
153 { | |
154 std::string cmdStr = StoneSampleCommands::StoneSerialize(cmd); | |
155 return StoneSampleCommands::StoneDispatchToHandler(cmdStr, this); | |
156 } | |
157 | |
158 virtual std::string GetTitle() const {return "CtPetDoseStructFusion";} | |
159 | |
160 #if ORTHANC_ENABLE_WASM==1 | |
161 virtual void InitializeWasm(); | |
162 #endif | |
163 | |
164 #if ORTHANC_ENABLE_QT==1 | |
165 virtual QStoneMainWindow* CreateQtMainWindow(); | |
166 #endif | |
167 }; | |
168 | |
169 | |
170 } |