/// <summary> /// Set up the dialog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void renderWindowControl1_Load(object sender, EventArgs e) { //Setup the variables and the background vtkRenderer ren1 = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer(); mapper.SetInputConnection(puzzle.GetOutputPort()); mapper2.SetInputConnection(arrows.GetOutputPort()); actor.SetMapper(mapper); actor2.SetMapper(mapper2); ren1.AddActor(actor); ren1.AddActor(actor2); ren1.SetBackground(0.1, 0.2, 0.4); //Set up the camera ren1.ResetCamera(); vtkCamera cam = ren1.GetActiveCamera(); cam.Elevation(-40); renderWindowControl1.RenderWindow.Render(); //Change the style to a trackball style //Equivalent of pressing 't' vtkRenderWindowInteractor iren = renderWindowControl1.RenderWindow.GetInteractor(); vtkInteractorStyleSwitch istyle = vtkInteractorStyleSwitch.New(); iren.SetInteractorStyle(istyle); (istyle).SetCurrentStyleToTrackballCamera(); //Add events to the iren instead of Observers iren.MouseMoveEvt += new vtkObject.vtkObjectEventHandler(MotionCallback); iren.CharEvt += new vtkObject.vtkObjectEventHandler(CharCallback); }
/// <summary> /// Crée les objets de base : renderer, axes, interactor. /// </summary> private void initBaseObjects() { // Nous créons un renderer qui va faire le rendu de notre entitée. _renderer = vtkRenderer.New(); _stlLoader = new STLLoader(this._renderer); _stlLoader.VolumeColor = Properties.Settings.Default.VolumeColor; _stlLoader.EdgeColor = Properties.Settings.Default.EdgeColor; _stlLoader.ShowVolume = Properties.Settings.Default.ShowVolume; _stlLoader.ShowEdges = Properties.Settings.Default.ShowEdges; this.aretesToolStripMenuItem.Checked = (bool)loadSetting("ShowEdges"); this.volumeToolStripMenuItem.Checked = (bool)loadSetting("ShowVolume"); _renderer.SetBackground(1, 1, 1); // background color white vtkRenderCtl.RenderWindow.AddRenderer(_renderer); // Nous créons un interactor qui permet de bouger la caméra. _interactor = vtkRenderWindowInteractor.New(); _interactor.SetRenderWindow(vtkRenderCtl.RenderWindow); //axes vtkAxes axes = vtkAxes.New(); axes.SetScaleFactor(10); addActor(axes.GetOutput()); /* * //outil de mesure * vtkDistanceWidget wdgDistance = vtkDistanceWidget.New(); * wdgDistance.SetInteractor(_interactor); * wdgDistance.CreateDefaultRepresentation(); * ((vtkDistanceRepresentation)wdgDistance.GetRepresentation()).SetLabelFormat("%-#6.3g mm"); * wdgDistance.On(); */ Camera.SetPosition(0, 0, -300); vtkRenderCtl.RenderWindow.Render(); _interactor.RenderEvt += _interactor_RenderEvt; vtkInteractorStyleSwitch style = vtkInteractorStyleSwitch.New(); style.SetCurrentStyleToTrackballCamera(); _interactor.SetInteractorStyle(style); _interactor.Start(); }
public vtkRenderWindowInteractor coordinate_interactor() { //Declare new interactor style vtkInteractorStyle interactorSyle = vtkInteractorStyle.New(); //Set new mouse events interactorSyle.LeftButtonPressEvt += null; interactorSyle.LeftButtonReleaseEvt += new vtkObject.vtkObjectEventHandler(get_coordinates); //Create new interactor vtkRenderWindowInteractor interactor = vtkRenderWindowInteractor.New(); interactor.SetInteractorStyle(interactorSyle); return(interactor); }
//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()); }
public static void ShowPolydata(string airwayPath) { if (!File.Exists(airwayPath)) { MessageBox.Show("文件不存在!"); return; } vtkRenderWindow renWin = vtkRenderWindow.New(); renWin.SetSize(600, 600); vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor(); renWin.SetInteractor(iren); vtkInteractorStyleTrackballCamera interactorStyle = new vtkInteractorStyleTrackballCamera(); iren.SetInteractorStyle(interactorStyle); vtkRenderer renderer = vtkRenderer.New(); renderer.GradientBackgroundOn(); renderer.SetBackground(0, 0, 0); renderer.SetBackground2(0, 0, 1); renWin.AddRenderer(renderer); vtkXMLPolyDataReader reader = new vtkXMLPolyDataReader(); reader.SetFileName(airwayPath); reader.Update(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.ScalarVisibilityOff(); mapper.SetInput(reader.GetOutput()); reader.Dispose(); vtkActor actor = new vtkActor(); actor.SetMapper(mapper); renderer.AddActor(actor); renWin.Render(); }
//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(); }
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(); }
/// <summary> /// Display the render window with the slice in it /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void renderWindowControl1_Load(object sender, EventArgs e) { //Get the name of the Unsigned Char volume that you want to load fileName = "../../../head.vti"; //Create all the objects for the pipeline vtkXMLImageDataReader reader = vtkXMLImageDataReader.New(); vtkImageActor iactor = vtkImageActor.New(); vtkImageClip clip = vtkImageClip.New(); vtkContourFilter contour = vtkContourFilter.New(); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); vtkActor actor = vtkActor.New(); vtkInteractorStyleImage style = vtkInteractorStyleImage.New(); vtkRenderer renderer = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer(); //Read the Image reader.SetFileName(fileName); //Go through the visulization pipeline iactor.SetInputData(reader.GetOutput()); renderer.AddActor(iactor); reader.Update(); int[] extent = reader.GetOutput().GetExtent(); iactor.SetDisplayExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); clip.SetInputConnection(reader.GetOutputPort()); clip.SetOutputWholeExtent(extent[0], extent[1], extent[2], extent[3], (extent[4] + extent[5]) / 2, (extent[4] + extent[5]) / 2); contour.SetInputConnection(clip.GetOutputPort()); contour.SetValue(0, 100); mapper.SetInputConnection(contour.GetOutputPort()); mapper.SetScalarVisibility(1); //Go through the graphics pipeline actor.SetMapper(mapper); actor.GetProperty().SetColor(0, 1, 0); renderer.AddActor(actor); //Give a new style to the interactor vtkRenderWindowInteractor iren = renderWindowControl1.RenderWindow.GetInteractor(); iren.SetInteractorStyle(style); //Add new events to the interactor style style.LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(iren_LeftButtonPressEvt); style.LeftButtonReleaseEvt += new vtkObject.vtkObjectEventHandler(iren_LeftButtonReleaseEvt); style.MouseMoveEvt += new vtkObject.vtkObjectEventHandler(iren_MouseMoveEvt); //Update global variables this.trackBar1.Maximum = extent[5]; this.trackBar1.Minimum = extent[4]; this.Interactor = iren; this.RenderWindow = renderWindowControl1.RenderWindow; this.Renderer = renderer; this.Clip = clip; this.ImageActor = iactor; }
//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(); }
public static void ShowPolydata(string airwayPath, string lesionPath) { vtkAppendPolyData appendPolydata = new vtkAppendPolyData(); if (File.Exists(airwayPath)) { vtkXMLPolyDataReader reader = new vtkXMLPolyDataReader(); reader.SetFileName(airwayPath); reader.Update(); appendPolydata.AddInput(reader.GetOutput()); reader.Dispose(); } else { MessageBox.Show("airwayPath : " + airwayPath + "文件不存在!"); } if (File.Exists(lesionPath)) { vtkXMLPolyDataReader reader = new vtkXMLPolyDataReader(); reader.SetFileName(lesionPath); reader.Update(); appendPolydata.AddInput(reader.GetOutput()); reader.Dispose(); } else { MessageBox.Show("lesionPath : " + lesionPath + "文件不存在!"); } vtkRenderWindow renWin = vtkRenderWindow.New(); renWin.SetSize(600, 600); vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor(); renWin.SetInteractor(iren); vtkInteractorStyleTrackballCamera interactorStyle = new vtkInteractorStyleTrackballCamera(); iren.SetInteractorStyle(interactorStyle); vtkRenderer renderer = vtkRenderer.New(); renderer.GradientBackgroundOn(); renderer.SetBackground(0, 0, 0); renderer.SetBackground2(0, 0, 1); renWin.AddRenderer(renderer); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.ScalarVisibilityOff(); mapper.SetInput(appendPolydata.GetOutput()); vtkActor actor = new vtkActor(); actor.SetMapper(mapper); renderer.AddActor(actor); renderer.Render(); renderer.ResetCamera(); renWin.Render(); //Thread thread = new Thread(new ThreadStart( // delegate // { // iren.Start(); // })); //thread.Start(); }
public void CreateViewport(Grid Window) { WindowsFormsHost VTK_Window = new WindowsFormsHost(); // Create Windows Forms Host for VTK Window RenWinControl = new RenderWindowControl(); // Initialize VTK Renderer Window Control // Clear input Window and add new host Window.Children.Clear(); Window.Children.Add(VTK_Window); VTK_Window.Child = RenWinControl; // Create Render Window renderWindow = RenWinControl.RenderWindow; // Initialize Interactor Inter = vtkRenderWindowInteractor.New(); Inter.LeftButtonPressEvt += new vtkObject.vtkObjectEventHandler(SelectPointClick); Inter.RightButtonPressEvt += new vtkObject.vtkObjectEventHandler(UnselectPointClick); renderWindow.SetInteractor(Inter); Inter.Initialize(); InterStyleTrack = vtkInteractorStyleTrackballCamera.New(); //Inter.SetInteractorStyle(InterStyleTrack); InterStylePick = vtkInteractorStyleRubberBandPick.New(); Inter.SetInteractorStyle(InterStylePick); // Initialize View Viewport = renderWindow.GetRenderers().GetFirstRenderer(); Viewport.RemoveAllViewProps(); CreateViewportBorder(Viewport, new double[3] { 128.0, 128.0, 128.0 }); // Set default background color Viewport.GradientBackgroundOn(); Viewport.SetBackground(163.0 / 255.0, 163.0 / 255.0, 163.0 / 255.0); Viewport.SetBackground2(45.0 / 255.0, 85.0 / 255.0, 125.0 / 255.0); // Other properties Viewport.GetActiveCamera().ParallelProjectionOn(); // Initialize Selection objects AppendFaces = vtkAppendPolyData.New(); Faces = vtkPolyData.New(); SelectionMode = false; SelectionSize = 0.1; SelectionPoints = vtkPoints.New(); SelectionActor = vtkActor.New(); SelectionPolyData = vtkPolyData.New(); SelectionPolyData.SetPoints(SelectionPoints); SelectionSphere = vtkSphereSource.New(); SelectionSphere.SetPhiResolution(12); SelectionSphere.SetThetaResolution(12); SelectionSphere.SetRadius(SelectionSize); SelectionGlyph = vtkGlyph3D.New(); SelectionGlyph.SetInput(SelectionPolyData); SelectionGlyph.SetSourceConnection(SelectionSphere.GetOutputPort()); SelectionMapper = vtkPolyDataMapper.New(); SelectionMapper.SetInputConnection(SelectionGlyph.GetOutputPort()); SelectionActor.SetMapper(SelectionMapper); SelectionActor.GetProperty().SetColor(1, 1, 1); SelectionActor.VisibilityOn(); Viewport.AddActor(SelectionActor); // Create new Properties and Objects CreateColorMap(); CreateScalarBar(); CreateAxes(); CreateSlider(); CreateClipPlane(); }
private void renderWindowControl1_Load(object sender, EventArgs e) { vtkRenderWindow renWin = renderWindowControl1.RenderWindow; _render = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer(); //_render.SetBackground(1, 1, 1); _render.SetBackground(1.0, 1.0, 1.0); // 设置页面底部颜色值 _render.SetBackground2(0.529, 0.8078, 0.92157); // 设置页面顶部颜色值 _render.SetGradientBackground(true); // 开启渐变色背景设置 double axesScale = 1; // 初始化vtk窗口 vtkAxesActor axes = vtkAxesActor.New(); axes.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetColor(1, 0, 0); //修改X字体颜色为红色 axes.GetYAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0, 2, 0); //修改Y字体颜色为绿色 axes.GetZAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0, 0, 3); //修改Z字体颜色为蓝色 axes.SetConeRadius(0.3); axes.SetConeResolution(20); //axes->SetTotalLength(10, 10, 10); //修改坐标尺寸 vtkAxesActor axes1 = vtkAxesActor.New(); axes1.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetColor(1, 0, 0); //修改X字体颜色为红色 axes1.GetYAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0, 2, 0); //修改Y字体颜色为绿色 axes1.GetZAxisCaptionActor2D().GetCaptionTextProperty().SetColor(0, 0, 3); //修改Z字体颜色为蓝色 axes1.SetConeRadius(0.03); axes1.AxisLabelsOff(); axes1.GetXAxisCaptionActor2D().GetCaptionTextProperty().SetFontSize(1); //axes1.SetConeRadius(0.3); axes1.SetConeResolution(20); _render.AddActor(axes1); vtkRenderWindowInteractor interactor = vtkRenderWindowInteractor.New(); interactor.SetRenderWindow(renWin); vtkInteractorStyleTrackballCamera style = vtkInteractorStyleTrackballCamera.New(); interactor.SetInteractorStyle(style); renWin.SetInteractor(interactor); interactor.Initialize(); vtkCamera aCamera = vtkCamera.New(); aCamera.SetViewUp(0, 0, 1); //设视角位置 aCamera.SetPosition(0, -3 * axesScale, 0); //设观察对象位 aCamera.SetFocalPoint(0, 0, 0); //设焦点 aCamera.ComputeViewPlaneNormal(); //自动 _render.SetActiveCamera(aCamera); _render.ResetCamera(); renWin.Render(); widget1 = vtkOrientationMarkerWidget.New(); widget1.SetOutlineColor(0.9300, 0.5700, 0.1300); widget1.SetOrientationMarker(axes); widget1.SetInteractor(interactor); widget1.SetViewport(0.0, 0.0, 0.25, 0.25); widget1.SetEnabled(1); widget1.InteractiveOff(); //_render.AddViewProp(FrustumCone.genActor(new CompontData())); }