GCC Code Coverage Report


Directory: ./
File: modules/ui/qt/series/viewer.hpp
Date: 2024-05-31 17:23:24
Exec Total Coverage
Lines: 0 4 0.0%
Branches: 0 13 0.0%

Line Branch Exec Source
1 /************************************************************************
2 *
3 * Copyright (C) 2009-2024 IRCAD France
4 * Copyright (C) 2012-2019 IHU Strasbourg
5 *
6 * This file is part of Sight.
7 *
8 * Sight is free software: you can redistribute it and/or modify it under
9 * the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * Sight is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
20 *
21 ***********************************************************************/
22
23 #pragma once
24
25 #include <app/config_manager.hpp>
26
27 #include <data/vector.hpp>
28
29 #include <service/controller.hpp>
30
31 #include <map>
32
33 namespace sight::module::ui::qt::series
34 {
35
36 /**
37 * @brief This Service allows to preview the selected series in the Vector. For the moment, it works only on a
38 * single selection.
39 *
40 * @section XML XML Configuration
41 *
42 * @code{.xml}
43 <service type="sight::module::ui::qt::series::viewer">
44 <in key="series" uid="..." auto_connect="true" />
45 <parentView wid="..."/>
46 <configs>
47 <config id="2DSimpleConfig" type="data::image_series" />
48 <config id="sight::io::dicom::2d_pacs_preview" type="data::dicom_series" >
49 <parameter replace="PACS_CONFIGURATION" by="None" />
50 </config>
51 <config id="3DSimpleConfig" type="data::model_series" />
52 </configs>
53 </service>
54 </service>
55 @endcode
56 * @subsection Input Input
57 * - \b series [sight::data::vector]: vector containing the series to preview.
58 * @subsection Configuration Configuration
59 * - \b parentView: wid of the view where the config will install its windows.
60 * - \b config: gives the available association between data type and associated config.
61 * - \b id: identifier of the config to launch
62 * - \b type: classname of the object stored in Vector associated to this config.
63 * - \b parameter: allow to pass specific value to the associated config
64 * - \b replace: name of the parameter to be replaced
65 * - \b by: specific value to replace for the parameter
66 */
67 class viewer : public service::controller
68 {
69 public:
70
71 SIGHT_DECLARE_SERVICE(viewer, service::controller);
72
73 /// Constructor
74 viewer() = default;
75
76 /// Destructor
77 ~viewer() noexcept override = default;
78
79 protected:
80
81 /// Calls updating on starting.
82 void starting() override;
83
84 /// Stops the config if it is running.
85 void stopping() override;
86
87 /// Configures the service.
88 void configuring() override;
89
90 /**
91 * @brief Launch the config on the object if possible.
92 *
93 * If there is a single selection : it launches an config on the object defined in this service configuration
94 * (stored in m_seriesConfigs). The selected object fwID replaces the 'objectID' parameter in the config.
95 * no configuration are launched if there is no selection, a multiple selection or if there is no configuration
96 * associated with the selected object.
97 */
98 void updating() override;
99
100 /**
101 * @brief Returns proposals to connect service slots to associated object signals,
102 * this method is used for obj/srv auto connection
103 *
104 * Connect Vector::ADDED_OBJECTS_SIG to this::service::slots::UPDATE
105 * Connect Vector::REMOVED_OBJECTS_SIG to this::service::slots::UPDATE
106 */
107 connections_t auto_connections() const override;
108
109 void info(std::ostream& _sstream) override;
110
111 private:
112
113 using replace_values_map_t = std::map<std::string, std::string>;
114
115 /// Stucture to register configuration informations.
116 struct series_config_info
117 {
118 /// Id of the configuration to launch.
119 std::string config_id;
120
121 /// Stores the parameters to pass to config.
122 replace_values_map_t parameters;
123 };
124
125 using series_config_map_t = std::map<std::string, series_config_info>;
126
127 /// config manager
128 app::config_manager::sptr m_config_template_manager;
129
130 /// Stores the wid of the view where the config will install its windows.
131 std::string m_parent_view;
132
133 /// Stores the association between data type and associated configuration.
134 series_config_map_t m_series_configs;
135
136 static constexpr std::string_view SERIES = "series";
137
138 data::ptr<data::vector, data::access::in> m_series {this, SERIES, true};
139 };
140
141 } // namespace sight::module::ui::qt::series
142