Exemple #1
0
        private vtkTextWidget CreateClipButton(string Text, double[] Position, int FontSize)
        {
            // Create Text Actor and Representation
            vtkTextActor TextActor = vtkTextActor.New();

            TextActor.SetInput(Text);
            TextActor.GetTextProperty().SetBold(0);
            TextActor.GetTextProperty().SetFontFamilyToArial();
            vtkTextRepresentation Rep = vtkTextRepresentation.New();

            Rep.SetPosition(Position[0], Position[1]);
            Rep.SetTextActor(TextActor);
            Rep.SetShowBorderToOff();

            // Set widget
            vtkTextWidget Widget = vtkTextWidget.New();

            Widget.SetRepresentation(Rep);
            Widget.GetTextActor().GetTextProperty().SetFontSize(FontSize);
            Widget.GetTextActor().SetTextScaleModeToViewport();
            Widget.SetInteractor(renderWindow.GetInteractor());
            Widget.SelectableOn();
            Widget.SetEnabled(0);
            Widget.ResizableOff();

            return(Widget);
        }
Exemple #2
0
        private void SetClipPlaneNormal(vtkObject sender, vtkObjectEventArgs e)
        {
            vtkTextWidget widget = sender as vtkTextWidget;
            string        text   = widget.GetTextActor().GetInput();

            if (text == "Clip X")
            {
                SetClipPlane("X");
            }
            if (text == "Clip Y")
            {
                SetClipPlane("Y");
            }
            if (text == "Clip Z")
            {
                SetClipPlane("Z");
            }

            Refresh();
        }
Exemple #3
0
        private void CreateClipPlane()
        {
            // Clip Plane
            ClipPlane = vtkPlane.New();

            vtkPoints ClipPoints = vtkPoints.New();

            ClipPlaneSize = 1;

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    double y = j * ClipPlaneSize / 9 - ClipPlaneSize / 2;
                    double z = i * ClipPlaneSize / 9 - ClipPlaneSize / 2;
                    ClipPoints.InsertNextPoint(0, y, z);
                }
            }
            vtkUnstructuredGrid ClipGrid = vtkUnstructuredGrid.New();

            ClipGrid.SetPoints(ClipPoints);
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    vtkQuad quad = vtkQuad.New();
                    quad.GetPointIds().SetId(0, i * 10 + j);
                    quad.GetPointIds().SetId(1, i * 10 + j + 1);
                    quad.GetPointIds().SetId(2, (i + 1) * 10 + j + 1);
                    quad.GetPointIds().SetId(3, (i + 1) * 10 + j);
                    ClipGrid.InsertNextCell(quad.GetCellType(), quad.GetPointIds());
                }
            }

            vtkDataSetMapper ClipMapper = vtkDataSetMapper.New();

            ClipMapper.SetInput(ClipGrid);

            ClipPlaneActor = vtkActor.New();
            ClipPlaneActor.SetMapper(ClipMapper);
            ClipPlaneActor.GetProperty().EdgeVisibilityOn();
            ClipPlaneActor.GetProperty().SetColor(195.0 / 255.0, 195.0 / 255.0, 195.0 / 255.0);
            ClipPlaneActor.GetProperty().SetOpacity(0.1);
            ClipPlaneActor.VisibilityOff();
            Viewport.AddActor(ClipPlaneActor);

            //  ------------- Clip Plane Buttons --------------------------------------------
            Grid = CreateClipButton("Grid OFF", new double[2] {
                0.875, 0.39
            }, 8);
            Grid.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(ShowGrid);

            Reverse = CreateClipButton("Reverse", new double[2] {
                0.875, 0.34
            }, 8);
            Reverse.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(ReverseClipPlaneNormal);

            ClipX = CreateClipButton("Clip X", new double[2] {
                0.88, 0.29
            }, 8);
            ClipX.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(SetClipPlaneNormal);

            ClipY = CreateClipButton("Clip Y", new double[2] {
                0.88, 0.24
            }, 8);
            ClipY.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(SetClipPlaneNormal);

            ClipZ = CreateClipButton("Clip Z", new double[2] {
                0.88, 0.19
            }, 8);
            ClipZ.StartInteractionEvt += new vtkObject.vtkObjectEventHandler(SetClipPlaneNormal);
        }