Unit - 3 Segments
Unit - 3 Segments
SEGMENTS
INTRODUCTION:
Until now we have discussed a single picture on the display. In practice, the image on the display screen is often
composed of several pictures or items of information. An image may contain several views of an object and
related information. It may also contain close up view of a particular component.
Example: We wish to display an internal plan of a living room. The plan may contain various objects such as TV,
Show piece, Table, etc. Each object has a set of attributes such as size, color and its position in the room. We
might wish to see all these objects simultaneously or a single object at a time.
To view the entire image or a part of the image with various attributes we need to organize the image information
in a particular manner. The image information is stored in the display file.
Existing structure of the display file does not satisfy our requirements of viewing the image. Hence the display
structure is modified to reflect the sub picture structure. To achieve this, display file is divided into segments.
Each segment corresponds to a component or an object of the overall display and is associated with a set of
attributes.
The presence of segment allows:
➢ Sub division of picture
➢ Visualization of a particular part of the picture.
➢ Scaling, rotation and translation of a particular part of the picture.
SEGMENT: The segment is a unit of the display file. (Used to define a unit of picture)
➢ It is efficient to define and modify a picture as a set of sub pictures. A segment is a set of output
primitives that are joined for modification purpose.
➢ It is a logical unit and a collection of display file instructions representing graphics primitives that
can be manipulated as a single unit.
The programmer must be able to name the different parts of the picture. Secondly furnish with
subroutines or functions that affect the desired modification on the appropriate parts. The display file
has two fundamental attributes that are required. Names or labels can be assigned to sets of instructions
and these instructions can be easily modified.
Function for segmenting the display file: For a sequential disk file we open a file to add data to it. We
close the file when we have added the last data items and the file is completed. To change the contents
of a file, we open it again, and the new data to replace the old and close the file. To get rid of a file,
delete it.
Similar operations are ideal for display file segments. To create a new segment, we open it and then call
graphics primitive to add to the segment the lines and text to be displayed. Then close the segment. To
remove a segment from the display file, we delete it.
A pseudo display file contains segment definitions from which appropriate bits in the frame buffer of
set.
Memory management for segment storage:
➢ Blocks must be assigned as segments when segments are created.
➢ Blocks must be returned to the storage pool as segments are deleted.
➢ Options
- Fixed size blocks
Easy to manage
Lead to fragmentation
-Variable sized blocks
Avoid fragmentation
More Memory management
➢ Make changes only at the end of the refresh cycle.
Segment Format:
Segment Attributes: A create segment can have number of attributes such as
1. Visibility
2. Priority
3. Highlights
4. Transformation
1. Visibility: Visibility of a segment can be set by the user with function
set_visibility(id, v)
where v is visible (posted) or invisible (unposted) which controls the display of segments and id the
segment number.
set_segment_priority(id, p)
where id is the segment number and p is the priority parameter which is a numeric value lying between 0
and 1.
Lower priority segments have values near 0 and are displayed first up to the highest priority segments
which are displayed last. If two segments have same priority number then uses either first in first out
scheme or segment number to break the priority tie. Since high priority segments paint over low
priority segments in the region of overlap, this property can be made use of in animation where objects
move part each other.
set_highlight(id, h)
where id is the segment number and h = highlighted or normal. The highlighting depends on the type of
displayed device used.
4. Transformation: To achieve segment transformations, the user can specify the transformation(i.e.,
size, position and orientation) matrix which needs to be applied to the individual segments.
set_segment_transformation(id, matrix)
where id is the segment number and matrix specifies the elements of transformation matrix.