Drag and Drop Canvas Question

All,

I am currently working on a GUI using ROOT classes and drag-n-drop functionality as discussed in the tutorial, root.cern.ch/root/html/tutorials … rop.C.html.

So far I have been rather successful (already having a previous understanding of QT and signal handling).

My question is this: What exactly is happening during a canvas drop. For example, I drag a leaf on top of a canvas/pad. A graph appears out of this, but the functional language for this behavior is somewhat opaque.

Does anyone have an idea of what classes I can inherit from in order to keep track of data dragged onto a canvas? Then I can attach signals to this process and move onward.

For example, I would like to do the following (in pseudocode c++).


TH1D *h1 = new TH1D("name","descrip",10,0,1);
//h1 is now a visual object that I can drag about in my gui (similar to what is shown in the tutorial)
//I create some embedded canvas

TRootEmbeddedCanvas *feC = new TRootEmbeddedCanvas("e_can",frame,dimx,dimy);
//attach to frame/skipping showing this

//create canvas for implementation and divided elements
TCanvas *fCan = feC->GetCanvas();
fCan->Divide(3,2);

//I want to attach a nice robust signal here for passing a data that gets DND on the individual pad

Currently, I am using a much sloppier way for handling the data passing for some object being dropped on a canvas. It is a workaround considering I just look for the specific pad to be modified and then call functions to handle the work around. I would much rather be able to handle a nicer implementation as shown below.

//current sloppy implementation
for (int i=1;i<=6;i++)
{
   fCan->cd(i);
   gPad->Connect("Modified()","DNDframe",this, "DataDroppedCanvasFunction()")
}

//The implementation that I want is shown below
for (int i=1;i<=6;i++)
{
   fCan->cd(i);
   gPad->Connect("DataDropped(TDNDData*)","DNDframe",this, "DataDroppedCanvasFunction(TDNDData*)")
}

At the moment, I don’t know of any signal class that does this handling for regular canvas. Now if the only solution is to move to TGCanvas, then I guess I will. If anyone has any experience/feedback regarding this issue please let me know.

Thank you as always,
John Perry
ISR-1, LANL

Hi,

Any class inheriting from TObject, and having a Draw() method can be dragged and dropped in a canvas (or in any other “DND aware” widget (as shown in the tutorial). There is no signal/slot involved in the process, only object serialisation. The “DataDropped(TDNDData*)” signal is only emitted by the TGListTree and TGTextView classes.
One solution would be to create your own class emitting a signal in its Draw() method…

Cheers, Bertrand.

Thank you Bertrand,

I will get right on top of this. I’ll make a special class and override the Draw function adding a signal slot to it after I inherit the original Draw function. When I solve this issue, I’ll post some code for posterity.

John