Insert a QTclVtkWidget. VTK is a high level 3D library written in C++ that can be scripted using Tcl . For detailed description have a look at the VTK documentation and the available literature.
Example for visualization of a 2D dataset in data1.vtk (surface.tcl)
# create pipeline # create a hue lookup table vtkLookupTable lut # blue to red lut SetHueRange 0.66667 0.0 lut Build # create black to white colormap vtkLookupTable lbw # black to white lbw SetHueRange 0 0.0 lbw SetSaturationRange 0 0 lbw SetValueRange 0 1 vtkStructuredPointsReader reader reader SetFileName "data1.vtk" reader Update #reader needed otherwise range 0..1 set valuerange [[reader GetOutput] GetScalarRange] set minv [lindex $valuerange 0] set maxv [lindex $valuerange 1] # puts "data range $minv .. $maxv" set dims [[reader GetOutput] GetDimensions] set dim1 [lindex $dims 0] set dim2 [lindex $dims 1] set dim3 [lindex $dims 2] # puts "dim1 = $dim1 dim2 = $dim2" # volgende echt nodig ... # vtkStructuredPointsGeometryFilter plane vtkImageDataGeometryFilter plane plane SetInput [reader GetOutput] # SetExtent not needed .. vtkWarpScalar warp warp SetInput [plane GetOutput] warp UseNormalOn warp SetNormal 0.0 0.0 1 warp SetScaleFactor 1 vtkCastToConcrete caster caster SetInput [warp GetOutput] vtkPolyDataNormals normals normals SetInput [caster GetPolyDataOutput] normals SetFeatureAngle 60 vtkPolyDataMapper planeMapper planeMapper SetInput [normals GetOutput] planeMapper SetLookupTable lut eval planeMapper SetScalarRange [[reader GetOutput] GetScalarRange] vtkTransform transform transform Scale 0.02 0.02 0.02 vtkActor dataActor dataActor SetMapper planeMapper dataActor SetUserMatrix [transform GetMatrix] renderer AddActor dataActor renderer SetBackground 1 1 1 set cam1 [renderer GetActiveCamera] $cam1 ParallelProjectionOff
data1.vtk is following:
data1.vtk could be a profile measurement for example. Your server may generate data1.vtk and update your screen when new measurements are available.
# vtk DataFile Version 2.0 2D scalar data ASCII DATASET STRUCTURED_POINTS DIMENSIONS 20 20 1 ORIGIN -10.000 -10.000 0.000 SPACING 1.000 1.000 1.000 POINT_DATA 400 SCALARS scalars float LOOKUP_TABLE default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 1.0 1.0 0.5 0.0 0.0 2.0 4.0 6.0 6.0 6.0 6.0 4.0 2.0 0.0 0.0 0.5 1.0 1.5 1.5 1.5 1.5 1.0 0.5 0.0 0.0 2.0 4.0 6.0 8.0 8.0 6.0 4.0 2.0 0.0 0.0 0.5 1.0 1.5 2.0 2.0 1.5 1.0 0.5 0.0 0.0 2.0 4.0 6.0 8.0 8.0 6.0 4.0 2.0 0.0 0.0 0.5 1.0 1.5 2.0 2.0 1.5 1.0 0.5 0.0 0.0 2.0 4.0 6.0 6.0 6.0 6.0 4.0 2.0 0.0 0.0 0.5 1.0 1.5 1.5 1.5 1.5 1.0 0.5 0.0 0.0 2.0 4.0 4.0 4.0 4.0 4.0 4.0 2.0 0.0 0.0 0.5 1.0 1.0 1.0 1.0 1.0 1.0 0.5 0.0 0.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 2.0 0.0 0.0 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
Here are the corresponding slot functions.
typedef struct // (todo: define your data structure here) { int xangle; } DATA; static int slotInit(PARAM *p, DATA *d) { if(p == NULL || d == NULL) return -1; d->xangle = 0; pvDownloadFile(p,"data1.vtk"); //... pvVtkTclScript(p,VtkTclWidget1,"surface.tcl"); pvVtkTclPrintf(p,VtkTclWidget1,"dataActor RotateX %d",0); pvVtkTclPrintf(p,VtkTclWidget1,"dataActor RotateY %d",0); pvVtkTclPrintf(p,VtkTclWidget1,"renderer Render"); pvVtkTclPrintf(p,VtkTclWidget1,"reader Modified"); pvVtkTclPrintf(p,VtkTclWidget1,"reader Update"); pvVtkTclPrintf(p,VtkTclWidget1,"renderer Render"); //... return 0; } static int slotSliderEvent(PARAM *p, int id, DATA *d, int val) { if(p == NULL || id == 0 || d == NULL || val < -1000) return -1; if(id == Slider1) { int delta; delta = (val-50)*3 - d->xangle; d->xangle += delta; pvVtkTclPrintf(p,VtkTclWidget1,"reader SetFileName \"data1.vtk\""); pvVtkTclPrintf(p,VtkTclWidget1,"reader Modified"); pvVtkTclPrintf(p,VtkTclWidget1,"reader Update"); pvVtkTclPrintf(p,VtkTclWidget1,"dataActor RotateX %d",delta); pvVtkTclPrintf(p,VtkTclWidget1,"renderer Render"); } return 0; }