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

reorganization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 27 Apr 2017 14:50:20 +0200
parents Samples/SingleFrameApplication.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 "SampleApplicationBase.h"
25
26 #include "../../Framework/Layers/SingleFrameRendererFactory.h"
27 #include "../../Framework/Widgets/LayeredSceneWidget.h"
28 #include "../../Resources/Orthanc/Core/Logging.h"
29
30 namespace OrthancStone
31 {
32 namespace Samples
33 {
34 class SingleFrameApplication : public SampleApplicationBase
35 {
36 public:
37 virtual void DeclareCommandLineOptions(boost::program_options::options_description& options)
38 {
39 boost::program_options::options_description generic("Sample options");
40 generic.add_options()
41 ("instance", boost::program_options::value<std::string>(),
42 "Orthanc ID of the instance")
43 ("frame", boost::program_options::value<unsigned int>()->default_value(0),
44 "Number of the frame, for multi-frame DICOM instances")
45 ("smooth", boost::program_options::value<bool>()->default_value(true),
46 "Enable linear interpolation to smooth the image")
47 ;
48
49 options.add(generic);
50 }
51
52 virtual void Initialize(BasicApplicationContext& context,
53 IStatusBar& statusBar,
54 const boost::program_options::variables_map& parameters)
55 {
56 using namespace OrthancStone;
57
58 if (parameters.count("instance") != 1)
59 {
60 LOG(ERROR) << "The instance ID is missing";
61 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
62 }
63
64 std::string instance = parameters["instance"].as<std::string>();
65 int frame = parameters["frame"].as<unsigned int>();
66
67 std::auto_ptr<SingleFrameRendererFactory> renderer;
68 renderer.reset(new SingleFrameRendererFactory(context.GetOrthancConnection(), instance, frame));
69
70 std::auto_ptr<LayeredSceneWidget> widget(new LayeredSceneWidget);
71 widget->SetSlice(renderer->GetSliceGeometry());
72 widget->AddLayer(renderer.release());
73
74 if (parameters["smooth"].as<bool>())
75 {
76 RenderStyle s;
77 s.interpolation_ = ImageInterpolation_Linear;
78 widget->SetLayerStyle(0, s);
79 }
80
81 context.SetCentralWidget(widget.release());
82 }
83 };
84 }
85 }