
<plugin id="Tuto03DataService" >

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

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

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

            <!-- The root data object in tutoDataService is a ::sight::data::Image. -->
            <object uid="image" type="sight::data::Image" />

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

            <!-- Frame service:
                The frame creates a container for the rendering service and a menu bar.
                In this tutorial, the gui services will automatically start the services they register using the
                'start="true"' attribute.
            -->
            <service uid="mainFrame" type="sight::module::ui::base::SFrame" >
                <gui>
                    <frame>
                        <name>Tuto03DataService</name>
                        <icon>Tuto03DataService/tuto.ico</icon>
                        <minSize width="800" height="600" />
                    </frame>
                    <menuBar />
                </gui>
                <registry>
                    <menuBar sid="menuBarView" start="true" />
                    <view sid="imageRenderSrv" start="true" />
                </registry>
            </service>

            <!--
                Menu bar service:
                This service defines the list of the menus displayed in the menu bar.
                Here, we have only one menu: File
                Each <menu> declared into the <layout> tag, must have its associated <menu> into the <registry> tag.
                The <layout> tags defines the displayed information, whereas the <registry> tags defines the
                services information.
            -->
            <service uid="menuBarView" type="sight::module::ui::base::SMenuBar" >
                <gui>
                    <layout>
                        <menu name="File" />
                    </layout>
                </gui>
                <registry>
                    <menu sid="menuView" start="true" />
                </registry>
            </service>

            <!--
                Menu service:
                This service defines the actions displayed in the "File" menu.
                Here, it registers two actions: "Open file", and "Quit".
                As in the menu bar service, each <menuItem> declared into the <layout> tag, must have its
                associated <menuItem> into the <registry> tag.

                It's possible to associate specific attributes for <menuItem> to configure their style, shortcut...
                In this tutorial, the attribute 'specialAction' has the value "QUIT". On MS Windows, there's no
                impact, but on Linux this value installs the default 'Quit' system icon in the menuItem.
            -->
            <service uid="menuView" type="sight::module::ui::base::SMenu" >
                <gui>
                    <layout>
                        <menuItem name="Open image" shortcut="Ctrl+O" />
                        <separator />
                        <menuItem name="Quit" specialAction="QUIT" shortcut="Ctrl+Q" />
                    </layout>
                </gui>
                <registry>
                    <menuItem sid="openImageAct" start="true" />
                    <menuItem sid="quitAct" start="true" />
                </registry>
            </service>

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

            <!--
                Quit action:
                The action service (::sight::module::ui::base::SQuit) is a generic action that will close the application
                when the user click on the menuItem "Quit".
            -->
            <service uid="quitAct" type="sight::module::ui::base::SQuit" />

            <!--
                Open file action:
                This service (::sight::module::ui::base::com::SStarter) is a generic action, it starts and updates the
                services given in the configuration when the user clicks on the action.
                Here, the reader selector will be called when the action is clicked.
            -->
            <service uid="openImageAct" type="sight::module::ui::base::com::SStarter" >
                <start uid="imageReaderSrv" />
            </service>

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

            <!--
                Reader selector dialog:
                This is a generic service that shows a dialog to display all the readers or writers available for its
                associated data. By default it is configured to show readers. (Note: if there is only one reading
                service, it is directly selected without prompting.)
                Here, the only reader available to read a ::sight::data::Image is ::sight::module::io::vtk::ImageReaderService (see
                Tuto02DataServiceBasic), so the selector will not be displayed.
                When the service is chosen, it is started, updated and stopped, so the data is read.
            -->
            <service uid="imageReaderSrv" type="sight::module::ui::base::io::SSelector" >
                <inout key="data" uid="image" />
            </service>

            <!--
                3D visualization service of medical images:
                Here, the service attribute 'autoConnect="true"' allows the rendering to listen the modification of
                the data image. So, when the image is loaded, the visualization will be updated.
            -->
            <service uid="imageRenderSrv" type="sight::module::viz::sample::SImage" >
                <in key="image" uid="image" autoConnect="true" />
            </service>

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

            <!--
                Here, we only start the frame because all the others services are managed by the gui service:
                - the frame starts the menu bar and the redering service
                - the menu bar starts the menu services
                - the menus starts the actions
            -->
            <start uid="mainFrame" />

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