/* $XConsortium: pick10.pi,v 5.3 94/04/17 20:48:37 hersh 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. ******************************************************************/ ## pick10.pi - ## Test picking with different primitives source macro.pi macro im_pick_test(@msg) i_fake_button(1,0,testpt1,1); preq_pick(1,1,1,&inqstatus,&inqpath); im_ifneq(inqstatus,PIN_STATUS_OK, "failed: %s is not being picked\n",@msg); status = i_compare_Ppoint(inqpath,exppath); im_ifneq(status,1,"failed: %s, pick path != expected\n",@msg); i_fake_button(1,0,testpt2,1); preq_pick(1,1,1,&inqstatus,&inqpath); im_ifneq(inqstatus,PIN_STATUS_NONE, "failed: %s is incorrectly being picked\n",@msg); pdel_elem(); endmacro tbegintest("pick10","Test picking with different primitives"); # INITIALIZE: initial/inquire pick path, pick filter, name set data # and test points pelem1 = I_Ppick_path_elem(0,1,5); exppath = I_Ppick_path(1,&pelem1); pelem2 = I_Ppick_path_elem(0,0,0); inqpath = I_Ppick_path(0,&pelem2); ia = IA_Pint(1,1); inset = I_Pint_list(1,ia); exset = I_Pint_list(0,NULL); pfilter = I_Pfilter(inset,exset); nset = I_Pint_list(1,ia); testpt1 = I_Ppoint3 (0.5,0.5,0.0); testpt2 = I_Ppoint3 (0.1,0.1,0.0); # setup: open phigs, open workstation, open structure i_open_phigs(NULL,0) i_open_x_ws(1,&xdisplay,&xwindow,0,0,200,200); # set pick filter and pick mode pset_pick_filter(1,1,&pfilter); popen_struct(1) ppost_struct(1,1,1.0) padd_names_set(&nset); pset_pick_id(1); pset_anno_char_ht(0.03); pset_char_ht(0.03); # test different primitives # 1. annotation text atxpos1 = I_Ppoint3(0.5,0.5,0.0); atxoffset1 = I_Ppoint3( 0.0,0.0,0.0); panno_text_rel3(&atxpos1,&atxoffset1,"PEX-SI"); im_pick_test("annotation text"); # 3. fill area fapts3 = IA_Ppoint3(4, 0.5,0.5,0.0, 0.6,0.5,0.0, 0.6,0.4,0.0, 0.5,0.4,0.0) fa3 = I_Ppoint_list3(4,fapts3); pfill_area3(&fa3); im_pick_test("fill area"); # 4. fill area set pts4 = IA_Ppoint3(4, 0.5,0.5,0.0, 0.6,0.5,1.0, 0.6,0.4,1.0, 0.5,0.4,0.0) fas4 = I_Ppoint_list3(4,pts4); fas4_l = I_Ppoint_list_list3(1,&fas4); pfill_area_set3(&fas4_l); im_pick_test("fill area set"); # 5. fill area set with data ptarr5 = IA_Ppoint3(4, 0.5,0.5,0.0, 0.6,0.5,1.0, 0.6,0.4,1.0, 0.5,0.4,0.0) varr5 = I_Pfacet_vdata_arr3(PVERT_COORD,ptarr5); vlst5 = I_Pfacet_vdata_list3(4,varr5); vdata5 = IA_Pfacet_vdata_list3(1,vlst5); pfill_area_set3_data(PFACET_NONE,PEDGE_NONE,PVERT_COORD,PMODEL_RGB,NULL,1,NULL,vdata5); im_pick_test("fill area set with data"); # 6. nurb curve floatarr6 = IA_Pfloat(7, 0.0,0.0,0.0,0.1,0.2,0.2,0.2); knots6 = I_Pfloat_list(7, floatarr6); cpts6 = IA_Ppoint3(4, 0.5,0.5,0.0, 0.6,0.6,1.0, 0.7,0.6,1.0, 0.8,0.5,0.0); ctlpts6 = I_Ppoint_list34(4,"3D",cpts6); pnuni_bsp_curv(3,&knots6,PNON_RATIONAL,&ctlpts6,0.0,0.2); im_pick_test("nurb curve"); # 7. nurb surface floatarr7 = IA_Pfloat(6, 0.0,0.0,0.0,0.1,0.1,0.1); knots7 = I_Pfloat_list(6, floatarr7); cpts7 = IA_Ppoint3(9, 0.5,0.3,1.0, 0.6,0.35,1.0, 0.7,0.3,1.0, 0.5,0.4,0.5, 0.6,0.45,0.5, 0.7,0.4,0.5, 0.5,0.5,0.0, 0.6,0.55,0.0, 0.7,0.5,0.0); grid7 = I_Ppoint_grid34(3,3,"3D",cpts7); pnuni_bsp_surf(3,3,&knots7,&knots7,PNON_RATIONAL,&grid7,0,NULL) im_pick_test("nurb surface"); # 8. polyline plpts8 = IA_Ppoint3(2, 0.5,0.5,0.0, 0.7,0.7,1.0); pl8 = I_Ppoint_list3(2,plpts8); ppolyline3(&pl8); im_pick_test("polyline"); # 9. polymarker pmpts9 = IA_Ppoint3(2, 0.5,0.5,0.0, 0.7,0.7,0.0); pm9 = I_Ppoint_list3(2,pmpts9); ppolymarker3(&pm9); im_pick_test("polymarker"); # 10. polyline set with data ptarr10 = IA_Ppoint3(2,0.5,0.5,0.0, 0.7,0.7,1.0); lva10 = I_Pline_vdata_arr3(PVERT_COORD,ptarr10); lv10 = I_Pline_vdata_list3(2,lva10); vdata10 = IA_Pline_vdata_list3(1,lv10); ppolyline_set3_data(PVERT_COORD,PMODEL_RGB,1,vdata10); im_pick_test("polyline set with data"); # 11. quad mesh with data dim11 = I_Pint_size(2,2); ptarr11 = IA_Ppoint3(4,0.5,0.5,0.0, 0.6,0.5,0.0, 0.5,0.4,0.0, 0.6,0.4,0.0); vdata11 = I_Pfacet_vdata_arr3(PVERT_COORD, ptarr11); pquad_mesh3_data(PFACET_NONE,PVERT_COORD,PMODEL_RGB,&dim11,NULL,&vdata11); im_pick_test("quad mesh with data"); # 12. triangle strip with data ptarr12 = IA_Ppoint3(3,0.5,0.5,0.0, 0.6,0.6,0.0, 0.7,0.5,1.0); vdata12 = I_Pfacet_vdata_arr3(PVERT_COORD, ptarr12); ptri_strip3_data(PFACET_NONE,PVERT_COORD,PMODEL_RGB,3,NULL,&vdata12); im_pick_test("triangle strip with data"); # 13. set of fill area set with data ia13 = IA_Pint(3,0,1,2); il13 = I_Pint_list(3,ia13); ill13 = I_Pint_list_list(1,&il13); vlist13 = IA_Pint_list_list(1,ill13); ptarr13 = IA_Ppoint3(3, 0.5,0.5,0.0, 0.6,0.6,0.0, 0.7,0.5,1.0); varr13 = I_Pfacet_vdata_arr3(PVERT_COORD, ptarr13); vdata13 = I_Pfacet_vdata_list3(3,varr13); pset_of_fill_area_set3_data(PFACET_NONE,PEDGE_NONE,PVERT_COORD,PMODEL_RGB,1,NULL,NULL,vlist13,&vdata13); im_pick_test("set of fill area set with data"); # 14. text txpos14 = I_Ppoint3( 0.5,0.5,0.0); dir14 = IA_Pvec3(2, 1.0,0.0,0.0, 0.0,1.0,0.0); ptext3(&txpos14,dir14,"PEX-SI"); im_pick_test("text"); tendtest();