当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkContextView函数代码示例

本文整理汇总了Python中vtk.vtkContextView函数的典型用法代码示例。如果您正苦于以下问题:Python vtkContextView函数的具体用法?Python vtkContextView怎么用?Python vtkContextView使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了vtkContextView函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestColorTransferFunction

def TestColorTransferFunction(int ,  char):
    # Set up a 2D scene, add an XY chart to it
    view = vtk.vtkContextView()
    view.GetRenderer().SetBackground(1.0, 1.0, 1.0)
    view.GetRenderWindow().SetSize(400, 300)
    
    chart = vtk.vtkChartXY()
    chart.SetTitle('Chart')
    view.GetScene().AddItem(chart)
    
    colorTransferFunction = vtk.vtkColorTransferFunction()
    colorTransferFunction.AddHSVSegment(50.,0.,1.,1.,85.,0.3333,1.,1.)
    colorTransferFunction.AddHSVSegment(85.,0.3333,1.,1.,170.,0.6666,1.,1.)
    colorTransferFunction.AddHSVSegment(170.,0.6666,1.,1.,200.,0.,1.,1.)
    
    colorTransferFunction.Build()
    
    colorTransferItem = vtk.vtkColorTransferFunctionItem()
    colorTransferItem.SetColorTransferFunction(colorTransferFunction)
    chart.AddPlot(colorTransferItem)
    
    controlPointsItem = vtk.vtkColorTransferControlPointsItem()
    controlPointsItem.SetColorTransferFunction(colorTransferFunction)
    controlPointsItem.SetUserBounds(0., 255., 0., 1.)
    chart.AddPlot(controlPointsItem)
    
    # Finally render the scene and compare the image to a reference image
    view.GetRenderWindow().SetMultiSamples(1)
    if view.GetContext().GetDevice().IsA( "vtkOpenGLContextDevice2D") :
      view.GetInteractor().Initialize()
      view.GetInteractor().Start()
    else:
        print 'GL version 2 or higher is required.'
    
    return EXIT_SUCCESS
开发者ID:behollis,项目名称:DBSViewer,代码行数:35,代码来源:TestColorTransferFunction.py

示例2: testLinePlot

    def testLinePlot(self):
        "Test if line plots can be built with python"

        # Set up a 2D scene, add an XY chart to it
        view = vtk.vtkContextView()
        view.GetRenderer().SetBackground(1.0,1.0,1.0)
        view.GetRenderWindow().SetSize(400,300)
        chart = vtk.vtkChartXY()
        view.GetScene().AddItem(chart)

        # Create a table with some points in it
        table = vtk.vtkTable()

        arrX = vtk.vtkFloatArray()
        arrX.SetName("X Axis")

        arrC = vtk.vtkFloatArray()
        arrC.SetName("Cosine")

        arrS = vtk.vtkFloatArray()
        arrS.SetName("Sine")

        arrS2 = vtk.vtkFloatArray()
        arrS2.SetName("Sine2")

        numPoints = 69
        inc = 7.5 / (numPoints - 1)

        for i in range(0,numPoints):
            arrX.InsertNextValue(i*inc)
            arrC.InsertNextValue(math.cos(i * inc) + 0.0)
            arrS.InsertNextValue(math.sin(i * inc) + 0.0)
            arrS2.InsertNextValue(math.sin(i * inc) + 0.5)

        table.AddColumn(arrX)
        table.AddColumn(arrC)
        table.AddColumn(arrS)
        table.AddColumn(arrS2)

        # Now add the line plots with appropriate colors
        line = chart.AddPlot(0)
        line.SetInput(table,0,1)
        line.SetColor(0,255,0,255)
        line.SetWidth(1.0)

        line = chart.AddPlot(0)
        line.SetInput(table,0,2)
        line.SetColor(255,0,0,255);
        line.SetWidth(5.0)

        line = chart.AddPlot(0)
        line.SetInput(table,0,3)
        line.SetColor(0,0,255,255);
        line.SetWidth(4.0)

        view.GetRenderWindow().SetMultiSamples(0)

        img_file = "TestLinePlot.png"
        vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25)
        vtk.test.Testing.interact()
开发者ID:BobObara,项目名称:VTK,代码行数:60,代码来源:TestLinePlot.py

示例3: __init__

    def __init__(self, parent=None):
        QCellWidget.__init__(self, parent)
        
        centralLayout = QtGui.QVBoxLayout()
        self.setLayout(centralLayout)
        centralLayout.setMargin(0)
        centralLayout.setSpacing(0)
                
        self.view = vtk.vtkContextView()
        self.widget = QVTKRenderWindowInteractor(self, 
                                                 rw=self.view.GetRenderWindow(),
                                                 iren=self.view.GetInteractor()
                                                )

        self.chart = vtk.vtkChartParallelCoordinates()
        self.view.GetScene().AddItem(self.chart)

        self.layout().addWidget(self.widget)

        # Create a annotation link to access selection in parallel coordinates view
        self.annotationLink = vtk.vtkAnnotationLink()
        # 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
        self.annotationLink.GetCurrentSelection().GetNode(0).SetFieldType(1)     # Point
        self.annotationLink.GetCurrentSelection().GetNode(0).SetContentType(4)   # Indices
        # Connect the annotation link to the parallel coordinates representation
        self.chart.SetAnnotationLink(self.annotationLink)
        self.annotationLink.AddObserver("AnnotationChangedEvent", self.selectionCallback)
开发者ID:imclab,项目名称:vistrails,代码行数:28,代码来源:plots.py

示例4: generateParallelCoordinatesPlot

    def generateParallelCoordinatesPlot( self ):
        input = self.inputModule().getOutput() 
        ptData = input.GetPointData()
        narrays = ptData.GetNumberOfArrays()
        arrays = []
        # Create a table with some points in it...
        table = vtk.vtkTable()
        for iArray in range( narrays ):
            table.AddColumn(  ptData.GetArray( iArray ) )                  
        
        # Set up a 2D scene, add an XY chart to it
        view = vtk.vtkContextView()
#        view.SetRenderer( self.renderer )    
#        view.SetRenderWindow( self.renderer.GetRenderWindow() )
        view.GetRenderer().SetBackground(1.0, 1.0, 1.0)
        view.GetRenderWindow().SetSize(600,300)
        
        plot = vtk.vtkPlotParallelCoordinates()
        plot.SetInput(table)
                
        view.GetScene().AddItem(plot)
                                
        view.ResetCamera()
        view.Render()       
        # Start interaction event loop
        view.GetInteractor().Start()
开发者ID:imclab,项目名称:vistrails,代码行数:26,代码来源:ParallelCoordinatesModule.py

示例5: addPlot

    def addPlot(self,_plotName,_style="Lines"):   # called directly from Steppable; add a (possibly more than one) plot to a plot window

        self.plotWindowInterfaceMutex.lock()
#        self.plotWindowMutex.lock()

#        return
#        print MODULENAME,'   addPlot():  _plotName= ',_plotName
#        import pdb; pdb.set_trace()
        
#        self.plotData[_plotName] = [array([],dtype=double),array([],dtype=double),False]  # 'array': from PyQt4.Qwt5.anynumpy import *
        
        self.chart = vtk.vtkChartXY()
#        self.chart.GetAxis(vtk.vtkAxis.LEFT).SetLogScale(True)
#        self.chart.GetAxis(vtk.vtkAxis.BOTTOM).SetLogScale(True)
#        self.numCharts += 1
        self.plotData[_plotName] = [self.chart]

        self.view = vtk.vtkContextView()
        self.ren = self.view.GetRenderer()
#        self.renWin = self.qvtkWidget.GetRenderWindow()
        self.renWin = self.pW.GetRenderWindow()
        self.renWin.AddRenderer(self.ren)

        # Create a table with some points in it
        self.table = vtk.vtkTable()

        self.arrX = vtk.vtkFloatArray()
        self.arrX.SetName("xarray")

        self.arrC = vtk.vtkFloatArray()
        self.arrC.SetName("yarray")

        numPoints = 5
        numPoints = 15
        inc = 7.5 / (numPoints - 1)

#        for i in range(0,numPoints):
#            self.arrX.InsertNextValue(i*inc)
#            self.arrC.InsertNextValue(math.cos(i * inc) + 0.0)

#        self.arrX.InsertNextValue(0.0)
#        self.arrC.InsertNextValue(0.0)
#        self.arrX.InsertNextValue(0.1)
#        self.arrC.InsertNextValue(0.1)

        self.table.AddColumn(self.arrX)
        self.table.AddColumn(self.arrC)

        # Now add the line plots with appropriate colors
        self.line = self.chart.AddPlot(0)
        self.line.SetInput(self.table,0,1)
        self.line.SetColor(0,0,255,255)
        self.line.SetWidth(1.0)


        self.view.GetRenderer().SetBackground([0.6,0.6,0.1])
        self.view.GetRenderer().SetBackground([1.0,1.0,1.0])
        self.view.GetScene().AddItem(self.chart)

        self.plotWindowInterfaceMutex.unlock()
开发者ID:CompuCell3D,项目名称:CompuCell3D,代码行数:60,代码来源:PlotManagerVTK.py

示例6: initialize

def initialize(self, VTKWebApp, args):
    dataid = args.id
    treedata = getDBdata(dataid)
    VTKWebApp.tree1 = treedata["tree1"]
    VTKWebApp.tree2 = treedata["tree2"]
    VTKWebApp.table = dataid+ ".csv"

    # Create default pipeline (Only once for all the session)
    if not VTKWebApp.view:
        # read the trees
        treeReader1 = vtk.vtkNewickTreeReader()
        treeReader1.SetReadFromInputString(1)
        treeReader1.SetInputString(VTKWebApp.tree1)
        treeReader1.Update()
        tree1 = treeReader1.GetOutput()

        treeReader2 = vtk.vtkNewickTreeReader()
        treeReader2.SetReadFromInputString(1)
        treeReader2.SetInputString(VTKWebApp.tree2)
        treeReader2.Update()
        tree2 = treeReader2.GetOutput()

        # read the table
        tableReader = vtk.vtkDelimitedTextReader()
        tableReader.SetFileName(VTKWebApp.table)
        tableReader.SetHaveHeaders(True)
        tableReader.DetectNumericColumnsOn()
        tableReader.ForceDoubleOn()
        tableReader.Update()
        table = tableReader.GetOutput()

        # setup the tanglegram
        tanglegram = vtk.vtkTanglegramItem()
        tanglegram.SetTree1(tree1);
        tanglegram.SetTree2(tree2);
        tanglegram.SetTable(table);
        tanglegram.SetTree1Label("tree1");
        tanglegram.SetTree2Label("tree2");

        # setup the window
        view = vtk.vtkContextView()
        view.GetRenderer().SetBackground(1,1,1)
        view.GetRenderWindow().SetSize(800,600)

        iren = view.GetInteractor()
        iren.SetRenderWindow(view.GetRenderWindow())

        transformItem = vtk.vtkContextTransform()
        transformItem.AddItem(tanglegram)
        transformItem.SetInteractive(1)

        view.GetScene().AddItem(transformItem)
        view.GetRenderWindow().SetMultiSamples(0)

        iren.Initialize()
        view.GetRenderWindow().Render()

        # VTK Web application specific
        VTKWebApp.view = view.GetRenderWindow()
        self.Application.GetObjectIdMap().SetActiveObject("VIEW", view.GetRenderWindow())
开发者ID:chinchliff,项目名称:ArborWebApps,代码行数:60,代码来源:vtk_tanglegram.py

示例7: create_widgets

    def create_widgets(self):
        # transfer function control

        self.qtVtkWidget = DBSTransferFunctionWindowInteractor(self, \
            app=self.parent() ) 
        
        self._contextView = vtk.vtkContextView()
        self._contextView.SetRenderWindow(self.qtVtkWidget.GetRenderWindow())
开发者ID:behollis,项目名称:DBSViewer,代码行数:8,代码来源:dbsControlDialogs.py

示例8: testBarGraph

    def testBarGraph(self):
        "Test if bar graphs can be built with python"

        # Set up a 2D scene, add an XY chart to it
        view = vtk.vtkContextView()
        view.GetRenderer().SetBackground(1.0,1.0,1.0)
        view.GetRenderWindow().SetSize(400,300)
        chart = vtk.vtkChartXY()
        view.GetScene().AddItem(chart)

        # Create a table with some points in it
        table = vtk.vtkTable()

        arrMonth = vtk.vtkIntArray()
        arrMonth.SetName("Month")

        arr2008 = vtk.vtkIntArray()
        arr2008.SetName("2008")

        arr2009 = vtk.vtkIntArray()
        arr2009.SetName("2009")

        arr2010 = vtk.vtkIntArray()
        arr2010.SetName("2010")

        numMonths = 12

        for i in range(0,numMonths):
            arrMonth.InsertNextValue(i + 1)
            arr2008.InsertNextValue(data_2008[i])
            arr2009.InsertNextValue(data_2009[i])
            arr2010.InsertNextValue(data_2010[i])

        table.AddColumn(arrMonth)
        table.AddColumn(arr2008)
        table.AddColumn(arr2009)
        table.AddColumn(arr2010)

        # Now add the line plots with appropriate colors
        line = chart.AddPlot(2)
        line.SetInput(table,0,1)
        line.SetColor(0,255,0,255)

        line = chart.AddPlot(2)
        line.SetInput(table,0,2)
        line.SetColor(255,0,0,255);

        line = chart.AddPlot(2)
        line.SetInput(table,0,3)
        line.SetColor(0,0,255,255);

        view.GetRenderWindow().SetMultiSamples(0)
	view.GetRenderWindow().Render()

        img_file = "TestBarGraph.png"
        vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25)
        vtk.test.Testing.interact()
开发者ID:kramarb,项目名称:VTK,代码行数:57,代码来源:TestBarGraph.py

示例9: __init__

	def __init__(self, data_source, input_link=None, highlight_link=None):
		"""Parallel coordinates view constructor needs a valid DataSource plus
		and external annotation link (from the icicle view).
		"""

		self.ds = data_source

		self.input_link = None
		if input_link is not None:
			self.SetInputAnnotationLink(input_link)

		# Set up a 2D scene, add an XY chart to it
		self.view = vtk.vtkContextView()
		self.view.GetRenderer().SetBackground(1.0, 1.0, 1.0)
		self.view.GetRenderWindow().SetSize(600,300)

		self.chart = vtkvtg.vtkMyChartParallelCoordinates()

		self.highlight_link = None
		if highlight_link is not None:
			self.SetHighlightAnnotationLink(highlight_link)

		# Create a annotation link to access selection in parallel coordinates view
		self.link = vtk.vtkAnnotationLink()
		# 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
		self.link.GetCurrentSelection().GetNode(0).SetFieldType(1)     # Point
		# The chart seems to force INDEX selection, so I'm using vtkConvertSelection below to get
		# out PedigreeIds...
		self.link.GetCurrentSelection().GetNode(0).SetContentType(4)   # 2 = PedigreeIds, 4 = Indices
		# Connect the annotation link to the parallel coordinates representation
		self.chart.SetAnnotationLink(self.link)

		# Set up callback for ID -> Pedigree ID conversion & copy to output link
		self.link.AddObserver("AnnotationChangedEvent", self.PCoordsSelectionCallback)

		# Set up output annotation link which will carry pedigree ids to image flow view
		# Type and field will be set during conversion to pedigree ids in PCoordsSelectionCallback
		self.output_link = vtk.vtkAnnotationLink()

		self.view.GetScene().AddItem(self.chart)
		# self.view.ResetCamera()
		# self.view.Render()

		# Set default scale range to show: 'all', 'coarse', 'fine'
		# TODO: Should check the menu to see which is checked so default is
		#   set by GUI
		self.scale_range = 'coarse'

		# Want to keep track of whether the node coming in on the input_link
		# is new or not
		self.input_link_idx = 0

		# Flag for whether to color by 'category_ids'
		# TODO: Should check the menu to see which is checked so default is
		#   set by GUI
		self.SetColorByArray("None")
开发者ID:emonson,项目名称:MultiScaleSVD,代码行数:57,代码来源:pcoords_chart.py

示例10: testPythonItem

    def testPythonItem(self):
        width = 400
        height = 400

        view = vtk.vtkContextView()
        renWin = view.GetRenderWindow()
        renWin.SetSize(width, height)

        area = vtk.vtkInteractiveArea()
        view.GetScene().AddItem(area)

        drawAreaBounds = vtk.vtkRectd(0.0, 0.0, 1.0, 1.0)

        vp = [0.05, 0.95, 0.05, 0.95]
        screenGeometry = vtk.vtkRecti(int(vp[0] * width),
                                      int(vp[2] * height),
                                      int((vp[1] - vp[0]) * width),
                                      int((vp[3] - vp[2]) * height))

        item = vtk.vtkPythonItem()
        item.SetPythonObject(CustomPythonItem(buildPolyData()))
        item.SetVisible(True)
        area.GetDrawAreaItem().AddItem(item)

        area.SetDrawAreaBounds(drawAreaBounds)
        area.SetGeometry(screenGeometry)
        area.SetFillViewport(False)
        area.SetShowGrid(False)

        axisLeft = area.GetAxis(vtk.vtkAxis.LEFT)
        axisRight = area.GetAxis(vtk.vtkAxis.RIGHT)
        axisBottom = area.GetAxis(vtk.vtkAxis.BOTTOM)
        axisTop = area.GetAxis(vtk.vtkAxis.TOP)
        axisTop.SetVisible(False)
        axisRight.SetVisible(False)
        axisLeft.SetVisible(False)
        axisBottom.SetVisible(False)
        axisTop.SetMargins(0, 0)
        axisRight.SetMargins(0, 0)
        axisLeft.SetMargins(0, 0)
        axisBottom.SetMargins(0, 0)

        renWin.Render()

        # Create a vtkTesting object
        rtTester = vtk.vtkTesting()
        rtTester.SetRenderWindow(renWin)

        for arg in sys.argv[1:]:
            rtTester.AddArgument(arg)

        # Perform the image comparison test and print out the result.
        result = rtTester.RegressionTest(0.0)

        if result == 0:
            raise Exception("TestPythonItem failed.")
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:56,代码来源:testPythonItem.py

示例11: __init__

    def __init__(self):
        self._rendererScene = vtk.vtkRenderer()
        self._rendererScene.SetBackground(self.COLOR_BG)

        self._renderWindowScene = vtk.vtkRenderWindow()
        self._renderWindowScene.AddRenderer(self._rendererScene)
        self._renderWindowInteractor = vtk.vtkRenderWindowInteractor()
        self._renderWindowInteractor.SetRenderWindow(self._renderWindowScene)
        #self._interactorStyle = vtk.vtkInteractorStyleUnicam()
        self._interactorStyle = self.KeyPressInteractorStyle()
        self._interactorStyle.SetCamera(self._rendererScene.GetActiveCamera())
        self._interactorStyle.SetRenderer(self._rendererScene)
        self._interactorStyle.SetRenderWindow(self._renderWindowScene)

        self._contextViewPlotCurv = vtk.vtkContextView()
        self._contextViewPlotCurv.GetRenderer().SetBackground(self.COLOR_BG_PLOT)

        self._contextInteractorStyleCurv = self.KeyPressContextInteractorStyle()
        self._contextInteractorStyleCurv.SetRenderWindow(self._contextViewPlotCurv.GetRenderWindow())
        
        self._chartXYCurv = vtk.vtkChartXY()
        self._contextViewPlotCurv.GetScene().AddItem(self._chartXYCurv)
        self._chartXYCurv.SetShowLegend(True)
        self._chartXYCurv.GetAxis(vtk.vtkAxis.LEFT).SetTitle("")
        self._chartXYCurv.GetAxis(vtk.vtkAxis.BOTTOM).SetTitle("")

        self._contextViewPlotTors = vtk.vtkContextView()
        self._contextViewPlotTors.GetRenderer().SetBackground(self.COLOR_BG_PLOT)

        self._contextInteractorStyleTors = self.KeyPressContextInteractorStyle()
        self._contextInteractorStyleTors.SetRenderWindow(self._contextViewPlotTors.GetRenderWindow())
        
        self._chartXYTors = vtk.vtkChartXY()
        self._contextViewPlotTors.GetScene().AddItem(self._chartXYTors)
        self._chartXYTors.SetShowLegend(True)
        self._chartXYTors.GetAxis(vtk.vtkAxis.LEFT).SetTitle("")
        self._chartXYTors.GetAxis(vtk.vtkAxis.BOTTOM).SetTitle("")

        self._textActor = vtk.vtkTextActor()
        self._textActor.GetTextProperty().SetColor(self.COLOR_LENGTH)

        self._addedBSpline = False
开发者ID:trianam,项目名称:voropath,代码行数:42,代码来源:plotter.py

示例12: initialize

    def initialize(self):
        global renderer, renderWindow, renderWindowInteractor, cone, mapper, actor

        # Bring used components
        self.registerVtkWebProtocol(protocols.vtkWebMouseHandler())
        self.registerVtkWebProtocol(protocols.vtkWebViewPort())
        self.registerVtkWebProtocol(protocols.vtkWebViewPortImageDelivery())
        self.registerVtkWebProtocol(protocols.vtkWebViewPortGeometryDelivery())

        # Update authentication key to use
        self.updateSecret(_PhylogeneticTree.authKey)

        # Create default pipeline (Only once for all the session)
        if not _PhylogeneticTree.view:
            # read in  a tree
            treeReader = vtk.vtkNewickTreeReader()
            treeReader.SetFileName(_PhylogeneticTree.treeFilePath)
            treeReader.Update()
            reader = treeReader.GetOutput()

            # read in  a table
            tableReader = vtk.vtkDelimitedTextReader()
            tableReader.SetFileName(_PhylogeneticTree.csvFilePath)
            tableReader.SetHaveHeaders(True)
            tableReader.DetectNumericColumnsOn()
            tableReader.Update()
            table = tableReader.GetOutput()

            # play with the heatmap vis
            treeHeatmapItem = vtk.vtkTreeHeatmapItem()
            treeHeatmapItem.SetTree(reader);
            treeHeatmapItem.SetTable(table);

            # setup the window
            view = vtk.vtkContextView()
            view.GetRenderer().SetBackground(1,1,1)
            view.GetRenderWindow().SetSize(800,600)

            iren = view.GetInteractor()
            iren.SetRenderWindow(view.GetRenderWindow())

            transformItem = vtk.vtkContextTransform()
            transformItem.AddItem(treeHeatmapItem)
            transformItem.SetInteractive(1)

            view.GetScene().AddItem(transformItem)
            view.GetRenderWindow().SetMultiSamples(0)

            iren.Initialize()
            view.GetRenderWindow().Render()

            # VTK Web application specific
            _PhylogeneticTree.view = view.GetRenderWindow()
            self.Application.GetObjectIdMap().SetActiveObject("VIEW", view.GetRenderWindow())
开发者ID:Andy-Sun,项目名称:VTK,代码行数:54,代码来源:vtk_web_phylogenetic_tree.py

示例13: generateParallelCoordinatesChart

    def generateParallelCoordinatesChart( self ):
        input = self.inputModule().getOutput() 
        ptData = input.GetPointData()
        narrays = ptData.GetNumberOfArrays()
        arrays = []
        # Create a table with some points in it...
        table = vtk.vtkTable()
        for iArray in range( narrays ):
            table.AddColumn(  ptData.GetArray( iArray ) )                  
        
        # Set up a 2D scene, add an XY chart to it
        view = vtk.vtkContextView()
#        view.SetRenderer( self.renderer )    
#        view.SetRenderWindow( self.renderer.GetRenderWindow() )
        view.GetRenderer().SetBackground(1.0, 1.0, 1.0)
        view.GetRenderWindow().SetSize(600,300)
        
        chart = vtk.vtkChartParallelCoordinates()
        
        brush = vtk.vtkBrush()
        brush.SetColorF (0.1,0.1,0.1)
        chart.SetBackgroundBrush(brush)
        
        # Create a annotation link to access selection in parallel coordinates view
        annotationLink = vtk.vtkAnnotationLink()
        # 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
        annotationLink.GetCurrentSelection().GetNode(0).SetFieldType(1)     # Point
        annotationLink.GetCurrentSelection().GetNode(0).SetContentType(4)   # Indices
        # Connect the annotation link to the parallel coordinates representation
        chart.SetAnnotationLink(annotationLink)
        
        view.GetScene().AddItem(chart)
                
        
        chart.GetPlot(0).SetInput(table)
        
        def selectionCallback(caller, event):
                annSel = annotationLink.GetCurrentSelection()
                if annSel.GetNumberOfNodes() > 0:
                        idxArr = annSel.GetNode(0).GetSelectionList()
                        if idxArr.GetNumberOfTuples() > 0:
                                print VN.vtk_to_numpy(idxArr)
        
        # Set up callback to update 3d render window when selections are changed in 
        #       parallel coordinates view
        annotationLink.AddObserver("AnnotationChangedEvent", selectionCallback)
                
#        view.ResetCamera()
#        view.Render()       
#        view.GetInteractor().Start()
        return view 
开发者ID:imclab,项目名称:vistrails,代码行数:52,代码来源:ParallelCoordinatesModule.py

示例14: initialize

def initialize(self, VTKWebApp, args):
    VTKWebApp.treeFilePath = args.tree
    VTKWebApp.csvFilePath = args.table

    # Create default pipeline (Only once for all the session)
    if not VTKWebApp.view:
        # read in  a tree
        treeReader = vtk.vtkNewickTreeReader()
        treeReader.SetFileName(VTKWebApp.treeFilePath)
        treeReader.Update()
        reader = treeReader.GetOutput()

        # read in  a table
        tableReader = vtk.vtkDelimitedTextReader()
        tableReader.SetFileName(VTKWebApp.csvFilePath)
        tableReader.SetHaveHeaders(1)
        tableReader.DetectNumericColumnsOn()
        tableReader.Update()
        table = tableReader.GetOutput()

        # play with the heatmap vis
        treeHeatmapItem = vtk.vtkTreeHeatmapItem()
        treeHeatmapItem.SetTree(reader)
        treeHeatmapItem.SetTable(table)

        # setup the window
        view = vtk.vtkContextView()
        view.GetRenderer().SetBackground(1, 1, 1)
        view.GetRenderWindow().SetSize(800, 600)

        iren = view.GetInteractor()
        iren.SetRenderWindow(view.GetRenderWindow())

        transformItem = vtk.vtkContextTransform()
        transformItem.AddItem(treeHeatmapItem)
        transformItem.SetInteractive(1)

        view.GetScene().AddItem(transformItem)
        view.GetRenderWindow().SetMultiSamples(0)

        iren.Initialize()
        view.GetRenderWindow().Render()

        # VTK Web application specific
        VTKWebApp.view = view.GetRenderWindow()
        self.Application.GetObjectIdMap().SetActiveObject("VIEW", view.GetRenderWindow())
开发者ID:hafen,项目名称:tangelo,代码行数:46,代码来源:vtkweb_tree.py

示例15: testLinePlot

    def testLinePlot(self):
        "Test if colored parallel coordinates plots can be built with python"

        # Set up a 2D scene, add a PC chart to it
        view = vtk.vtkContextView()
        view.GetRenderer().SetBackground(1.0, 1.0, 1.0)
        view.GetRenderWindow().SetSize(600,300)

        chart = vtk.vtkChartParallelCoordinates()
        view.GetScene().AddItem(chart)

        # Create a table with some points in it
        arrX = vtk.vtkFloatArray()
        arrX.SetName("XAxis")

        arrC = vtk.vtkFloatArray()
        arrC.SetName("Cosine")

        arrS = vtk.vtkFloatArray()
        arrS.SetName("Sine")

        arrS2 = vtk.vtkFloatArray()
        arrS2.SetName("Tan")

        numPoints = 200
        inc = 7.5 / (numPoints-1)

        for i in range(numPoints):
            arrX.InsertNextValue(i * inc)
            arrC.InsertNextValue(math.cos(i * inc) + 0.0)
            arrS.InsertNextValue(math.sin(i * inc) + 0.0)
            arrS2.InsertNextValue(math.tan(i * inc) + 0.5)

        table = vtk.vtkTable()
        table.AddColumn(arrX)
        table.AddColumn(arrC)
        table.AddColumn(arrS)
        table.AddColumn(arrS2)

        # Create blue to gray to red lookup table
        lut = vtk.vtkLookupTable()
        lutNum = 256
        lut.SetNumberOfTableValues(lutNum)
        lut.Build()

        ctf = vtk.vtkColorTransferFunction()
        ctf.SetColorSpaceToDiverging()
        cl = []
        # Variant of Colorbrewer RdBu 5
        cl.append([float(cc)/255.0 for cc in [202, 0, 32]])
        cl.append([float(cc)/255.0 for cc in [244, 165, 130]])
        cl.append([float(cc)/255.0 for cc in [140, 140, 140]])
        cl.append([float(cc)/255.0 for cc in [146, 197, 222]])
        cl.append([float(cc)/255.0 for cc in [5, 113, 176]])
        vv = [float(xx)/float(len(cl)-1) for xx in range(len(cl))]
        vv.reverse()
        for pt,color in zip(vv,cl):
            ctf.AddRGBPoint(pt, color[0], color[1], color[2])

        for ii,ss in enumerate([float(xx)/float(lutNum) for xx in range(lutNum)]):
            cc = ctf.GetColor(ss)
            lut.SetTableValue(ii,cc[0],cc[1],cc[2],1.0)

        lut.SetAlpha(0.25)
        lut.SetRange(-1, 1)

        chart.GetPlot(0).SetInputData(table)
        chart.GetPlot(0).SetScalarVisibility(1)
        chart.GetPlot(0).SetLookupTable(lut)
        chart.GetPlot(0).SelectColorArray("Cosine")

        view.GetRenderWindow().SetMultiSamples(0)
        view.GetRenderWindow().Render()

        img_file = "TestParallelCoordinatesColors.png"
        vtk.test.Testing.compareImage(view.GetRenderWindow(),vtk.test.Testing.getAbsImagePath(img_file),threshold=25)
        vtk.test.Testing.interact()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:77,代码来源:TestParallelCoordinatesColors.py


注:本文中的vtk.vtkContextView函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。