File: compositor_selector.hpp

package info (click to toggle)
sight 25.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 42,184 kB
  • sloc: cpp: 289,476; xml: 17,257; ansic: 9,878; python: 1,379; sh: 144; makefile: 33
file content (142 lines) | stat: -rw-r--r-- 4,261 bytes parent folder | download | duplicates (3)
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
/************************************************************************
 *
 * Copyright (C) 2014-2024 IRCAD France
 * Copyright (C) 2014-2019 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 <ui/__/editor.hpp>

#include <viz/scene3d/compositor/chain_manager.hpp>
#include <viz/scene3d/layer.hpp>

#include <QCheckBox>
#include <QComboBox>
#include <QGroupBox>
#include <QListWidget>
#include <QObject>
#include <QPointer>
#include <QVBoxLayout>

#include <vector>

namespace sight::module::ui::viz
{

/**
 * @brief   Allows to select an Ogre Compositor and apply it to a layer
 */
class compositor_selector : public QObject,
                            public sight::ui::editor
{
Q_OBJECT

public:

    SIGHT_DECLARE_SERVICE(compositor_selector, sight::ui::editor);

    /** @} */

    /**
     * @name Slots API
     * @{
     */
    using init_layer_slot_t = core::com::slot<void (sight::viz::scene3d::layer::sptr)>;

    /// Slot: Populate the list of available compositors for the selected layer
    static const core::com::slots::key_t INIT_COMPOSITOR_LIST_SLOT;

    /** @} */

    /// Constructor.
    compositor_selector() noexcept;

    /// Destructor. Does nothing
    ~compositor_selector() noexcept override;

protected:

    /**
     * @brief method description:
     * @code{.xml}
        <service uid="compositor_selectorInstance" type="sight::module::ui::viz::compositor_selector">
             <parameter>param</parameter>
        </service>
       @endcode
     * - \b Parameter : parameter description.
     */
    void configuring() override;

    /// Sets the connections and the UI elements
    void starting() override;

    /// Destroys the connections and cleans the container
    void stopping() override;

    /// Does nothing
    void updating() override;

private Q_SLOTS:

    /// Slot: called when a layer is selected
    /// Sets the current layer and initializes the compositor list
    void on_selected_layer_item(int _index);

    /// Slot: called when an item of the list widget is checked
    void on_selected_compositor_item(QListWidgetItem* _compositor_item);

private:

    /// Slot: Populate the list of available compositors for the selected layer
    void init_compositor_list(sight::viz::scene3d::layer::sptr _layer);

    /// Retrieves all the layers from the application thanks to the render services
    void refresh_renderers();

    /// Checks if there is an XML configured compositor chain.
    /// Sets the local compositor chain according to this.
    void synchronise_with_layer_compositor_chain();

    /// Retrieves the available compositors from the compositor resource group and stores them in the list widget
    void update_compositor_list();

    /// Iterates through the compositor chain and checks the enabled compositors
    void check_enabled_compositors();

    /// Iterates through the compositor chain and unchecks them
    void uncheck_compositors();

    /// Indicates if a compositor is enabled on the layer
    bool is_enabled_compositor(const std::string& _compositor_name);

    QPointer<QComboBox> m_layers_box;

    QPointer<QListWidget> m_compositor_chain;

    std::vector<sight::viz::scene3d::layer::wptr> m_layers;
    sight::viz::scene3d::layer::wptr m_current_layer;

    sight::viz::scene3d::compositor::chain_manager::compositor_chain_t m_layer_compositor_chain;

    ///Connection service, needed for slot/signal association
    core::com::helper::sig_slot_connection m_connections;
};

} // namespace sight::module::ui::viz