internal OrientationEnumPackage(vtkPolyData polyData, vtkRenderWindow renwin, vtkRenderer mainRenderer)
        {
            this._renwin       = renwin;
            this._mainRenderer = mainRenderer;

            int oldNumberOfRenderer = renwin.GetNumberOfLayers();

            Console.WriteLine(string.Format("oldNumberOfRenderer = {0}", oldNumberOfRenderer));
            int newNumberOfRenderer = oldNumberOfRenderer + 1;

            mainRenderer.SetLayer(0);

            _topRenderer = vtkRenderer.New();
            _topRenderer.SetViewport(0, 0, 0.2, 0.2);
            _topRenderer.SetLayer(newNumberOfRenderer - 1);
            _topRenderer.InteractiveOff();

            _xmlPolyDataPackage = new XmlPolyDataPackage(polyData, _topRenderer);
            //xmlPolyDataPackage.SetOpacity(0.8);
            //xmlPolyDataPackage.Actor.GetProperty().ShadingOn();
            //xmlPolyDataPackage.Actor.GetProperty().SetAmbient(0.8);
            //xmlPolyDataPackage.SetColor(1, 1, 0.5);
            _xmlPolyDataPackage.SetColor(255 / 255.0, 204 / 255.0, 102 / 255.0);

            renwin.SetNumberOfLayers(newNumberOfRenderer);
            renwin.AddRenderer(_topRenderer);

            //_topRenderer.SetActiveCamera(mainRenderer.GetActiveCamera());
        }
        public WatermarkPackage(vtkRenderWindow renwin, vtkRenderer mainRenderer, vtkImageData maskImage)
        {
            int oldNumberOfRenderer = renwin.GetNumberOfLayers();

            Console.WriteLine(string.Format("oldNumberOfRenderer = {0}", oldNumberOfRenderer));
            int newNumberOfRenderer = oldNumberOfRenderer + 1;

            mainRenderer.SetLayer(0);

            vtkRenderer _topRenderer = vtkRenderer.New();

            _topRenderer.SetViewport(0, 0, 1, 1);
            _topRenderer.SetLayer(newNumberOfRenderer - 1);
            _topRenderer.InteractiveOff();
            _topRenderer.GetActiveCamera().ParallelProjectionOn();

            mainRenderer.SetLayer(1);
            _topRenderer.SetLayer(0);

            renwin.SetNumberOfLayers(newNumberOfRenderer);
            renwin.AddRenderer(_topRenderer);

            // Display the image
            _actor = vtkImageActor.New();

            _actor.SetInput(maskImage);
            _actor.SetOpacity(0.8);

            _topRenderer.AddActor(_actor);

            _topRenderer.ResetCameraClippingRange();
            _topRenderer.ResetCamera();
            _topRenderer.GetActiveCamera().Zoom(1.6);
        }
Exemple #3
0
        public void SetTopMost()
        {
            vtkRenderer _aRender = _rendererPackage.Renderer;

            if (_aRender.GetLayer() > 0)
            {
                return;
            }

            if (_aRender.GetRenderWindow().GetRenderers().GetNumberOfItems() == 1)
            {
                vtkRenderer ren1 = vtkRenderer.New(); // 2d actor
                ren1.SetLayer(1);                     // top layer
                ren1.InteractiveOff();

                _aRender.SetLayer(0);
                _aRender.GetRenderWindow().SetNumberOfLayers(2);
                _aRender.GetRenderWindow().AddRenderer(ren1);

                //ren1.SetActiveCamera(_aRender.GetActiveCamera());

                //new SpherePackage(ren1, new double[] { 0, 0, 0 }, 600).SetOpacity(0.01f);

                _aRender.SetActiveCamera(ren1.GetActiveCamera());

                _aRender.RemoveActor(Actor);
                ren1.AddActor(Actor);

                _aRender.InteractiveOn();
            }
            else
            {
                for (int i = 0; i < _aRender.GetRenderWindow().GetRenderers().GetNumberOfItems(); ++i)
                {
                    int layer = vtkRenderer.SafeDownCast(_aRender.GetRenderWindow().GetRenderers().GetItemAsObject(i)).GetLayer();

                    if (layer == 1)
                    {
                        vtkRenderer.SafeDownCast(_aRender.GetRenderWindow().GetRenderers().GetItemAsObject(i)).AddActor(Actor);
                    }
                    else
                    {
                        vtkRenderer.SafeDownCast(_aRender.GetRenderWindow().GetRenderers().GetItemAsObject(i)).RemoveActor(Actor);
                    }
                }
            }
        }
        public ArrowPackage2(double[] startPoint, double[] endPoint, RendererPackage rendererPackage)
        {
            int oldNumberOfRenderer = rendererPackage.RenderWindow.GetNumberOfLayers();

            Console.WriteLine(string.Format("oldNumberOfRenderer = {0}", oldNumberOfRenderer));
            int newNumberOfRenderer = oldNumberOfRenderer + 1;

            rendererPackage.Renderer.SetLayer(0);

            _topRenderer = vtkRenderer.New();
            _topRenderer.SetViewport(0, 0, 1, 1);
            _topRenderer.SetLayer(newNumberOfRenderer - 1);
            _topRenderer.InteractiveOff();

            //new XmlPolyDataPackage(polyData, _topRenderer).SetColor(1, 0, 0);

            rendererPackage.RenderWindow.SetNumberOfLayers(newNumberOfRenderer);
            rendererPackage.RenderWindow.AddRenderer(_topRenderer);

            //Create an arrow.
            _arrowSource = vtkArrowSource.New();
            _arrowSource.SetShaftRadius(0.02);
            _arrowSource.SetTipRadius(0.04);

            _arrowSource.SetShaftRadius(0.05);
            _arrowSource.SetTipRadius(0.1);

            //_arrowSource.SetShaftRadius(2);
            //_arrowSource.SetTipRadius(4);

            //_arrowSource.SetTipLength(10);
            _arrowSource.SetShaftResolution(100);
            _arrowSource.SetTipResolution(100);

            //Create a mapper and actor for the arrow
            _mapper     = vtkPolyDataMapper.New();
            _arrowActor = vtkActor.New();

            // Generate a random start and end point
            // Compute a basis
            UpdatePosition(endPoint, startPoint);

            // Create spheres for start and end point
            //vtkSphereSource sphereStartSource = new vtkSphereSource();
            //sphereStartSource.SetCenter(VTKUtil.ConvertIntPtr(startPoint));
            //vtkPolyDataMapper sphereStartMapper = vtkPolyDataMapper.New();
            //sphereStartMapper.SetInputConnection(sphereStartSource.GetOutputPort());
            //vtkActor sphereStart = new vtkActor();
            //sphereStart.SetMapper(sphereStartMapper);
            //sphereStart.GetProperty().SetColor(1.0, 1.0, .3);

            //vtkSphereSource sphereEndSource = new vtkSphereSource();
            //sphereEndSource.SetCenter(VTKUtil.ConvertIntPtr(endPoint));
            //vtkPolyDataMapper sphereEndMapper = vtkPolyDataMapper.New();
            //sphereEndMapper.SetInputConnection(sphereEndSource.GetOutputPort());
            //vtkActor sphereEnd = new vtkActor();
            //sphereEnd.SetMapper(sphereEndMapper);
            //sphereEnd.GetProperty().SetColor(1.0, .3, .3);

            //_arrowSource.Update();
            //_mapper.SetInput(_arrowSource.GetOutput());
            //_arrowActor.SetMapper(_mapper);

            _arrowActor.GetProperty().SetOpacity(0.2);
            _arrowActor.GetProperty().SetColor(0, 1, 0);

            _topRenderer.AddActor(_arrowActor);
            //rendererPackage.AddActor(sphereStart);
            //rendererPackage.AddActor(sphereEnd);
        }