<plugin id="Tuto04MeshGeneratorCpp" library="true" >

    <requirement id="sight::module::ui::base" />
    <requirement id="sight::module::viz::scene3d" />
    <requirement id="sight::module::viz::scene3dQt" />
    <requirement id="sight::module::ui::qt" />
    <requirement id="sight::module::service" />

    <extension implements="::sight::service::extension::Factory" >
        <type>sight::ui::base::IAction</type>
        <service>Tuto04MeshGeneratorCpp::SMeshModifier</service>
        <object>sight::data::Mesh</object>
    </extension>

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

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

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

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

            <service uid="mainFrame" type="sight::module::ui::base::SFrame" >
                <gui>
                    <frame>
                        <name>Tuto04MeshGeneratorCpp</name>
                        <icon>Tuto04MeshGeneratorCpp/tuto.ico</icon>
                    </frame>
                    <menuBar/>
                </gui>
                <registry>
                    <menuBar sid="menuBarView" start="true" />
                    <view sid="genericSceneSrv" start="true" />
                </registry>
            </service>

            <service uid="progressBarView" type="sight::module::ui::base::SJobBar" />

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

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

            <service uid="modifierFileView" type="sight::module::ui::base::SMenu" >
                <gui>
                    <layout>
                        <menuItem name="Shake mesh point" shortcut="Q" />
                        <separator/>
                        <menuItem name="Colorize mesh point" shortcut="U" />
                        <menuItem name="Colorize mesh cells" shortcut="I" />
                        <separator/>
                        <menuItem name="Compute points normals" shortcut="O" />
                        <menuItem name="Compute cells normals" shortcut="P" />
                        <separator/>
                        <menuItem name="Shake points normals" shortcut="L" />
                        <menuItem name="Shake cells normals" shortcut="M" />
                        <separator/>
                        <menuItem name="mesh deformation" shortcut="D" />
                    </layout>
                </gui>
                <registry>
                    <menuItem sid="shakeMeshPointAct" start="true" />
                    <menuItem sid="colorizeMeshPointAct" start="true" />
                    <menuItem sid="colorizeMeshCellsAct" start="true" />
                    <menuItem sid="colorizeComputePointsNormalsAct" start="true" />
                    <menuItem sid="colorizeComputeCellsNormalsAct" start="true" />
                    <menuItem sid="shakePointsNormalsAct" start="true" />
                    <menuItem sid="shakeCellsNormalsAct" start="true" />
                    <menuItem sid="meshDeformationAct" start="true" />
                </registry>
            </service>

            <!-- *************************** Begin generic scene *************************** -->

            <service uid="genericSceneSrv" type="sight::viz::scene3d::SRender" >
                <scene>
                    <background topColor="#36393E" bottomColor="#36393E" />

                    <layer id="default" order="1" />
                    <adaptor uid="trackballInteractorAdp" />
                    <adaptor uid="meshAdp" />
                </scene>
            </service>

            <service uid="trackballInteractorAdp" type="sight::module::viz::scene3d::adaptor::STrackballCamera" >
                <config layer="default" priority="0" />
            </service>

            <service uid="meshAdp" type="sight::module::viz::scene3d::adaptor::SMesh" autoConnect="true" >
                <inout key="mesh" uid="mesh" />
                <config layer="default" />
            </service>

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

            <service uid="openMeshAct" type="sight::module::ui::base::com::SStarter" >
                <start uid="meshReaderSrv" />
            </service>

            <service uid="saveMeshAct" type="sight::module::ui::base::com::SStarter" >
                <start uid="meshWriterSrv" />
            </service>

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

            <service uid="shakeMeshPointAct" type="Tuto04MeshGeneratorCpp::SMeshModifier" >
                <inout key="mesh" uid="mesh" />
                <config functor="ShakeMeshPoint" />
            </service>

            <service uid="colorizeMeshPointAct" type="Tuto04MeshGeneratorCpp::SMeshModifier" >
                <inout key="mesh" uid="mesh" />
                <config functor="ColorizeMeshPoints" />
            </service>

            <service uid="colorizeMeshCellsAct" type="Tuto04MeshGeneratorCpp::SMeshModifier" >
                <inout key="mesh" uid="mesh" />
                <config functor="ColorizeMeshCells" />
            </service>

            <service uid="colorizeComputePointsNormalsAct" type="Tuto04MeshGeneratorCpp::SMeshModifier" >
                <inout key="mesh" uid="mesh" />
                <config functor="ComputePointNormals" />
            </service>

            <service uid="colorizeComputeCellsNormalsAct" type="Tuto04MeshGeneratorCpp::SMeshModifier" >
                <inout key="mesh" uid="mesh" />
                <config functor="ComputeCellNormals" />
            </service>

            <service uid="shakePointsNormalsAct" type="Tuto04MeshGeneratorCpp::SMeshModifier" >
                <inout key="mesh" uid="mesh" />
                <config functor="ShakePointNormals" />
            </service>

            <service uid="shakeCellsNormalsAct" type="Tuto04MeshGeneratorCpp::SMeshModifier" >
                <inout key="mesh" uid="mesh" />
                <config functor="ShakeCellNormals" />
            </service>

            <service uid="meshDeformationAct" type="Tuto04MeshGeneratorCpp::SMeshModifier" >
                <inout key="mesh" uid="mesh" />
                <config functor="MeshDeformation" />
            </service>

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

            <service uid="meshReaderSrv" type="sight::module::ui::base::io::SSelector" >
                <inout key="data" uid="mesh" />
                <type mode="reader" />
            </service>

            <service uid="meshWriterSrv" type="sight::module::ui::base::io::SSelector" >
                <inout key="data" uid="mesh" />
                <type mode="writer" />
            </service>

            <!-- ******************************* Connections ***************************************** -->
            <connect>
                <signal>meshReaderSrv/jobCreated</signal>
                <signal>meshWriterSrv/jobCreated</signal>
                <slot>progressBarView/showJob</slot>
            </connect>

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

            <start uid="mainFrame" />
            <start uid="progressBarView" />
            <start uid="trackballInteractorAdp" />
            <start uid="meshAdp" />

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