Exemplo n.º 1
0
        public void Dispose()
        {
            if (Viewers != null)
            {
                Viewers.Internal.Values.ToList().ForEach(viewer => viewer.Dispose());
                Viewers.Internal.Clear();
            }

            if (RenderingStrategies != null)
            {
                RenderingStrategies.Internal.Values.ToList().ForEach(renderingStrategies => renderingStrategies.Internal.Values.ToList().ForEach(renderingStrategy => renderingStrategy.Dispose()));
                RenderingStrategies.Internal.Clear();
            }

            if (TileManager != null)
            {
                TileManager.Dispose();
                TileManager = null;
            }

            //Thrust.Terminate();
            //Cuda.Terminate();
            D3D11.Terminate(ref mDxgiFactory, ref mD3D11Device);

            Console.WriteLine("\nMojo terminating...\n");
        }
Exemplo n.º 2
0
        public Engine(Dictionary <RenderingPaneHwndDescription> renderingPaneHwndDescriptions)
        {
            Console.WriteLine("\nMojo initializing...\n");

            D3D11.Initialize(out mDxgiFactory, out mD3D11Device);
            Cuda.Initialize(mD3D11Device);
            Thrust.Initialize();

            Segmenter = new Segmenter
            {
                Interop = new Interop.Segmenter(mD3D11Device, mD3D11Device.ImmediateContext, Constants.Parameters)
            };

            Viewers = new Dictionary <Viewer>
            {
                {
                    "Segmenter2D", new Viewer
                    {
                        RenderingPane = new RenderingPane(mDxgiFactory,
                                                          mD3D11Device,
                                                          mD3D11Device.ImmediateContext,
                                                          renderingPaneHwndDescriptions.Get("Segmenter2D").Handle,
                                                          renderingPaneHwndDescriptions.Get("Segmenter2D").Width,
                                                          renderingPaneHwndDescriptions.Get("Segmenter2D").Height,
                                                          new Segmenter2D.RenderingStrategy(mD3D11Device,
                                                                                            mD3D11Device.ImmediateContext,
                                                                                            Segmenter)),
                        UserInputHandler = new Segmenter2D.UserInputHandler(Segmenter)
                    }
                }
            };
        }
Exemplo n.º 3
0
        public void Dispose()
        {
            Viewers.Internal.Values.ToList().ForEach(viewer => viewer.Dispose());
            Segmenter.Dispose();

            Thrust.Terminate();
            Cuda.Terminate();
            D3D11.Terminate(ref mDxgiFactory, ref mD3D11Device);

            Console.WriteLine("\nMojo terminating...\n");
        }
Exemplo n.º 4
0
        public Engine(ObservableDictionary <string, D3D11HwndDescription> d3d11HwndDescriptions)
        {
            Console.WriteLine("\nMojo initializing...\n");

            try
            {
                D3D11.Initialize(out mDxgiFactory, out mD3D11Device);
                //Cuda.Initialize( mD3D11Device );
                //Thrust.Initialize();

                TileManager = new TileManager(new Interop.TileManager(mD3D11Device, mD3D11Device.ImmediateContext, Constants.ConstParameters));

                Tools = new ObservableDictionary <ViewerMode, ObservableDictionary <ToolMode, ITool> >
                {
                    {
                        ViewerMode.TileManager2D,
                        new ObservableDictionary <ToolMode, ITool>
                        {
                            { ToolMode.Null, new NullTool() },
                            { ToolMode.AdjustSegmentation, new AdjustSegmentationTool(TileManager, this) },
                            { ToolMode.MergeSegmentation, new MergeSegmentationTool(TileManager, this) },
                            { ToolMode.DrawMergeSegmentation, new DrawMergeSegmentationTool(TileManager, this) },
                            { ToolMode.SplitSegmentation, new SplitSegmentationTool(TileManager, this) }
                        }
                    }
                };

                RenderingStrategies = new ObservableDictionary <ViewerMode, ObservableDictionary <ToolMode, IRenderingStrategy> >
                {
                    {
                        ViewerMode.TileManager2D,
                        new ObservableDictionary <ToolMode, IRenderingStrategy>
                        {
                            { ToolMode.Null, new NullRenderingStrategy(mD3D11Device, mD3D11Device.ImmediateContext) },
                            { ToolMode.AdjustSegmentation, new AdjustSegmentationRenderingStrategy(mD3D11Device, mD3D11Device.ImmediateContext, TileManager) },
                            { ToolMode.MergeSegmentation, new MergeSegmentationRenderingStrategy(mD3D11Device, mD3D11Device.ImmediateContext, TileManager) },
                            { ToolMode.DrawMergeSegmentation, new DrawMergeSegmentationRenderingStrategy(mD3D11Device, mD3D11Device.ImmediateContext, TileManager) },
                            { ToolMode.SplitSegmentation, new SplitSegmentationRenderingStrategy(mD3D11Device, mD3D11Device.ImmediateContext, TileManager) }
                        }
                    }
                };

                Viewers = new ObservableDictionary <ViewerMode, Viewer>
                {
                    {
                        ViewerMode.TileManager2D,
                        new Viewer
                        {
                            D3D11RenderingPane = new D3D11RenderingPane(mDxgiFactory,
                                                                        mD3D11Device,
                                                                        mD3D11Device.ImmediateContext,
                                                                        d3d11HwndDescriptions.Get("TileManager2D"))
                            {
                                RenderingStrategy = RenderingStrategies.Internal[ViewerMode.TileManager2D].Internal[ToolMode.Null]
                            },
                            UserInputHandler = Tools.Internal[ViewerMode.TileManager2D].Internal[ToolMode.Null]
                        }
                    }
                };
            }
            catch (Exception e)
            {
                String errorMessage = "Error opening main window:\n\n" + e.Message + "\n\nYou might want to try one of the following:\n - Install the \"DirectX End-User Runtime\" (from the Microsoft website).\n - Install the latest graphics drivers for your graphics card.\n - Reinstall the latest Mojo release.";
                MessageBox.Show(errorMessage, "Initialization Error", MessageBoxButton.OK, MessageBoxImage.Error);
                Console.WriteLine(errorMessage);
                Application.Current.Shutdown(1);
            }
        }