How to let TPolyLine respond to the click of mouse?

Hi rooters,

I draw many poly lines to form some hexagon in the canvas, and furthermore, I want to make use of this hexagon to give a respond to the mouse click. But, I have a close look the TPolyLine class, and I can’t find a member function fullfiling my demand.

Do you have any idea for this?

Thanks in advance.

Xiaodong

see example in $ROOTSYS/tutorials/graphics/triangles.C

Rene

Thanks Rene, this marco is very helpful for me! It is just what I am looking for. Thanks again.

Regards,

Xiaodong

one question about TPolyLine, how to let it not give a respond to the mouse dragging.

Thanks,

Xiaodong

You can replace your TPolyLine by a TGraph *gr and do

gr->SetBit(TGraph::kNotEditable);
Rene

hello Rene,

Thank you for quickly answer. Following your suggestion, I still can not get success. The points in the graph can not be changed but the polyline still is like normal, i.e., when I use mouse drag it, it still change. maybe I didn’t enderstand your means. Could you please give me further explanation for your idea?

Thanks in advance.

Xiaodong
polyline.C (425 Bytes)

My suggestion was to use TGraph instead of TPolyLine as shown in the attachment

Rene
polyline.C (510 Bytes)

But in my standalone program, I want to use TPolyLine show hexagon shape, and using the different filling colors show the difference of events, it quite like the “hexagon bin histogram”. When I click this hexagon region, it will give a respond to show detailed information about the corresponding event. All of them have been solved following your first answer, but one thing is during the program running, when somebody click the ployline, sometimes will drag the mouse, so the hexagon shape will be changed, which is not I hope to see. That is my subject of second question. Hope I gave a clear description.

So, if that, is there some easy way to solve this? or have some other solution I don’t know?

Thanks,

Xiaodong

Take this example in the attachment and pick the SVN trunk of ROOT.

Rene
triangles.C (1.56 KB)

Now, I wrote a daughter of TPolyLine class and overloaded the mother function, ExecuteEvent(). The above problem is solved, but I don’t think it is a good way. Hope to get much more new idea for that.

Thanks,

Xiaodong