Mouse click event capture

Hi,

I would like to show some informations about the volume clicked with the mouse.
In other words, I need a pointer for function called every time someone click in a volume with the mouse.

Is it possible?

Luciano

[quote]Hi,

I would like to show some informations about the volume clicked with the mouse.
In other words, I need a pointer for function called every time someone click in a volume with the mouse.

Is it possible?

Luciano[/quote]

IMHO If ROOT’s standard context menu, which you can open on a selected object, is not enough for you, I guess the answer is no.

Hi Luciano,

Yes, it is possible. You can see as an example the macro $ROOTSYS/tutorials/gui/exec3.C. It shows how to connect a slot method to the signal “ProcessedEvent(Int_t,Int_t,Int_t,TObject*)” of the canvas. This signal method provides information about the event, its x,y location and the TObject involved in this event. The list of all events is included below: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, kESC = 27, kMouseMotion = 51, kMouseEnter = 52, kMouseLeave = 53, kButton1Double = 61, kButton2Double = 62, kButton3Double = 63 };For more information about signals/slots communication mechanism, please see the chapter “Event Processing: Signals and Slots” on page 394 at ftp://root.cern.ch/root/doc/chapter26.pdf

Please do not hesitate to ask questions if you have any.

Cheers, Ilka

Hi Ilka,

Thank you very much for your reply!
Before I try this, let me ask you one more question: Does this work in the opengl mode?

[quote]Hi,

I would like to show some informations about the volume clicked with the mouse.
In other words, I need a pointer for function called every time someone click in a volume with the mouse.

Is it possible?

Luciano[/quote]

Can you, please, give more details?

  1. How do you want “to show some informations about the volume clicked with the mouse”.
  2. Which information do you want? About OpenGL object or real object in geometry?
  3. What do you mean by “a pointer for function called every time someone click in a volume with the mouse” ?

1- simply using the cout to print out the informations in the console
2- Those are specific information concerning the detector. Each volume represents a detector cell. if I know the volume clicked, I can print out the energy deposited in the cell.
3- Ilka explains this in more details in the answer bellow

Luciano

Hi Luciano,

The example I poined out works for the objects drawn in a canvas without openGL. Timur (tpochep) is a GL expert and will give you the right answer is that works in openGL mode or not.

Cheers, Ilka

[quote=“lucianom”]Hi Ilka,

Thank you very much for your reply!
Before I try this, let me ask you one more question: Does this work in the opengl mode?[/quote]
Please check the slide 17 from
"Qt & ROOT" by V.Fine,
ROOT Workshop 2005
agenda.cern.ch/askArchive.php?ba … AtCERN.pdf
There are other solutions too.

Hi Valera,
I have a question related to the “Click mouse action of QGLViewer” (page 14,15).
Do these bindings correspond to some “standart” for GL viewers?

thnx. Regards. Valeriy

[quote=“Valeriy Onuchin”]I have a question related to the “Click mouse action of QGLViewer” (page 14,15).
Do these bindings correspond to some “standart” for GL viewers?[/quote]What do you mean? One said[quote=“fine”]There are other solutions too.[/quote] It seems to me the original question was not about the mouse binding. It was about the 3D object selection. Can you elaborate a little bit more? [ul](Rene did ask me several times to conduct the Qt-ROOT unrelated discussion elsewhere. Please, do not reply here. If you want to continue, switch to the Qt-root list. May be you should communicate the QGLViewer author directy too artis.imag.fr/Members/Gilles.Deb … index.html )[/ul]
I think the mouse binding is described by the QGLViewer docs (this is where those slides came from). You may have realized one can choose there any binding he / she likes and remove those he / she dislikes.
( artis.imag.fr/Members/Gilles.Deb … mouse.html and mark which binding has to be changed from your standpoint. This will spare us and the list members hours of the fruitless reading. [/list:u]Anyway, such flexibility is the mandatory component of any reliable 3D interactive package. I am still puzzled with your “standard”. The number of the available mouse events is far less the number of the needed events to interact with the arbitrary 3D scene. By this reason the mouse event binding varies from one viewer to another one even within one and the same package. For example, both Open Inventor and Coin3D packages provide a bunch of the different viewers with the different mouse binding.
I believe (from my experience) we can not choose the “one size fit all” mouse binding (if you know that let me know to adopt )
[ul] - for the “online monitoring software” for the control room

  • to debug the offline reconstruction code
  • to debug the “detector geometry” for the GEANT simulation code alike
  • to provide the animation for public relation events.[/ul]Of course the “mouse binding” is a crucial component of the interactive package and should be carefully designed. However it is not the job of the low level 3D rendering package. This level should provide the tool (API) to select suitable binding and some reasonable default to start from.

Any concrete comments / suggestions / corrections for the code and for the documentation are welcome
They will be appreciated, and they will be included in the code and documentation. (The proper credit is to be provided too :wink:

Have you any real suggestion?

Valery Fine wrote:

I simplify my question -
“when I roll middle button (roller) of the mouse toward myself -> the GL scene is
moving to direction out of me. Is it standart behaviour for GL/3D viewers?”

The experience with DOOM :slight_smile: , VTK (vtk.org/) based applications,
blender (blender.org), etc. shows that “some” standart
bindings exist (like editors key/mouse bindings).

The answer to this question is crucial for a moment, because ROOT 3D/2D
graphics development “rushing” to GL area and it is important to follow
the GL/3D viewers standarts.

Valeriy,

You are perfectly right. Timur is supposed to fix this oddity asap.

Rene

Rene,
strangelly enought, but this “oddity” is standart for GL/3D viewers.

Regards. Valeriy

[quote=“Valeriy Onuchin”]Valery Fine wrote:

I simplify my question -
“when I roll middle button (roller) of the mouse toward myself -> the GL scene is
moving to direction out of me. Is it standart behaviour for GL/3D viewers?”
[/quote] Hi Valeriy,
What you see has a very simple explanation.
There are more then one :bulb: model and all of them them are “standard” if you want.
(read carefully doc.coin3d.org/SoQt/classSoQtViewer.html
that defines 4 different viewers those correspond 4 different “standard” models to understand the difference. There are more then 4. See: tgs.com/support/oiv_doc/index.htm too ) )
That has nothing to do with the mouse binding at all.

The question is what part of the 3d scene you interact with.
All text books explain that one can interact with the “object” and one can interact with the “camera”.
Imagine you interacted with the “camera” rather with the “object” and everything are becoming correct and intuitive.
Did you ride the trains? Can you recall which direction the train station premise moves as soon as the train starts moving on?

Apparently if you have the perspective projection and you interact with the “camera”, and move the "camera " with the mouse wheel towards you the way you described you make the camera moves out of the object. This gave you an impression (recall the train) the object was moving in the opposite direction . In fact that’s more intuitive especially for the game, because in the real life (and in the game too) you can not move the object but you do move yourself (think, you are camera) . I do not think it is appropriated speaking about the “standard”. One should clearly define his current 3D interaction model first (“examine view”, “walk view”, “fly through view” etc). Normally the advanced 3D packages do allow developers to choose between camera / object interaction and switch between them. It is the user who decides what part of the 3D scene hi / she wants to interact with at the moment. It is never hard-coded (standardized) by the 3d development kit.

[quote=“Valeriy Onuchin”]Valery Fine wrote:

I simplify my question -
“when I roll middle button (roller) of the mouse toward myself -> the GL scene is
moving to direction out of me. Is it standart behaviour for GL/3D viewers?”

The experience with DOOM :slight_smile: , VTK (vtk.org/) based applications,
blender (blender.org), etc. shows that “some” standart
bindings exist (like editors key/mouse bindings).[/quote]Please read doc.coin3d.org/SoQt/classSoQtPlaneViewer.html . It says,