Exemple #1
0
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkXMLTreeReader(), 'Reading vtkXMLTree.',
         (), ('vtkXMLTree',),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
Exemple #2
0
 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(self,
                                       module_manager,
                                       vtk.vtkXMLTreeReader(),
                                       'Reading vtkXMLTree.', (),
                                       ('vtkXMLTree', ),
                                       replaceDoc=True,
                                       inputFunctions=None,
                                       outputFunctions=None)
	def __init__(self, input_file):
		reader1 = vtk.vtkXMLTreeReader()
		reader1.SetFileName("treetest.xml")
		
		self.view = vtk.vtkIcicleView()
		self.view.SetRepresentationFromInput(reader1.GetOutput())
		self.view.SetAreaSizeArrayName("size")
		self.view.SetAreaColorArrayName("level")
		self.view.SetAreaLabelArrayName("name")
		self.view.SetAreaLabelVisibility(True)
		self.view.SetAreaHoverArrayName("name")
		self.view.SetShrinkPercentage(0.05)
		self.view.SetLayerThickness(3.0)
		self.view.UseGradientColoringOff()
		self.view.Update()
		
		rep = self.view.GetRepresentation(0)
		
		# If you don't set the FieldType explicitly it ends up as UNKNOWN (as of 21 Feb 2010)
		# See vtkSelectionNode doc for field and content type enum values
		# enum		SelectionContent { 
		#	SELECTIONS, GLOBALIDS, PEDIGREEIDS, VALUES, 
		#	INDICES, FRUSTUM, LOCATIONS, THRESHOLDS, 
		#	BLOCKS 
		# }
		# enum		SelectionField { 
		#	CELL, POINT, FIELD, VERTEX, 
		#	EDGE, ROW 
		# }
		self.link = rep.GetAnnotationLink()
		self.link.GetCurrentSelection().GetNode(0).SetFieldType(3)		# Vertex
		self.link.GetCurrentSelection().GetNode(0).SetContentType(2)		# Pedigree Ids
		
		# Set up callback to update 3d render window when selections are changed in 
		#	parallel coordinates view
		self.link.AddObserver("AnnotationChangedEvent", self.IcicleSelectionCallback)
		
		self.view.ResetCamera()
		self.view.Render()
Exemple #4
0
def main():
    tree_fn = "vtklibrary.xml"
    graph_fn = "vtkclasses.xml"

    reader1 = vtk.vtkXMLTreeReader()
    reader1.SetFileName(tree_fn)
    reader1.SetEdgePedigreeIdArrayName("tree edge")
    reader1.GenerateVertexPedigreeIdsOff()
    reader1.SetVertexPedigreeIdArrayName("id")

    reader2 = vtk.vtkXMLTreeReader()
    reader2.SetFileName(graph_fn)
    reader2.SetEdgePedigreeIdArrayName("graph edge")
    reader2.GenerateVertexPedigreeIdsOff()
    reader2.SetVertexPedigreeIdArrayName("id")

    reader1.Update()
    reader2.Update()

    # straight VTK
    # we need this for getting the view going
    rw = vtk.vtkRenderWindow()
    # and this
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(rw)

    iren.AddObserver('CharEvent', lambda o, e: observer_charevent(o, e, view))

    # connect existing rw+iren to the view
    view = vtk.vtkHierarchicalGraphView()
    view.SetupRenderWindow(rw)

    #view.DisplayHoverTextOff()
    view.GetRenderWindow().SetMultiSamples(0)
    view.SetHierarchyFromInputConnection(reader1.GetOutputPort())
    view.SetGraphFromInputConnection(reader2.GetOutputPort())
    view.SetVertexColorArrayName("VertexDegree")
    view.SetColorVertices(True)
    view.SetVertexLabelArrayName("id")
    view.SetVertexLabelVisibility(True)
    view.SetScalingArrayName("TreeRadius")
    view.SetBundlingStrength(cur_bs)

    view.Update()
    #view.SetGraphEdgeColorArrayName("graph edge")
    #view.SetColorGraphEdgesByArray(True)

    view.AddObserver('SelectionChangedEvent', observer_selchanged)

    lstrat = 'cosmic tree'
    if lstrat == 'cosmic tree':
        cls = vtk.vtkCosmicTreeLayoutStrategy()
        cls.SetNodeSizeArrayName("VertexDegree")
        cls.SetSizeLeafNodesOnly(True)
    elif lstrat == 'circ':
        cls = vtk.vtkCircularLayoutStrategy()
    elif lstrat == 'tree':
        cls = vtk.vtkTreeLayoutStrategy()
        cls.SetAngle(360)
        cls.SetRadial(True)
        cls.SetLogSpacingValue(0.8)
        cls.SetLeafSpacing(0.9)

    view.SetLayoutStrategy(cls)

    theme = vtk.vtkViewTheme.CreateMellowTheme()
    theme.SetLineWidth(1)
    view.ApplyViewTheme(theme)

    view.GetRenderer().ResetCamera()

    iren.Initialize()
    rw.Render()
    iren.Start()
Exemple #5
0
def main():  
    tree_fn = "vtklibrary.xml";
    graph_fn = "vtkclasses.xml";

    reader1 = vtk.vtkXMLTreeReader()
    reader1.SetFileName(tree_fn)
    reader1.SetEdgePedigreeIdArrayName("tree edge")
    reader1.GenerateVertexPedigreeIdsOff()
    reader1.SetVertexPedigreeIdArrayName("id")

    reader2 = vtk.vtkXMLTreeReader()
    reader2.SetFileName(graph_fn)
    reader2.SetEdgePedigreeIdArrayName("graph edge")
    reader2.GenerateVertexPedigreeIdsOff()
    reader2.SetVertexPedigreeIdArrayName("id")

    reader1.Update()
    reader2.Update()

    # straight VTK
    # we need this for getting the view going
    rw = vtk.vtkRenderWindow()
    # and this
    iren = vtk.vtkRenderWindowInteractor()
    iren.SetRenderWindow(rw)

    iren.AddObserver('CharEvent', lambda o, e: observer_charevent(o,e,view))

    # connect existing rw+iren to the view
    view = vtk.vtkHierarchicalGraphView()
    view.SetupRenderWindow(rw)

    #view.DisplayHoverTextOff()
    view.GetRenderWindow().SetMultiSamples(0)
    view.SetHierarchyFromInputConnection(reader1.GetOutputPort())
    view.SetGraphFromInputConnection(reader2.GetOutputPort())
    view.SetVertexColorArrayName("VertexDegree")
    view.SetColorVertices(True)
    view.SetVertexLabelArrayName("id")
    view.SetVertexLabelVisibility(True)
    view.SetScalingArrayName("TreeRadius")
    view.SetBundlingStrength(cur_bs)

    view.Update()
    #view.SetGraphEdgeColorArrayName("graph edge")
    #view.SetColorGraphEdgesByArray(True)

    view.AddObserver('SelectionChangedEvent', observer_selchanged)

    lstrat = 'cosmic tree'
    if lstrat == 'cosmic tree':
        cls = vtk.vtkCosmicTreeLayoutStrategy()
        cls.SetNodeSizeArrayName("VertexDegree")
        cls.SetSizeLeafNodesOnly(True)
    elif lstrat == 'circ':
        cls = vtk.vtkCircularLayoutStrategy()
    elif lstrat == 'tree':
        cls = vtk.vtkTreeLayoutStrategy()
        cls.SetAngle(360)
        cls.SetRadial(True)
        cls.SetLogSpacingValue(0.8)
        cls.SetLeafSpacing(0.9)

    view.SetLayoutStrategy(cls)

    theme = vtk.vtkViewTheme.CreateMellowTheme()
    theme.SetLineWidth(1)
    view.ApplyViewTheme(theme)
     
    view.GetRenderer().ResetCamera()
 
    iren.Initialize()
    rw.Render()
    iren.Start()