[vtkusers] How to do picking action with vtkCellPicker on multiples vtkDataSet?

Leguay Romain romain.leguay at etu.u-bordeaux1.fr
Wed Jun 15 04:22:06 EDT 2011


Thanks David,
I think I need some glasses....
I have again some difficulties to do the picking. My soft doesn't go inside my callback function.
I put my code if anyone found some errors inside it:
@Override
	public IZone computeOperator() {
		getPicker();
		picker.RemoveAllObservers();
		picker.AddObserver("EndPickEvent", this, "pickerFunction");

		return null;
	}

public void pickerFunction() {
		if (picker.GetCellId() < 0) {
			Logger.log(Activator.getDefault(), IExtendedStatus.DEBUG,
					"Aucune zone sélectionnée");
		} else {
			
			vtkDataSet dataSetPicked = picker.GetDataSet();
			IZone currentZone = null;
			for (IZone zone : dataSet.getZones()) {
				if (dataSetPicked == zone.getVtkDataSet()) {
					currentZone = zone;
					break;
				}
			}

			mapper = new VtkMapper(currentZone);
			mapper.getVtkMapper().ScalarVisibilityOff();

			vtkActor actor = new vtkActor();
			actor.SetMapper(mapper.getVtkMapper());
			actor.GetProperty().SetColor(colorDataSetPicked.getR(),
					colorDataSetPicked.getG(), colorDataSetPicked.getB());
			actor.GetProperty().SetOpacity(colorDataSetPicked.getAlpha());
			setVtkProp3D(actor);
		}
	}


@Override
	public void applyOperator(IDataSet dataSet, vtkRenderer renderer) {
                //Add an actor of my model. on my vtkRender
		MeshPlotTest meshPlot = new MeshPlotTest();
		Collection<IDataSet> dataSetList = new ArrayList<IDataSet>(1);
		dataSetList.add(dataSet);
		meshPlot.applyPlot(dataSetList, renderer);
		
               //Add the picking
		IOperator operator = new PickingOperator();
		ColorRGBA colorPicked = new ColorRGBA(1, 0, 0, 1);
		((PickingOperator)operator).setDataSet(dataSet);
		((PickingOperator)operator).setColorDataSetPicked(colorPicked);
		operator.computeOperator();
		
		getCanvas().getIren().SetPicker(((PickingOperator)operator).getPicker());
	}



Does anyone know why my picking doesn't work?

Thanks,

Romain


Le Mardi 14 Juin 2011 18:02 CEST, David Gobbi <david.gobbi at gmail.com> a écrit: 
 
> Hi Romain,
> 
> Have you looked at the methods that vtkCellPicker inherits from vtkPicker?
> 
> GetDataSet()
> GetMapper()
> GetProp3D()
> GetPickPosition()
> 
>  - David
> 
> 
> On Tue, Jun 14, 2011 at 9:38 AM, Leguay Romain
> <romain.leguay at etu.u-bordeaux1.fr> wrote:
> > Hello everyone!
> > I display multiple vtkDataSet on my renderer. I try to do a picking and
> > display witch vtkDataSet I click. I try to do this with a vtkCellPicker but
> > I can just get the selected point and the cellId.
> > I don't know how to proceed unless testing for each cell contains my point.
> > Has anyone got better ideas?
> >
> > Thanks,
> >
> > Romain
 
 
 
 




More information about the vtkusers mailing list