[vtkusers] Change default mouse buttons

Max smapersmaper at gmail.com
Thu May 23 04:41:46 EDT 2013


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Kitware.VTK;

namespace SmallEventsExample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void renderWindowControl1_Load(object sender, EventArgs e)
        {
            vtkCylinderSource cylinder = new vtkCylinderSource();
            cylinder.SetResolution(66);
            cylinder.SetRadius(2);
            cylinder.SetHeight(30);
            cylinder.Update();

            vtkPolyDataMapper mapper2 = vtkPolyDataMapper.New();
            mapper2.SetInputConnection(cylinder.GetOutputPort());

            vtkActor actor2 = vtkActor.New();
            actor2.SetMapper(mapper2);

            vtkRenderWindow renderWindow =
renderWindowControl1.RenderWindow;

            vtkRenderer renderer =
renderWindow.GetRenderers().GetFirstRenderer();

            vtkRenderWindowInteractor inter = renderWindow.GetInteractor();

            //renderWindow.SetInteractor(inter);

            interactorStyle =
vtkInteractorStyle.New();//inter.GetInteractorStyle();
            inter.SetInteractorStyle(interactorStyle);
            interactorStyle.RightButtonPressEvt += new
vtkObject.vtkObjectEventHandler(rightButtonPressVtkEvt);
            interactorStyle.RightButtonReleaseEvt += new
vtkObject.vtkObjectEventHandler(rightButtonReleaseVtkEvt);

            interactorStyle.SetInteractor(inter);

            renderer.AddActor(actor2);
            renderer.ResetCamera();
            renderWindow.Render();
        }

        vtkInteractorStyle interactorStyle;

        void rightButtonPressVtkEvt(vtkObject sender, vtkObjectEventArgs e)
        {
            interactorStyle.StartRotate();

           

        }

        void rightButtonReleaseVtkEvt(vtkObject sender, vtkObjectEventArgs
e)
        {
            interactorStyle.EndRotate();
        }

    }
}




--
View this message in context: http://vtk.1045678.n5.nabble.com/Change-default-mouse-buttons-tp5720853p5720903.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list