[vtkusers] How to use vtkAngleWidget only once ?

David Doria daviddoria at gmail.com
Fri Aug 3 10:58:25 EDT 2012


On Fri, Aug 3, 2012 at 10:54 AM, yarram <somasekhar.vit at gmail.com> wrote:
> Here is my code that is placed in MouseMoveEvent of callback class:
>
> if(this->readyAngle == 1)
>         {
>                 vtkSmartPointer<vtkAngleRepresentation2D> rep =
> vtkSmartPointer<vtkAngleRepresentation2D>::New();
>                 rep->ArcVisibilityOff();
>
>                 vtkSmartPointer<vtkAngleWidget> angleWidget =
> vtkSmartPointer<vtkAngleWidget>::New();
>                 angleWidget->SetRepresentation(rep);
>                 angleWidget->SetInteractor(iren);
>                 angleWidget->CreateDefaultRepresentation();
>
>                 angleWidget->On();
>
>                 iren->Start();
>         }
>
> And I use the following code to deactivate the widget in
> LeftButtonReleaseEvent:
>
> if(this->readyAngle == 1)
> {
>         angleWidget->Off();
>         this->readyAngle = 0;
> }
>
> And the variable "this->readyAngle" equal to 1, when a button is pressed.
> The widget is working only when the last statement "iren->Start();" is used.
> And I want to deactivate the widget immediately after I use the widget for
> first time. Please help me.

How are you getting into the MouseMoveEvent if you haven't already
started the interactor? This is why *fully compilable* code is always
important when helping with problems.

The typical design is to start the interactor at the very "beginning"
of the program, and use the "event loop" (callback mechanism or
subclass function reimplementations) to implement the program logic.

David



More information about the vtkusers mailing list