User defined cursors, TGTooltips, Context menu titles, Pointing-down y-axes: my (ROOT) problems exposed...

From: Giorgio De Nunzio <giorgio.denunzio_at_aliceposta.it>
Date: Mon, 3 Oct 2005 09:54:12 +0200


Hi all, in particular Rene', Valeri and Bertrand, who are kindly helping me (Hope I am forgetting none!!)
Sorry for replying so late, but I still have mail problems. In particular, when trying to write to the list I get the msg:

>This is the Postfix program at host cabis.unile.it.
>I'm sorry to have to inform you that the message returned
>below could not be delivered to one or more destinations.
...
><roottalk_at_pcroot.cern.ch>: host cernmxlb.cern.ch[137.138.166.163] said:
> 550-5.7.1 Relaying denied. No reverse DNS configured for IP
212.189.128.35.
> 550 See http://cern.ch/mmms/why.aspx?rdns=1&ip=212.189.128.35 for more
> information. (in reply to MAIL FROM command)

I have to investigate further. I am now obliged to use another mail server (the Telecom ADSL one), but there again strange things happen..

OK, back to my ROOT questions.
Before all, thanks for your kind interest and help! All of my present ROOT problems come from the same piece of code...

I have defined a class, TAnnotation, which derives from TEllipse and TString (but the latter can, and will possibly, change): it is an empty circle drawn around an image detail, with a comment to be written somewhere.

  1. (TGTooltip problem) When the user moves the mouse pointer over the TAnnotation object, the comment must appear somewhere near the object (here, the TGTooltip object enters the game).
  2. (context menu) When the user right-clicks on the TAnnotation obj, a context menu must appear (and I'd like to put "Annotation modify" on top of it, instead of "TAnnotation": here is the context menu title question)
  3. (cursors) The user, in certain conditions, can modify the TAnnotation (move the circle, change its size, change the comment). I use a boolean data member, fLocked, to decide if the user has the right of modifying the TAnnotation: in this case when he/she moves the mouse pointer over it, standard enlarge/move handles are shown and the cursor is also standard (various arrows etc). If the user cannot modify the annotation, I want a different cursor to be shown (a user defined cursors, eg a padlock).
  4. (axes inversion) I'd like to invert the y axis for the image and the objects drawn on it.

Details (figures correspond to the above list).

  1. Nothing new about the TGTooltip problem: I have not continued testing. The only thing I have thought is that perhaps I have to change the "parent" parameter of the tooltip, so that it is not gClient->GetRoot() but the frame in which the TEmbeddedCanvas (where my objects are drawn) lives. I do not know if I am clear enough...
  2. Rene' proposed to change the inheritance from TString to TNamed and use the SetName method. I have tried but, when compiling, I get:

"Warning: multiple ambiguous inheritance TObject and TX. Cint will not get correct base object address"

I have tried to define a simpler class and try:

class TX : public TEllipse, public TNamed { public:
  TX() : TEllipse(), TNamed() {}

   ClassDef(TX ,1)
};

...

ClassImp(TX)

Compiling, I get the aforementioned message. Uh, perhaps I have not even tried to see if the context menu title changed, anyway.

3) Cursors.
I understand very well that this is not a top priority problem, so feel free to completely neglect it.

I have written this code in my HandleEvent() method:

   case kMouseMotion:     // shows the different cursors (arrows, cross)
      cout << "kMouseMotion\n";

      if (fLocked)
          gPad->SetCursor(kHand);        // CURSOR CHANGE!
      else {
          px1 = gPad->XtoAbsPixel(fX1);
          py1 = gPad->YtoAbsPixel(fY1);
          Tx = Bx = px1;
          ... OMISSIS ...
          if ((TMath::Abs(px - Tx) < kMaxDiff) &&
              (TMath::Abs(py - Ty) < kMaxDiff)) {             // top edge
             T = kTRUE;
             gPad->SetCursor(kTopSide);        // CURSOR CHANGE!
          }
          else
          if ((TMath::Abs(px - Bx) < kMaxDiff) &&
              (TMath::Abs(py - By) < kMaxDiff)) {             // bottom edge
             B = kTRUE;
             gPad->SetCursor(kBottomSide);        // CURSOR CHANGE!
          ... OMISSIS ...
          else {
            INSIDE = kTRUE;
            gPad->SetCursor(kMove);        // CURSOR CHANGE!
          }
          pxold = px;  pyold = py;
      }
      break;
          ... OMISSIS ...

The code is taken from TEllipse HandleEvent(), with some modifications.

As you can see, I have set the cursor to kHand when the TEllipse cannot be modified, while as usual kMove, kTopSide, etc are used when fLocked is false and the user can modify the TAnnotation object.

I simply don't like that kHand pattern: I'd like something more informative or nicer, eg a closed padlock.
Just as an initial test, I have tried to #include <qcursor.h> but there was no such file. I'll try again and look for it: possibly I have to download Qt separately, or simply use the right path.

4) I have not tried the sample codes sent to me by Rene' yet (thanks!). I remember I had already seen that code, but the inverted axes did not work at the time. It was a dfferent ROOT version. I'll take a look at the source and try to adapt it to my need.

Thanks for your patience in reading all this!

Ciao
Giorgio



Dr. Giorgio De Nunzio

Dipartimento di Scienza dei Materiali
Universita' di Lecce

tel. 0832 297084
giorgio.denunzio_at_unile.it Received on Mon Oct 03 2005 - 09:51:22 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:12 MET