File: slice_index_dicom_editor.hpp

package info (click to toggle)
sight 25.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 42,184 kB
  • sloc: cpp: 289,476; xml: 17,257; ansic: 9,878; python: 1,379; sh: 144; makefile: 33
file content (168 lines) | stat: -rw-r--r-- 5,381 bytes parent folder | download
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/************************************************************************
 *
 * Copyright (C) 2020-2025 IRCAD France
 * Copyright (C) 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 <core/thread/timer.hpp>
#include <core/thread/worker.hpp>

#include <data/image.hpp>
#include <data/series_set.hpp>

#include <io/__/service/reader.hpp>
#include <io/dimse/data/pacs_configuration.hpp>

#include <service/has_services.hpp>
#include <service/notifier.hpp>

#include <ui/__/editor.hpp>

#include <QLineEdit>
#include <QObject>
#include <QPointer>
#include <QSlider>

namespace sight::module::io::dimse
{

/**
 * @brief This editor service is used to select a slice index and pull the image from the pacs if it is not
 *        available on the local computer.
 *
 * @section XML XML Configuration
 * @code{.xml}
    <service type="sight::module::io::dimse::slice_index_dicom_editor">
        <in key="pacsConfig" uid="..." />
        <inout key="series" uid="..." />
        <inout key="image" uid="..." />
        <config delay="500" dicomReader="sight::module::io::dicom::series_set_reader" readerConfig="config" />
    </service>
   @endcode
 *
 * @subsection Input Input:
 * - \b pacsConfig [sight::io::dimse::data::pacs_configuration]: PACS configuration data.
 *
 * @subsection In-Out In-Out:
 * - \b series [sight::data::dicom_series]: DICOM series where to extract the images.
 * - \b image [sight::data::image]: downloaded slice.
 *
 * @subsection Configuration Configuration:
 * - \b delay (optional, unsigned, default=500): delay to wait between each slice move.
 * - \b dicomReader (mandatory, string): reader type to use.
 * - \b readerConfig (optional, string, default=""): configuration for the DICOM Reader.
 */
class slice_index_dicom_editor final :
    public QObject,
    public sight::ui::editor,
    public sight::service::has_services,
    private sight::service::notifier
{
Q_OBJECT;

public:

    /// Generates default methods as New, dynamicCast, ...
    SIGHT_DECLARE_SERVICE(slice_index_dicom_editor, sight::ui::editor);

    /// Creates the service.
    slice_index_dicom_editor() noexcept;

    /// Destroys the service.
    ~slice_index_dicom_editor() noexcept override = default;

protected:

    /// Configures the service.
    void configuring(const config_t& _config) override;

    /// Creates the slider.
    void starting() override;

    /**
     * @brief Proposals to connect service slots to associated object signals.
     * @return A map of each proposed connection.
     *
     * Connect data::dicom_series::MODIFIED_SIG of s_DICOMSERIES_INOUT to service::slots::UPDATE
     */
    service::connections_t auto_connections() const override;

    /// Updates slider informations and retrieve the image.
    void updating() override;

    /// Destroys the slider.
    void stopping() override;

private Q_SLOTS:

    /// Updates slider information and trigger the slice puller timer.
    void change_slice_index(int _value);

private:

    /// Fills editor information.
    void set_slider_information(unsigned _value);

    /// Retrieves the local slice or pull it, then, read it.
    void retrieve_slice();

    /**
     * @brief Pulls the slice from the PACS.
     * @param _selected_slice_index index of the slice to pull.
     */
    void pull_slice(std::size_t _selected_slice_index) const;

    /**
     * @brief Reads a local slice.
     * @param _dicom_series the dicom series instance.
     * @param _selected_slice_index index of the slice to read.
     */
    void read_slice(
        const data::series& _dicom_series,
        std::size_t _selected_slice_index
    ) const;

    /// Contains the worker of the series enquire thread.
    core::thread::worker::sptr m_request_worker;

    /// Contains the slider.
    QPointer<QSlider> m_slider {nullptr};

    /// Contains the slider informations.
    QPointer<QLineEdit> m_line_edit {nullptr};

    /// Contains the timer used to trigger the new slice retrieving.
    core::thread::timer::sptr m_slice_trigger {nullptr};

    /// Defines the delay to wait to trigger a slice retrieving.
    unsigned int m_delay {500};

    /// Contains the series_set where the DICOM reader sets its output.
    data::series_set::sptr m_series_set;

    data::ptr<sight::io::dimse::data::pacs_configuration, data::access::in> m_config {this, "pacsConfig"};
    data::ptr<sight::data::image, data::access::inout> m_image {this, "image"};

    static constexpr std::string_view DICOMSERIES_INOUT = "series";
    data::ptr<sight::data::series, data::access::inout> m_series {this, DICOMSERIES_INOUT};
};

} // namespace sight::module::io::dimse.