[vtkusers] vtkSphereHandleRepresentation problem
Karthik Krishnan
karthik.krishnan at kitware.com
Tue Apr 15 12:31:04 EDT 2008
On Tue, Apr 15, 2008 at 7:38 AM, Greg Ushomirsky <gregus at gmail.com> wrote:
> Hi,
>
> I'm having a problem using vtkSphereHandleRepresentation class. I have
> a simple program that places the widget at the location of an existing
> actor. When I press "i", I expect to see the sphere and be able to
> move it.. However, what happens is (1) I don't see the sphere widget
> (2) the cursor changes into a hand the first time around, but, after
> I click on the middle of the actor (where the sphere handle should
> be), the cursor changes back into an arrow. After that, no matter how
> many times I press "i", it looks like the interaction doesn't start
> again. What am I doing wrong??
Nice catch.
There was indeed a bug in vtkSphereHandleRepresentation. Sorry about
that. I should've added a test when I committed the class.
The prop was getting culled away due to a bug in reporting the bounds
for the prop. This was just fixed CVS..
A test exercising it has also been added:
Testing/Cxx/Widgets/TestSphereHandleWidget.cxx
http://public.kitware.com/cgi-bin/viewcvs.cgi/Widgets/vtkSphereHandleRepresentation.cxx?sortby=date&view=log
http://public.kitware.com/cgi-bin/viewcvs.cgi/Widgets/vtkSphereHandleRepresentation.h?sortby=date&view=log
http://public.kitware.com/cgi-bin/viewcvs.cgi/Widgets/Testing/Cxx/TestSphereHandleWidget.cxx?sortby=date&view=log
-----
As you've figured out by now, I've added a
vtkPolygonalHandleRepresentation3D class that can represent arbitrary
polygonal shapes
as handles.
Setting the handle source to be the output of a vtkSphereSource
results in the same behaviour as using a
vtkSphereHandleRepresentation.
In addition the class "vtkPolygonalHandleRepresentation3D" is
integrated into the
PointPlacer framework in VTK, thereby allowing you to place contraints
on the placement of the handles. See the test:
TestPolygonalRepresentationHandleWidget.cxx which constrains the
handle placement on the surface of the terrain.
Thanks
--
karthik
>
> Below is an excerpt from the program I use. Note that if I create a
> vtkPointHandleRepresentation instead of a
> vtkSphereHandleRepresentation, or even if I make a
> vtkPolygonalHandleRepresentation and feed it a sphere source, the
> interaction proceeds as it should, or at least the widget is visible.
> This leads me to believe that there may be a problem with
> vtkSphereHandleRepresentation.
>
> Also, it would be helpful to have either an example of the class being
> used, or at least a regression test that can be used as a basis for
> new code. Do these exist??
>
> Thanks in advance,
> Greg
>
> =======code===============
> #include "vtkCamera.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkPolyData.h"
> #include "vtkPointSource.h"
> #include "vtkRenderer.h"
> #include "vtkActor.h"
> #include "vtkProperty.h"
> #include "vtkSmartPointer.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkParticleReader.h"
> #include "vtkCylinderSource.h"
> #include "vtkPointHandleRepresentation3D.h"
> #include "vtkSphereHandleRepresentation.h"
> #include "vtkPolygonalHandleRepresentation3D.h"
> #include "vtkHandleWidget.h"
> #include "vtkIndent.h"
>
> int main( int argc, char *argv[] )
> {
> vtkSmartPointer<vtkRenderer> ren = vtkRenderer::New();
> vtkSmartPointer<vtkRenderWindow> renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren);
>
> vtkSmartPointer<vtkRenderWindowInteractor> iren =
> vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
>
> vtkSmartPointer<vtkCylinderSource> src = vtkCylinderSource::New();
> vtkSmartPointer<vtkPolyDataMapper> mapper = vtkPolyDataMapper::New();
> mapper->SetInputConnection(src->GetOutputPort());
>
> vtkSmartPointer<vtkActor> actor = vtkActor::New();
> actor->SetMapper(mapper);
>
> ren->AddActor(actor);
>
> //THIS WIDGET DOES NOT WORK
> vtkSmartPointer<vtkSphereHandleRepresentation> handleRep =
> vtkSphereHandleRepresentation::New();
>
> //BUT THIS ONE SEEMS TO WORK JUST FINE
> //vtkSmartPointer<vtkPointHandleRepresentation3D> handleRep =
> vtkPointHandleRepresentation3D::New();
>
> //OR EVEN THIS ONE
> //vtkSmartPointer<vtkPolygonalHandleRepresentation3D> handleRep =
> vtkPolygonalHandleRepresentation3D::New();
> //vtkSmartPointer<vtkSphereSource> sph = vtkSphereSource::New();
> //sph->SetThetaResolution(16); sph->SetPhiResolution(8); sph->SetRadius(0.1);
> //handleRep->SetHandle(sph->GetOutput());
>
>
> handleRep->PlaceWidget(actor->GetBounds());
> vtkHandleWidget *handleWidget = vtkHandleWidget::New();
> handleWidget->SetInteractor(iren);
> handleWidget->SetRepresentation(handleRep);
>
>
> ren->SetBackground(0,0,0);
> iren->Initialize();
>
> renWin->Render();
>
> iren->Start();
>
> return 0;
> }
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list