UserInteractionVisualTool class
In This Topic
Basic concepts
UserInteractionVisualTool is the base class for visual tools, which perform interaction between the user and
interactive object in
ImageViewer using input devices (like keyboard, mouse, etc).
The class allows to implement custom (user-defined) logic of interaction between a collection of interactive objects and the user.
The classes, which are derived from this class, are visual tools, like
AnnotationVisualTool,
RectangularSelectionTool,
CustomSelectionTool.
Basics concepts of the interactive communication model are:
- Interaction - changing of some object properties (size, location,...) using input devices (like keyboard, mouse etc).
- Interactive object - an object that implements IInteractiveObject interface with which is possible to communicate interactively.
IInteractiveObject interface defines the base properties of interactive object, necessary for organizing the interaction process:
- Interaction controller - an object that defines the logic of communication between some sets of interaction areas and interactive object (e.g. controller of type
RectangularObjectTransformer contains a logic of rectangular objects transformation as well as a set of interaction areas with help of which the current object is being transformed).
Interactive communication controllers implement IInteractionController interface and that provides them with the following properties:
- Interaction area - some area on an object using which the user communicates with interactive object (e.g. the point pulling which the object can be stretched or rotated).
The interaction area can be either invisible (e.g. the area using which is performed relocation of object) or
visible (e.g. rotation point, rotation assistant).
Every interaction area is derived from InteractionArea class and has the following features:
- Interaction visual tool - a class, which is derived from UserInteractionVisualTool class and provides the following functionality:
- storing of interactive objects collection
- displaying of interactive objects in the image viewer
- choosing of active object (interactive is currently in progress with)
- displaying of interaction areas of active interaction controller
- determining of active area and converting of events from input devices (like mouse etc) to the interaction events for transferring to the interaction controller of active object.
Basic working principles of interaction model
The interaction model work can be divided into 5 steps:
- The interaction visual tool gets the selected object and counted it as active object, the interaction visual tool gets the interaction controller from active object
and counted it as active interaction controller.
- The interaction visual tool performs call of UpdateInteractionAreas method for active interaction controller and gets a list of interaction areas using InteractionAreas property
of interaction controller. The interaction visual tool displays interaction areas over other interactive objects in image viewer.
- The interaction visual tool analyzes events coming from input devices (e.g. mouse button clicking, mouse pointer relocation) and determines the interaction area the user is working with.
Events from input devices are converted to the interaction events according to the type of interaction area and then are directed to the active interaction controller
using IInteractionController.OnInteraction(InteractionEventArgs) method.
- The interaction controller in OnInteraction method performs the logic of interaction between interaction area and interactive object.
For example: Interactive object supports rotation by implementing the interface of interactive object in which exist RotationAngle property.
After the controller receives the interaction event with rotation point (rotation point - interaction area) it will calculate rotation angle on which is necessary
to rotate the object and will change object's RotationAngle property for necessary angle.
- When the interaction controller changes any property, which varies object's state (e.g. Rotation angle), the object will generate StateChanged event
to which is subscribed the interaction visual tool.
The interaction visual tool will be performing the update of interactive areas in active interaction controller and then redrawing of interactive object and
interactive areas in image viewer.
Hierarchy of interactive objects interfaces
IInteractiveObject - the base interface, which defines general characteristics of all interactive objects.
IRectangularInteractiveObject - defines the rectangular object, which supports rotation.
IPointBasedInteractiveObject - defines the object, which consists from set of points.
Note: the fact that properties of interactive objects are described by hierarchy of interfaces, made possible to create interactive objects,
which could implement at once several interactive objects interfaces. For example, an object may support overpatching of its base points
(
IPointBasedInteractiveObject) as well as overpatching of its shape (stretching, compaction, rotation) using rectangular object interface
(
IRectangularInteractiveObject).
Hierarchy of interaction controllers
The interaction controllers are divided into 2 groups for convenience:
- builders - perform initial building of new object
- transformers - perform transformation of existing object
IInteractionController - the base interface, which defines general characteristics of all interactive communication controllers.
RectangularObjectBuilder - builder of objects implementing
IRectangularInteractiveObject interface.
RectangularObjectTransformer - transformer of objects implementing
IRectangularInteractiveObject interface.
Provides the ability to relocate, stretch, compress, rotate object.
PointBasedObjectPointBuilder - builder of objects implementing
IPointBasedInteractiveObject interface.
Provides the ability to construct an object by adding to it new points by mouse click.
PointBasedObjectFreehandBuilder - builder of objects implementing
IPointBasedInteractiveObject interface.
Provides the ability to construct an object by adding to it new points by mouse movement.
PointBasedObjectLineBuilder - builder of objects implementing
IPointBasedInteractiveObject interface.
Provides the ability to construct an object which consists from two points (line).
PointBasedObjectRectangularBuilder - builder of objects implementing
IPointBasedInteractiveObject interface.
Provides the ability to construct an object by scaling all its points.
PointBasedObjectPointTransformer - transformer of objects implementing
IPointBasedInteractiveObject interface.
Provides the ability to mark, relocate, remove, add object's points.
PointBasedObjectRectangularTransformer - transformer of objects implementing
IPointBasedInteractiveObject interface.
Provides the ability to relocate, stretch, compress, rotate object.
PointBasedObjectDistortionTransformer - transformer of objects implementing [IPointBasedInteractiveObject interface.
Provides the ability to apply distortion and skew.
CompositeInteractionController - the composite interaction controller, which can combine the work of multiple interaction controllers and is used to:
- integrate the functionality of multiple interaction controllers, which are working with one interactive object
- merge several controllers, which are working with different interactive objects and thus organize interaction with composite interactive object.
Hierarchy of interaction areas
The base class for all interaction areas is
InteractionArea class.
Interaction areas are divided into 3 groups for convenience:
- Points of interactive object:
- InteractionPoint - the interaction point in the shape of circle, characterized by the position and the radius.
This area is used as a point of changing the object size in most interaction controllers.
- InteractionRectangularPoint - the interaction point in the shape of rectangle, characterized by the position and the radius.
- InteractionPolygonPoint - the interaction point in the shape of rectangle (derived from InteractionRectangularPoint),
characterized by the index of object's point with which it is tied.
This area is used in controllers of IPointBasedInteractiveObject objects for interaction with the object's points.
- RotationPoint - the interaction area, which is derived from InteractionPoint and is used to perform object rotation.
- RotationAssistantArea - the interaction area that defines "rotation assistant" - area in the shape of circle divided into sectors,
using which can be performed the rotation of object on exact angle.
- Interaction areas connected with interactive object:
- InteractiveObjectArea - the interaction area that coincides with area of interactive object, which is defined by IInteractiveObject.IsPointOnObject(X,Y) method.
This area is used in some interaction controllers for the assignment of area using which is implemented changing of object position.
- InteractiveObjectBoundingBoxArea - the interaction area that coincides with bounding rectangle of interactive object.
This area is used in some interaction controllers for the assignment of area using which is implemented changing of object position.
- InteractiveObjectBoundingBoxSelection - the interaction area, which is derived from InteractiveObjectBoundingBoxArea.
This area is used in some interaction controllers for the designation of object's bounding rectangle area.
- Interaction areas connected with image viewer:
- ImageViewerArea - the area covering the whole image viewer. This area is used in builders for the assignment of object's building area.