<plugin id="Tuto09MesherWithGenericScene">

    <requirement id="servicesReg" />

    <extension implements="::fwServices::registry::AppConfig">
        <id>Tuto09MesherWithGenericScene</id>
        <type>parameters</type>
        <config>

            <object type="::fwData::Composite">

                <service uid="MyIHM" impl="::gui::frame::DefaultFrame" type="::fwGui::IFrameSrv" autoConnect="no">
                    <gui>
                        <frame>
                            <name>Tuto09MesherWithGenericScene</name>
                            <icon>Bundles/Tuto09MesherWithGenericScene_0-1/tuto.ico</icon>
                        </frame>
                        <menuBar />
                    </gui>
                    <registry>
                        <menuBar sid="myMenuBar" start="yes" />
                        <view sid="multiView_scene1" start="yes" />
                    </registry>
                </service>

                <service uid="myMenuBar" type="::fwGui::IMenuBarSrv" impl="::gui::aspect::DefaultMenuBarSrv" autoConnect="no">
                    <gui>
                        <layout>
                            <menu name="File" />
                            <menu name="Mesher" />
                        </layout>
                    </gui>
                    <registry>
                        <menu sid="menu_File" start="yes" />
                        <menu sid="menu_Mesher" start="yes" />
                    </registry>
                </service>


                <service uid="multiView_scene1" type="::gui::view::IView" impl="::gui::view::DefaultView" autoConnect="no">
                    <gui>
                        <layout type="::fwGui::CardinalLayoutManager">
                            <view align="center" minWidth="200" />
                            <view align="right" minWidth="200" minHeight="200" position="0" />
                            <view align="right" minWidth="200" minHeight="80" position="1" />
                            <view align="right" minWidth="200" minHeight="200" position="2" />
                            <view align="bottom" minHeight="30" resizable="no" />
                        </layout>
                    </gui>
                    <registry>
                        <view sid="genericScene" start="yes" />
                        <view sid="listOrganEditor" start="yes" />
                        <view sid="organMaterialEditor" />
                        <view sid="representationEditor" />
                        <view sid="multiView_scene1_bottom" start="yes" />
                    </registry>
                </service>
                <service uid="multiView_scene1_bottom" type="::gui::view::IView" impl="::gui::view::DefaultView" autoConnect="no">
                    <gui>
                        <layout type="::fwGui::LineLayoutManager">
                            <orientation value="horizontal" />
                            <view proportion="0" minWidth="30" />
                            <view proportion="0" minWidth="50" />
                            <view proportion="1" />
                            <view proportion="0" minWidth="30" />
                        </layout>
                    </gui>
                    <registry>
                        <view sid="sliceListEditor" />
                        <view sid="showScanEditor" />
                        <view sid="sliderIndexEditor" />
                        <view sid="snapshotScene1Editor" start="yes" />
                    </registry>
                </service>


                <service uid="snapshotScene1Editor" type="::gui::editor::IEditor" impl="::uiVisu::SnapshotEditor" autoConnect="no">
                    <snap>
                        <scene uid="genericScene" />
                    </snap>
                </service>

                <service uid="menu_File" type="::fwGui::IMenuSrv" impl="::gui::aspect::DefaultMenuSrv" autoConnect="no">
                    <gui>
                        <layout>
                            <menuItem name="Open image" shortcut="Ctrl+O" />
                            <menuItem name="Save meshes" shortcut="Ctrl+S" />
                            <separator />
                            <menuItem name="Quit" specialAction="QUIT" shortcut="Ctrl+Q" />
                        </layout>
                    </gui>
                    <registry>
                        <menuItem sid="action_openImage" start="yes" />
                        <menuItem sid="action_saveModelSeries" start="yes" />
                        <menuItem sid="action_quit" start="yes" />
                    </registry>
                </service>
                <service uid="menu_Mesher" type="::fwGui::IMenuSrv" impl="::gui::aspect::DefaultMenuSrv" autoConnect="no">
                    <gui>
                        <layout>
                            <menuItem name="Create Mesh 50" />
                            <menuItem name="Create Mesh 80" />
                        </layout>
                    </gui>
                    <registry>
                        <menuItem sid="action_createMesh50" start="no" />
                        <menuItem sid="action_createMesh80" start="no" />
                    </registry>
                </service>

                <service uid="action_openImage" type="::fwGui::IActionSrv" impl="::gui::action::StarterActionService" autoConnect="no">
                    <start uid="imageReader" />
                </service>
                <service uid="action_saveModelSeries" type="::fwGui::IActionSrv" impl="::gui::action::StarterActionService" autoConnect="no">
                    <start uid="modelSeriesWriter" />
                </service>
                <service uid="action_quit" type="::fwGui::IActionSrv" impl="::gui::action::QuitAction" autoConnect="no" />
                
                <item key="image">
                    <object uid="imageUID"  type="::fwData::Image">
                        <service uid="imageReader" impl="::uiIO::editor::IOSelectorService" type="::gui::editor::IDialogEditor" autoConnect="no">
                            <type mode="reader" />
                        </service>
                    </object>
                </item>
        
                <!-- CompositeVisu description -->
                <item key="myCompositeVisu">
                    <object uid="myCompositeVisu" type="::fwData::Composite">
                       
                       <service uid="updaterImageUID" impl="::ctrlSelection::updater::ObjFromMsgUpdaterSrv" type="::ctrlSelection::IUpdaterSrv" autoConnect="no">
                            <update compositeKey="image" onEvent="NEW_IMAGE" fromUID="imageUID" actionType="ADD_OR_SWAP"/>
                        </service>
                
                        <service uid="mesher50ServiceUID" impl="::opVTKMesh::SVTKMesher" type="::opVTKMesh::IMesher" autoConnect="no">
                            <config>
                                <percentReduction>50</percentReduction>
                                <image>image</image>
                                <modelSeries>modelSeries</modelSeries>
                            </config>
                        </service>
                        
                        <service uid="mesher80ServiceUID" impl="::opVTKMesh::SVTKMesher" type="::opVTKMesh::IMesher" autoConnect="no">
                            <config>
                                <percentReduction>80</percentReduction>
                                <image>image</image>
                                <modelSeries>modelSeries</modelSeries>
                            </config>
                        </service>

                        <service uid="updaterReconstUID" impl="::ctrlSelection::updater::SReconstructionFromModelSeriesUpdater" type="::ctrlSelection::IUpdaterSrv" autoConnect="no">
                            <update compositeKey="reconstruction" onEvent="NEW_RECONSTRUCTION_SELECTED" fromUID="*" actionType="ADD_OR_SWAP" />
                        </service>

                        <service uid="managerUID" impl="::ctrlSelection::manager::SwapperSrv" type="::ctrlSelection::IManagerSrv" autoConnect="yes">
                            <mode type="stop" />
                            <config>

                                <object id="image" type="::fwData::Image">
                                    <!-- This service convert a simple fwData::Image to medical Image -->
                                    <service impl="::ctrlSelection::MedicalImageSrv" type="::fwServices::IController"  autoConnect="yes" />
                                    <service uid="action_createMesh50" impl="::gui::action::StarterActionService" type="::fwGui::IActionSrv" autoConnect="no">
                                        <start_if_exists uid="mesher50ServiceUID" />
                                    </service>
                                    <service uid="action_createMesh80" impl="::gui::action::StarterActionService" type="::fwGui::IActionSrv" autoConnect="no">
                                        <start_if_exists uid="mesher80ServiceUID" />
                                    </service>
                                    <service uid="sliceListEditor" type="::gui::editor::IEditor" impl="::uiImage::SliceListEditor" autoConnect="yes">
                                        <negatoAdaptor uid="MPRNegatoScene3D" slices="3" />
                                    </service>
                                    <service uid="showScanEditor" type="::gui::editor::IEditor" impl="::uiImage::ShowScanEditor" autoConnect="no">
                                        <negatoAdaptor uid="MPRNegatoScene3D" />
                                    </service>
                                    <service uid="sliderIndexEditor" type="::gui::editor::IEditor" impl="::uiImage::SliceIndexPositionEditor" autoConnect="yes">
                                        <sliceIndex>axial</sliceIndex>
                                    </service>
                                </object>
                                
                                <object id="reconstruction" type="::fwData::Reconstruction">
                                    <service uid="organMaterialEditor" impl="::uiReconstruction::OrganMaterialEditor" type="::gui::editor::IEditor" autoConnect="no" />
                                    <service uid="representationEditor" impl="::uiReconstruction::RepresentationEditor" type="::gui::editor::IEditor" autoConnect="no" />
                                </object>
                                
                            </config>
                        </service>

                        <service uid="genericScene" impl="::fwRenderVTK::VtkRenderService" type="::fwRender::IRender" autoConnect="yes">
                            <scene>

                                <picker id="myPicker" vtkclass="fwVtkCellPicker" />
                                <renderer id="default" background="0.0" />
                                <adaptor id="modelSeriesAdaptor" class="::visuVTKAdaptor::ModelSeries" objectId="modelSeries">
                                    <config renderer="default" picker="" />
                                </adaptor>
                                <adaptor uid="MPRNegatoScene3D" id="MPRNegato3D" class="::visuVTKAdaptor::NegatoMPR" objectId="image">
                                    <config renderer="default" picker="myPicker" mode="3D" slices="3" sliceIndex="axial" />
                                </adaptor>
                                <adaptor id="snapshot1" class="::visuVTKAdaptor::Snapshot" objectId="self">
                                    <config renderer="default" />
                                </adaptor>

                            </scene>
                        </service>
                        
                        <item key="modelSeries">
                            <object uid="modelSeriesUID" type="::fwMedData::ModelSeries">
                                <service uid="listOrganEditor" impl="::uiMedData::editor::SModelSeriesList" type="::gui::editor::IEditor" autoConnect="yes" />
                                <service uid="modelSeriesWriter" impl="::uiIO::editor::IOSelectorService" type="::gui::editor::IDialogEditor" autoConnect="no">
                                    <type mode="writer" />
                                </service>
                            </object>
                        </item>
                        
                        <connect>
                            <signal>modelSeriesUID/objectModified</signal>
                            <slot>updaterReconstUID/receive</slot>
                        </connect>
                        <connect>
                            <signal>imageUID/objectModified</signal>
                            <slot>updaterImageUID/receive</slot>
                        </connect>
                    </object>
                    
                </item>

                <start uid="MyIHM" />
                <start uid="updaterReconstUID" />
                <start uid="updaterImageUID" />
                <start uid="managerUID" />

            </object>

        </config>
    </extension>

</plugin>
