Canvas Position

Hello! 8)

Thank you for your framework! I’m writing quite an extensive and feature reach analytical gui application for people in our lab based solely on root, and recently got few requested features that I’m trying to figure out how to implement.

The idea is that there would be an option to place a marker in an arbitrary position in the TH1s to mark some features of the graphs. So because I want to make this to be accessible from a context menu of TCanvas, I don’t really have an access to Event Arguments, such as mouse position, if I would have simply done it using say, double click…

Do you have any suggestions how I can find out the position from which the context menu was called, so I could instanciate Marker at that point?

I guess one way to do it, would be to simply track all the canvas mouse movements and then use the last set of values when instantiating… but I thought may be there is a better way… besides the program is already quite heavily multithreaded and global shared memory updates is not what I would want to bring in(though I guess I could derive from TCanvas and make each of them to handle it separately)…

Another question - is it there an easy way to lock the th1 in a place? So that histos wouldn’t move when people accidentally click and drag on them in the canvas… because it happens a lot.

using ROOT 5.34

MainFrame::MainFrame()
{ 
   .... 
    // Context menu set up
	TClass *class = gROOT->GetClass("TCanvas");
	TClassMenuItem *n;
	TList *list = class->GetMenuList();
     
	n = new TClassMenuItem(TClassMenuItem::kPopupUserFunction, cl,
		"Place a Marker", "PlaceMarker", this, "TObject*,const char*",0);
	list->AddFirst(n);
   ...
}

void MainFrame::PlaceMarker(TObject* c,const char* message)
{
	((TCanvas*)c)->cd();
	TMarker* m = new TMarker();
	m->SetMarkerSize(1);
	m->SetMarkerColor(kRed);
	m->SetMarkerStyle(3);
	// Here I want to figure out X and Y...
	m->DrawMarker(_X_,_Y_);
	((TCanvas*)c)->Modified();
	printf("Marker Placed %s\n", message);
}

Thank you for your time! :wink:
Jacob

I am not sur there is an easy way. Let see what our GUI expert will says when he will be back.

 h->SetBit( kCannotPick )
Thank you very much! 

Looking forward to hear opinions of Gui experts. I was thinking, may be there is a way to get the list of all the context menus from some global reference and get position of the last one?

Thank you very much!

Looking forward to hear opinions of Gui experts. I was thinking, may be there is a way to get the list of all the context menus from some global reference and get position of the last one?

Hey guys :slight_smile: I Know it’s Monday, every one’s back to work.

Don’t you mind if I up this post once, in case you got any new ideas? :bulb:

Hi,

I’ll check if there is a solution and let you know.

Cheers, Bertrand.

Hi Jacob,

You could try to connect to the ProcessedEvent() signal from the TCanvas to memorize the right click coordinate, and then use it in MainFrame::PlaceMarker()

Cheers, Bertrand.

[quote=“bellenot”]Hi Jacob,

You could try to connect to the ProcessedEvent() signal from the TCanvas to memorize the right click coordinate, and then use it in MainFrame::PlaceMarker()

Cheers, Bertrand.[/quote]

Thank you Very much! That’s what I was thinking… :smiley: