<plugin id="Tuto06Filter" version="@PROJECT_VERSION@" >

    <requirement id="servicesReg" />
    <requirement id="guiQt" />

    <extension implements="::fwServices::registry::AppConfig" >
        <id>Tuto06Filter_AppCfg</id>
        <config>

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

            <!-- This is the source image for the filtering. -->
            <object uid="myImage1" type="::fwData::Image" />
            <!-- This is the output image for the filtering. "deferred" defines that the image is not created at the
                 beginning, but will be created by a service. -->
            <object uid="myImage2" type="::fwData::Image" src="deferred" />

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

            <!-- Windows & Main Menu -->
            <service uid="mainFrame" type="::gui::frame::SDefaultFrame" >
                <gui>
                    <frame>
                        <name>Tuto06Filter</name>
                        <icon>Tuto06Filter-@PROJECT_VERSION@/tuto.ico</icon>
                        <minSize width="1280" height="720" />
                    </frame>
                    <menuBar />
                </gui>
                <registry>
                    <menuBar sid="menuBarView" start="yes" />
                    <view sid="containerView" start="yes" />
                </registry>
            </service>

            <service uid="menuBarView" type="::gui::aspect::SDefaultMenuBar" >
                <gui>
                    <layout>
                        <menu name="File" />
                        <menu name="Filter" />
                    </layout>
                </gui>
                <registry>
                    <menu sid="menuFileView" start="yes" />
                    <menu sid="menuFilterView" start="yes" />
                </registry>
            </service>

            <!-- Menus -->
            <service uid="menuFileView" type="::gui::aspect::SDefaultMenu" >
                <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="yes" />
                    <menuItem sid="quitAct" start="yes" />
                </registry>
            </service>

            <service uid="menuFilterView" type="::gui::aspect::SDefaultMenu" >
                <gui>
                    <layout>
                        <menuItem name="Compute image filter" />
                        <menuItem name="Toggle vertical image flipping" />
                    </layout>
                </gui>
                <registry>
                    <menuItem sid="imageFilterAct" start="yes" />
                    <menuItem sid="imageFlipperAct" start="yes" />
                </registry>
            </service>

            <service uid="containerView" type="::gui::view::SDefaultView" >
                <gui>
                    <layout type="::fwGui::LineLayoutManager" >
                        <orientation value="horizontal" />
                        <view proportion="1" />
                        <view proportion="1" />
                    </layout>
                </gui>
                <registry>
                    <view sid="image1Srv" start="yes" />
                    <!-- As the output image is deferred, the service cannot be started at the beginning. -->
                    <view sid="image2Srv" start="no" />
                </registry>
            </service>

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

            <!-- Action to quit the application -->
            <service uid="quitAct" type="::gui::action::SQuit" />

            <!-- Action to open image file: call update on image reader service -->
            <service uid="openImageAct" type="::gui::action::SSlotCaller" >
                <slots>
                    <slot>imageReaderSrv/update</slot>
                </slots>
            </service>

            <!-- Action apply threshold filter: call update on threshold filter service -->
            <service uid="imageFilterAct" type="::gui::action::SSlotCaller" >
                <slots>
                    <slot>imageFilterSrv/update</slot>
                </slots>
            </service>

            <!-- Action apply flip filter: call 'flipAxisY' slot on flip service -->
            <service uid="imageFlipperAct" type="::gui::action::SSlotCaller" >
                <slots>
                    <slot>imageFlipperSrv/flipAxisY</slot>
                </slots>
            </service>

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

            <!-- Reader of the input image -->
            <service uid="imageReaderSrv" type="::uiIO::editor::SIOSelector" >
                <inout key="data" uid="myImage1" />
                <type mode="reader" />
            </service>

            <!--
                Threshold filter:
                Applies a threshold filter. The source image is 'myImage1' and the
                output image is 'myImage2'.
                The two images are declared above.
             -->
            <service uid="imageFilterSrv" type="::opImageFilter::SThreshold" >
                <in key="source" uid="myImage1" />
                <out key="target" uid="myImage2" />
                <config>
                    <threshold>50</threshold>
                </config>
            </service>

            <!--
                Flip filter:
                Applies a flip filter. The source image is 'myImage1' and the
                output image is 'myImage2'.
                The two images are declared above.
             -->
            <service uid="imageFlipperSrv" type="::opImageFilter::SFlip" >
                <in key="source" uid="myImage1" />
                <out key="target" uid="myImage2" />
            </service>

            <!--
                Renderer of the 1st Image:
                This is the source image for the filtering.
            -->
            <service uid="image1Srv" type="::visuBasic::SImage" >
                <in key="image" uid="myImage1" autoConnect="yes" />
            </service>

            <!--
                Rendered for the 2nd Image:
                This is the output image for the filtering.
            -->
            <service uid="image2Srv" type="::visuBasic::SImage" >
                <in key="image" uid="myImage2" autoConnect="yes" />
            </service>

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

            <start uid="mainFrame" />
            <start uid="imageReaderSrv" />
            <start uid="imageFilterSrv" />
            <start uid="imageFlipperSrv" />

            <!-- start the service using a deferred image -->
            <start uid="image2Srv" />

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