[vtkusers] vtkDistanceWidget handles bug in VTK 5.10.1 ?
Vincent Gratsac
vincent.gratsac.lists at gmail.com
Wed Aug 14 13:18:40 EDT 2013
Hi all,
I'm trying to use vtkDistanceWidget but it seems that there is a problem
with its handles.
When I first draw the vtkDistanceWidget, all is ok. Handles are placed
at the two extremitites of the green line.
I can interact with the view in order to do some rotations or zooms on
the render window.
But if i click again on one of the handles and move it to another place,
then when trying again to interact with the view, all objects will move
correctly except the handles that I previously moved.
An important point is that I can't reproduce this behavior with VTK
5.4.2, but unfortunately, I can't use this version for my software
development.
Maybe someone already experienced this and found a solution...
Here is the code that I reproduces the problem :
> #include "vtkDistanceWidget.h"
> #include "vtkDistanceRepresentation2D.h"
> #include "vtkSphereSource.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkCommand.h"
> #include "vtkInteractorEventRecorder.h"
> #include "vtkRegressionTestImage.h"
> #include "vtkDebugLeaks.h"
> #include "vtkCoordinate.h"
> #include "vtkMath.h"
> #include "vtkHandleWidget.h"
> #include "vtkPointHandleRepresentation2D.h"
> #include "vtkAxisActor2D.h"
> #include "vtkProperty2D.h"
>
>
> // The actual test function
> int main( int argc, char *argv[] )
> {
> // Create the RenderWindow, Renderer and both Actors
> //
> vtkRenderer *ren1 = vtkRenderer::New();
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> renWin->AddRenderer(ren1);
>
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
>
> // Create a test pipeline
> //
> vtkSphereSource *ss = vtkSphereSource::New();
> vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
> mapper->SetInput(ss->GetOutput());
> vtkActor *actor = vtkActor::New();
> actor->SetMapper(mapper);
>
> // Create the widget and its representation
> vtkPointHandleRepresentation2D *handle =
> vtkPointHandleRepresentation2D::New();
> handle->GetProperty()->SetColor(1,0,0);
> handle->GetSelectedProperty()->SetColor(0,0,1);
> // handle->SetActiveRepresentation(110);
>
> vtkDistanceRepresentation2D *rep = vtkDistanceRepresentation2D::New();
> rep->SetHandleRepresentation(handle);
>
> rep->GetAxis()->SetNumberOfMinorTicks(4);
> rep->GetAxis()->SetTickLength(9);
> rep->GetAxis()->SetTitlePosition(0.2);
>
> vtkDistanceWidget *widget = vtkDistanceWidget::New();
> widget->SetInteractor(iren);
> widget->CreateDefaultRepresentation();
> widget->SetRepresentation(rep);
>
> // Add the actors to the renderer, set the background and size
> //
> ren1->AddActor(actor);
> ren1->SetBackground(0.1, 0.2, 0.4);
> renWin->SetSize(300, 300);
>
> // render the image
> //
> iren->Initialize();
> renWin->Render();
> widget->On();
>
> iren->Start();
>
> ss->Delete();
> mapper->Delete();
> actor->Delete();
> handle->Delete();
> rep->Delete();
> widget->Off();
> widget->Delete();
> iren->Delete();
> renWin->Delete();
> ren1->Delete();
>
> return 0;
> }
More information about the vtkusers
mailing list