pro candycane compile_opt idl2 ;regular cylinder for the stem mesh_obj, 3, vertex_list1, polygon_list1, replicate(0.1,60,64), p4=2.0 ;now make the curved part of the candy cane theta = findgen(60)*6*!dtor x = 0.1 * cos(theta) + 0.5 y = 0.1 * sin(theta) z = fltarr(60) mesh_obj, 6, vertex_list2, polygon_list2, transpose([[x],[y],[z]]), $ p1 = 60, p2 = [0,0,0], p3=[0,-1,0], p4=0, p5=!pi*1.1 ;subtract off 0.5 on x to line up the stem vertex_list2[0,*] = vertex_list2[0,*] - 0.5 ;add 2 to the curved part to attach it at the top vertex_list2[2,*] = vertex_list2[2,*] + 2.0 ;concatenate vertex_list = [ [vertex_list1],[vertex_list2]] ;get out x,y,z for below x = reform(vertex_list[0,*]) y = reform(vertex_list[1,*]) z = reform(vertex_list[2,*]) ;mod the poly list to get the right connectivity index = (lindgen(n_elements(polygon_list2))) mod 5 goodInd = where( index ne 0) polygon_list2[goodInd] = polygon_list2[goodInd] + max(polygon_list1) + 1 ;concantenate polygon_list = [polygon_list1, polygon_list2] void = dialog_message(['Now for a nice trick on running the function graphics on the bridge so',$ 'we can interact with them. If we do not do this then the message',$ 'boxes block and keep us from being able to rotate the objects']) oBridge = obj_new('IDL_IDLbridge') oBridge->setVar,'vertex_list',vertex_list oBridge->setVar,'polygon_list',polygon_list oBridge->setVar,'x',x oBridge->setVar,'y',y oBridge->setVar,'z',z void = dialog_message(['So what I want is to use the function graphics to display a candy cane. First I want to make a plot3d',$ 'object with the correct scale but with the data points and axes hidden. To get the candycane without any',$ 'distortion the aspect ratio in x, y, and z must be 1']) oBridge->execute, 'op = plot3d(x,y,z,aspect_ratio=1,aspect_z=1,axis_style=0)' void = dialog_message(['Now hide the points']) oBridge->execute,'op.hide =1' void = dialog_message(['From reading the help it appears that all we have to do is specify the ',$ ' polygon connectivity for the function polygon']) oBridge->execute,'oPoly = polygon(x,y,z,connectivity=polygon_list, data=1, fill_color=[255,0,0])' void = dialog_message(['If you are running this on IDL 8.1 or before the shape is right, but where is the color and filled polgyon faces?',$ 'If you look close you will see a little red on the curve part', $ 'On IDL 8.2 and later the faces are filled, but it still does not look quite right']) void = dialog_message(['Maybe my polygons and vertices are incorrect? Lets try making a regular IDLgrPolygon', $ 'and displaying it with xobjView', $ 'MAKE SURE YOU CLICK AND DRAG TO ROTATE IT!']) ;notice the double quotes below since I have a string in the execute statement oBridge->execute,"oIDLpoly = obj_new('IDLgrPolygon',x,y,z,polygon=polygon_list,color=[255,0,0])" oBridge->execute,'xObjView, oIDLpoly,title="Regular IDL Polygon", tlb=wGoodTLB' void = dialog_message(['Good, its not my points and vertices. So what is happening?', $ 'After stepping through the function graphics code with the debugger',$ 'it appears that the polygon list is getting messed up. ',$ 'My first attempt to get at the data and connectivity list was this IDL statement',$ ' oPoly->getProperty, polygon=polyList, data=data ', $ 'But we get an error that these are undefined properties. So after ',$ 'poking around with the debugger I found the undocumented keyword that',$ 'turns off the propery checking. So now we call it like this and it works!', $ ' oPoly->getProperty, polygon=polyList, data=data, /undocumented ']) oBridge->execute,'oPoly->getProperty, polygon=polyList, data=data, /undocumented void = dialog_message(['Now build a regular IDLgrpolygon from these points and display it', $ 'MAKE SURE YOU CLICK AND DRAG TO ROTATE IT!']) oBridge->execute,"oBadPoly = obj_new('IDLgrPolygon',data,polygon=polyList,color=[255,0,0])" oBridge->execute,'xObjView, oBadPoly, title="Bad Polygon", tlb=wBadTLB' void = dialog_message(['What I need to do is replace the bad points with good ones. ',$ 'After more digging with the debugger I discover that the IDLitVispolygon', $ 'setProperty method has the keywords __polygon and __data to pass in ',$ 'these values as long as the undocumented keyword is also set',$ ' oPoly->setProperty, __polygon=polygon_list, __data=vertex_list, /undocumented ']) ;get rid of the xobjviews oBridge->execute,'widget_control, wGoodTLB, /destroy oBridge->execute,'widget_control, wBadTLB, /destroy oBridge->execute,'vertex_colors = bytarr(3,n_elements(vertex_list[0,*]))' oBridge->execute,'vertex_colors[0,*] = 255B' oBridge->execute,'oPoly->setProperty, __polygon=polygon_list, __data=vertex_list, linestyle=6, vert_color=vertex_colors, /undocumented' void = dialog_message(['Excellent! Now lets add the stripe. (This takes a while, but looks cool)']) oBridge->execute,'ring = lonarr(3,60)' oBridge->execute,'ring[*,0:20] = (2L^24)-1' ;make a part of the ring white oBridge->execute,'for i=0, n_elements(vertex_list[0,*])-1, 60 do begin oPoly->getProperty, vert_color=vertex_colors, /undocumented ' + $ ' & vertex_colors[*,i:i+59] += ring & ring = shift(ring,3) & oPoly->setProperty, vert_color=vertex_colors, /undocumented oBridge->execute,"oText1 = text(0.2, 0.15, font_size=20, '$\it M^HE^AR^PR^PY^Y C^NH^ER^WI^ S^YT^EM^AA^RS $') oBridge->execute,"oText2 = text(0.2, 0.1, font_size=20, '$\it From Kling Research and Software $') void = dialog_message(['Happy New Year!!!!']) return & end