I would like to ask you for some hints regarding the following issue:
Suppose there are few dozens of points on a graph. A user should choose one of them, get some info on it (like coordinates and a data set to which the point is connected) and be able to delete the rest. That means, in my humble opinion, every point should be fully-fledged clickable object.
Should I use TGraph class or something completely different? How to start?
TGImageMap has required functionality, but it works only with images, not with graphs. I ponder one can convert graph to image and then proceed with this class, but it seems to me overcomplicated.
MM To be short. I would suggest you to choose some suitable but still simple class, for example TPolyMarker root.cern.ch/root/html522/TPolyM … oPrimitive
Then read root.cern.ch/root/html522/TPad.html to understand how the method above is used.
It says, [quote]When the mouse is moved on the Pad, The member function DistancetoPrimitive
is called for all the elements in the pad. DistancetoPrimitive returns
the distance in pixels to this object.
when the object is within the distance window, the member function
ExecuteEvent is called for this object.
in ExecuteEvent, move, changes can be performed on the object.
For examples of DistancetoPrimitive and ExecuteEvent functions,
see classes TLine::DistancetoPrimitive, TLine::ExecuteEvent
[/quote]The next step you may want to subclass TPolyMarker and overload that method.
There are the other approaches too. What would be the best one dependents of the scale of your project and your final goal.
Many thanks for the hints!
Sorry for the delay in response, but I was out of town. I will check your idea and then get back with the - hopefuly fortunate - result.
This part of the project is tiny. It only involves a dozen of points on a 2d graph from which user have to choose one and in a result get a parameter that is related to this point.
You can use the TMarker class objects for each of your point (see: root.cern.ch/root/html522/TMarker.html ).
Then you can use the method root.cern.ch/root/html522/TPad.h … etSelected to learn which point was selected by the user.
See example: $ROOTSYS/tutorials/graphics/triangles.C. It does what you need.