[vtkusers] need urgent help (picking with vtkPropPicker)
Jan-Gerrit Drexhage
jdrexhage at wiwi.uni-bielefeld.de
Tue Mar 25 17:40:00 EST 2003
Hello,
i have a problem to get the exact pointcoordinates from picking from a
glyph/Spike and time is running out for me.
public class SpikeMaker{
vtkSphereSource mySphereGlyph;
vtkConeSource myConeGlyph;
vtkCylinderSource myCylinderGlyph;
vtkGlyph3D myGlyph;
vtkPoints mySpikePoints;
vtkPolyDataMapper mySpikeMapper;
vtkPolyData mySpiker;
vtkActor mySpikeActor;
vtkActor myGlypher;
vtkPolyDataMapper myGlyphMapper;
vtkPolyDataMapper mySphereGlyphMapper, myConeGlyphMapper,
myCylinderGlyphMapper;
vtkProperty mySphereProps, myConeProps, myCylinderProps;
VTKmyFrame vmf;
vtkProperty prop;
double rad = 0.04;
public SpikeMaker(double[][] give){
setCubeGlyph(give);
}
protected void setCubeGlyph(double[][] cylinder){
myGlyph = new vtkGlyph3D();
mySpikePoints = new vtkPoints();
mySpikeMapper = new vtkPolyDataMapper();
mySpiker = new vtkPolyData();
for (int k = 0; k < cylinder.length; k++) {
mySpikePoints.InsertPoint(k, cylinder[k]);
};
mySpiker.SetPoints(mySpikePoints);
mySpikeMapper = new vtkPolyDataMapper();
mySpikeMapper.SetInput(mySpiker);
mySpikeActor = new vtkActor();
mySpikeActor.SetMapper(mySpikeMapper);
myGlypher = new vtkActor();
myGlyphMapper = new vtkPolyDataMapper();
myCylinderGlyph = new vtkCylinderSource();
myCylinderGlyph.SetRadius(rad);
myCylinderGlyph.SetHeight(rad);
myCylinderGlyph.SetResolution(4);
myCylinderGlyphMapper = new vtkPolyDataMapper();
myCylinderGlyphMapper.SetInput(myCylinderGlyph.GetOutput());
myGlyph = new vtkGlyph3D();
myGlyph.SetInput(mySpiker);
myGlyph.SetSource(myCylinderGlyph.GetOutput());
myGlyphMapper.SetInput(myGlyph.GetOutput());
myGlypher.SetMapper(myGlyphMapper);
prop = myGlypher.GetProperty(); //for coloring
}
I used this picked method, though it is just the picking itself, how can I
read out now which point (if there is a point under the mouse) I selected?
vtkIdType and a reference on the classname (ie SpikeMaker[0] or
SpikeMaker[1] as it is generated in an other class) as result would be
enough.
void picked() {
vtkPropPicker picker = new vtkPropPicker();
System.out.println("Selection point: ("+ lastX +", "+ lastY);
picker.PickProp(lastX, vtkpane.GetRenderWindow().GetSize()[1]-lastY,
vtkpane.GetRenderer());
/*
myvtkProp = picker.GetProp();
vtkActor actor = picker.GetActor();
*/
}
Many thanks in advance!
~Jan
More information about the vtkusers
mailing list