当前位置: 首页>>代码示例>>C#>>正文


C# vtkRenderWindowInteractor.SetInteractorStyle方法代码示例

本文整理汇总了C#中vtkRenderWindowInteractor.SetInteractorStyle方法的典型用法代码示例。如果您正苦于以下问题:C# vtkRenderWindowInteractor.SetInteractorStyle方法的具体用法?C# vtkRenderWindowInteractor.SetInteractorStyle怎么用?C# vtkRenderWindowInteractor.SetInteractorStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vtkRenderWindowInteractor的用法示例。


在下文中一共展示了vtkRenderWindowInteractor.SetInteractorStyle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: c3DWorld

        //public c3DWorld(Kitware.VTK.RenderWindowControl CurrentrenderWindowControl, Sequence Seq)
        //{
        //    this.ren1 = CurrentrenderWindowControl.RenderWindow.GetRenderers().GetFirstRenderer();
        //    this.renWin = CurrentrenderWindowControl.RenderWindow;
        //    if (Seq == null)
        //    {
        //        Xres = Yres = Zres = 0;
        //    }
        //    else
        //    {
        //        Xres = Seq.XResolution;
        //        Yres = Seq.YResolution;
        //        Zres = Seq.ZResolution;
        //    }
        //    ListPolyDataMapper = new List<vtkPolyDataMapper>();
        //    ListObject = new List<cObject3D>();
        //    ListVolume = new List<cVolume3D>();
        //}
        /// <summary>
        /// Create a 3D world
        /// </summary>
        /// <param name="CurrentrenderWindowControl">vtk Control</param>
        /// <param name="Dimensions">in pixels</param>
        /// <param name="Resolution">spatial resolutions</param>
        public c3DWorld(cPoint3D Dimensions, cPoint3D Resolution, RenderWindowControl CurrentrenderWindowControl, int[] WinPos)
        {
            // int[] Pos =  renWin.GetPosition();

            //,
            if (CurrentrenderWindowControl == null)
            {
                renWin = vtkRenderWindow.New();
                renWin.LineSmoothingOn();
                renWin.PointSmoothingOn();
                renWin.SetWindowName("3D World");
                renWin.BordersOn();
                renWin.DoubleBufferOn();

                renWin.SetSize(750, 500);

                //   if(WinPos!=null)            renWin.SetPosition(WinPos[0], WinPos[1]);
                // this.ren1 = CurrentrenderWindowControl.RenderWindow.GetRenderers().GetFirstRenderer();
                //CurrentrenderWindowControl.RenderWindow;
            }

            //// Menu Strip Construction
            //this.contextMenuStripActorPicker = new ContextMenuStrip();
            //ToolStripMenuItem StripMenuItemDisplay = new ToolStripMenuItem("Display");
            //contextMenuStripActorPicker.Items.Add(StripMenuItemDisplay);

            this.ren1 = vtkRenderer.New();
            //renWin = CurrentrenderWindowControl.RenderWindow;//vtkRenderWindow.New();

            renWin.AddRenderer(ren1);

            iren = new vtkRenderWindowInteractor();
            iren.SetRenderWindow(renWin);

            //iren.SetInteractorStyle(vtkInteractorStyleJoystickCamera.New());
            iren.SetInteractorStyle(vtkInteractorStyleTrackballCamera.New());
            //   iren.SetInteractorStyle(vtkInteractorStyleTerrain.New());

            // iren.LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(RenderWindow_LeftButtonPressEvt);
            iren.KeyPressEvt += new vtkObject.vtkObjectEventHandler(RenderWindow_KeyPressEvt);
            iren.RightButtonPressEvt += new vtkObject.vtkObjectEventHandler(RenderWindow_RightButtonPressEvt);

            //Render();
            //this.ren1 =

            Xres = Resolution.X;
            Yres = Resolution.Y;
            Zres = Resolution.Z;

            SizeX = (int)Dimensions.X;
            SizeY = (int)Dimensions.Y;
            SizeZ = (int)Dimensions.Z;

            //  double[] fp = ren1.GetActiveCamera().GetFocalPoint();
            //   double[] p = ren1.GetActiveCamera().GetPosition();

            //   ren1.GetActiveCamera().ParallelProjectionOn();

            //   double dist = Math.Sqrt((p[0] - fp[0]) * (p[0] - fp[0]) + (p[1] - fp[1]) * (p[1] - fp[1]) + (p[2] - fp[2]) * (p[2] - fp[2]));
            //    ren1.GetActiveCamera().SetPosition(fp[0], fp[1], fp[2] + dist*1000);
            //    ren1.GetActiveCamera().Zoom(2);
            //ren1.Render();
            //  this.Render();
            ListPolyDataMapper = new List<vtkPolyDataMapper>();
            ListObject = new List<cObject3D>();

            //     Vtk_CameraViewOrientation = ren1.GetActiveCamera();
        }
开发者ID:cyrenaique,项目名称:HCS,代码行数:92,代码来源:c3DWorld.cs

示例2: GenerateGraph

        //vtkRenderWindow RenderWindow;
        private void GenerateGraph()
        {
            // get a reference to the renderwindow of our renderWindowControl1
            vtkRenderWindow RenderWindow = renderWindowControl1.RenderWindow;

            //renWin = vtkRenderWindow.New();
            RenderWindow.LineSmoothingOn();
            RenderWindow.PointSmoothingOn();
            //  RenderWindow.SetWindowName("3D World");
            // RenderWindow.BordersOn();
            RenderWindow.DoubleBufferOn();
            //RenderWindow.SetSize(WinPos[0], WinPos[1]);

            //this.ren1 = vtkRenderer.New();

            // this.Input.renWin = RenderWindow;

            this.Input.AssociatedVTKRenderer = RenderWindow.GetRenderers().GetFirstRenderer();
            //Input.AssociatedVTKRenderer = this.Input.AssociatedVTKRenderer;
            Input.AssociatedrenderWindow = renderWindowControl1;

            foreach (var item in this.Input.ListObject)
            {
                item.AddMeToTheWorld(this.Input.AssociatedVTKRenderer);
            }

            foreach (var item in this.Input.ListVolume)
            {
                item.AddMeToTheWorld(this.Input.AssociatedVTKRenderer);
            }

            foreach (var item in this.Input.ListLights)
            {
                item.AddMeToTheWorld(this.Input.AssociatedVTKRenderer);
            }

            RenderWindow.AddRenderer(this.Input.AssociatedVTKRenderer);

            iren = new vtkRenderWindowInteractor();
            iren.SetRenderWindow(RenderWindow);

            // iren.SetInteractorStyle(vtkInteractorStyleJoystickCamera.New());
            iren.SetInteractorStyle(vtkInteractorStyleTrackballCamera.New());
               // iren.SetInteractorStyle(vtkInteractorStyleTrackballActor.New());
            iren.Start();
            //   iren.SetInteractorStyle(vtkInteractorStyleTerrain.New());

            // iren.LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(RenderWindow_LeftButtonPressEvt);
            iren.KeyPressEvt += new vtkObject.vtkObjectEventHandler(RenderWindow_KeyPressEvt);
            iren.RightButtonPressEvt += new vtkObject.vtkObjectEventHandler(RenderWindow_RightButtonPressEvt);

            this.Input.AssociatedVTKRenderer.SetBackground(this.Input.BackGroundColor.R / 255.0, this.Input.BackGroundColor.G / 255.0, this.Input.BackGroundColor.B / 255.0);

            this.Input.AssociatedVTKRenderer.SetActiveCamera(this.Input.Vtk_CameraView);

            // Setup offscreen rendering
            //vtkGraphicsFactory graphics_factory = vtkGraphicsFactory.New();
            //  graphics_factory.SetOffScreenOnlyMode( 1);
            //  graphics_factory.SetUseMesaClasses( 1 );

            //  vtkImagingFactory imaging_factory = vtkImagingFactory.New();
            //  imaging_factory.SetUseMesaClasses( 1 );

            // A renderer and render window
            // vtkRenderer renderer = vtkRenderer.New();
            //vtkRenderWindow renderWindow =
            //  vtkRenderWindow.New();
            //  RenderWindow.SetOffScreenRendering(1);
            //renderWindow.AddRenderer(renderer);

            RenderWindow.Render();

            //vtkWindowToImageFilter windowToImageFilter =
            //  vtkWindowToImageFilter.New();
            //windowToImageFilter.SetInput(RenderWindow);
            //windowToImageFilter.Update();

            //vtkPNGWriter writer =
            //  vtkPNGWriter.New();
            //writer.SetFileName("screenshot1.png");
            //writer.SetInputConnection(windowToImageFilter.GetOutputPort());
            //writer.Write();

            //Renderer.ResetCamera();

            // Input.Render();
        }
开发者ID:cyrenaique,项目名称:HCSA,代码行数:88,代码来源:cViewer3D.cs

示例3: Main

        static void Main(string[] args)
        {
            //
            // Next we create an instance of vtkConeSource and set some of its
            // properties. The instance of vtkConeSource "cone" is part of a visualization
            // pipeline (it is a source process object); it produces data (output type is
            // vtkPolyData) which other filters may process.
            //
            vtkConeSource cone = new vtkConeSource();
            cone.SetHeight( 3.0f );
            cone.SetRadius( 1.0f );
            cone.SetResolution( 10 );

            //
            // In this example we terminate the pipeline with a mapper process object.
            // (Intermediate filters such as vtkShrinkPolyData could be inserted in
            // between the source and the mapper.)  We create an instance of
            // vtkPolyDataMapper to map the polygonal data into graphics primitives. We
            // connect the output of the cone souece to the input of this mapper.
            //
            vtkPolyDataMapper coneMapper = new vtkPolyDataMapper();
            coneMapper.SetInput( cone.GetOutput() );

            //
            // Create an actor to represent the cone. The actor orchestrates rendering of
            // the mapper's graphics primitives. An actor also refers to properties via a
            // vtkProperty instance, and includes an internal transformation matrix. We
            // set this actor's mapper to be coneMapper which we created above.
            //
            vtkActor coneActor = new vtkActor();
            coneActor.SetMapper( coneMapper );

            //
            // Create the Renderer and assign actors to it. A renderer is like a
            // viewport. It is part or all of a window on the screen and it is
            // responsible for drawing the actors it has.  We also set the background
            // color here
            //
            vtkRenderer ren1 = new vtkRenderer();
            ren1.AddActor( coneActor );
            ren1.SetBackground( 0.1f, 0.2f, 0.4f );

            //
            // Finally we create the render window which will show up on the screen
            // We put our renderer into the render window using AddRenderer. We also
            // set the size to be 300 pixels by 300
            //
            vtkRenderWindow renWin = new vtkRenderWindow();
            renWin.AddRenderer( ren1 );
            renWin.SetSize( 300, 300 );

            vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();
            iren.SetRenderWindow(renWin);

            vtkInteractorStyleTrackballCamera style =
                new vtkInteractorStyleTrackballCamera();
            iren.SetInteractorStyle(style);

            vtkBoxWidget boxWidget = new vtkBoxWidget();
            boxWidget.SetInteractor(iren);
            boxWidget.SetPlaceFactor(1.25f);

            boxWidget.SetProp3D(coneActor);
            boxWidget.PlaceWidget();

            boxWidget.AddObserver((uint) EventIds.InteractionEvent,
                new vtkDotNetCallback(myCallback));

            boxWidget.On();

            iren.Initialize();
            iren.Start();

            vtkWin32OpenGLRenderWindow win32win =
                vtkWin32OpenGLRenderWindow.SafeDownCast(renWin);
            if ( null != win32win ) win32win.Clean();
        }
开发者ID:unidevop,项目名称:sjtu-project-pipe,代码行数:77,代码来源:Cone6.cs

示例4: Visualization3D

        //wizualizacja 3d -----------------------------------------------------------------
        public Visualization3D(RenderWindowControl window, DicomLoader dicomLoader, Chart chart)
        {
            _chart = chart;
            _window = window;
            _dicomLoader = dicomLoader;
            PresetReader = new XmlPresetReader();

            // Create a mapper and actor
            _mapper = vtkSmartVolumeMapper.New();
            _mapper.SetInput(_dicomLoader.GetOutput());
            _volume = vtkVolume.New();
            SetOpacityFunction();
            SetGradientOpacity();
            _volume.SetMapper(_mapper);

            renderer = vtkRenderer.New();
            renderer.AddVolume(_volume);
            _window.RenderWindow.GetRenderers().RemoveAllItems();
            _window.RenderWindow.AddRenderer(renderer);
            _window.RenderWindow.GetRenderers().GetFirstRenderer().AddVolume(_volume);

            // An interactor
            _renderWindowInteractor = vtkRenderWindowInteractor.New();
            _renderWindowInteractor.SetRenderWindow(_window.RenderWindow);

            //Camera style
            vtkInteractorStyleTrackballCamera style = vtkInteractorStyleTrackballCamera.New();
            style.AutoAdjustCameraClippingRangeOff();
            _renderWindowInteractor.SetInteractorStyle(style);

            //Create and setup planes
            PlaneWidgetX = new PlaneWidget(Axis.X);
            SetupPlane(PlaneWidgetX);
            PlaneWidgetY = new PlaneWidget(Axis.Y);
            SetupPlane(PlaneWidgetY);
            PlaneWidgetZ = new PlaneWidget(Axis.Z);
            SetupPlane(PlaneWidgetZ);

            // Render
            _window.RenderWindow.Render();

            //ClipingModule
            _clipingModule = new ClipingModule(GetObjectSize());
        }
开发者ID:SabariSankar,项目名称:ksiazek-legien-inz,代码行数:45,代码来源:Visualization3D.cs


注:本文中的vtkRenderWindowInteractor.SetInteractorStyle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。