vtk画折线,并且禁止鼠标交互
VTK画图,禁止鼠标拖动时滚动图形,鼠标滚轮滚动时放大/缩小图形的方法。
renderLine.InteractiveOff();
下面是VTK画折线的代码
// Create five points double[,] p = new double[,] { { 0.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, { 0.0, 1.0, 2.0 }, { 0.0, 3.0, 3.0 } }; // Create the points vtkPoints points = vtkPoints.New(); for (int i = 0; i < 5; i++) points.InsertNextPoint(p[i, 0], p[i, 1], p[i, 2]); vtkPolyLine polyLine = vtkPolyLine.New(); polyLine.GetPointIds().SetNumberOfIds(5); for (int i = 0; i < 5; i++) polyLine.GetPointIds().SetId(i, i); // Create a cell array to store the lines in and add the lines to it vtkCellArray cells = vtkCellArray.New(); cells.InsertNextCell(polyLine); vtkPolyData polyData = vtkPolyData.New(); polyData.SetPoints(points); polyData.SetLines(cells); vtkPolyDataMapper mapper = vtkPolyDataMapper.New(); mapper.SetInput(polyData); vtkActor actor = vtkActor.New(); actor.SetMapper(mapper); //vtkRenderWindow renderWindow = renderWindowControl1.RenderWindow; //vtkRenderer renderer = renderWindow.GetRenderers().GetFirstRenderer(); //vtkRenderer renderLine = vtkRenderer.New(); //renderLine.SetBackground(0.2, 0.3, 0.4); renderLine.AddActor(actor); renderLine.ResetCamera(); vtkCamera camera = renderLine.GetActiveCamera(); camera.Zoom(1.5); //渲染窗口添加网格渲染器 renderWindow.AddRenderer(renderLine); //渲染窗口开启双缓冲 renderWindow.SetDoubleBuffer(1); renderWindow.Render();