Exemplo n.º 1
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;
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///A process translated from the tcl scripts
 /// </summary>
 public static void MotionCallback(double x, double y)
 {
     //Global Variable Declaration Skipped
     // Compute display point from Tk display point.[]
     WindowY = 400;
     y       = WindowY - y;
     z       = ren1.GetZ((int)x, (int)y);
     ren1.SetDisplayPoint((double)x, (double)y, (double)z);
     ren1.DisplayToWorld();
     pt = ren1.GetWorldPoint();
     //tk_messageBox -message "$pt"[]
     x   = (double)(lindex(pt, 0));
     y   = (double)(lindex(pt, 1));
     z   = (double)(lindex(pt, 2));
     val = puzzle.SetPoint((double)x, (double)y, (double)z);
     if ((val) != LastVal)
     {
         renWin.Render();
         LastVal = val;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Moves the sphere when the mouse is clicked in
        /// position (x,y)
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        void ButtonCallback(double x, double y)
        {
            if (!in_piece_rotation)
            {
                in_piece_rotation = true;
                vtkRenderer ren1 = renderWindowControl1.RenderWindow.GetRenderers().GetFirstRenderer();
                ren1.SetDisplayPoint(x, y, ren1.GetZ((int)x, (int)y));
                ren1.DisplayToWorld();
                double[] pt = ren1.GetWorldPoint();

                x = pt[0];
                y = pt[1];
                double z = pt[2];

                for (int i = 0; i <= 100; i += 10)
                {
                    puzzle.SetPoint(x, y, z);
                    puzzle.MovePoint(i);
                    renderWindowControl1.RenderWindow.Render();
                    this.Update();
                }
                in_piece_rotation = false;
            }
        }