Commit d302294a authored by David Gobbi's avatar David Gobbi

BUG: The vtkPicker and vtkAreaPicker were inconsistent in what they added to...

BUG: The vtkPicker and vtkAreaPicker were inconsistent in what they added to the Prop3Ds pick list (i.e. all hit props) vs. what they generated PickEvents for (only the hit props that were closer that any prop that had previously been hit during the pick).  Now, for all pickers, only one PickEvent is generated, and it is only generated for the hit prop that is closest to the camera.  In vtkRenderedAreaPicker, the PickEvent was moved to the end of the pick to make sure that Mapper, DataSet, etc. are set before it is generated.
parent 1512bd98
......@@ -35,7 +35,7 @@
#include "vtkPoints.h"
#include "vtkExtractSelectedFrustum.h"
vtkCxxRevisionMacro(vtkAreaPicker, "1.17");
vtkCxxRevisionMacro(vtkAreaPicker, "1.18");
vtkStandardNewMacro(vtkAreaPicker);
//--------------------------------------------------------------------------
......@@ -203,7 +203,6 @@ void vtkAreaPicker::DefineFrustum(double x0, double y0, double x1, double y1,
int vtkAreaPicker::PickProps(vtkRenderer *renderer)
{
vtkProp *prop;
int picked=0;
int pickable;
double bounds[6];
......@@ -257,7 +256,6 @@ int vtkAreaPicker::PickProps(vtkRenderer *renderer)
//cerr << "mapper ABFISECT" << endl;
if (this->ABoxFrustumIsect(bounds, dist))
{
picked = 1;
if ( ! this->Prop3Ds->IsItemPresent(prop) )
{
this->Prop3Ds->AddItem(static_cast<vtkProp3D *>(prop));
......@@ -284,8 +282,6 @@ int vtkAreaPicker::PickProps(vtkRenderer *renderer)
this->DataSet = NULL;
}
}
static_cast<vtkProp3D *>(propCandidate)->Pick();
this->InvokeEvent(vtkCommand::PickEvent,NULL);
}
}
}//mapper
......@@ -296,7 +292,6 @@ int vtkAreaPicker::PickProps(vtkRenderer *renderer)
//cerr << "imageA ABFISECT" << endl;
if (this->ABoxFrustumIsect(bounds, dist))
{
picked = 1;
if ( ! this->Prop3Ds->IsItemPresent(prop) )
{
this->Prop3Ds->AddItem(imageActor);
......@@ -308,8 +303,6 @@ int vtkAreaPicker::PickProps(vtkRenderer *renderer)
this->Mapper = mapper; // mapper is null
this->DataSet = imageActor->GetInput();
}
imageActor->Pick();
this->InvokeEvent(vtkCommand::PickEvent,NULL);
}
}
}//imageActor
......@@ -318,6 +311,16 @@ int vtkAreaPicker::PickProps(vtkRenderer *renderer)
}//for all parts
}//for all props
int picked = 0;
if (this->Path)
{
// Invoke pick method if one defined - prop goes first
this->Path->GetFirstNode()->GetViewProp()->Pick();
this->InvokeEvent(vtkCommand::PickEvent,NULL);
picked = 1;
}
// Invoke end pick method if defined
this->InvokeEvent(vtkCommand::EndPickEvent,NULL);
......
......@@ -36,7 +36,7 @@
#include "vtkBox.h"
#include "vtkImageActor.h"
vtkCxxRevisionMacro(vtkPicker, "1.98");
vtkCxxRevisionMacro(vtkPicker, "1.99");
vtkStandardNewMacro(vtkPicker);
// Construct object with initial tolerance of 1/40th of window. There are no
......@@ -106,11 +106,6 @@ void vtkPicker::MarkPicked(vtkAssemblyPath *path, vtkProp3D *prop3D,
// The point has to be transformed back into world coordinates.
// Note: it is assumed that the transform is in the correct state.
this->Transform->TransformPoint(mapperPos,this->PickPosition);
// Invoke pick method if one defined - actor goes first
prop3D->Pick();
this->InvokeEvent(vtkCommand::PickEvent,NULL);
}
// Perform pick operation with selection point provided. Normally the
......@@ -124,7 +119,6 @@ int vtkPicker::Pick(double selectionX, double selectionY, double selectionZ,
vtkCamera *camera;
vtkAbstractMapper3D *mapper = NULL;
double p1World[4], p2World[4], p1Mapper[4], p2Mapper[4];
int picked=0;
int *winSize;
double x, y, t;
double *viewport;
......@@ -385,8 +379,6 @@ int vtkPicker::Pick(double selectionX, double selectionY, double selectionZ,
if ( t < VTK_DOUBLE_MAX )
{
picked = 1;
double p[3];
p[0] = (1.0 - t)*p1World[0] + t*p2World[0];
p[1] = (1.0 - t)*p1World[1] + t*p2World[1];
......@@ -424,6 +416,16 @@ int vtkPicker::Pick(double selectionX, double selectionY, double selectionZ,
}//for all parts
}//for all actors
int picked = 0;
if (this->Path)
{
// Invoke pick method if one defined - prop goes first
this->Path->GetFirstNode()->GetViewProp()->Pick();
this->InvokeEvent(vtkCommand::PickEvent,NULL);
picked = 1;
}
// Invoke end pick method if defined
this->InvokeEvent(vtkCommand::EndPickEvent,NULL);
......
......@@ -35,7 +35,7 @@
#include "vtkPlane.h"
#include "vtkPoints.h"
vtkCxxRevisionMacro(vtkRenderedAreaPicker, "1.9");
vtkCxxRevisionMacro(vtkRenderedAreaPicker, "1.10");
vtkStandardNewMacro(vtkRenderedAreaPicker);
//--------------------------------------------------------------------------
......@@ -53,7 +53,7 @@ vtkRenderedAreaPicker::~vtkRenderedAreaPicker()
int vtkRenderedAreaPicker::AreaPick(double x0, double y0, double x1, double y1,
vtkRenderer *renderer)
{
int rc = 0;
int picked = 0;
vtkProp *propCandidate;
vtkImageActor *imageActor = NULL;
vtkAbstractMapper3D *mapper = NULL;
......@@ -78,12 +78,10 @@ int vtkRenderedAreaPicker::AreaPick(double x0, double y0, double x1, double y1,
// Software pick resulted in a hit.
if ( this->Path )
{
rc = 1;
picked = 1;
//invoke the pick event
propCandidate = this->Path->GetLastNode()->GetViewProp();
propCandidate->Pick();
this->InvokeEvent(vtkCommand::PickEvent,NULL);
//find the mapper and dataset corresponding to the picked prop
pickable = this->TypeDecipher(propCandidate, &imageActor, &mapper);
......@@ -142,11 +140,15 @@ int vtkRenderedAreaPicker::AreaPick(double x0, double y0, double x1, double y1,
}
}
}
// Invoke pick method if one defined - prop goes first
this->Path->GetFirstNode()->GetViewProp()->Pick();
this->InvokeEvent(vtkCommand::PickEvent,NULL);
}
this->InvokeEvent(vtkCommand::EndPickEvent,NULL);
return rc;
return picked;
}
//----------------------------------------------------------------------------
......
......@@ -39,7 +39,7 @@
#include "vtkCamera.h"
#include "vtkAbstractCellLocator.h"
vtkCxxRevisionMacro(vtkSurfacePicker, "1.14");
vtkCxxRevisionMacro(vtkSurfacePicker, "1.15");
vtkStandardNewMacro(vtkSurfacePicker);
//----------------------------------------------------------------------------
......@@ -343,13 +343,6 @@ double vtkSurfacePicker::IntersectWithLine(double p1[3], double p2[3],
// The position comes from the data, so put it into world coordinates
this->Transform->TransformPoint(this->MapperPosition, this->PickPosition);
// Legacy from vtkPicker: call Pick() on every prop that gets to here,
// even though the pick isn't yet complete.
// Whether or not a prop that is under the cursor gets to this point
// in the code depends on the order of the props in the Renderer.
prop->Pick();
this->InvokeEvent(vtkCommand::PickEvent, NULL);
}
return tMin;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment