<plugin id="tuto04_signal_slot">
    <requirement id="sight::module::service" />
    <requirement id="sight::module::ui::qt" />

    <extension implements="sight::app::extension::config">
        <id>Tuto04SignalSlot_AppCfg</id>
        <config>
            <!-- ******************************* Objects declaration ****************************** -->

            <!-- The main data object is sight::data::mesh. -->
            <object uid="mesh" type="sight::data::mesh" />

            <!-- ******************************* UI declaration *********************************** -->

            <service uid="mainFrame" type="sight::module::ui::frame">
                <gui>
                    <frame>
                        <name>tuto04_signal_slot</name>
                        <icon>tuto04_signal_slot/tuto.ico</icon>
                        <minSize width="1280" height="720" />
                    </frame>
                    <menubar />
                </gui>
                <registry>
                    <menubar sid="menuBarView" start="true" />
                    <view sid="containerView" start="true" />
                </registry>
            </service>

            <service uid="menuBarView" type="sight::module::ui::menubar">
                <gui>
                    <layout>
                        <menu name="File" />
                    </layout>
                </gui>
                <registry>
                    <menu sid="menuFileView" start="true" />
                </registry>
            </service>

            <service uid="menuFileView" type="sight::module::ui::menu">
                <gui>
                    <layout>
                        <menuItem name="Open mesh" shortcut="Ctrl+O" />
                        <separator />
                        <menuItem name="Quit" specialAction="QUIT" shortcut="Ctrl+Q" />
                    </layout>
                </gui>
                <registry>
                    <menuItem sid="openMeshAct" start="true" />
                    <menuItem sid="quitAct" start="true" />
                </registry>
            </service>

            <!--
                Default view service:
                This service defines the view layout. The type 'sight::ui::layout::cardinal' represents a main
                central view and other views at the 'right', 'left', 'bottom' or 'top'.
                Here the application contains a central view at the right.

                Each <view> declared into the <layout> tag, must have its associated <view> into the <registry> tag.
                A minimum window height and a width are given to the two non-central views.
            -->
            <service uid="containerView" type="sight::module::ui::view">
                <gui>
                    <layout type="sight::ui::layout::cardinal">
                        <view align="center" />
                        <view caption="Move cameras 1,2" align="right" minWidth="600" minHeight="100" />
                        <view caption="Move camera 3" align="right" minWidth="600" minHeight="100" />
                    </layout>
                </gui>
                <registry>
                    <view sid="rendering1Srv" start="true" />
                    <view sid="rendering2Srv" start="true" />
                    <view sid="rendering3Srv" start="true" />
                </registry>
            </service>

            <!-- ******************************* Actions ****************************************** -->

            <service uid="openMeshAct" type="sight::module::ui::action" />
            <service uid="quitAct" type="sight::module::ui::quit" />

            <!-- ******************************* Services ***************************************** -->

            <service uid="meshReaderSrv" type="sight::module::ui::io::selector">
                <inout key="data" uid="mesh" />
                <!-- mode is optional (by default it is "reader") -->
                <type mode="reader" />
            </service>

            <!--
                Visualization services:
                We have three rendering service representing a 3D scene displaying the loaded mesh. The scene are
                shown in the windows defines in 'view' service.
            -->
            <service uid="rendering1Srv" type="sight::module::viz::sample::mesh">
                <in key="mesh" uid="mesh" auto_connect="true" />
            </service>

            <service uid="rendering2Srv" type="sight::module::viz::sample::mesh">
                <in key="mesh" uid="mesh" auto_connect="true" />
            </service>

            <service uid="rendering3Srv" type="sight::module::viz::sample::mesh">
                <in key="mesh" uid="mesh" auto_connect="true" />
            </service>

            <!-- ******************************* Connections ***************************************** -->

            <!--
                Each 3D scene owns a 3D camera that can be moved by clicking in the scene.
                - When the camera move, a signal 'camUpdated' is emitted with the new camera information (position,
                focal, view up).
                - To update the camera without clicking, you could call the slot 'updateCamPosition'

                Here, we connect some rendering services signal 'camUpdated' to the others service slot
                'updateCamPosition', so the cameras are synchronized between scenes.
            -->
            <connect>
                <signal>rendering1Srv/cam_updated</signal>
                <slot>rendering2Srv/update_cam_position</slot>
                <slot>rendering3Srv/update_cam_position</slot>
            </connect>

            <connect>
                <signal>rendering2Srv/cam_updated</signal>
                <slot>rendering1Srv/update_cam_position</slot>
            </connect>

            <connect>
                <signal>openMeshAct/clicked</signal>
                <slot>meshReaderSrv/update</slot>
            </connect>

            <!-- ******************************* Start services ***************************************** -->

            <start uid="mainFrame" />
            <start uid="meshReaderSrv" />
        </config>
    </extension>
</plugin>
