GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ClickCollector.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christophe Theisen *
3  * stezow(AT)ipnl.in2p3.fr, christophe.theisen(AT)cea.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef GW_CLICKCOLLECTOR_H
24 #include "ClickCollector.h"
25 #endif
26 #ifndef ROOT_TCanvas_H
27 #include "TCanvas.h"
28 #endif
29 #ifndef ROOT_TVirtualFitter_H
30 #include "TVirtualFitter.h"
31 #endif
32 #ifndef ROOT_TObject_H
33 #include "TObject.h"
34 #endif
35 
36 
37 #include <iostream>
38 #include <fstream>
39 
40 using namespace std;
41 using namespace GwD;
42 
43 // ROOT dictionnary
45 
46 // set statics
47 ClickCollector *ClickCollector::gfCollector = 0;
48 
49 ClickCollector::ClickCollector() : fLastPx(0), fLastPy(0), fCollectMode(kKeyPress), fMarker()
50 {
51  // set marker style for peaks
52  fMarker.SetMarkerStyle(20); fMarker.SetMarkerColor(2); gfCollector = this;
53 }
54 
55 void ClickCollector::DoCollect(Int_t event, Int_t px, Int_t py, TObject */*obj*/)
56 {
57  // Collect event.
58  // if event = fCollectMode ( = double click by default ) it adds a "click"
59  // to the list of clicks and displays a TCross at that position.
60  if ( event == kMouseMotion ) {fLastPx = px; fLastPy = py; return; } // keep memory of the last position
61  if ( event == fCollectMode && fIsActive ) {
62  if ( gROOT->GetSelectedPad() ) {
63  fMarker.DrawMarker(gROOT->GetSelectedPad()->AbsPixeltoX(fLastPx),
64  gROOT->GetSelectedPad()->AbsPixeltoY(fLastPy));
65  gROOT->GetSelectedPad()->Update();
66  }
67  }
68 }
69 
71 {
72  if ( gfCollector == NULL ) new ClickCollector(); return gfCollector;
73 }
74 
void DoCollect(Int_t event, Int_t px, Int_t py, TObject *obj)
Definition: CollectOn.C:68
static ClickCollector * TheCollector()
ClassImp(ClickCollector)