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


Python vtk.vtkTable函数代码示例

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


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

示例1: 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

示例2: make_spreadsheet

def make_spreadsheet(column_names, table):
    # column_names is a list of strings
    # table is a 2D numpy.ndarray
    # returns a vtkTable object that stores the table content

    # Create a vtkTable to store the output.
    rows = table.shape[0]

    if (table.shape[1] != len(column_names)):
        print('Warning: table number of columns differs from number of '
              'column names')
        return

    from vtk import vtkTable, vtkFloatArray
    vtk_table = vtkTable()
    for (column, name) in enumerate(column_names):
        array = vtkFloatArray()
        array.SetName(name)
        array.SetNumberOfComponents(1)
        array.SetNumberOfTuples(rows)
        vtk_table.AddColumn(array)

        for row in range(0, rows):
            array.InsertValue(row, table[row, column])

    return vtk_table
开发者ID:OpenChemistry,项目名称:tomviz,代码行数:26,代码来源:utils.py

示例3: testMultiTreeOutputs

    def testMultiTreeOutputs(self):
        outputs = vtk.vtkStringArray()
        outputs.SetNumberOfComponents(1)
        outputs.SetNumberOfTuples(2)
        outputs.SetValue(0, "tree1")
        outputs.SetValue(1, "tree2")
        rcal = vtk.vtkRCalculatorFilter()


        rcal.SetRscript("library(ape)\n\
                         tree1 = read.tree(text=\"" + tree_data + "\")\n\
                         tree2 = read.tree(text=\"" + tree_data + "\")\n")

        rcal.GetTrees(outputs)

        input = vtk.vtkTable()
        rcal.SetInputData(input)

        rcal.Update()

        compo = rcal.GetOutput()
        tree1 = compo.GetPieceAsDataObject(0)
        self.assertTrue(tree1.IsA('vtkTree'))
        tree2 = compo.GetPieceAsDataObject(1)
        self.assertTrue(tree2.IsA('vtkTree'))
开发者ID:0004c,项目名称:VTK,代码行数:25,代码来源:TestRCalculatorFilter.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(chart, reader, name):
        data1 = reader.GetOutput()
        
        coords = vtk.vtkFloatArray()
        coords.SetName("Coords")

        for i in range(data1.GetNumberOfPoints()):
                x,y,z = data1.GetPoint(i)
		coords.InsertNextValue(y)

	table = vtk.vtkTable()
	table.AddColumn(coords)
	table.AddColumn(data1.GetPointData().GetArray("S_g"))
        table.AddColumn(data1.GetPointData().GetArray("S_n"))
        table.AddColumn(data1.GetPointData().GetArray("S_w"))

        line1 = chart.AddPlot(vtk.vtkChart.LINE)
        line1.SetInput(table, 0, 1)
	line1.SetMarkerStyle(vtk.vtkPlotPoints.CROSS)

        line2 = chart.AddPlot(vtk.vtkChart.LINE)
        line2.SetInput(table, 0, 2)
	line2.SetMarkerStyle(vtk.vtkPlotPoints.PLUS)

        line3 = chart.AddPlot(vtk.vtkChart.LINE)
        line3.SetInput(table, 0, 3)
        line3.SetMarkerStyle(vtk.vtkPlotPoints.CIRCLE)
开发者ID:alyupa,项目名称:multiphase-flow-modeling,代码行数:27,代码来源:zsatu-single.py

示例6: 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

示例7: testTableInputOutput

    def testTableInputOutput(self):
        rcal = vtk.vtkRCalculatorFilter()
        rcal.SetRscript("output = input\n");
        rcal.PutTable('input')
        rcal.GetTable('output')

        value = 1
        array = vtk.vtkDoubleArray()
        array.SetNumberOfComponents(1)
        array.SetNumberOfTuples(4)
        array.SetName('test')
        for i in range(0, 4):
            array.SetValue(i, value)
            value += 1

        input = vtk.vtkTable()
        input.AddColumn(array)
        rcal.SetInputData(input)

        rcal.Update()

        t1 = rcal.GetOutput().GetColumnByName('test')
        value = 1

        for i in range(0, t1.GetNumberOfTuples()):
            self.assertEqual(value, t1.GetValue(i))
            value += 1
开发者ID:0004c,项目名称:VTK,代码行数:27,代码来源:TestRCalculatorFilter.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: 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

示例10: GetNodeOneScaleCoeffTable

	def GetNodeOneScaleCoeffTable(self, node_id):
		"""Returns a table of the wavelet coefficients at a single node at a single
		scale for plotting on a scatter plot. Relying on icicle_view already having
		called GetWaveletCoeffImages() with correct positions of leaf nodes in view,
		otherwise just using original Matlab-saved LeafNodes ordering.
		This version supports category labels."""

		if self.data_loaded:

			# For a given node_id, concatenate wavelet coeffs in proper order
			# (according to leaf node positions in icicle view if it was set already)
			# Columns of table will be rows of the wavelet coeffs image

			scale = self.Scales[node_id]

			leaf_offspring = N.array(list(self.get_leaf_children(self.cp, node_id)))
			offspring_idxs = self.LeafNodesImap[leaf_offspring]
			offspring_pos = self.mapped_leaf_pos[offspring_idxs]
			sorted_offspring_pos_idxs = N.argsort(offspring_pos)
			sorted_offspring_idxs = offspring_idxs[sorted_offspring_pos_idxs]
			img_tuple = tuple(pp for pp in self.CelCoeffs[sorted_offspring_idxs, scale])
			# The image comes out with shape (npts, ndims)
			# May need to reorder (reverse) this...?
			img = N.concatenate(img_tuple, axis=0)

			table = vtk.vtkTable()
			for ii in range(img.shape[1]):
				column = VN.numpy_to_vtk(img[:,ii].copy(), deep=True)
				column.SetName(str(scale) + '.' + str(ii))
				table.AddColumn(column)

			IDtuple = tuple(self.PointsInNet[xx] for xx in self.LeafNodes[sorted_offspring_idxs])
			IDarray = N.concatenate(IDtuple)
			# Trying to set PedigreeIds to that parallel coords selections have correct IDs
			IDvtk = VN.numpy_to_vtk(IDarray, deep=True)
			IDvtk.SetName('pedigree_ids')
			table.AddColumn(IDvtk)
			table.GetRowData().SetActivePedigreeIds('pedigree_ids')

			# Adding in category labels
			# Name needs to end in _ids so plots will ignore it
			if self.hasLabels:
				for ii in range(self.cat_labels.shape[0]):
					CATvtk = VN.numpy_to_vtk(self.cat_labels[ii,IDarray], deep=True)
					CATvtk.SetName(self.label_names[ii])
					table.AddColumn(CATvtk)

			return table


		else:
			raise IOError, "Can't get image until data is loaded successfully"
开发者ID:emonson,项目名称:MultiScaleSVD,代码行数:52,代码来源:data_source.py

示例11: createTable

    def createTable(self, matrix):
        table = vtk.vtkTable()
        for col, attr in zip(matrix.values.T, matrix.attributes):
            column = VN.numpy_to_vtk(col.copy(), deep=True)
            column.SetName(attr)
            table.AddColumn(column)
        self.chart.GetPlot(0).SetInput(table)

        min_ = matrix.values.min()-0.01
        max_ = matrix.values.max()+0.01
        for i in range(self.chart.GetNumberOfAxes()):
            self.chart.GetAxis(i).SetRange(min_, max_)
            self.chart.GetAxis(i).SetBehavior(vtk.vtkAxis.FIXED);
开发者ID:imclab,项目名称:vistrails,代码行数:13,代码来源:plots.py

示例12: testTableOutput

    def testTableOutput(self):
        rcal = vtk.vtkRCalculatorFilter()
        rcal.SetRscript("output = list(test=c(1,2,3,4))\n");
        rcal.GetTable('output')
        input = vtk.vtkTable()
        rcal.SetInputData(input)

        rcal.Update()

        t1 = rcal.GetOutput().GetColumnByName('test')
        value = 1

        for i in range(0, t1.GetNumberOfTuples()):
            self.assertEqual(value, t1.GetValue(i))
            value += 1
开发者ID:0004c,项目名称:VTK,代码行数:15,代码来源:TestRCalculatorFilter.py

示例13: addPlot

def addPlot(chart, reader, name):
        data1 = reader.GetOutput()
        
        coords = vtk.vtkFloatArray()
        coords.SetName("Coords")

        for i in range(data1.GetNumberOfPoints()):
                x,y,z = data1.GetPoint(i)
		coords.InsertNextValue(y)

	scalars = data1.GetPointData().GetArray("P_w")
	scalars.SetName(name)

	table = vtk.vtkTable()
	table.AddColumn(coords)
	table.AddColumn(scalars)

        line1 = chart.AddPlot(vtk.vtkChart.LINE)
        line1.SetInput(table, 0, 1)
开发者ID:alyupa,项目名称:multiphase-flow-modeling,代码行数:19,代码来源:zpres-single.py

示例14: createSource

    def createSource(self):
        r = vtk.vtkEnsembleSource()

        aColumn = vtk.vtkIntArray()
        aColumn.SetName("Resolution")
        nrows = len(TestEnsemble.resolutions)
        for res in TestEnsemble.resolutions:
            aColumn.InsertNextValue(res)
        table = vtk.vtkTable()
        table.SetNumberOfRows(nrows)
        table.GetRowData().AddArray(aColumn)
        r.SetMetaData(table)

        for res in TestEnsemble.resolutions:
            c = vtk.vtkConeSource()
            c.SetResolution(res)
            r.AddMember(c)

        return r
开发者ID:0004c,项目名称:VTK,代码行数:19,代码来源:TestEnsemble.py

示例15: PlotSelectedData

def PlotSelectedData(data, state, view, text_init):
    nb_sources = 0
    for i in range(data.GetPointData().GetNumberOfArrays()):
        if data.GetPointData().GetGlobalIds('Potentials-'+str(i)):
            nb_sources += 1
    view.GetRenderer().RemoveActor2D(text_init)
    chart = vtk.vtkChartXY()
    view.GetScene().RemoveItem(0)
    view.GetScene().AddItem(chart)
    chart.SetShowLegend(True)
    table = vtk.vtkTable()
    X = vtk.vtkDoubleArray(); X.SetName("X")
    if state:
        numPoints = data.GetNumberOfCells()
        chart.GetAxis(0).SetTitle('Current'); 
    else:
        numPoints = data.GetNumberOfPoints()
        chart.GetAxis(0).SetTitle('Potential'); 
    chart.GetAxis(0).SetRange(0,nb_sources)
    for j in range(nb_sources):
        X.InsertNextValue(j)
    table.AddColumn(X)
    for i in range(numPoints):
        Y = vtk.vtkDoubleArray()
        if state:
            Y.SetName("id"+str(data.GetCellData().GetGlobalIds('Indices').GetValue(i)))
        else:
            Y.SetName("id"+str(data.GetPointData().GetGlobalIds('Indices').GetValue(i)))
        for j in range(nb_sources):
            if state:
                Y.InsertNextValue(data.GetCellData().GetGlobalIds('Currents-'+str(j)).GetValue(i))
            else:
                Y.InsertNextValue(data.GetPointData().GetGlobalIds('Potentials-'+str(j)).GetValue(i))
        table.AddColumn(Y)
        # Now add the line plots
        line = chart.AddPlot(0)
        line.SetInput(table,0,i+1)
        line.SetColor(0,1,0)
        line.SetWidth(1.0)
    view.GetRenderWindow().Render()
开发者ID:agramfort,项目名称:openmeeg_viz,代码行数:40,代码来源:om_display.py


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