• Aucun résultat trouvé

Using Multiple Viewports

The Displaying Process

8.3. Using Multiple Viewports

Functions:

GM_$VIEWPORT_CLEAR GM_$VIEWPORT_CREATE GM $VIEWPORT SET BOUNDS GM-$VIEWPORT-INQ-BOUNDS GM-$VIEWPORT-SELECT GM-$VIEWPORT-DELETE GM-$VIEWPORT-INQ CURRENT GM-$VIEWPORT-MOvE

GM-$VIEWPORT-SET BORDER SIZE GM=$VIEWPORT=INQ=BORDER=SIZE

When you initialize the 2D GMR package in direct, borrow, and main-bitmap modes, the package does the following:

ED Creates one viewport.

ED Makes the viewport fill the GM bitmap .

• Assigns number 1 to the viewport.

ED Makes number 1 the current viewport.

To use multiple viewports, you create additional viewports with GM_ $VIEWPORT _ CREATE.

The 2D GMR package assigns numbers to viewports as they are created.

The current viewport is the last viewport created or selected. The current viewport is changed each time you call GM $VIEWPORT CREATE or GM $VIEWPORT SELECT.

GM_ $VIEWPORT _ CLEAR clears the current viewport. Only planes enabled by the current value of the plane mask are affected.

Several routines which interact with viewports operate on the current viewport. These routines include GM _ $VIEWPORT _ SET _ BOUNDS, GM _ $VIEWPOR T _ REFRESH, GM_$DISPLAY _FILE, and GM_$DISPLAY _SEGMENT.

The Displaying Process 8-4

GM _ $VIEWPORT _ INQ _ BOUNDS returns the bounds of the current viewport as fractions of the GM bitmap. Space outside of all viewports is empty.

GM...,.. $VIEWPORT _MOVE translates the current viewport, carrying the VIew with it. The translation is expressed in fractions of the display bitmap size.

GM_$VIEWPORT _INQ_ CURRENT returns the number of the current viewport. When GM _ $INPUT _ EVENT _ WAIT collects locator data, it also returns the number of the viewport to tell what viewport you are in.

GM $VIEWPORT DELETE deletes a viewport. Because viewports may not overlap, you must delete all but one viewport if a single viewport is to fill the entire GM bitmap. If you delete the current viewport, there is no current viewport and you must select or create a current viewport before calling routines that operate on the current viewport.

GM_$VIEWPORT _SET _BORDER_SIZE sets the border size of the current viewport to the specified values, either in pixels or in fraction-of-bitmap coordinates. This routine sets sizes of the four edges independently, for each viewport.

GM_$VIEWPORT _INQ_BORDER_SIZE returns the border SIze of the current viewport, either in pixels or in fraction-of-bitmap coordinates.

The default border type is in pixels, and the default width is 1,1,1,1. Viewport borders are drawn with color value 1 for compatibility with monochrome nodes. Also for this compatibility, the 2D GMR package sets the color map for color value 1 to white.

With a color node, you may want to use the viewport background color, instead of a border, to differentiate viewports from the overall display or the window background. Changing the color map to black is usually not practical because the cursor is also set to color value 1. An alternative is to create the viewport, set the border width to 0 pixels, and then refresh the viewport.

8 .. 4. Segment Visibility Criteria

Functions:

GM_$VISIBLE_SET_MASK GM $VISIBLE INQ MASK GM=$VISIBLE=SET=THRESHOLD GM_$VISIBLE_INQ_THRESHOLD

You can establish two criteria for segment visibility. You may use a threshold to eliminate segments with visible values too small. You may also use a mask to eliminate segments missing certain bits in their visible values.

To assign visible values to segments, use GM_$SEGMENT _SET _ VISIBLE (see Section 7.2).

A segment is displayed only if it meets both the visible mask and threshold criteria. The visible mask criterion requires that at least one bit be 11111 in both the segment's visible value and the visible mask. The visible threshold criterion requires that the segment's visible value be greater than the visible threshold.

One use for this pair of methods is to set the lowest bit (1) in the visible value in all segments containing, for example, a floor plan; the next lowest bit (2) containing data for ducting; and and the next bit (4) containing data for electrical systems. Higher bits can be used to give larger visible values to larger segments.

With the above settings, visible masks with the following values perform in this way:

1 displays only the floor plan 2 displays only ducting

5 displays the floor plan and electrical data 7 displays all three groups of data

If a segment does not satisfy both of the segment visibility criteria, none of that segment IS

displayed. Any segment which it instances is not checked for visibility and is not displayed.

In borrow, direct, and main-bitmap modes, you may assign separate visible mask and threshold values to each viewport. Thus, different viewports can display separate parts of a data base.

Within-GPR mode has only one visible mask and one visible threshold value.

GM _ $VISIBLE _ SET _ THRESHOLD establishes a minimum segment visible value. Segments with smaller visible values are not displayed. The default value is 1, in which case all segments of nonzero visible value satisfy the threshold criterion.

GM_$VISIBLE_SET _MASK allows you to base segment visibility on individual bits within the visible value for each segment. If any bit is 1 in both the mask and the segment visible number, the segment may be visible. The default value is 16#7FFFFFFF, in which case all segments of nonzero visible value satisfy the mask criteria.

GM and GM _ $VISIBLE _ INQ _ MASK return the current

value of these ."' .... ,..'" ... '-,.,.. for the specified viewport.

Functions:

You can the entire file or segment. The picture is automatically centered in the current viewport, with a scale calculated so that 95% of the viewport is filled in one dimension amd does not overflow the viewport in the other.

A segment from one file can be displayed in one viewport. A segment from another open file can be displayed in another viewport. But only one segment may be displayed in any viewport, and it may not instance segments in other files. To display the contents of more than one segment in the single viewport, build a new segment including instances of the other segments.

GM_$DISPLAY _FILE displays the entire current file in the current viewport. The primary segment of the file is displayed.

The Displaying Process 8-6

GM $DISPLAY _ SEGMENT displays the specified current viewport.

but not the entire file, III the

GM $DISPLAY SEGMENT is used in within-GPR mode only. It displays the specified segment, with the specified transformation, in the current CPR-specified bitmap (see Chapter 11).

8.6 .. Displaying

Functions:

GM_$D ISPLAY_F ILE_PART GM_$DISPLAY_SEGMENT_PART

a

Only one segment may be displayed per viewport, but you can specify what part of that segment is displayed or change the part of that segment that is displayed. You may want to see only part of a graphic image you have developed. For you may want to see only the wheel of a car, not the entire body of the car that you have been modeling.

To get part of an image in a view, you use or

GM_$DISPLAY _FILE_PART to specify in segment coordinates the part of the segment (or file) you want displayed. That part of the segment (or file) is centered in the current viewport with a scale automatically set so that the specified part of the file is displayed as follows: One of the two dimensions fills the viewport, and the other dimension does not overflow the viewport.

This allows you to look at the entire file or segment in one and a smaller part of a file or segment in another viewport. The same file or can appear in different viewports (see Figure 4-1.

You may want the contents of a segment to be much smaller than the This is possible because the 2D GMR package uses the rectangular bounds that you specify, not the current bounds of the coordinate data within the In this way, you can override this coordinate data based on coordinates within the se~~ment.

The 2D GMR package then sets the view transformation from world coordinates of that segment to display pixels so that one dimension fills the current (not 95%). The other dimension is centered in the viewport and does not overflow it. This means that if the aspect ratio of the region you defined is different than the aspect ratio the viewport, you will see more than the area you requested. It will continue to display all the way out to the edge of the viewport. But you are guaranteed that this entire bounded will be viewed in the viewport, and one dimension or the other will fill the entire viewport.

GM_$DISPLAY _FILE_PART displays Bounds are in segment coordinates of the GM $DISPLAY SEGMENT PART viewport.

of the

the current viewport.

segment III the current