1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
/************************************************************************
*
* Copyright (C) 2018-2024 IRCAD France
* Copyright (C) 2018-2020 IHU Strasbourg
*
* This file is part of Sight.
*
* Sight is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Sight. If not, see <https://www.gnu.org/licenses/>.
*
***********************************************************************/
#pragma once
#include <data/matrix4.hpp>
#include <data/vector.hpp>
#include <service/base.hpp>
namespace sight::module::geometry
{
/**
* @brief This service manages vectors of matrices and can be connected to the matrices list visualization service (
* for example list_view on Sight)
*
* This service allows to insert or remove matrices from a list into vector group.
* When an input matrix is updated, this matrix is pushed into the outputVector.
* When the service receive the "selectMatrix" slot, the selected matrix is updated.
* The number of elements in each group (matrices, selectedMatrix, vector) must be the same.
* If we have 2 elements in selectedMatrix group, the 2 selected matrices are updated in the same time.
* The same with adding or removing a matrix from the vector.
*
* @section Signals Signals
* - \b matrixAdded(int index, std::string text): Emitted when a matrix is inserted on a vector
* - \b matrixRemoved(int index): Emitted when a matrix is removed from the list
*
* @section Slots Slots
* - \b selectMatrix(int index, std::string text): Called when a matrix is selected
* - \b removeMatrix(int index): Called when a matrix is removed from the list
*
* @section XML XML Configuration
* @code{.xml}
<service type="sight::module::geometry::matrix_list">
<inout group="matrices">
<key uid="..." />
<key uid="..." />
...
</inout>
<inout group="selectedMatrix">
<key uid="..." />
<key uid="..." />
...
</inout>
<out group="vector">
<key uid="..." />
<key uid="..." />
...
</out>
</service>
@endcode
*
* @subsection InOut InOut:
* - \b matrices [sight::data::matrix4]: input matrix
* - \b selectedMatrix [sight::data::matrix4]: selected matrix
*
* @subsection Output Output:
* - \b vector [sight::data::vector]: vector containing matrices
*/
class matrix_list final : public service::base
{
public:
/// Generates default methods like New, dynamicCast,...
SIGHT_DECLARE_SERVICE(matrix_list, service::base);
/// Initializes signals.
matrix_list() noexcept;
/// Destroys the service.
~matrix_list() noexcept override;
protected:
/// Gets parameters from map.
void starting() override;
/// Does nothing.
void stopping() override;
/// Stores computed matrices from input vector into a list of strings.
void updating() override;
/// This method is used to configure the service parameters.
void configuring() override;
private:
/// SLOT: selects a matrix.
void select_matrix(int /*index*/);
///SLOT: removes a matrix.
void remove_matrix(int /*_index*/);
using matrix_added_signal_t = core::com::signal<void (int, std::string)>;
using matrix_removed_signal_t = core::com::signal<void (int)>;
static constexpr std::string_view MATRICES_INOUT = "matrices";
static constexpr std::string_view SELECTED_INOUT = "selectedMatrix";
static constexpr std::string_view VECTOR_INOUT = "vector";
data::ptr_vector<data::matrix4, data::access::inout> m_input_vector {this, MATRICES_INOUT};
data::ptr_vector<data::matrix4, data::access::inout> m_selected_vector {this, SELECTED_INOUT};
data::ptr_vector<data::vector, data::access::out> m_output_vector {this, VECTOR_INOUT};
};
} // namespace sight::module::geometry.
|