Method: GtkVTKRenderWindow#Pan

Defined in:
lib/VTK/gtk/GtkVTKRenderWindow.rb

#Pan(x, y) ⇒ Object



410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
# File 'lib/VTK/gtk/GtkVTKRenderWindow.rb', line 410

def Pan(x,y)
  if @CurrentRenderer

    renderer = @CurrentRenderer
    camera = @CurrentCamera
    (pPoint0,pPoint1,pPoint2) = camera.GetPosition
    (fPoint0,fPoint1,fPoint2) = camera.GetFocalPoint

    if (camera.GetParallelProjection)
      renderer.SetWorldPoint(fPoint0,fPoint1,fPoint2,1.0)
      renderer.WorldToDisplay
      fx,fy,fz = renderer.GetDisplayPoint
      renderer.SetDisplayPoint(fx-x+@LastX,
                               fy+y-@LastY,
                               fz)
      renderer.DisplayToWorld
      fx,fy,fz,fw = renderer.GetWorldPoint
      camera.SetFocalPoint(fx,fy,fz)

      renderer.SetWorldPoint(pPoint0,pPoint1,pPoint2,1.0)
      renderer.WorldToDisplay
      fx,fy,fz = renderer.GetDisplayPoint
      renderer.SetDisplayPoint(fx-x+@LastX,
                               fy+y-@LastY,
                               fz)
      renderer.DisplayToWorld
      fx,fy,fz,fw = renderer.GetWorldPoint
      camera.SetPosition(fx,fy,fz)

    else
      (fPoint0,fPoint1,fPoint2) = camera.GetFocalPoint
      # Specify a point location in world coordinates
      renderer.SetWorldPoint(fPoint0,fPoint1,fPoint2,1.0)
      renderer.WorldToDisplay
      # Convert world point coordinates to display coordinates
      dPoint = renderer.GetDisplayPoint
      focalDepth = dPoint[2]

      aPoint0 = @ViewportCenterX + (x - @LastX)
      aPoint1 = @ViewportCenterY - (y - @LastY)

      renderer.SetDisplayPoint(aPoint0,aPoint1,focalDepth)
      renderer.DisplayToWorld

      (rPoint0,rPoint1,rPoint2,rPoint3) = renderer.GetWorldPoint
      if (rPoint3 != 0.0)
        rPoint0 = rPoint0/rPoint3
        rPoint1 = rPoint1/rPoint3
        rPoint2 = rPoint2/rPoint3
      end

      camera.SetFocalPoint((fPoint0 - rPoint0) + fPoint0, 
                           (fPoint1 - rPoint1) + fPoint1,
                           (fPoint2 - rPoint2) + fPoint2) 

      camera.SetPosition((fPoint0 - rPoint0) + pPoint0, 
                         (fPoint1 - rPoint1) + pPoint1,
                         (fPoint2 - rPoint2) + pPoint2)
    end

    @LastX = x
    @LastY = y

    self.Render
  end
end