Mercurial > hg > orthanc-stone
annotate Applications/Samples/SimpleViewer/SimpleViewerApplication.cpp @ 1057:5df50e0f0390
removing unused class IPromise
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 11 Oct 2019 13:37:21 +0200 |
parents | bcd3ea868bcd |
children | 2d8ab34c8c91 |
rev | line source |
---|---|
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
1 /** |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
2 * Stone of Orthanc |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
439 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
6 * |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
10 * the License, or (at your option) any later version. |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
11 * |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
15 * Affero General Public License for more details. |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
16 * |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
19 **/ |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
20 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
21 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
22 #include "SimpleViewerApplication.h" |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
23 |
377 | 24 #if ORTHANC_ENABLE_QT == 1 |
25 # include "Qt/SimpleViewerMainWindow.h" | |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
26 #endif |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
27 |
377 | 28 #if ORTHANC_ENABLE_WASM == 1 |
29 # include <Platforms/Wasm/WasmViewport.h> | |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
30 #endif |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
31 |
377 | 32 namespace SimpleViewer |
33 { | |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
34 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
35 void SimpleViewerApplication::Initialize(StoneApplicationContext* context, |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
36 Deprecated::IStatusBar& statusBar, |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
37 const boost::program_options::variables_map& parameters) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
38 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
39 context_ = context; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
40 statusBar_ = &statusBar; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
41 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
42 {// initialize viewports and layout |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
43 mainLayout_ = new Deprecated::LayoutWidget("main-layout"); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
44 mainLayout_->SetPadding(10); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
45 mainLayout_->SetBackgroundCleared(true); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
46 mainLayout_->SetBackgroundColor(0, 0, 0); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
47 mainLayout_->SetHorizontal(); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
48 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
49 thumbnailsLayout_ = new Deprecated::LayoutWidget("thumbnail-layout"); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
50 thumbnailsLayout_->SetPadding(10); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
51 thumbnailsLayout_->SetBackgroundCleared(true); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
52 thumbnailsLayout_->SetBackgroundColor(50, 50, 50); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
53 thumbnailsLayout_->SetVertical(); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
54 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
55 mainWidget_ = new Deprecated::SliceViewerWidget(IObserver::GetBroker(), "main-viewport"); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
56 //mainWidget_->RegisterObserver(*this); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
57 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
58 // hierarchy |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
59 mainLayout_->AddWidget(thumbnailsLayout_); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
60 mainLayout_->AddWidget(mainWidget_); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
61 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
62 // sources |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
63 smartLoader_.reset(new Deprecated::SmartLoader(IObserver::GetBroker(), context->GetOrthancApiClient())); |
743 | 64 smartLoader_->SetImageQuality(Deprecated::SliceImageQuality_FullPam); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
65 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
66 mainLayout_->SetTransmitMouseOver(true); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
67 mainWidgetInteractor_.reset(new MainWidgetInteractor(*this)); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
68 mainWidget_->SetInteractor(*mainWidgetInteractor_); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
69 thumbnailInteractor_.reset(new ThumbnailInteractor(*this)); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
70 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
71 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
72 statusBar.SetMessage("Use the key \"s\" to reinitialize the layout"); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
73 statusBar.SetMessage("Use the key \"n\" to go to next image in the main viewport"); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
74 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
75 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
76 if (parameters.count("studyId") < 1) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
77 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
78 LOG(WARNING) << "The study ID is missing, will take the first studyId found in Orthanc"; |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
79 context->GetOrthancApiClient().GetJsonAsync("/studies", new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage>(*this, &SimpleViewerApplication::OnStudyListReceived)); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
80 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
81 else |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
82 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
83 SelectStudy(parameters["studyId"].as<std::string>()); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
84 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
85 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
86 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
87 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
88 void SimpleViewerApplication::DeclareStartupOptions(boost::program_options::options_description& options) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
89 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
90 boost::program_options::options_description generic("Sample options"); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
91 generic.add_options() |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
92 ("studyId", boost::program_options::value<std::string>(), |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
93 "Orthanc ID of the study") |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
94 ; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
95 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
96 options.add(generic); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
97 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
98 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
99 void SimpleViewerApplication::OnStudyListReceived(const Deprecated::OrthancApiClient::JsonResponseReadyMessage& message) |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
100 { |
377 | 101 const Json::Value& response = message.GetJson(); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
102 |
411 | 103 if (response.isArray() && |
104 response.size() >= 1) | |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
105 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
106 SelectStudy(response[0].asString()); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
107 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
108 } |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
109 void SimpleViewerApplication::OnStudyReceived(const Deprecated::OrthancApiClient::JsonResponseReadyMessage& message) |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
110 { |
377 | 111 const Json::Value& response = message.GetJson(); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
112 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
113 if (response.isObject() && response["Series"].isArray()) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
114 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
115 for (size_t i=0; i < response["Series"].size(); i++) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
116 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
117 context_->GetOrthancApiClient().GetJsonAsync("/series/" + response["Series"][(int)i].asString(), new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage>(*this, &SimpleViewerApplication::OnSeriesReceived)); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
118 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
119 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
120 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
121 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
122 void SimpleViewerApplication::OnSeriesReceived(const Deprecated::OrthancApiClient::JsonResponseReadyMessage& message) |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
123 { |
377 | 124 const Json::Value& response = message.GetJson(); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
125 |
411 | 126 if (response.isObject() && |
127 response["Instances"].isArray() && | |
128 response["Instances"].size() > 0) | |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
129 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
130 // keep track of all instances IDs |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
131 const std::string& seriesId = response["ID"].asString(); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
132 seriesTags_[seriesId] = response; |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
133 instancesIdsPerSeriesId_[seriesId] = std::vector<std::string>(); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
134 for (size_t i = 0; i < response["Instances"].size(); i++) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
135 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
136 const std::string& instanceId = response["Instances"][static_cast<int>(i)].asString(); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
137 instancesIdsPerSeriesId_[seriesId].push_back(instanceId); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
138 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
139 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
140 // load the first instance in the thumbnail |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
141 LoadThumbnailForSeries(seriesId, instancesIdsPerSeriesId_[seriesId][0]); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
142 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
143 // if this is the first thumbnail loaded, load the first instance in the mainWidget |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
144 if (mainWidget_->GetLayerCount() == 0) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
145 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
146 smartLoader_->SetFrameInWidget(*mainWidget_, 0, instancesIdsPerSeriesId_[seriesId][0], 0); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
147 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
148 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
149 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
150 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
151 void SimpleViewerApplication::LoadThumbnailForSeries(const std::string& seriesId, const std::string& instanceId) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
152 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
153 LOG(INFO) << "Loading thumbnail for series " << seriesId; |
527
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
154 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
155 Deprecated::SliceViewerWidget* thumbnailWidget = |
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
156 new Deprecated::SliceViewerWidget(IObserver::GetBroker(), "thumbnail-series-" + seriesId); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
157 thumbnails_.push_back(thumbnailWidget); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
158 thumbnailsLayout_->AddWidget(thumbnailWidget); |
527
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
159 |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
160 thumbnailWidget->RegisterObserverCallback( |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
161 new Callable<SimpleViewerApplication, Deprecated::SliceViewerWidget::GeometryChangedMessage> |
388
20f149669c1f
renamed LayerWidget as SliceViewerWidget
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
377
diff
changeset
|
162 (*this, &SimpleViewerApplication::OnWidgetGeometryChanged)); |
527
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
163 |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
164 smartLoader_->SetFrameInWidget(*thumbnailWidget, 0, instanceId, 0); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
165 thumbnailWidget->SetInteractor(*thumbnailInteractor_); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
166 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
167 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
168 void SimpleViewerApplication::SelectStudy(const std::string& studyId) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
169 { |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
170 context_->GetOrthancApiClient().GetJsonAsync("/studies/" + studyId, new Callable<SimpleViewerApplication, Deprecated::OrthancApiClient::JsonResponseReadyMessage>(*this, &SimpleViewerApplication::OnStudyReceived)); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
171 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
172 |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
173 void SimpleViewerApplication::OnWidgetGeometryChanged(const Deprecated::SliceViewerWidget::GeometryChangedMessage& message) |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
174 { |
406
5d359b115b29
use of callables in OrthancVolumeImage
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
393
diff
changeset
|
175 // TODO: The "const_cast" could probably be replaced by "mainWidget_" |
726
4f2416d519b4
moving layers, widgets and loaders to Deprecated namespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
535
diff
changeset
|
176 const_cast<Deprecated::SliceViewerWidget&>(message.GetOrigin()).FitContent(); |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
177 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
178 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
179 void SimpleViewerApplication::SelectSeriesInMainViewport(const std::string& seriesId) |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
180 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
181 smartLoader_->SetFrameInWidget(*mainWidget_, 0, instancesIdsPerSeriesId_[seriesId][0], 0); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
182 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
183 |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
184 bool SimpleViewerApplication::Handle(const StoneSampleCommands::SelectTool& value) |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
185 { |
527
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
186 currentTool_ = value.tool; |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
187 return true; |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
188 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
189 |
535
79bb0a02d1cc
- Added ORTHANC_OVERRIDE to several methods (translates to "override" in C++ 11 compilers)
Benjamin Golinvaux <bgo@osimis.io>
parents:
527
diff
changeset
|
190 bool SimpleViewerApplication::Handle(const StoneSampleCommands::Action& value) |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
191 { |
527
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
192 switch (value.type) |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
193 { |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
194 case ActionType_Invert: |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
195 // TODO |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
196 break; |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
197 case ActionType_UndoCrop: |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
198 // TODO |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
199 break; |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
200 case ActionType_Rotate: |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
201 // TODO |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
202 break; |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
203 default: |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
204 throw std::runtime_error("Action type not supported"); |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
205 } |
b1377625e4ba
Removed ICommand and friends + fixed warnings + added missing header files in
Benjamin Golinvaux <bgo@osimis.io>
parents:
439
diff
changeset
|
206 return true; |
319
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
207 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
208 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
209 #if ORTHANC_ENABLE_QT==1 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
210 QStoneMainWindow* SimpleViewerApplication::CreateQtMainWindow() |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
211 { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
212 return new SimpleViewerMainWindow(dynamic_cast<OrthancStone::NativeStoneApplicationContext&>(*context_), *this); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
213 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
214 #endif |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
215 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
216 #if ORTHANC_ENABLE_WASM==1 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
217 void SimpleViewerApplication::InitializeWasm() { |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
218 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
219 AttachWidgetToWasmViewport("canvasThumbnails", thumbnailsLayout_); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
220 AttachWidgetToWasmViewport("canvasMain", mainWidget_); |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
221 } |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
222 #endif |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
223 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
224 |
daa04d15192c
new SimpleViewer sample that has been split in multiple files to be able to scale it
am@osimis.io
parents:
diff
changeset
|
225 } |