X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 28 Mar 2008 11:24 AM by  anon
obtain
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
28 Mar 2008 11:24 AM
    hello, I 've created a widget_draw which contain object graphic (idlgrplot, idlgrmodel and idlgrview), my idlgrplot contain data in longitude latitude, and has been normalized in [0,1] to fit with the viewplane_rect ([0,0,1,1]) of my idlgrview. My question is : I want to know how can obtain the exact postion of my cursor mouse after click in the widget_draw in the normalized coord of my idlgrplot. . When i click in my widget_draw, that make an event, and event.x and event.y return the device coord and i don't how i could obtain the exact normalized coord of my idlgrplot. i try with the 'convert_coord' but it works only with direct graphics, and i use object graphics Thanks for your answer

    Deleted User



    New Member


    Posts:
    New Member


    --
    28 Mar 2008 11:24 AM
    The normalized coordinate can be calculated with basic math: normalizedX = event.X / wDrawWidth normalizedY = event.Y / wDrawHeight In most applications WIDGET_DRAW dimensions are static, so those 'windowWidth' and 'windowHeight' values are easy to acquire. If, however, your WIDGET_DRAW dimensions can change dynamically, a programmer can query them dynamically with call syntax like: wDrawGeometry = widget_info(wDraw, /GEOM) wDrawWidth = wDrawGeometry.XSIZE wDrawHeight = wDrawGeometry.YSIZE The above code is an option for dynamically-size draw windows, but I would actually recommend maintaining 'wDrawWidth' and 'wDrawHeight' variables and updating them every time you handle any resize event. James Jones

    Deleted User



    New Member


    Posts:
    New Member


    --
    28 Mar 2008 11:24 AM
    You will probably want to use the IDLgrWindow::PickData method to return your normalized coordinate position. It's not clear from your description if you're normalizing the data in the IDLgrPlot, or if you're scaling your container IDLgrModel to cause the normalization. I'll assume it's the latter, since that makes life simpler. I'm also going to assume that you've stored your IDLgrView as the GRAPHICS_TREE property of the IDLgrWindow, otherwise you'll need to get your IDLgrView reference ("oview") by "some other means". Here's some example code for extracting the data coordinates from the plot in your event handler. widget_control, event.id, get_value = odrawwindow odrawwindow->getproperty, graphics_tree = oview omodel = oview->get(position = 0) oplt = omodel->get(position = 0) r = odrawwindow->pickdata(oview, oplt, [event.x, event.y], xyz, pick_status = ps) if (ps eq 1) then begin datax = xyz[0] datay = xyz[1] endif If you are normalizing your data *before* you populate the IDLgrPlot object, then datax and datay will be in normalized coordinates and you will want to perform an additional mathematical inversion to convert back to lat/long. realdatax = datax*xscaleinversion + xoffset realdatay = data*yscaleinversion + yoffset Jim.
    You are not authorized to post a reply.