0% found this document useful (0 votes)
53 views15 pages

Unit 5 CG

The document discusses various computer input devices and how they work. It describes different types of locators, selectors, and valuators that provide positional or selected information to the computer. It also covers how to enable and disable different classes of input devices and algorithms for reading from locators and valuators.

Uploaded by

Sathish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views15 pages

Unit 5 CG

The document discusses various computer input devices and how they work. It describes different types of locators, selectors, and valuators that provide positional or selected information to the computer. It also covers how to enable and disable different classes of input devices and algorithms for reading from locators and valuators.

Uploaded by

Sathish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

 Computer graphics gives dimensions for a communication between the user and the

machine.
 Interaction is the two way process. It is desirable to allow the user to respond to this
information.
 The most common form of computer output is a string of character printed on the
page (or) on the surface of the CRT Terminal.
 The corresponding form of input is also a stream of character coming from a
keyboard.
 Computer graphics extends the form of output to include two dimensional images,
lines, polygons, arcs, colors.
 The graphics display can show the positions of objects and the relationship between
object.

 Various hardware devices have been developed to enable the user to interact.
 These devices can be separated into two classes’ locators and selectors.

 Locators or devices which gives position information the computer it typically


receives from locator the co-ordinate for a points using a locator we can indicate a
position on the screen.

 Select devices or used to select a particular graphical object is selector may pic a
particular item but divisors no information about where that items located on the
screen.

 Have two potentiometers mounted on the keyboard which the user can adjust.
 One potentiometer is used for the X direction other for the Y direction.
 Analog to digital Converts change the potential metre setting into your digital value
which the computer can be read.
 The two potentiometers readings together form the co-ordinate of a point some
feedback mechanism is needed
 This may be in the form of a special screen cursor that is a special marker placed on
the screen at the point which is being indicated.

 Another locator device is a joystick


 A joystick has two potentiometers just as a pad of thumb wheels over them; they
have been attached to a single level.

 Moving the level forward or back changes the setting on one potentiometers moving
it left or right changes the setting on the other potentiometers.
 Some locator devices use switches attached to wheels instead of potentiometer as the
wheels or turned the switches produce pulse which may be counted.
 The count indicates how much year will has routed this mechanism is often found in
mouse and trackballs such wheels X and Y directions.
 Photo cells in the bottom of the mouse since the movement across the grid and
produce pulses to report the motion.

 A track ball is essentially your mouse turned upside down the ball which turns the
wheels is large and move the directly by the operator.

 A tablet is composed of a flat surface a pen like stylus or window like tablet cursor
the tablet is also able to since the position of the stylus or tablet cursor on the
surface.

 A drawing or blueprint might be placed upon the surface and the stylus used to track
it.
 It is necessary to turning the tablet off and on so that the computer can only read co-
ordinate values when the user is ready to build a switch into the tip of the stylus
which turns on only when the stylus is pressed down.

 Light pen selected device is light pen is composed of a photocell mounted in a pen
like case this pin maybe pointed at the screen on a refresh display.
 The pen will send Apple whenever the phosphor below it eliminator the light pin can
easily determine the time at which the Phosphorus illuminated.
 Handling of event driven devices can be conducted in two different ways. The first is
to enter a pooling loop, which is a loop which checks the statics of the device until
an event indicated.
 When an event occurs, the loop is exited with the result of the event.
 A disadvantage of this schema is that the processor is essentially idle while it is
waiting.

For an event,

An alternative approaches is an interrupt which is send by the device when an event


occurs.
An interrupt is an electrical signal which causes the processor to break the normal
execution sequence and transfer control to a special interrupt handling routine.
By using the interrupt mechanism, the processor is fresh to carry out some other
operation while it is waiting for an event to take place.
When the event occurs processing is interrupted and the device which caused it is
serviced.
After servicing the device, processing can continue.
EVENT QUEUE

When events occur before the program is ready for them, when information from an
event-driven device is finally needed the event queue is searched to see what events
have transpired.
If no event has an occurred and the queue is empty, a pooling loop can still be
employed to repeatedly check the status of the event queue, instead of checking the
status of individual devices.
Input device event handling algorithm:
Five classes of the devices.
The first is the button which is an event driven device that sends an interrupt when it
is pressed.
It sends no information other than the fact that it has been pressed.
The second class of the device is the pick. The pick is typified by the light pen.
It is an event driven device which selects some portion of the display.
The third class is the keyboard and the fourth is the locator. a locator is a sample
device that returns the coordinates of some portion.
Finally we shall include your valuator which like a locator is sample to device but it
returns only one value.
The valuator might be a dial or not which can be set by the user.
We assume that some mechanism is available for turning these devices logically on
or off so that protein shall be provided which allow the user to enabled or disable of
each window.
We create a flag for each class the setting of the flats will determine whether or not a
particular class is enabled
Instead of enabling and disabling individual devices we shall simplified this process
to the enabling or disabling of the classes.

ALGORITHM ENABLE-GROUP (CLASS):-

BEGIN
IF CLASS =1 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PERMIT INPUT FROM THE BUTTON
DEVICES;
BUTTON←TRUE;
END;

IF CLASS =2 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PERMIT INPUT FROM THE PICK DEVICES;
PICK←TRUE;
END;

IF CLASS =3 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PERMIT INPUT FROM THE KEYBOARD
DEVICES;
KEYBOARD←TRUE;
END;

IF CLASS =4 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PERMIT INPUT FROM THE LOCATOR
DEVICES;
LOCATOR←TRUE;
END;

IF CLASS =5 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PERMIT INPUT FROM THE VALUATOR
DEVICES;
VALUATOR←TRUE;
END;
END;
Input Device Type Class Number
Button 1
Pick 2
Keyboard 3
Locator 4
Valuator 5

ALGORITHM DISABLE-GROUP (CLASS):-

BEGIN
IF CLASS =1 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PROHIBIT INPUT FROM THE BUTTON
DEVICES;
BUTTON←FALSE;
END;

IF CLASS =2 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PROHIBIT INPUT FROM THE PICK DEVICES;
PICK←FALSE;
END;

IF CLASS =3 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PROHIBIT INPUT FROM THE KEYBOARD
DEVICES;
KEYBOARD←FALSE;
END;

IF CLASS =4 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PROHIBIT INPUT FROM THE LOCATOR
DEVICES;
LOCATOR←FALSE;
END;
IF CLASS =5 THEN
BEGIN
PERFORM ALL OPERATIONS NEEDED TO PROHIBIT INPUT FROM THE VALUATOR
DEVICES;
VALUATOR←FALSE;
END;
END;
Locator is a sampled device and, therefore, may be read at any time; there is no wait for an
event to be placed on the event queue.
We need only a routine locators are sampled devices, our simulation of a locator need not
involve the AWAIT_EVENT routine.
For an actual locator device the current coordinate values are read from the device and
retuned.
In a keyboard simulation, coordinate values will be read from the keyboard and routine.

Algorithm READ-LOCATOR(X, Y)
BEGIN
IF NOT LOCATOR THEN RETURN ERROR 'LOCATOR NOT ENABLED";
OBTAIN (X, Y) FROM LOCATOR DEVICE OR ITS SIMULATION:
CONVERTTO NORMALIZED DEVICE COORDINATES IF NECESSARY;
RETURN;
END;
Valuators are treated in essentially the same way as locators. One Variable as returned
instead of a coordinate pair.

Algorithm READ-VALUATOR (V)


BEGIN
IF NOT VALUATOR THEN RETURN ERROR "VALUATOR NOT ENABLED:”
OBTAIN V FROM VALUATOR DEVICE OR ITS SIMULATION;
RETURN;
END;

A useful feature for pick devices is the ability to set the detectability of portions of the
display.
We may wish to be able to pick an item from a subset of the items appearing on a display.
We want all other items of the display to be ignored by the pick device.
This can be done by disabling the interrupt mechanism when portions of the display which
we wish to ignore are being drawn.
We can give Segments detectability attribute so that a segment may or may not be
detectable by a pick device. We do this by giving each segment a detectability flag.

Algorithm SET-DETECTABILITY (SEGMENT-NAME, ON-OFF)


BEGIN
IF SEGMENT_NAME<1 OR SEGMENT_NAME > NUMBER_OF_SEGMENTS
THEN
RETURN ERROR ‘INVALID SEGMENT’;
DETECTABLE [SEGMENT_NAME] ←ON-OFF;
RETURN;
END;
We have added a new segment attribute.
This means that occur routines which manage the segment table must be extended to include
this new property.
The CREATE_SEGMENT routine, which manages the segment table, must be extended to
include this new property.
The CREATE_SEGMENT routine, which initializes all attributes & the
RENAME_SEGMENT routine, which copies all attributes to a new position in the table.

Algorithm CREATE_SEGMENT (SEGMENT-NAME)


BEGIN
IF NOW_OPEN > 0 THEN RETUEN ERROR ‘SEGMENT STILL OPEN’;
…………..
……………….
……………..
TRANSLATE_X [SEGMENT-NAME] ← TRANSLATE_X [0];
TRANSLATE_Y [SEGMENT-NAME] ← TRANSLATE_Y [0];
DETECTABLE [SEGMENT-NAME] ← DETECTABLE [0];
NOW-OPEN_ SEGMENT-NAME;
RETURN;
END;
Algorithm RENAME_SEGMENT (SEGMENT-NAME-OLD, SEGMENT-NAME-NEW)
BEGIN
…..…………..
……………….
……………..
TRANSLATE_X [SEGMENT-NAME-NEW] ← TRANSLATE_X [SEGMENT-NAME-OLD];
TRANSLATE_Y [SEGMENT-NAME-NEW] ← TRANSLATE_Y [SEGMENT-NAME-OLD];
DETECTABLE [SEGMENT-NAME-NEW] ← DETECTABLE [SEGMENT-NAME-OLD];
Delete the old segment
SEGMENT-SIZE [SEGMENT-NAME-OLD] ←0;
RETURN;
END;

Suppose we have a locator, but no pick device.


We know that the user is interested in the part of the picture located at position (x, y), but do
not know which segment is being drawn there.
To find out, we shall step through the display-file instructions segment by segment as if we
were drawing the image.
But instead of generating line and character images, we will ask how close the lines and
characters are to the locator position.
If a line or a character is sufficiently close, we will assume that it is the item at which the
user is pointing.

We will note what segment we are considering and return it as the value of the pick
selection.
We can determine the distance between a point (x, y) and a character.
We simplify the problem by treating the character as if it were a point (X, Y).
Then we can use the distance formula to give

D = [(x - xc)2 + (y-yc)2]1/2


If this distance is close enough ,
D <APERTURE
Then, we have found the segment.
This formula will select a character if its point lies within a circle of radius APERTURE
centred on the locator point.
A more efficient test is to select a point lying within a square with side 2 * APERTURE
centred on the locator point. In this case, the test condition becomes

|x-xc|+|y-yc| < APERTURE


Absolute value is much easier to calculate than squares.

(x-xc)2+(y-yc)2 > (APERTURE)2 (x-xc)2+(y-yc)2 < (APERTURE)2 NOT selected.


A preliminary test should be made to determine if the point lies too far beyond the segment
end points that is, we can reject the segment if,

X < min (x1, x2) – APERTURE


or X > max (x1, x2) + APERTURE
or Y < min (y1, y2) - APERTURE
or Y > max (y1, y2) + APERTURE

(x-xc)2+(y-yc)2 < (APERTURE)2 |x-xc|+|y-yc| < APERTURE


An important part of an interactive system is echoing. Echoing provides the user with

information about his actions.

This allows the user to compare what he has done against what he wanted to do.

For keyboard input, echoing usually takes the form of displaying the typed characters.

Locators may be echoed by a screen cursor displayed at the current locator position.

This allows the user to see the current locator setting and to relate its position to the objects
on the display.

Echoing a Location

A pick may be echoed by identifying the selected objects on the display. The
selected objects may be flashed or made brighter or perhaps, altered in color.

Echoing a buttons and menu selection


This will allow the user to determine whether or not he has selected the intended
objects.

Buttons, when used to select menu items, can be echoed by flashing or


highlighting the selected items.

For a valuator, display of the current setting in numerical form or as a position on


a scale is possible.

It is important that some form of echoing be present, no matter what form it


takes. Without it, the user feels that he is working in the dark and may never feel
comfortable with the program.

Point plotting gives the user the capability of selecting a particular point on the
screen. This is usually done by a combination of a locator and a button.
The locator is used to tell which point the user selects.
The button indicates when the locator is correctly positioned.
The algorithm to perform point plotting must await the button event; as soon as it
occurs, the locator may be read.
The selection of points can be used in many different ways.
One use for the point-plotting routine is to enter line segments.
The idea here is to connect the successive points selected by the user with line
segments, like a child's "connect-the-dots" drawing.
The user can indicate whether to continue or terminate the process by which
button is pushed.
The UPDATE (PEN-ON) determines whether linking should cease.
This may be governed by an event, such as lifting the stylus, or by the passing of a time
limit or a limit on the allowed number of line segments.
Note that we could collect the sequence of locator positions without connecting them with
line segments. Such a sequence of points is called a stroke. Inking displays strokes.

Raster displays can extend inking to painting with a brush.


A brush is a pattern of pixel values. When painting, we repeatedly sample the locator
position.
Each time the position changes we copy the brush pattern into the frame buffer.
The pattern is centred on the current locator position.
The effect is to draw this pattern repeatedly on the display along the path of the locator.
The instances of the pattern usually overlap, resulting in a shape that looks as though the
brush has moved across the display leaving a trail of paint.

A Grid
The shape of the trail depends on both the path of the locator and the shape of the brush.
It is often the case that the user wants to connect endpoints of several lines, and frequently
horizontal and vertical lines predominate.
But it can be difficult to position to a single point, and it may be hard to get a line perfectly
horizontal or vertical. A technique to aid in such constructions is a grid.
A grid is a pattern of special points. Often the user can make these points either visible or
invisible.

Vector refresh and some raster displays allow a technique called rubber band lines.
This technique allows the user to see what a line will look like before fixing it in place.
The basic process is the same as line plotting; the user adjusts the locator to place the
endpoint of the next line segment.
The user presses a button when the locator is correctly positioned.
The difference is that a line is constantly drawn between the last endpoint and the locator.
As the locator moves, the line is redrawn in a new position, giving the appearance of a
rubber band stretched between the fixed endpoint and the locator point.

The user might wish not only to create new images but to alter and adjust existing images as
well. This is naturally a pick operation. Suppose the user wanted remove portions of the
image.

Selecting a segment with a Pick


An AWAIT-PICK operation will determine which segment should be removed and the
SET-VISIBILITY routine can make it invisible.
Notice that this technique cannot be used to bring the item back.
Another desirable modification might be a change in the image transformation.
For example, the user may wish to change the position of a segment's image.
It is usually most convenient for the user to indicate the new position by pointing at it with
locator.
The user can use a pick to select the segment to be moved and then select some point on the
image with the locator.
Finally, the locator is moved to the place to where the point on the image should be moved.

The image can be continuously shifted and redrawn to follow the locator movements.
The image appears to be attached to the locator, the user can see how the picture will look
before fixing the new image translation values. This technique is called dragging.

You might also like