/// <summary>
        /// Executes the initialize action.
        /// </summary>
        ///
        /// <param name="hWnd">The HWND we present to when rendering.</param>
        ///
        /// <seealso cref="M:ActivizWPF.Framework.Native.HwndWrapper.OnInitialize(IntPtr)"/>
        protected override void OnInitialize(IntPtr hWnd)
        {
            try
            {
                vtkLogoWidget vtkLogoWidget = new vtkLogoWidget();

                _renderer     = vtkRenderer.New();
                _renderWindow = vtkRenderWindow.New();

                _renderWindowInteractor = vtkRenderWindowInteractor.New();

                vtkInteractorStyleSwitch interactorStyleSwitch = _renderWindowInteractor.GetInteractorStyle() as vtkInteractorStyleSwitch;

                if (null != interactorStyleSwitch)
                {
                    interactorStyleSwitch.SetCurrentStyleToTrackballCamera();
                }

                _renderWindow.SetParentId(hWnd);
                _renderWindow.AddRenderer(_renderer);

                AttachInteractor();

                vtkLogoWidget.Dispose();
            }
            catch (Exception ex)
            {
                log.ErrorException("OnInitialize()", ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Highlights pieces
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void MotionCallback(vtkObject sender, vtkObjectEventArgs e)
        {
            //Make sure the piece isn't in an animation
            //durring a click or bad things happen
            if (!in_piece_rotation)
            {
                vtkRenderWindowInteractor iren   = renderWindowControl1.RenderWindow.GetInteractor();
                vtkInteractorStyleSwitch  istyle = (vtkInteractorStyleSwitch)iren.GetInteractorStyle();

                //return if the user is performing interaction
                if (istyle.GetState() != 0)
                {
                    return;
                }

                int[] pos = iren.GetEventPosition();
                int   x   = pos[0];
                int   y   = pos[1];

                vtkRenderer ren1 = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
                ren1.SetDisplayPoint(x, y, ren1.GetZ(x, y));
                ren1.DisplayToWorld();
                double [] pt  = ren1.GetWorldPoint();
                double    val = puzzle.SetPoint(pt[0], pt[1], pt[2]);
                if (!LastValExists || val != LastVal)
                {
                    renderWindowControl1.RenderWindow.Render();
                    LastVal       = val;
                    LastValExists = true;
                }
            }
        }