Applying Actions
Actions are processes that can be applied to the images attached to cells within the container/image viewer. LEADTOOLS supports several standard or "built-in" actions and custom or "user-defined" actions.
Built-in Actions
LEADTOOLS supports the following built-in actions:
Window Leveling: Maps grayscale intensities using a user defined color map (LUT).
Alpha: A window-leveling factor used when the window leveling lookup table is not linear.
Scale: Increases or decreases the size of the image in the cell.
Offset: Changes the offset of the image within the cell.
Magnifying Glass: Magnifies the image in the cell.
Stack: Scrolls the images within the cell.
Annotation ruler: adds a ruler object to the cell.
Annotation rectangle: adds a rectangle object to the cell.
Annotation ellipse: adds an ellipse object to the cell.
Annotation angle: adds an angle object to the cell.
Annotation highlight: adds a highlight object to the cell.
Annotation arrow: adds an arrow object to the cell.
Annotation text: adds a text object to the cell.
Rectangle region: adds a rectangle region to the cell.
Square region: adds a square region to the cell.
Elliptical region: adds an elliptical region to the cell.
Circular region: adds a circular region to the cell.
Free hand region: adds a free hand region to the cell.
Polygon region: adds a polygon region to the cell.
Magic Wand region: adds a magic wand region to the cell.
Color Range region: adds a color range region to the cell.
Custom Actions
Custom actions are completely controlled by the user, including any mouse movement and keystroke association. These are handled through the LImageViewer::ActionCallback function. This callback function must be set by setting LImageViewer::EnableActionCallback to TRUE.
Adding Actions
Regardless of whether the action is built-in or custom, any action must be added to a container before it can be used. To add an action to a container, call LImageViewer::AddAction. Since the Image Viewer supports custom actions, there is no limit on how many actions a container can have. However, an action cannot be added to a container twice. To determine how many actions are currently in a particular container, call LImageViewer::GetActionCount.
Next, assign a mouse button or a keyboard key to the action. To assign a mouse button to the action, call LImageViewer::SetAction, and pass the action and associated mouse button values together. An action can only be assigned to one mouse button.
To assign a keyboard shortcut to the action call LImageViewer::SetKeyboardAction. To get the current keystroke combination associated with a specific action, call LImageViewer::GetKeyboardAction.
Once the action has been added, it is considered "active". To determine whether a specific action is active, call LImageViewer::IsActionActive. To check whether the button or the flag is valid to be assigned to the specific action, use the function LImageViewer::IsButtonValid.
The LImageViewer::SetAction function also lets the user decide whether the applied action will affect one cell, selected cells, or all cells in the container, and whether the action is applied during mouse movement or after mouse button release. You can also retrieve the assigned mouse button and flags to the specified action by calling the function LImageViewer::GetActionButton.
Action Properties
Each action has both general and specific properties. The general properties, like the cursor, are common to all cells within the container. These are applied at the container level. Specific properties, such as the width used by the window level action, are used to manually change values used by the action. These are applied at the cell level. The properties used by each action are contained in an action-specific structure.
Action properties that apply to the entire container can be found in the DISPCONTAINERACTIONPROPS structure. Each of the action-specific structures contains a DISPCONTAINERACTIONPROPS structure, as well as other properties, related to the specific action. Some of the additional properties related to the specific properties are also applied at the container level and are therefore "general" properties, while others are applied at the cell level and are therefore "specific" properties.
The current properties associated with a specific action can be retrieved by calling LImageViewer::GetActionProperties. To change the properties for a specific action, call LImageViewer::SetActionProperties. When an action is no longer needed in a container, it can be removed by calling LImageViewer::RemoveAction.
How action works
Any action must be added to a container before it can be used. To add
an action to a container, call LImageViewer::AddAction.
Next, assign an action to a mouse button by calling LImageViewer::SetAction,
or assign an action to a keyboard key by calling LImageViewer::SetKeyboardAction.
For example, if
the “Window Level” action is assigned to the left mouse button, when the
user clicks and hold the mouse button, then drags in any directio,. the
brightness and contrast of gray image will be changed according to the
direction of drag.
LImageViewer::SetKeyboardAction
allows you to set a keystroke to imitate the mouse movement in any of
four ordinal directions. For example, assign the
key Shift + Left to initiate the same effect as dragging the mouse to
the left.
The following describes action behaviors when it is assigned to a mouse button:
Window level |
a. |
The user must click and hold the mouse to start the effect. Releasing the assigned mouse button ends the action. |
|
b. |
Dragging the mouse to the left decreases the center parameter. |
|
c. |
Dragging the mouse to the right increases the center parameter. |
|
d. |
Dragging the mouse upward decreases the width parameter. |
|
e. |
Dragging the mouse downward increases the width parameter. |
Alpha |
a. |
The user must click and hold the mouse to start the effect. Releasing the assigned mouse button ends the action. |
|
b. |
Dragging the mouse to the left increases the alpha factor. |
|
c. |
Dragging the mouse to the right decreases the alpha factor. |
Scale |
a. |
The user must click and hold the mouse to start the effect. Releasing the assigned mouse button ends the action. |
|
b. |
Dragging the mouse downward enlarges the image. |
|
c. |
Dragging the mouse upward shrinks the image. |
Magnify Glass |
The user must click and hold the mouse to start the effect. The magnify glass will appear. Dragging the mouse causes the magnify glass to move with the cursor. Releasing the assigned mouse button ends the action. |
|
Stack |
a. |
The user must click and hold the mouse to start the effect. Releasing the assigned mouse button ends the action. It’s better to assign the mouse wheel to the stack action. So if the user wheels up or down, the stack action will take effect. |
|
b. |
Dragging the mouse downward shows the next frame. |
|
c. |
Dragging the mouse upward shows the previous frame. |
Offset |
a. |
The user must click and hold the mouse to start the effect. Releasing the assigned mouse button ends the action. |
|
b. |
Dragging the mouse to the left moves the image to the left. |
|
c. |
Dragging the mouse to the right moves the image to the right. |
|
d. |
Dragging the mouse upward moves the image up. |
|
e. |
Dragging the mouse downward moves the image down. |
Rectangle Region |
The user must click and drag to create a rectangular region. |
|
Ellipse region |
The user must click and drag to create an elliptical region. |
|
Square region |
The user must click and drag to create a square region. |
|
Circle region |
The user must click and drag to create a circular region. |
|
Polygon region |
The user must click many times to create a polygonal region. On each the point the user must click, and after finishing the shape, the user must double-click to end the action and to complete the polygonal region. |
|
Free hand region |
The user must click and drag to create a custom region. |
|
Magic wand region |
a. |
The user must click and hold the mouse to start the effect and to assign the point that will be taken as a start point for the magic wand. Releasing the assigned mouse button ends the action. |
|
b. |
Dragging the mouse downward increases the magic wand threshold. |
|
c. |
Dragging the mouse upward decreases the magic wand threshold. |
Color range region |
a. |
The user must click and hold the mouse to start the effect. When the user releases the assigned mouse button, the action will end. |
|
b. |
Dragging the mouse left/right increases/decreases the lower tolerance. |
|
c. |
Dragging the mouse left/right increases/decreases the upper tolerance. |
Rectangle Annotation |
The user must click and drag to create a rectangular annotation object. |
|
Ellipse Annotation |
The user must click and drag to create an elliptical annotation object. |
|
Arrow Annotation |
The user must click and drag to create the arrow annotation object. |
|
Text Annotation |
The user must click on the area where the text object must be placed and write the text, and then press Enter to finish. Pressing Ctrl + Enter causes the editor to create a new line. |
|
Angle Annotation |
The user must click three times to create the angle annotation object; first click to create the angle base, the second and the third to create the edge of the angle. |
|
Ruler annotation |
The user must click and drag to create the ruler annotation object. |
|
Highlight annotation |
The user must click and drag to create the highlight annotation object. |
For more information on the properties of the various actions, refer to the structures listed below: