[vtkusers] How to remove points/handle from one vtkDistanceWidget or vtkAngleWidget?

Arnaud GELAS arnaud_gelas at hms.harvard.edu
Tue Jul 20 16:29:55 EDT 2010


Karthik,

Thanks! your example works fine, however that was not what I had meant...

I would like to reinitialize the widget, i.e. Once I make one 
measurement (as it is now in the example), I would like to be able to 
make another measurement without having to drag and drop the two nodes 
(after calling one method) I can click on the screen.

Can you drive me how to proceed, please?

I could not find the way to remove the two points from the scene...


Thanks,
Arnaud


On 07/20/2010 01:47 PM, Karthik Krishnan wrote:
> Arnaud:
>
> The attached example works.
>
> Please make sure you "git pull" now. I just fixed a bug (thanks to 
> your use case) when the widget is defined prior to enabling it.
>
> I rearranged a few lines in your example code, (removed the 
> interactor->Start() being called twice etc, added a prop so the camera 
> doesn't go out of whack), nothing significant.
>
> --------
>   commit d832206da3502f395281e447e28305d11ff301c6
>   Author: Karthik Krishnan <karthik.krishnan at kitware.com 
> <mailto:karthik.krishnan at kitware.com>>
>   Date:   Tue Jul 20 23:10:00 2010 +0530
>
>       ENH: The interactor must be set before enabling the widget.
>
>       When the method WidgetIsDefined() is called (ie the widget is 
> defined
>       programmatically) and then the method SetEnabled is invoked, we run
>       into a bug, in that the internal HandleWidgets are enabled without
>       having their interactors set. Hence propagate the interactor 
> from self
>       into the child widgets always.
> ---------
>
> Thanks for the feedback.
> --
> karthik
>
>
> On Tue, Jul 20, 2010 at 9:52 PM, Arnaud GELAS 
> <arnaud_gelas at hms.harvard.edu <mailto:arnaud_gelas at hms.harvard.edu>> 
> wrote:
>
>     Hi Karthik,
>
>     Thanks for looking at it!
>
>     I have been trying it (by modifying the example from the wiki),
>     but it's still not clear to me what has changed in the behaviour
>     of the window? and how to "reinitialize the widget"?
>     I guess I may have made mistakes in the code. Can you have a look
>     and tell me what I am doing wrong, please?
>
>     Thanks,
>     Arnaud
>
>
>
>     On 07/19/2010 02:44 PM, Karthik Krishnan wrote:
>>     Arnaud:
>>
>>     I just pushed a bunch of changes. The class vtkDistanceWidget,
>>     vtkAngleWidget and vtkBiDimensionalWidget all now have the
>>     following two methods :
>>
>>       // Description:
>>       // Set the state of the widget to "defined" (in case its widget
>>     and its
>>       // representation were initialized programmatically). This must
>>     generally
>>       // be followed by a Render() for things to visually take effect.
>>       virtual void WidgetIsDefined();
>>
>>       // Description:
>>       // Has the widget been defined completely yet ? ie. Have the
>>     end points been
>>       // laid and is it in Manipulate mode ?
>>       virtual int IsWidgetDefined();
>>
>>
>>     So what you can do is :
>>
>>      representation->SetPoint1WorldPosition(...)
>>      representation->SetPoint2WorldPosition(...)
>>      distanceWidget->SetRepresentation(representation);
>>      distanceWidget->EnabledOn();
>>      distanceWidget->WidgetIsDefined();
>>      distanceWidget->Render();
>>
>>     Internally, the WidgetIsDefined() call, sets the widget state to
>>     "manipulate", releases any focus that it may have grabbed during
>>     the define phase, builds the representation and shows/hides the
>>     handles properly.
>>
>>     The same is the case for the other 2 widgets....
>>
>>     If I can slowly add it to a good number of widgets (several
>>     widgets have a "define" phase during which their query is
>>     invalid), then I'd like to make this a default no-op method in
>>     the base class, vtkAbstractWidget, so that subclasses can
>>     implement it in whatever way they choose to.
>>
>>     Please let me know if you have any issues.
>>
>>     Thanks
>>     --
>>     karthik
>>
>>
>>     On Fri, Jul 16, 2010 at 12:38 AM, Karthik Krishnan
>>     <karthik.krishnan at kitware.com
>>     <mailto:karthik.krishnan at kitware.com>> wrote:
>>
>>         Yes. That's missing and its an often needed feature. I'll add
>>         this functionality in tomorrow Arnaud.
>>
>>         Thanks
>>         --
>>         karthik
>>
>>
>>         On Thu, Jul 15, 2010 at 7:37 PM, Arnaud GELAS
>>         <arnaud_gelas at hms.harvard.edu
>>         <mailto:arnaud_gelas at hms.harvard.edu>> wrote:
>>
>>             Actually I am more interested in being able to
>>             reinitialize these widgets.
>>             For instance, when you want to measure different objects
>>             that are far apart, and I guess it would be faster to
>>             reinitialize the widget than to drag these points to
>>             another part of my image (quite far from here).
>>
>>             How should I proceed?
>>
>>             Thanks,
>>             Arnaud
>>
>>
>>             On 07/15/2010 09:56 AM, Karthik Krishnan wrote:
>>>             How can the widget exist in a valid state without its
>>>             end points ? Do you mean you want to re-define the
>>>             widget from start in response to a key press ?
>>>
>>>             Please let us know.
>>>
>>>             Thanks
>>>             --
>>>             karthik
>>>
>>>             On Thu, Jul 15, 2010 at 7:21 PM, Arnaud GELAS
>>>             <arnaud_gelas at hms.harvard.edu
>>>             <mailto:arnaud_gelas at hms.harvard.edu>> wrote:
>>>
>>>                 Hi all,
>>>
>>>                 I would like to be able to
>>>                  * delete points/handles from these widgets with a key
>>>                  * reinitialize these widgets without any
>>>                 points/handle on the screen.
>>>
>>>                 I could not figure out how to proceed?
>>>                 Is it possible with the existing code?
>>>
>>>                 Thanks,
>>>
>>>                 Best Regards,
>>>                 Arnaud
>>>                 _______________________________________________
>>>                 Powered by www.kitware.com <http://www.kitware.com>
>>>
>>>                 Visit other Kitware open-source projects at
>>>                 http://www.kitware.com/opensource/opensource.html
>>>
>>>                 Please keep messages on-topic and check the VTK FAQ
>>>                 at: http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>>                 Follow this link to subscribe/unsubscribe:
>>>                 http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>
>>
>>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100720/5a23fcd6/attachment.htm>


More information about the vtkusers mailing list