comparison Applications/Samples/SynchronizedSeriesApplication.h @ 51:b340879da9bd

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Apr 2017 14:50:20 +0200
parents Samples/SynchronizedSeriesApplication.h@28956ed68280
children d20e25cfcf3a 4cff7b1ed31d
comparison
equal deleted inserted replaced
49:c45f368de5c0 51:b340879da9bd
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 Osimis, 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 "SampleInteractor.h"
25
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"
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 {
42 std::auto_ptr<ISeriesLoader> loader(new OrthancSeriesLoader(context.GetOrthancConnection(), series));
43
44 std::auto_ptr<SampleInteractor> interactor(new SampleInteractor(*loader, false));
45
46 std::auto_ptr<LayeredSceneWidget> widget(new LayeredSceneWidget);
47 widget->AddLayer(new SeriesFrameRendererFactory(loader.release(), false));
48 widget->SetSlice(interactor->GetCursor().GetCurrentSlice());
49 widget->SetInteractor(*interactor);
50
51 context.AddInteractor(interactor.release());
52
53 return widget.release();
54 }
55
56 public:
57 virtual void DeclareCommandLineOptions(boost::program_options::options_description& options)
58 {
59 boost::program_options::options_description generic("Sample options");
60 generic.add_options()
61 ("a", boost::program_options::value<std::string>(),
62 "Orthanc ID of the 1st series")
63 ("b", boost::program_options::value<std::string>(),
64 "Orthanc ID of the 2nd series")
65 ("c", boost::program_options::value<std::string>(),
66 "Orthanc ID of the 3rd series")
67 ;
68
69 options.add(generic);
70 }
71
72 virtual void Initialize(BasicApplicationContext& context,
73 IStatusBar& statusBar,
74 const boost::program_options::variables_map& parameters)
75 {
76 if (parameters.count("a") != 1 ||
77 parameters.count("b") != 1 ||
78 parameters.count("c") != 1)
79 {
80 LOG(ERROR) << "At least one of the three series IDs is missing";
81 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
82 }
83
84 std::auto_ptr<LayeredSceneWidget> a(CreateSeriesWidget(context, parameters["a"].as<std::string>()));
85 std::auto_ptr<LayeredSceneWidget> b(CreateSeriesWidget(context, parameters["b"].as<std::string>()));
86 std::auto_ptr<LayeredSceneWidget> c(CreateSeriesWidget(context, parameters["c"].as<std::string>()));
87
88 SiblingSliceLocationFactory::Configure(*a, *b);
89 SiblingSliceLocationFactory::Configure(*a, *c);
90 SiblingSliceLocationFactory::Configure(*b, *c);
91
92 std::auto_ptr<LayoutWidget> layout(new LayoutWidget);
93 layout->SetPadding(5);
94 layout->AddWidget(a.release());
95
96 std::auto_ptr<LayoutWidget> layoutB(new LayoutWidget);
97 layoutB->SetVertical();
98 layoutB->SetPadding(5);
99 layoutB->AddWidget(b.release());
100 layoutB->AddWidget(c.release());
101 layout->AddWidget(layoutB.release());
102
103 context.SetCentralWidget(layout.release());
104 }
105 };
106 }
107 }