<plugin id="tuto13_mesh_generator_cpp" library="true">
    <requirement id="sight::module::ui" />
    <requirement id="sight::module::viz::scene3d" />
    <requirement id="sight::module::viz::scene3d_qt" />
    <requirement id="sight::module::ui::qt" />
    <requirement id="sight::module::service" />

    <extension implements="sight::service::extension::factory">
        <type>sight::ui::action</type>
        <service>tuto13_mesh_generator_cpp::mesh_modifier</service>
        <object>sight::data::mesh</object>
    </extension>

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

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

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

            <service uid="main_frame" type="sight::module::ui::frame">
                <gui>
                    <frame>
                        <name>tuto13_mesh_generator_cpp</name>
                        <icon>tuto13_mesh_generator_cpp/tuto.ico</icon>
                    </frame>
                    <menubar />
                </gui>
                <registry>
                    <menubar sid="menu_bar_view" />
                    <view sid="container_view" />
                </registry>
            </service>

            <service uid="container_view" type="sight::module::ui::view">
                <gui>
                    <layout type="sight::ui::layout::line">
                        <orientation value="vertical" />
                        <view proportion="0" background_color="#3E4453" />
                        <view proportion="0" />
                    </layout>
                </gui>
                <registry>
                    <view sid="generic_scene_srv" />
                    <view sid="progress_bar" />
                </registry>
            </service>

            <service uid="progress_bar" type="sight::module::ui::qt::progress_bar" />

            <service uid="menu_bar_view" type="sight::module::ui::menubar">
                <gui>
                    <layout>
                        <menu name="File" />
                        <menu name="Modify" />
                    </layout>
                </gui>
                <registry>
                    <menu sid="menu_file_view" />
                    <menu sid="modifier_file_view" />
                </registry>
            </service>

            <service uid="menu_file_view" type="sight::module::ui::menu">
                <gui>
                    <layout>
                        <menuItem name="Open mesh" shortcut="Ctrl+O" />
                        <menuItem name="Save mesh" shortcut="Ctrl+S" />
                        <separator />
                        <menuItem name="Quit" special_action="QUIT" shortcut="Ctrl+Q" />
                    </layout>
                </gui>
                <registry>
                    <menuItem sid="open_mesh_act" />
                    <menuItem sid="save_mesh_act" />
                    <menuItem sid="quit_act" />
                </registry>
            </service>

            <service uid="modifier_file_view" type="sight::module::ui::menu">
                <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="shake_mesh_point_act" />
                    <menuItem sid="colorize_mesh_point_act" />
                    <menuItem sid="colorize_mesh_cells_act" />
                    <menuItem sid="colorize_compute_points_normals_act" />
                    <menuItem sid="colorize_compute_cells_normals_act" />
                    <menuItem sid="shake_points_normals_act" />
                    <menuItem sid="shake_cells_normals_act" />
                    <menuItem sid="mesh_deformation_act" />
                </registry>
            </service>

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

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

                    <layer id="default">
                        <adaptor uid="trackball_interactor_adp" />
                        <adaptor uid="mesh_adp" />
                    </layer>
                </scene>
            </service>

            <service uid="trackball_interactor_adp" type="sight::module::viz::scene3d::adaptor::trackball_camera">
                <config priority="0" />
            </service>

            <service uid="mesh_adp" type="sight::module::viz::scene3d::adaptor::mesh" auto_connect="true">
                <in key="mesh" uid="mesh" />
            </service>

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

            <service uid="open_mesh_act" type="sight::module::ui::action" />

            <service uid="save_mesh_act" type="sight::module::ui::action" />

            <service uid="quit_act" type="sight::module::ui::quit" />

            <service uid="shake_mesh_point_act" type="tuto13_mesh_generator_cpp::mesh_modifier">
                <inout key="mesh" uid="mesh" />
                <config functor="ShakeMeshPoint" />
            </service>

            <service uid="colorize_mesh_point_act" type="tuto13_mesh_generator_cpp::mesh_modifier">
                <inout key="mesh" uid="mesh" />
                <config functor="ColorizeMeshPoints" />
            </service>

            <service uid="colorize_mesh_cells_act" type="tuto13_mesh_generator_cpp::mesh_modifier">
                <inout key="mesh" uid="mesh" />
                <config functor="ColorizeMeshCells" />
            </service>

            <service uid="colorize_compute_points_normals_act" type="tuto13_mesh_generator_cpp::mesh_modifier">
                <inout key="mesh" uid="mesh" />
                <config functor="ComputePointNormals" />
            </service>

            <service uid="colorize_compute_cells_normals_act" type="tuto13_mesh_generator_cpp::mesh_modifier">
                <inout key="mesh" uid="mesh" />
                <config functor="ComputeCellNormals" />
            </service>

            <service uid="shake_points_normals_act" type="tuto13_mesh_generator_cpp::mesh_modifier">
                <inout key="mesh" uid="mesh" />
                <config functor="ShakePointNormals" />
            </service>

            <service uid="shake_cells_normals_act" type="tuto13_mesh_generator_cpp::mesh_modifier">
                <inout key="mesh" uid="mesh" />
                <config functor="ShakeCellNormals" />
            </service>

            <service uid="mesh_deformation_act" type="tuto13_mesh_generator_cpp::mesh_modifier">
                <inout key="mesh" uid="mesh" />
                <config functor="MeshDeformation" />
            </service>

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

            <service uid="mesh_reader_srv" type="sight::module::ui::io::selector">
                <inout key="data" uid="mesh" />
                <type mode="reader" />
            </service>

            <service uid="mesh_writer_srv" type="sight::module::ui::io::selector">
                <inout key="data" uid="mesh" />
                <type mode="writer" />
            </service>

            <!-- ******************************* Connections ***************************************** -->
            <connect>
                <signal>mesh_reader_srv/monitor_created</signal>
                <signal>mesh_writer_srv/monitor_created</signal>
                <slot>progress_bar/add_monitor</slot>
            </connect>

            <connect>
                <signal>open_mesh_act/clicked</signal>
                <slot>mesh_reader_srv/update</slot>
            </connect>

            <connect>
                <signal>save_mesh_act/clicked</signal>
                <slot>mesh_writer_srv/update</slot>
            </connect>
        </config>
    </extension>
</plugin>
