Mercurial > hg > orthanc-stone
annotate Applications/Samples/SynchronizedSeriesApplication.h @ 99:efd9ef2b67f1 wasm
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 30 May 2017 21:08:31 +0200 |
parents | d20e25cfcf3a |
children | e2fe9352f240 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
40
7207a407bcd8
shared copyright with osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
5 * Copyright (C) 2017 Osimis, Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
47 | 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. | |
0 | 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 | |
47 | 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 | |
0 | 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "SampleInteractor.h" | |
25 | |
51 | 26 #include "../../Framework/Toolbox/OrthancSeriesLoader.h" |
27 #include "../../Framework/Layers/SeriesFrameRendererFactory.h" | |
28 #include "../../Framework/Layers/SiblingSliceLocationFactory.h" | |
29 #include "../../Framework/Widgets/LayoutWidget.h" | |
30 #include "../../Resources/Orthanc/Core/Logging.h" | |
0 | 31 |
32 namespace OrthancStone | |
33 { | |
34 namespace Samples | |
35 { | |
36 class SynchronizedSeriesApplication : public SampleApplicationBase | |
37 { | |
38 private: | |
39 LayeredSceneWidget* CreateSeriesWidget(BasicApplicationContext& context, | |
40 const std::string& series) | |
41 { | |
57 | 42 std::auto_ptr<ISeriesLoader> loader |
43 (new OrthancSeriesLoader(context.GetWebService().GetConnection(), series)); | |
0 | 44 |
45 std::auto_ptr<SampleInteractor> interactor(new SampleInteractor(*loader, false)); | |
46 | |
47 std::auto_ptr<LayeredSceneWidget> widget(new LayeredSceneWidget); | |
48 widget->AddLayer(new SeriesFrameRendererFactory(loader.release(), false)); | |
49 widget->SetSlice(interactor->GetCursor().GetCurrentSlice()); | |
50 widget->SetInteractor(*interactor); | |
51 | |
52 context.AddInteractor(interactor.release()); | |
53 | |
54 return widget.release(); | |
55 } | |
56 | |
57 public: | |
58 virtual void DeclareCommandLineOptions(boost::program_options::options_description& options) | |
59 { | |
60 boost::program_options::options_description generic("Sample options"); | |
61 generic.add_options() | |
62 ("a", boost::program_options::value<std::string>(), | |
63 "Orthanc ID of the 1st series") | |
64 ("b", boost::program_options::value<std::string>(), | |
65 "Orthanc ID of the 2nd series") | |
66 ("c", boost::program_options::value<std::string>(), | |
67 "Orthanc ID of the 3rd series") | |
68 ; | |
69 | |
70 options.add(generic); | |
71 } | |
72 | |
73 virtual void Initialize(BasicApplicationContext& context, | |
74 IStatusBar& statusBar, | |
75 const boost::program_options::variables_map& parameters) | |
76 { | |
77 if (parameters.count("a") != 1 || | |
78 parameters.count("b") != 1 || | |
79 parameters.count("c") != 1) | |
80 { | |
81 LOG(ERROR) << "At least one of the three series IDs is missing"; | |
82 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
83 } | |
84 | |
85 std::auto_ptr<LayeredSceneWidget> a(CreateSeriesWidget(context, parameters["a"].as<std::string>())); | |
86 std::auto_ptr<LayeredSceneWidget> b(CreateSeriesWidget(context, parameters["b"].as<std::string>())); | |
87 std::auto_ptr<LayeredSceneWidget> c(CreateSeriesWidget(context, parameters["c"].as<std::string>())); | |
88 | |
89 SiblingSliceLocationFactory::Configure(*a, *b); | |
90 SiblingSliceLocationFactory::Configure(*a, *c); | |
91 SiblingSliceLocationFactory::Configure(*b, *c); | |
92 | |
93 std::auto_ptr<LayoutWidget> layout(new LayoutWidget); | |
94 layout->SetPadding(5); | |
95 layout->AddWidget(a.release()); | |
96 | |
97 std::auto_ptr<LayoutWidget> layoutB(new LayoutWidget); | |
98 layoutB->SetVertical(); | |
99 layoutB->SetPadding(5); | |
100 layoutB->AddWidget(b.release()); | |
101 layoutB->AddWidget(c.release()); | |
102 layout->AddWidget(layoutB.release()); | |
103 | |
104 context.SetCentralWidget(layout.release()); | |
105 } | |
106 }; | |
107 } | |
108 } |