[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

400.0. "Dashed line problem" by STKHLM::GOLSSON (Gert Olsson, Malmoe (UGO)) Tue Mar 14 1989 10:08

    I need some help with a problem regarding dashed lines.
    
    I'm trying to use some different line styles by calling X$SET_DASHES.
    The calls doesn't seem to change the appearance. But if I run it with
    the debugger, stepping, and changing input focus back and forth between
    the calls to X$DRAW_LINE everything seems to work OK! I'm confused!!!
    
    Questions:
    	To my understanding I should be able to change the line appearance
        with calls to X$SET_DASHES even if I use the same graphic context.
        Is it so?
    
    	I have included the little test routine below here.
    	Any knowledgable who can take a look at it and see if I'm doing
	something completly crazy?
    
    Regards,
    Gert.

[ INHERIT('SYS$LIBRARY:DECW$XLIBDEF', 'SYS$LIBRARY:DECW$XLIBMSG', 
	  'SYS$LIBRARY:PASCAL$LIB_ROUTINES', 
	  'SYS$LIBRARY:PASCAL$MTH_ROUTINES') ]
PROGRAM lines ( INPUT, OUTPUT ) ;
 
{
PROGRAM DESCRIPTION: 
 
    Simple test of line types and dash lists in DECWindows
    environment.
}
 
CONST
    C_x_max = 400;
    C_y_max = 400;
    C_list_max = 10;
    C_pattern_max = 10;
    
TYPE
    sbyte =  [BYTE] -128..127;
    dash_list_type = ARRAY[1..C_list_max] OF
	RECORD
	    dash_list : ARRAY[1..C_pattern_max] OF sbyte;
	    dash_length : INTEGER;
	END;
 
VAR
    display_id, window_id, gc_id : UNSIGNED;
    fore_g, back_g : UNSIGNED;
    xswa : X$SET_WIN_ATTRIBUTES;
    xswa_mask : UNSIGNED;
    xvisual : X$VISUAL;
    xgcv : x$gc_values := ZERO;
    dash : dash_list_type;
    dummy : VARYING [80] OF char;

{-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*}
PROCEDURE open_ws;

BEGIN
    { Create the display }
    display_id := X$Open_Display();
    IF (display_id = 0) THEN LIB$STOP(X$_CANTOPEN);

    { Create and map the window }
    fore_g := x$white_pixel(display_id, x$default_screen(display_id));
    back_g := x$black_pixel(display_id, x$default_screen(display_id));

    xswa.x$l_swda_event_mask := 0;
    xswa.x$l_swda_background_pixel := back_g;
    xswa.x$l_swda_border_pixel := fore_g;

    xswa_mask := UOR(x$m_cw_event_mask, x$m_cw_back_pixel);
    xswa_mask := UOR(xswa_mask, x$m_cw_border_pixel);

    x$default_visual(display_id,x$default_screen(display_id),xvisual);

    window_id := x$create_window(display_id, x$default_root_window(display_id),
				 0, 0, C_x_max, C_y_max, 0, 
				 x$default_depth(display_id,
				 x$default_screen(display_id)), 
				 x$c_input_output, xvisual, xswa_mask, xswa);

    x$map_window(display_id, window_id);

    gc_id := x$create_gc(display_id, window_id, 0, xgcv);

    x$set_foreground(display_id, gc_id, fore_g);
    x$set_background(display_id, gc_id, back_g);

    X$Flush (display_id);

END;

{-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*}
PROCEDURE set_dash_values;

VAR
    i, j : INTEGER;

BEGIN
    FOR i := 1 TO C_list_max DO BEGIN
	WITH dash[i] DO BEGIN
	    dash_length := i; 
	    FOR j := 1 TO c_pattern_max DO BEGIN
		dash_list[j] := i*j;
	    END;	    
	END;
    END;
END;

{-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*}
PROCEDURE draw_lines;

VAR
    i, j, x1, y1, xo, y2, xd, dash_offset : INTEGER;

BEGIN
    xd := ROUND (C_x_max/(C_list_max + 1));
    xo := xd;
    y1 := ROUND (C_y_max/(C_list_max + 1));
    y2 := C_y_max - y1;
    dash_offset := 0;

    X$SET_LINE_ATTRIBUTES (display_id ,gc_id, 0,
			   X$C_LINE_DOUBLE_DASH, 0, 0);

    FOR i := 1 TO C_list_max DO BEGIN
	X$SET_DASHES (display_id, gc_id, dash_offset, dash[i].dash_list,
		      dash[i].dash_length);
	
	X$DRAW_LINE (display_id, window_id, gc_id, xo, y1, xo, y2);
{	X$FLUSH (display_id); }
{	X$SYNC (display_id, 0);}
	xo := xo + xd;
    END;
    X$SYNC (display_id, 0);
END;

{-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*}
BEGIN
    open_ws;
    set_dash_values;
    draw_lines;

    { Ask user for a "CR" before exiting to allow him to study result }
    WRITE ('Hit "CR" to end ');
    READLN (dummy);
END.

T.RTitleUserPersonal
Name
DateLines
400.1GPX server bug. Fixed in VMS 5.2STAR::BMATTHEWSTue Mar 14 1989 12:0016
This is a known bug that is fixed in VMS V5.2. The work around is to change
some other GC attribute to a different value that does not affect the drawing
of your dashed lines. For example if your line is width zero you could toggle
the join style between join miter and join beveled which is a nop for width
0 lines. The problem lies in the lazy evaluation that the server does. When
the GC attributes are changed the server only records the change in the most
minimal way possible. The server waits for the first draw using a modified GC
in order to do any extra processing needed to render with the new GC attributes.
Set dashes was not setting the proper state bit to indicate the further
processing was needed at draw time. In this case GPX needs to load the new
dash pattern into offscreen memory at the first draw using the GC modified by
set dashes. It turns out that only the gpx software has special processing
for dashed lines. Changing other GC attributes will cause the draw path to
modify the hardware to match the new GC attributes.
					Bill

400.2<Thanks, and nice with some info>STKHLM::GOLSSONGert Olsson, Malmoe (UGO)Thu Mar 16 1989 15:566
    
    Thanks for taking your time to explain the problem.
    It helped me out in a not so nice situation.
    
    Gert.