/* $XConsortium: viewxf3.pi,v 5.2 94/04/17 20:47:26 rws Exp $ */ /***************************************************************** Copyright (c) 1989, 1990, 1991,1990 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. Copyright (c) 1989, 1990, 1991,1990 by Sun Microsystems, Inc. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Sun Microsystems, and the X Consortium, not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ ## viewxf3.pi - ## Test view clipping ## Draw several polylines and verify the presence of pixels inside the ## viewport and the absence of pixels outside the viewport. source macro.pi source xpmacro.pi tbegintest("viewxf3","view clipping"); text = malloc(128); # SETUP: open phigs and a workstation, open and post a structure i_open_phigs(NULL,PDEF_MEM_SIZE); i_open_x_ws(1,&xdisplay,&xwindow,0,0,200,200); popen_struct(1); ppost_struct(1,1,1.0); # INITIALIZATION, OPERATION, VERIFICATION loop follows: # testing 2D case # initialize orientation mtx to identity, cliplimit # and data for the bounding box i_identity(orientmtx); i_identity(mapmtx); cliplimit = I_Plimit(0.4,0.8,0.4,0.8); box = IA_Ppoint(5, 0.4,0.4, 0.4,0.8, 0.8,0.8, 0.8,0.4, 0.4,0.4); plbox = I_Ppoint_list(5,box); # set view index and draw box that represent the viewport boundary pset_view_ind(1); ppolyline(&plbox); foreach @x1 @y1 @x2 @y2 @on1 @on2 @text ( 0.5; 0.5; 0.7; 0.7; 1; 1; "2D line entirely in"; 0.6; 0.6; 0.3; 0.4; 1; 0; "2D line crossing left edge"; 0.6; 0.6; 0.9; 0.4; 1; 0; "2D line crossing right edge"; 0.6; 0.6; 0.7; 0.9; 1; 0; "2D line crossing top edge"; 0.6; 0.6; 0.5; 0.3; 1; 0; "2D line crossing bottom edge"; 0.3; 0.3; 0.8; 0.3; 0; 0; "2D line entirely out"; ) line = IA_2_Ppoint(@x1,@y1,@x2,@y2); pl = I_Ppoint_list(2,line); ppolyline(&pl); testpt1 = I_Ppoint3(@x1,@y1,0.0); testpt2 = I_Ppoint3(@x2,@y2,0.0); # turn clipping off viewrep = I_Pview_rep(orientmtx,mapmtx,cliplimit,PIND_NO_CLIP); pset_view_rep(1,1,&viewrep); im_confirm_point3(xdisplay,xwindow,1,1,testpt1,1,5,1,@text); im_confirm_point3(xdisplay,xwindow,1,1,testpt2,1,5,1,@text); i_pause(); # turn clipping on viewrep = I_Pview_rep(orientmtx,mapmtx,cliplimit,PIND_CLIP); pset_view_rep(1,1,&viewrep); im_confirm_point3(xdisplay,xwindow,1,1,testpt1,@on1,5,1,@text); im_confirm_point3(xdisplay,xwindow,1,1,testpt2,@on2,5,1,@text); i_pause(); # remove polyline element from structure pdel_elem(); end # testing 3D case # initialize orientation mtx to identity, cliplimit, # and data for the bounding box (3D case) i_identity3(orientmtx3); i_identity3(mapmtx3); cliplimit3 = I_Plimit3(0.4,0.8, 0.4,0.8, 0.4,0.8); box3 = IA_Ppoint3(5, 0.4,0.4,0.6, 0.4,0.8,0.6, 0.8,0.8,0.6, 0.8,0.4,0.6, 0.4,0.4,0.6); plbox3 = I_Ppoint_list3(5,box3); # clear structure, set view index and draw the bounding box pempty_struct(1); pset_view_ind(1); ppolyline3(&plbox3); foreach @x1 @y1 @z1 @x2 @y2 @z2 @on1 @on2 @text ( 0.5; 0.5; 0.6; 0.7; 0.7; 0.6; 1; 1; "line entirely in"; 0.6; 0.6; 0.6; 0.3; 0.4; 0.6; 1; 0; "line crossing left edge"; 0.6; 0.6; 0.6; 0.9; 0.4; 0.6; 1; 0; "line crossing right edge"; 0.6; 0.6; 0.6; 0.7; 0.9; 0.6; 1; 0; "line crossing top edge"; 0.6; 0.6; 0.6; 0.5; 0.3; 0.6; 1; 0; "line crossing bottom edge"; 0.3; 0.3; 0.6; 0.8; 0.3; 0.6; 0; 0; "line entirely out"; 0.5; 0.5; 0.1; 0.7; 0.7; 0.6; 0; 1; "line crossing back edge"; 0.5; 0.5; 0.6; 0.7; 0.7; 0.9; 1; 0; "line crossing front edge"; ) line3 = IA_2_Ppoint3(@x1,@y1,@z1,@x2,@y2,@z2); pl3 = I_Ppoint_list3(2,line3); ppolyline3(&pl3); testpt1 = I_Ppoint3(@x1,@y1,@z1); testpt2 = I_Ppoint3(@x2,@y2,@z2); # turn clipping off viewrep3 = I_Pview_rep3(orientmtx3,mapmtx3,cliplimit3, PIND_NO_CLIP,PIND_NO_CLIP,PIND_NO_CLIP); pset_view_rep3(1,1,&viewrep3); im_confirm_point3(xdisplay,xwindow,1,1,testpt1,1,5,1,@text); im_confirm_point3(xdisplay,xwindow,1,1,testpt2,1,5,1,@text); i_pause(); # turn clipping on viewrep3 = I_Pview_rep3(orientmtx3,mapmtx3,cliplimit3,PIND_CLIP,PIND_CLIP,PIND_CLIP); pset_view_rep3(1,1,&viewrep3); im_confirm_point3(xdisplay,xwindow,1,1,testpt1,@on1,5,1,@text); im_confirm_point3(xdisplay,xwindow,1,1,testpt2,@on2,5,1,@text); i_pause(); # remove polyline element from structure pdel_elem(); end tendtest();