Re: ROOT Enhancement Request

Valery Fine (fine@mail.cern.ch)
Wed, 20 Aug 1997 14:43:04 +0100


Dear Reiner Rohlfs
On 20 Aug 97 at 13:24, you wrote:

> Is it possible to disable and enable buttons?
> At a graphical user interface I would like to show the
> user which buttons she/he can use at every moment.
>
> By the way, how can my application program be noticed that
> the user has pressed the middle mouse button at a pad and
> has changed the current pad.
>
The ROOT main event loop works with the pointers to the objects of
TObject class only.

Whatever the mouse event is reported ROOT finds the
pointer to the appropriated object and calls its
TObject::ExecuteEvent method
(see: http://root.cern.ch/root/html/TPad.html#TPad:ExecuteEvent ).

To supply your own function one may overload this method as
follows:

class TMyPadClass : public TPad {
public:
void ExecuteEvent(Int_t event, Int_t px, Int_t py)
{ // Put here your our actions

TPad::ExecuteEvent(event, px, py); // Call "standard" one if any
}
}

See as well http://root.cern.ch/root/html/TPad.html. It says:

" ...
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
TBox::DistancetoPrimitive, TBox::ExecuteEvent
TH1::DistancetoPrimitive, TH1::ExecuteEvent

... "

The further examples can be find with our "Search Engine"
(see http://root.cern.ch/root/Search.phtml ). Just supply "ExecuteEvent" as
a key to seach for.

All available events are defined with "Buttons.h" header file as follows:

//Z,+PATCH,//ROOT/INCLUDE.
//Z,+KEEP,Buttons,T=C++..
//*CMZ : 1.01/05 06/06/97 14.39.11 by Fons Rademakers
//*CMZ : 1.00/03 14/03/97 17.57.47 by Fons Rademakers
//*-- Author : Rene Brun 08/12/95

#ifndef ROOT_Buttons
#define ROOT_Buttons

// Copyright (C) 1995 CodeCERN. All rights reserved.

enum EEventType {
kNoEvent = 0,
kButton1Down = 1, kButton2Down = 2, kButton3Down = 3, kKeyDown = 4,
kButton1Up = 11, kButton2Up = 12, kButton3Up = 13, kKeyUp = 14,
kButton1Motion = 21, kButton2Motion = 22, kButton3Motion = 23, kKeyPress = 24,
kButton1Locate = 41, kButton2Locate = 42, kButton3Locate = 43,
kMouseMotion = 51
};

enum EEditMode {
kPolyLine = 1, kSPolyLine = 2, kPolyGone = 3,
kSPolyGone = 4, kBox = 5, kDelete = 6,
kPad = 7, kText = 8, kEditor = 9,
kExit = 10, kPave = 11, kPaveLabel = 12,
kPaveText = 13, kPavesText = 14, kEllipse = 15,
kArc = 16, kLine = 17, kArrow = 18,
kGraph = 19, kMarker = 20, kPolyMarker= 21,
kPolyLine3D= 22, kWbox = 23, kGaxis = 24,
kF1 = 25, kF2 = 26, kF3 = 27,
kDiamond = 28, kPolyMarker3D = 29
};

> I would like to enable and disable buttons depending on
> which pad is the current pad.
>

Might I advice you ? Would you mind to regard the way when one
should not wait our enhancement and go ahead OO-way. I mean it
should be relatively easy to derive your own class from our TPad and
provide a new functionality you want. If it is NOT easy it will be a
reason for "Bug report" or "Enhancement Request". From another hand
if it will be easy and useful we can incorporate your method for the
"common" TPad to make it available for whole "Free Software"
community.

I believe Rene will supply you a good advice for this particular
case (namely he will write some new code for you, myself work for
another project now), but I think it would be more useful for ROOT,
ROOT's users to let ROOT team implementing most general things. If
our users will provide us some pieces of code they found useful to be
included in ROOT this will be a great enhancement of ROOT.

I'd like to highlight that I has expressed my own personal opinion
only but the ROOT team position on this issue..

With my best regards,
Valery