[vtkusers] vtkChartXY SetTitle problem and vtk Interactor problem
Wang James
jameszbw at googlemail.com
Fri Jun 14 08:14:58 EDT 2013
Hello guys,
I am using ActiViz.NET 5.8.0 32-bit in VB.NET <http://vb.net/> (2008). I
met some problems related to vtkChartXY and vtkStructuredGrid on the
following code.
The code reads data from a file into a vtkTable, and then either plot a
XY-graph (case "1D" as in the code) or XYZ surface plot (case "2D" ). There
is only one plot window in the VB form. The code works but not perfect,
showing following problems.
Problem 1: For XY-plot (Case "1D" as in code below), I am NOT able to set
titles for the AXIS. I have expected to use:
chart.GetAxis(0).SetTitle("my label")
to set axis title following examples in C#. Oddly, there is NO such
SetTitle function when I tried in my VB.NET <http://vb.net/>. I have no
idea why this happen. Will it be a bug of Activiz.NET for
VB.NET<http://vb.net/>?
Or they change the function name to some other in VB.NET <http://vb.net/>
release?
Problem 2: For XYZ plot (Case 2D), the plot is interactive if it was called
before XY plot (Case 1D). However, the xyz plot will be frozen (i.e., NOT
interactive ) if I it was called after calling XYplot (Case 1D).
How to fix this?
I hope you guys can help me through. Thanks
Rgds,
James
============================== CODE in VB.NET <http://vb.net/>
============================
Private Sub drawplot(ByVal vtkPlotmode As String)
Dim reader As New vtkDelimitedTextReader
reader.SetFileName(vtkDataSourceFile)
reader.SetDetectNumericColumns( True)
reader.SetFieldDelimiterCharacters( " ")
reader.MergeConsecutiveDelimitersOn() 'Important, treat multiple
space as one
reader.SetHaveHeaders( True) 'Negletct first line, header
reader.Update()
'Read data into table of vtk
Dim table As New vtkTable
table = reader.GetOutput()
Select Case vtkPlotmode
Case "1D" 'xy plot
Dim view As New vtkContextView
view.GetRenderer.SetBackground(1, 1, 1)
view.SetRenderWindow(RenderWindowControl1.RenderWindow)
'Chart
Dim chart As vtkChartXY
chart = vtkChartXY.[New]
view.GetScene.AddItem(chart)
'Dim xLable As New vtkStringArray
'xLable.SetNumberOfValues(1)
'xLable.SetValue(0, "x")
chart.SetShowLegend( True)
'Set title
'chart.GetAxis(0).SetTitle("Intensity")
'Add line (type:0)
Dim line1 As vtkPlot = chart.AddPlot(0)
line1.SetInput(table, vtkXcolIndex - 1, vtkYcolIndex - 1)
line1.SetColor(0, 0, 255, 255)
line1.SetWidth(1.5)
view.Render()
Case "2D" 'xyz plot
'convert vtktable to vtkStructuredGridData
Dim structGrid As New vtkStructuredGrid
Dim convert1 As New vtkTableToStructuredGrid
convert1.SetInput(table)
convert1.SetOutput(structGrid)
convert1.SetWholeExtent(0, vtk2D_X_Extents, 0,
vtk2D_Y_Extents, 0, vtk2D_Z_Extents)
convert1.SetXColumn(table.GetColumnName(vtkXcolIndex - 1))
convert1.SetYColumn(table.GetColumnName(vtkYcolIndex - 1))
convert1.SetZColumn(table.GetColumnName(vtkZcolIndex - 1))
convert1.Update()
'Save and check convert1 is right with Paraview. Tested,
result ok
'Dim writer1 As New vtkStructuredGridWriter
'writer1.SetFileName("C:\test.vts")
'writer1.SetInput(structGrid)
'writer1.Write()
'MsgBox("writed.")
'Visualize mapper
Dim mapper As New vtkDataSetMapper
mapper.SetInputConnection(structGrid.GetProducerPort)
mapper.SetInput(structGrid)
'Actor
Dim actor1 As New vtkActor
actor1.SetMapper(mapper)
actor1.SetScale(30, 30, 1)
'render window
Dim ren1 As vtkRenderer
ren1 = vtkRenderer.[New]
Dim renWin1 As vtkRenderWindow
renWin1 = vtkRenderWindow.[New]
renWin1 = RenderWindowControl1.RenderWindow
ren1.AddActor(actor1)
renWin1.AddRenderer(ren1)
Dim interactor As vtkRenderWindowInteractor
interactor = vtkRenderWindowInteractor.[New]
renWin1.Render()
interactor.Start()
End Select
End Sub
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130614/8ca35d50/attachment.htm>
More information about the vtkusers
mailing list