comparison Applications/Samples/SimpleViewer/SimpleViewerApplication.h @ 319:daa04d15192c am-2

new SimpleViewer sample that has been split in multiple files to be able to scale it
author am@osimis.io
date Thu, 11 Oct 2018 13:16:54 +0200
parents
children 56b2e47d3c0c
comparison
equal deleted inserted replaced
318:3a4ca166fafa 319:daa04d15192c
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-2018 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 #include "Applications/IStoneApplication.h"
25
26 #include "Framework/Layers/OrthancFrameLayerSource.h"
27 #include "Framework/Layers/CircleMeasureTracker.h"
28 #include "Framework/Layers/LineMeasureTracker.h"
29 #include "Framework/Widgets/LayerWidget.h"
30 #include "Framework/Widgets/LayoutWidget.h"
31 #include "Framework/Messages/IObserver.h"
32 #include "Framework/SmartLoader.h"
33
34 #if ORTHANC_ENABLE_WASM==1
35 #include "Platforms/Wasm/WasmPlatformApplicationAdapter.h"
36 #include "Platforms/Wasm/Defaults.h"
37 #endif
38
39 #if ORTHANC_ENABLE_QT==1
40 #include "Qt/SimpleViewerMainWindow.h"
41 #endif
42
43 #include <Core/Logging.h>
44
45 #include "ThumbnailInteractor.h"
46 #include "MainWidgetInteractor.h"
47 #include "AppStatus.h"
48 #include "Messages.h"
49
50 using namespace OrthancStone;
51
52
53 namespace SimpleViewer
54 {
55
56 class SimpleViewerApplication :
57 public IStoneApplication,
58 public IObserver,
59 public IObservable
60 {
61 public:
62
63 struct StatusUpdatedMessage : public BaseMessage<SimpleViewerMessageType_AppStatusUpdated>
64 {
65 const AppStatus& status_;
66
67 StatusUpdatedMessage(const AppStatus& status)
68 : BaseMessage(),
69 status_(status)
70 {
71 }
72 };
73
74 enum Tools {
75 Tools_LineMeasure,
76 Tools_CircleMeasure,
77 Tools_Crop,
78 Tools_Windowing,
79 Tools_Zoom,
80 Tools_Pan
81 };
82
83 enum Actions {
84 Actions_Rotate,
85 Actions_Invert
86 };
87
88 private:
89 Tools currentTool_;
90 std::unique_ptr<MainWidgetInteractor> mainWidgetInteractor_;
91 std::unique_ptr<ThumbnailInteractor> thumbnailInteractor_;
92 LayoutWidget* mainLayout_;
93 LayoutWidget* thumbnailsLayout_;
94 LayerWidget* mainWidget_;
95 std::vector<LayerWidget*> thumbnails_;
96 std::map<std::string, std::vector<std::string>> instancesIdsPerSeriesId_;
97 std::map<std::string, Json::Value> seriesTags_;
98 BaseCommandBuilder commandBuilder_;
99
100 unsigned int currentInstanceIndex_;
101 OrthancStone::WidgetViewport* wasmViewport1_;
102 OrthancStone::WidgetViewport* wasmViewport2_;
103
104 IStatusBar* statusBar_;
105 std::unique_ptr<SmartLoader> smartLoader_;
106 std::unique_ptr<OrthancApiClient> orthancApiClient_;
107
108 public:
109 SimpleViewerApplication(MessageBroker& broker) :
110 IObserver(broker),
111 IObservable(broker),
112 currentTool_(Tools_LineMeasure),
113 mainLayout_(NULL),
114 currentInstanceIndex_(0),
115 wasmViewport1_(NULL),
116 wasmViewport2_(NULL)
117 {
118 }
119
120 virtual void Finalize() {}
121 virtual IWidget* GetCentralWidget() {return mainLayout_;}
122
123 virtual void DeclareStartupOptions(boost::program_options::options_description& options);
124 virtual void Initialize(StoneApplicationContext* context,
125 IStatusBar& statusBar,
126 const boost::program_options::variables_map& parameters);
127
128 void OnStudyListReceived(const OrthancApiClient::JsonResponseReadyMessage& message);
129
130 void OnStudyReceived(const OrthancApiClient::JsonResponseReadyMessage& message);
131
132 void OnSeriesReceived(const OrthancApiClient::JsonResponseReadyMessage& message);
133
134 void LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId);
135
136 void SelectStudy(const std::string& studyId);
137
138 void OnWidgetGeometryChanged(const LayerWidget::GeometryChangedMessage& message);
139
140 void SelectSeriesInMainViewport(const std::string& seriesId);
141
142 void SelectTool(Tools tool);
143 Tools GetCurrentTool() const {return currentTool_;}
144
145 void ExecuteAction(Actions action);
146
147 virtual std::string GetTitle() const {return "SimpleViewer";}
148 virtual void ExecuteCommand(ICommand& command);
149 virtual BaseCommandBuilder& GetCommandBuilder() {return commandBuilder_;}
150
151
152 #if ORTHANC_ENABLE_WASM==1
153 virtual void InitializeWasm();
154 #endif
155
156 #if ORTHANC_ENABLE_QT==1
157 virtual QStoneMainWindow* CreateQtMainWindow();
158 #endif
159 };
160
161
162 }