<?xml version="1.0" encoding="UTF-8"?>

<plugin id="Tuto16SceneQt3D" >

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

    <extension implements="::sight::service::extension::Config" >
        <id>Tuto16SceneQt3D_jsonReader_SrvCfg</id>
        <desc>JSON</desc>
        <config>
            <patcher />
            <windowTitle>Open JSON file</windowTitle>
        </config>
    </extension>

    <extension implements="::sight::service::extension::Config" >
        <id>Tuto16SceneQt3D_vtk_SrvCfg</id>
        <desc>VTK</desc>
        <config>
            <windowTitle>Open VTK file</windowTitle>
        </config>
    </extension>

    <extension implements="::sight::service::extension::AppConfig" >
        <id>Tuto16SceneQt3D_AppCfg</id>
        <config>

            <!-- ******************************* Objects declaration ****************************** -->

            <object uid="mesh" type="sight::data::Mesh" />
            <object uid="material" type="sight::data::Material" />

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

            <service uid="mainView" type="sight::module::ui::base::SFrame" >
                <gui>
                    <frame>
                        <name>Tuto16SceneQt3D</name>
                        <icon>Tuto16SceneQt3D/tuto.ico</icon>
                        <minSize width="1080" height="720" />
                    </frame>
                    <menuBar/>
                </gui>
                <registry>
                    <menuBar sid="menuBarView" start="true" />
                    <view sid="genericSceneSrv" start="true" />
                </registry>
            </service>

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

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

            <!-- ******************************* Begin Generic Scene ******************************* -->

            <service uid="genericSceneSrv" type="sight::viz::qt3d::SRender" >
                <scene>
                    <background color="#2d2d2d" />

                    <adaptor uid="meshAdp" />
                    <adaptor uid="materialAdp" />
                </scene>
            </service>

            <service uid="materialAdp" type="sight::module::viz::qt3d::adaptor::SMaterial" autoConnect="true">
                <inout key="material" uid="material" />
                <config materialName="mat"/>
            </service>

            <service uid="meshAdp" type="sight::module::viz::qt3d::adaptor::SMesh" autoConnect="true">
                <inout key="mesh" uid="mesh" />
                <config autoresetcamera="true" visible="true"  materialName="mat"/>
            </service>

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

            <service uid="meshReaderAct" type="sight::module::ui::base::io::SSelector" >
                <inout key="data" uid="mesh" />
                <type mode="reader" />
                <config id="Tuto16SceneQt3D_jsonReader_SrvCfg" service="::sight::module::io::atoms::SReader" />
                <config id="Tuto16SceneQt3D_vtk_SrvCfg" service="::sight::module::io::vtk::SMeshReader" />
            </service>

            <service uid="quitAct" type="sight::module::ui::base::SQuit" />

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

            <start uid="mainView" />
            <start uid="materialAdp" />
            <start uid="meshAdp" />

        </config>
    </extension>
</plugin>
