comparison Applications/Samples/Deprecated/SimpleViewer/SimpleViewerApplication.h @ 1347:bfd77672d825 broker

Moved Application/Samples/* to Application/Samples/Deprecated/*
author Benjamin Golinvaux <bgo@osimis.io>
date Tue, 07 Apr 2020 14:29:01 +0200
parents Applications/Samples/SimpleViewer/SimpleViewerApplication.h@8a0a62189f46
children c53a4667f895
comparison
equal deleted inserted replaced
1346:df8bf351c23f 1347:bfd77672d825
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-2020 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/Deprecated/Layers/CircleMeasureTracker.h"
33 #include "../../../Framework/Deprecated/Layers/LineMeasureTracker.h"
34 #include "../../../Framework/Deprecated/SmartLoader.h"
35 #include "../../../Framework/Deprecated/Widgets/LayoutWidget.h"
36 #include "../../../Framework/Deprecated/Widgets/SliceViewerWidget.h"
37 #include "../../../Framework/Messages/IObserver.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/SimpleViewerMainWindow.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
55 using namespace OrthancStone;
56
57
58 namespace SimpleViewer
59 {
60
61 class SimpleViewerApplication
62 : public IStoneApplication
63 , public IObserver
64 , public IObservable
65 , public StoneSampleCommands::IHandler
66 {
67 public:
68
69 struct StatusUpdatedMessage : public IMessage
70 {
71 ORTHANC_STONE_MESSAGE(__FILE__, __LINE__);
72
73 const AppStatus& status_;
74
75 StatusUpdatedMessage(const AppStatus& status)
76 : status_(status)
77 {
78 }
79 };
80
81 private:
82 Tool currentTool_;
83
84 std::unique_ptr<MainWidgetInteractor> mainWidgetInteractor_;
85 std::unique_ptr<ThumbnailInteractor> thumbnailInteractor_;
86 Deprecated::LayoutWidget* mainLayout_;
87 Deprecated::LayoutWidget* thumbnailsLayout_;
88 Deprecated::SliceViewerWidget* mainWidget_;
89 std::vector<Deprecated::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 Deprecated::WidgetViewport* wasmViewport1_;
94 Deprecated::WidgetViewport* wasmViewport2_;
95
96 Deprecated::IStatusBar* statusBar_;
97 std::unique_ptr<Deprecated::SmartLoader> smartLoader_;
98
99 Orthanc::Font font_;
100
101 public:
102 SimpleViewerApplication(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() ORTHANC_OVERRIDE {}
115 virtual Deprecated::IWidget* GetCentralWidget() ORTHANC_OVERRIDE {return mainLayout_;}
116
117 virtual void DeclareStartupOptions(boost::program_options::options_description& options) ORTHANC_OVERRIDE;
118 virtual void Initialize(StoneApplicationContext* context,
119 Deprecated::IStatusBar& statusBar,
120 const boost::program_options::variables_map& parameters) ORTHANC_OVERRIDE;
121
122 void OnStudyListReceived(const Deprecated::OrthancApiClient::JsonResponseReadyMessage& message);
123
124 void OnStudyReceived(const Deprecated::OrthancApiClient::JsonResponseReadyMessage& message);
125
126 void OnSeriesReceived(const Deprecated::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 Deprecated::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 void HandleSerializedMessage(const char* data) ORTHANC_OVERRIDE
159 {
160 StoneSampleCommands::StoneDispatchToHandler(data, this);
161 }
162
163 virtual std::string GetTitle() const ORTHANC_OVERRIDE {return "SimpleViewer";}
164
165 #if ORTHANC_ENABLE_WASM==1
166 virtual void InitializeWasm() ORTHANC_OVERRIDE;
167 #endif
168
169 #if ORTHANC_ENABLE_QT==1
170 virtual QStoneMainWindow* CreateQtMainWindow();
171 #endif
172 };
173
174
175 }