GCC Code Coverage Report


./
File: modules/geometry/__/point_to_landmark_distance.hpp
Date: 2025-01-21 16:21:04
Lines:
0/1
0.0%
Functions:
0/5
0.0%
Branches:
0/9
0.0%

Line Branch Exec Source
1 /************************************************************************
2 *
3 * Copyright (C) 2018-2024 IRCAD France
4 * Copyright (C) 2018-2020 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 <data/landmarks.hpp>
26 #include <data/matrix4.hpp>
27 #include <data/string.hpp>
28
29 #include <service/base.hpp>
30
31 #define GLM_ENABLE_EXPERIMENTAL
32 #include <glm/gtx/rotate_vector.hpp>
33 #undef GLM_ENABLE_EXPERIMENTAL
34
35 namespace sight::module::geometry
36 {
37
38 /**
39 * @brief Computes the intersection between a mesh and a line.
40 *
41 * @section Signals Signals
42 * - \b distanceChanged(float): Emitted when the distance between the point and the current landmark
43 * is modified
44 *
45 * @section Slots Slots
46 * - \b updateSelectedPoint(std::string , std::size_t ): update the transformation matrix of the point
47 * to the landmark when a landmark is selected
48 * - \b updatePoint(std::string ): update the transformation matrix of the point
49 * to the landmark when a landmark is added
50 * - \b removePoint( ): update the transformation matrix when a point is removed
51 *
52 * @section XML XML Configuration
53 * @code{.xml}
54 <service type="sight::module::geometry::point_to_landmark_distance">
55 <in key="pointMatrix" uid="..." />
56 <in key="landmark" uid="..." />
57 <inout key="pointToLandmarkMatrix" uid="..." />
58 <inout key="distanceText" uid="..." />
59 <config unit="mm" precision="6"/>
60 </service>
61 @endcode
62 *
63 * @subsection In In
64 * - \b pointMatrix [sight::data::matrix4]: point transformation matrix.
65 * - \b landmark [sight::data::landmarks]: landmark.
66 *
67 * @subsection In-Out In-Out
68 * - \b pointToLandmarkMatrix [sight::data::matrix4]: point to landmark transformation matrix
69 * - \b distanceText [sight::data::string]: string containing the distance
70 *
71 * @subsection Configuration Configuration
72 * - \b config(optional): contains the service configuration
73 * - \b unit: unit of the distance computed by this service
74 * - \b precision: precision of the displayed distance
75 */
76 class point_to_landmark_distance final : public service::base
77 {
78 public:
79
80 /// Generates default methods like New, dynamicCast, ...
81 SIGHT_DECLARE_SERVICE(point_to_landmark_distance, service::base);
82
83 /// Initializes signals and slots.
84 point_to_landmark_distance() noexcept;
85
86 /// Destroys the service.
87 ~point_to_landmark_distance() noexcept override;
88
89 protected:
90
91 /// Does nothing.
92 void starting() override;
93
94 /// Does nothing.
95 void stopping() override;
96
97 /// Generates and updates the mesh.
98 void updating() override;
99
100 /// Configures the service's parameters.
101 void configuring() override;
102
103 private:
104
105 using distance_changed_signal_t = core::com::signal<void (float)>;
106
107 /// SLOT: updates selected point.
108 void update_selected_point(std::string _name, std::size_t _index);
109
110 /// SLOT: updates added point.
111 void update_point(std::string _name);
112
113 /// SLOT: updates removed point.
114 void remove_point();
115
116 /// Selected landmark.
117 glm::dvec3 m_current_landmark {};
118
119 /// Bool showing if a landmark is selected.
120 bool m_landmark_selected {false};
121
122 /// Unit to concatenate with the computed result.
123 std::string m_unit;
124
125 /// Precision of the displayed distance.
126 int m_precision {6};
127
128 data::ptr<data::matrix4, sight::data::access::in> m_point_matrix {this, "pointMatrix"};
129 data::ptr<data::landmarks, sight::data::access::in> m_landmark {this, "landmark"};
130 data::ptr<data::matrix4, sight::data::access::inout> m_point_to_landmark_matrix {this, "pointToLandmarkMatrix"};
131 data::ptr<data::string, sight::data::access::inout> m_distance_text {this, "distanceText"};
132 };
133
134 } // namespace sight::module::geometry
135