1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
namespace Kitware.VTK
{
/// <summary>
/// UserControl derived implementation of vtkRenderWindow for use
/// in Windows Forms applications.
/// The client area of this UserControl is completely filled with
/// an instance of a vtkRenderWindow.
/// </summary>
[System.Runtime.InteropServices.ComVisible(true), System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)]
public partial class RenderWindowControl : UserControl
{
private Kitware.VTK.vtkRenderer m_Renderer;
private Kitware.VTK.vtkRenderWindow m_RenderWindow;
private Kitware.VTK.vtkRenderWindowInteractor m_RenderWindowInteractor;
/// <summary>
/// UserControl derived implementation of vtkRenderWindow for use
/// in Windows Forms applications.
/// The client area of this UserControl is completely filled with
/// an instance of a vtkRenderWindow.
/// </summary>
public RenderWindowControl()
{
InitializeComponent();
}
/// <summary>
/// TestAddActorsToRenderWindow.
/// </summary>
private void TestAddActorsToRenderWindow(Kitware.VTK.vtkRenderWindow renWin)
{
Kitware.VTK.vtkConeSource source = new Kitware.VTK.vtkConeSource();
Kitware.VTK.vtkMapper mapper = Kitware.VTK.vtkPolyDataMapper.New();
mapper.SetInputConnection(source.GetOutputPort());
Kitware.VTK.vtkActor actor = new Kitware.VTK.vtkActor();
actor.SetMapper(mapper);
Kitware.VTK.vtkRenderer ren = null;
ren = renWin.GetRenderers().GetFirstRenderer();
ren.AddActor(actor);
Kitware.VTK.vtkTextActor textActor = new Kitware.VTK.vtkTextActor();
textActor.SetInput(Kitware.VTK.vtkVersion.GetVTKSourceVersion());
ren.AddActor(textActor);
//int n = renWin.GetRenderers().GetNumberOfItems();
//System.Diagnostics.Debug.WriteLine(n);
//System.Diagnostics.Debug.WriteLine(
// Kitware.mummy.Runtime.Methods.Print(false)
// );
}
#region Public Properties
/// <summary>
/// This property gives you access to the vtkRenderWindow that
/// fills the client area.
/// </summary>
public Kitware.VTK.vtkRenderWindow RenderWindow
{
get
{
return this.m_RenderWindow;
}
}
private string m_TestText;
/// <summary>
/// Text property for test purposes.
/// </summary>
public string TestText
{
get
{
return m_TestText;
}
set
{
m_TestText = value;
}
}
private bool m_AddTestActors = false;
private bool m_AddedTestActors = false;
/// <summary>
/// Bool property for test purposes. If true, VTK actors will be added to
/// the render window in OnHandleCreated.
/// </summary>
public bool AddTestActors
{
get
{
return m_AddTestActors;
}
set
{
m_AddTestActors = value;
}
}
#endregion
}
}
|