VTK:VTK Entity Interaction Widget

Source: Internet
Author: User

Before VTK interactively using interactive styles and adding listening events two ways to extend VTK interaction. Recently contacted the widget that VTK used to complete the interaction. Because physical parts are provided, the interaction is more user-friendly. VTK's widget class was redesigned from the VTk5.1. The separation of interaction and entity expression is realized. To create a VTK widget, you need to complete the following steps:

1 Instantiating Widgets

2 instantiating an appropriate geometric expression

3 You can add interaction to widge with the Add listener event (each widget component has default events and handling methods)

4 the part must be activated or the part will not appear in the window


The widget has its own widget event (vtkWidgetEvent.h). Some widget events are listed here:

NoEvent
Select
Endselect
Delete
Translate
Endtranslate
Scale
Endscale
Resize

The conversion between Vtkevent and Widgetevent takes the Vtkwidgeteventtranslator class. The class can be obtained through the Geteventtranslator function.

There are two important functions in the Vtkwidgeteventtranslator class:

void Settranslation (unsigned long vtkevent, int modifier, char keycode, int repeatcount, const char *keysym, unsigned lon g widgetevent) int removetranslation (unsigned long vtkevent, int modifier, char keycode, int repeatcount, char *keysym)

One of the two functions is to add a vtkevent event and turn it into a widget event, and the other is to delete the event. All two functions have overloaded versions and only the longest are listed here. You can do this by using these two functions:

1. Delete the VTK event and WIDGWT event correspondence so that the widget event will not be monitored.

2. Change the correspondence between VTK events and widget events such as: vtkevent::leftbuttionpressevent corresponding widgetwvwnt::select can be changed to Vtkevent:: Keypressevent Correspondence Widgetwvwnt::select


The handler function for the Widgetevent event is a protected static function. The corresponding processing has been realized in the inside. The widgetevent is associated with the handler function within the general part through Vtkwidgetcallbackmapper.

For example: Select-------selectaction ();

Delete-------deleteaction ();


Widget->addobserver (Vtkcommand::interactionevent, seedcallback);
Use this function to add new events and callback functions to the part.

VTK:VTK Entity Interaction Widget

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.