Simple VTK Cone - Scala Way
Show a VTK cone using Scala's Swing.
import java.awt.BorderLayout
import javax.swing.JPanel
import swing._
import vtk._
/**
* Create a cone and display it in an application window using Scala's Swing
*/
object ScalaCone extends SimpleSwingApplication {
// Setup VTK rendering panel, this also loads VTK native libraries
var renWin: vtkPanel = new vtkPanel
// Create wrapper to integrate vtkPanel with Scala's Swing API
val scalaPanel = new Component {
override lazy val peer = new JPanel(new BorderLayout())
peer.add(renWin)
}
// Setup cone rendering pipeline
var cone = new vtkConeSource
cone.SetResolution(8)
var coneMapper = new vtkPolyDataMapper
coneMapper.SetInputConnection(cone.GetOutputPort)
var coneActor = new vtkActor
coneActor.SetMapper(coneMapper)
renWin.GetRenderer.AddActor(coneActor)
renWin.GetRenderer.ResetCamera
// Create the main application window
def top = new MainFrame {
title = "ScaleCone"
contents = scalaPanel
}
}