/*************************************************************************** * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck * * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.in2p3.fr * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ /** \file BaseLSPlayer.cpp compiled in libGWPHYSICS.so */ #include #ifndef ROOT_KeySymbols #include "KeySymbols.h" #endif #ifndef ROOT_TBox #include "TBox.h" #endif #ifndef ROOT_TCanvas #include "TCanvas.h" #endif #ifndef ROOT_TContextMenu #include "TContextMenu.h" #endif #ifndef ROOT_TGaxis #include "TGaxis.h" #endif #ifndef ROOT_TGToolTip #include "TGToolTip.h" #endif #ifndef ROOT_TList #include "TList.h" #endif #ifndef ROOT_TMath #include "TMath.h" #endif #ifndef ROOT_TMethod #include "TMethod.h" #endif #ifndef ROOT_TPad #include "TPad.h" #endif #ifndef ROOT_TVirtualX #include "TVirtualX.h" #endif #ifndef ROOT_TROOT #include "TROOT.h" #endif #ifndef Gw_BaseLSPlayer #include "BaseLSPlayer.h" #endif #ifndef Gw_BaseNucleus #include "BaseNucleus.h" #endif #ifndef Gw_GammaLink #include "GammaLink.h" #endif #ifndef Gw_NuclearLevel #include "NuclearLevel.h" #endif #ifndef Gw_Peak1D #include "Peak1D.h" #endif #ifndef Gw_EnsdfLevelSchemeReader #include "EnsdfLevelSchemeReader.h" #endif #ifndef Gw_RadLevelSchemeReader #include "RadLevelSchemeReader.h" #endif using namespace Gw; Float_t BaseLSPlayer::fgDefaultSize[4] = {28000, 32000, 0, 6000}; Float_t BaseLSPlayer::fgDefaultWidth = 600; Int_t BaseLSPlayer::fgDefaultToggleColor = 24; // //__________________________________________________________ BaseLSPlayer::BaseLSPlayer(LevelScheme* levelScheme) : TNamed("BaseLSPlayer", "Default"), fLastX(0), fLastY(0), fBox(new TBox(0, fgDefaultWidth, 0, fgDefaultWidth)), fSelectedLinks(new Cascade()), fSelectedLevels(new Cascade()), fSelectedCascades(new TList()), fNucleiList(new TList()), fLevelScheme(levelScheme), fDrawStyle(kUnknown), fAxis(new LSaxis()), fInfoTip(new TGToolTip(fBox, "", 350)), fIsOnAxis(true), fIsTipsOn(true), fIsLSSelected(false), fContextMenu(NULL), fCColorSelectedLink(BasePeak::gGateColor.k0), fPositionLabels(0.), fLog("BaseLSPlayer") //, // fURLtoSaveLS("./") { // default constructor fSelectedCascades->SetOwner(false); fNucleiList->SetOwner(true); fAxis->SetLineWidth(2); fAxis->SetNdivisions(510); fAxis->SetLabelSize(0.04); } //__________________________________________________________ BaseLSPlayer::~BaseLSPlayer() { // default destructor delete fSelectedLinks; // default wise not owner of the links (levels) delete fSelectedLevels; delete fSelectedCascades; delete fNucleiList; delete fAxis; delete fInfoTip; delete fBox; } //__________________________________________________________ void BaseLSPlayer::SetTipText(TObject* select) { TString name(select->ClassName()); if ( name.CompareTo("Gw::Link") == 0 ) { Link* link = static_cast ( select ); fInfoTip->SetText(Form("Strength: %5.1f", link->GetStrength().Get()) ); } if ( name.CompareTo("Gw::Level") == 0 ) { fInfoTip->SetText("Level"); } if ( select->InheritsFrom("Gw::GammaLink") ) { GammaLink* link = static_cast ( select ); if (link->IsE()) fInfoTip->SetText(Form("Strength: %6.1f\nEnergy: %6.1f\nPolarity: E%d", link->GetStrength().Get(), link->GetEnergy().Get(), link->GetLambda()) ); else fInfoTip->SetText(Form("Strength: %6.1f\nEnergy: %6.1f\nPolarity: M%d", link->GetStrength().Get(), link->GetEnergy().Get(), link->GetLambda()) ); } if ( select->InheritsFrom("Gw::NuclearLevel") ) { NuclearLevel* level = static_cast ( select ); if ( level->GetParity().IsParity(Parity::kPlus) ) fInfoTip->SetText(Form("Energy: %6.1f\nSpin: %s+\nHalf-Live: %6.1f", level->GetEnergy().Get(), level->GetSpin().GetString(), level->GetT().Get()) ); else fInfoTip->SetText(Form("Energy: %6.1f\nSpin: %s-\nHalf-Live: %6.1f", level->GetEnergy().Get(), level->GetSpin().GetString(), level->GetT().Get()) ); } } //__________________________________________________________ Bool_t BaseLSPlayer::Connect(TCanvas *canvas) { fLog.SetProcessMethod("Connect(TCanvas* )"); TCanvas *localCanvas = canvas; // in this case connect the current canvas if ( canvas == 0x0 ) { if ( TVirtualPad::Pad() ) localCanvas = TVirtualPad::Pad()->GetCanvas(); else { fLog << warning << "Pad not existing yet" << nline ; } } if ( localCanvas) { localCanvas->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "Gw::BaseLSPlayer", this, "HandleMovement(Int_t, Int_t, Int_t, TObject*)"); fContextMenu = localCanvas->GetContextMenu(); } fLog << dolog; return localCanvas != 0x0; } //__________________________________________________________ Bool_t BaseLSPlayer::Disconnect(TCanvas *canvas) { fLog.SetProcessMethod("Disconnect(TCanvas* )"); TCanvas *localCanvas = canvas; // in this case connect the current canvas if ( canvas == 0x0 ) { if ( TVirtualPad::Pad() ) { localCanvas = TVirtualPad::Pad()->GetCanvas(); } else { fLog << error << "Pad not existing" << dolog; } } if ( localCanvas ) { TQObject::Disconnect(localCanvas,"HandleMovement(Int_t, Int_t, Int_t, TObject*)",this); } fContextMenu = 0x0; fLog << dolog; return localCanvas != 0x0; } void BaseLSPlayer::RefreshLinks() { for(int i=0 ; iInheritsFrom("Gw::Link")) { Link* link = static_cast(GetLinkList().At(i)); link->RefreshPoints(); link->Paint(); } } gPad->Modified(); gPad->Update(); } //__________________________________________________________ void BaseLSPlayer::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* select) { // handle cursor mouvement TVirtualPad* pad = TVirtualPad::Pad(); pad->cd(); if (eventType == kButton1Up) { RefreshLinks(); } if (eventType == kMouseMotion) { // to keep track of the last mouse position fLastX = eventX; fLastY = eventY; if ( select->InheritsFrom("Gw::BaseLSPlayer") || select->InheritsFrom("Gw::Cascade") || select->InheritsFrom("Gw::LevelScheme") ) { pad->SetCursor(kPointer); } if ( select->InheritsFrom("Gw::Link") ) { Link* link = static_cast(select); if ( !link->IsMovable() ) pad->SetCursor(kPointer); } if ( select->InheritsFrom("Gw::Level") ) { Level* level = static_cast(select); if ( !level->IsMovable() ) pad->SetCursor(kPointer); } if (fIsTipsOn) { if ( select->InheritsFrom("Gw::Link") || select->InheritsFrom("Gw::Level")) { SetTipText(select); fInfoTip->Show(fLastX, fLastY); } else fInfoTip->Hide(); } } if( eventType == kKeyPress) { TObject *obj = 0x0; Int_t keysym = eventY; Color_t color = 0; Bool_t keyPress = false; switch ((EKeySym) keysym ) { case kKey_s: color = fCColorSelectedLink; keyPress = true; break; case kKey_0: case kKey_x: color = BasePeak::gGateColor.k0; fCColorSelectedLink = color; keyPress = true; break; case kKey_1: case kKey_y: color = BasePeak::gGateColor.k1; fCColorSelectedLink = color; keyPress = true; break; case kKey_2: case kKey_z: color = BasePeak::gGateColor.k2; fCColorSelectedLink = color; keyPress = true; break; case kKey_3: color = BasePeak::gGateColor.k3; fCColorSelectedLink = color; keyPress = true; break; default: keyPress = false; break; } if ( select->InheritsFrom("Gw::Link") && keyPress) { Link* link = static_cast(select); if (link->IsSelected()) { link->SetFillColor( Link::GetDefaultColor() ); link->DeSelected(); fSelectedLinks->Remove(link); } else { link->SetFillColor(color); link->Selected(); fSelectedLinks->Add(link); } TIter next(fSelectedLinks); while ( (obj = next()) ) link = static_cast ( obj ); fLevelScheme->SetCLink(link); } if ( (EKeySym)keysym == kKey_s) { if ( select->InheritsFrom("Gw::Level") ) { Level* level = static_cast(select); if (level->IsSelected()) { level->SetLineColor( Level::GetDefaultColor(level->GetDefaultColor()) ); level->DeSelected(); fSelectedLevels->Remove(level); } else { level->SetLineColor( Level::GetDefaultColor(Level::kSelected) ); level->Selected(); fSelectedLevels->Add(level); } TIter next(fSelectedLevels); while ( (obj = next()) ) level = static_cast ( obj ); fLevelScheme->SetCLevel(level); } Link* link = 0x0; if ( select->InheritsFrom("Gw::Cascade") ) { Cascade* cas = static_cast(select); if (cas->IsSelected()) { for (Int_t i = 0; i < cas->GetSize(); ++i) { link = static_cast (cas->At(i)); link->SetFillColor( Link::GetDefaultColor() ); link->DeSelected(); } cas->DeSelected(); cas->SetLabelColor(Cascade::kDefault); fSelectedCascades->Remove(cas); } else { for (Int_t i = 0; i < cas->GetSize(); ++i) { link = static_cast (cas->At(i)); link->SetFillColor(fCColorSelectedLink); link->Selected(); } cas->Selected(); cas->SetLabelColor(Cascade::kSelected); fSelectedCascades->Add(cas); } TIter next(fSelectedCascades); while ( (obj = next()) ) cas = static_cast ( obj ); fLevelScheme->SetCCascade(cas); } } if ( (EKeySym)keysym == kKey_g) ShowGate(); if ( (EKeySym)keysym == kKey_P) DrawProjTot(); if ( (EKeySym)keysym == kKey_t) { if (fIsOnAxis == true) { fIsOnAxis = false; fAxis->SetLineColor(GetDefaultToggleColor()); fAxis->SetLabelColor(GetDefaultToggleColor()); } else if (fIsOnAxis == false) { fIsOnAxis = true; fAxis->SetLineColor(1); fAxis->SetLabelColor(1); } } if ( (EKeySym)keysym == kKey_i) { if (fIsTipsOn == true) { fIsTipsOn = false; fInfoTip->Hide(); } else if (fIsTipsOn == false) fIsTipsOn = true; } if ( (EKeySym)keysym == kKey_a) { if (fIsLSSelected == true) { fIsLSSelected = false; DeSelect(); } else if (fIsLSSelected == false) { fIsLSSelected = true; Select(); } } if ( (EKeySym)keysym == kKey_h) { cout << "Keys used to interact with LSPlayer: " << endl; cout << "\t s: select a link/level/cascade " << endl; cout << "\t 1/x: select a link for a gate on x-axis " << endl; cout << "\t 2/y: select a link for a gate on y-axis " << endl; cout << "\t 3/z: select a link for a gate on z-axis " << endl; cout << "\t 4 : select a link for a gate on t-axis " << endl; cout << "\t a: select the whole level scheme " << endl; cout << "\t g: Show gates " << endl; cout << "\t P: Draw total projection " << endl; cout << "\t i: Toggle on/off information tips that appears when passing over an object" << endl; cout << "\t t: Toggle on/off active LS menu on canvas " << endl; cout << "\t l: Popup dialog box for Add Link method " << endl; cout << "\t e: Popup dialog box for Add Level method " << endl; cout << "\t f: Popup dialog box for Add First Level method " << endl; cout << "\t G: Popup dialog box for Add Ground Level method " << endl; cout << "\t w: Popup dialog box for writing level scheme in a root file " << endl; cout << "\t p: Popup dialog box for making projection from registered correlated space " << endl; } if ( (EKeySym)keysym == kKey_l) PopupAddLink(); if ( (EKeySym)keysym == kKey_e) PopupAddLevel(); if ( (EKeySym)keysym == kKey_f) PopupAddFirstLevel(); if ( (EKeySym)keysym == kKey_G) PopupAddGroundLevel(); if ( (EKeySym)keysym == kKey_w) PopupWriteLS(); if ( (EKeySym)keysym == kKey_p) PopupDoProject(); if(eventX != -666) { pad->Modified(); pad->Update(); } } pad->cd(); } //__________________________________________________________ Int_t BaseLSPlayer::CollectLinks(Option_t* o) { fLog.SetProcessMethod("CollectLinks(Option_t* )"); // create link list from pad TVirtualPad* pad = TVirtualPad::Pad(); pad->cd(); if ( !pad ) { fLog << error << "Pad not existing" << dolog; return 0; } TString opt = o; if ( !opt.Contains("+") ) fSelectedLinks->Clear(); TObject *obj; Int_t i = 0; TIter next(TVirtualPad::Pad()->GetListOfPrimitives()); while ( (obj = next()) ) // iterator skips empty slots if ( obj->InheritsFrom("Gw::Link") ) { if (!fSelectedLinks->FindObject(obj)) { Link* link = static_cast (obj); if ( link->IsSelected() ) { fSelectedLinks->Add(obj); i++; } } } fLog << info << Form("Collect %d links", i) << dolog; return i; } //__________________________________________________________ Int_t BaseLSPlayer::CollectLevels(Option_t* o) { fLog.SetProcessMethod("CollectLevels(Option_t* )"); // create link list from pad TVirtualPad* pad = TVirtualPad::Pad(); pad->cd(); if ( !pad ) { fLog << error << "Pad not existing" << dolog; return 0; } TString opt = o; if ( !opt.Contains("+") ) fSelectedLevels->Clear(); TObject *obj; Int_t i = 0; TIter next(TVirtualPad::Pad()->GetListOfPrimitives()); while ( (obj = next()) ) // iterator skips empty slots if ( obj->InheritsFrom("Gw::Level") ) { if (!fSelectedLevels->FindObject(obj)) { Level* level = static_cast (obj); if ( level->IsSelected() ) { fSelectedLevels->Add(obj); i++; } } } fLog << info << Form("Collect %d levels", i) << dolog; return i; } //__________________________________________________________ Int_t BaseLSPlayer::CollectCascades(Option_t* o) { fLog.SetProcessMethod("CollectCascades(Option_t* )"); // create link list from pad TVirtualPad* pad = TVirtualPad::Pad(); pad->cd(); if ( !pad ) { fLog << error << "Pad not existing" << dolog; return 0; } TString opt = o; if ( !opt.Contains("+") ) fSelectedCascades->Clear(); TObject *obj; Int_t i = 0; TIter next(TVirtualPad::Pad()->GetListOfPrimitives()); while ( (obj = next()) ) // iterator skips empty slots if ( obj->InheritsFrom("Gw::Cascade") ) { if (!fSelectedCascades->FindObject(obj)) { Cascade* cas = static_cast (obj); if ( cas->IsSelected() ) { fSelectedCascades->Add(obj); i++; } } } fLog << info << Form("Collect %d cascades", i) << dolog; return i; } //__________________________________________________________ Int_t BaseLSPlayer::DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/) { Int_t d; if (fIsOnAxis) d = 9999; else d = 0; return d; } //__________________________________________________________ void BaseLSPlayer::Draw(Option_t *opt) { // draw level scheme fLog.SetProcessMethod("Draw(Option_t* )"); TString style(opt); style.ToLower(); Level *level; Double_t xmin, xmax, ymin, ymax; Double_t xminOld = 0.; Double_t xmaxOld = 0.; // Double_t yminOld = 0.; Double_t ymaxOld = 0.; Double_t xRminOld, xRmaxOld, yRminOld, yRmaxOld; Bool_t p1 = false, p2 = false, pL = false; TList* levels = &fLevelScheme->GetLevelList(); TList* links = &fLevelScheme->GetLinkList(); TList* cascades = &fLevelScheme->GetCascadeList(); TLatex* name = &fLevelScheme->GetNameLatex(); // first draw label if (!style.Contains("-t")) name->Draw(""); if ( levels->GetSize() == 0 ) return; // switch to current style if (style.Contains("rad") && !IsDrawStyle(kRadware)) DoStyle(kRadware); if (style.Contains("ensdf") && !IsDrawStyle(kEnsdf)) { DoStyle(kEnsdf); } // add all levels to the current pad. if (!style.Contains("-le")) levels->Draw(""); if (!style.Contains("-b")) cascades->Draw(""); if (!style.Contains("-l")) links->Draw(""); // loop over all levels to determine the canvas range level = (Level *)levels->First(); xmin = level->GetX1(); xmax = level->GetX2(); ymin = level->GetY1(); ymax = level->GetY2(); TIter iter(levels); while ( (level = (Level *)iter()) ) { if ( level->GetX1() < xmin ) xmin = level->GetX1(); if ( level->GetX2() > xmax ) xmax = level->GetX2(); if ( level->GetY1() < ymin ) ymin = level->GetY1(); if ( level->GetY1() > ymax ) ymax = level->GetY1(); } Double_t xRmin = GetXRmin(xmin, xmax); Double_t xRmax = GetXRmax(xmin, xmax); Double_t yRmin = GetYRmin(ymin, ymax); Double_t yRmax = GetYRmax(ymin, ymax); if ( xmin > xmax || ymin > ymax ) { fLog << error << Form(" Problem when computing pad range, xmin > xmax or ymin > ymax") << dolog; return; } if ( TVirtualPad::Pad() != 0 ) { // in principle, gpad exists TVirtualPad::Pad()->Connect("RangeAxisChanged()", "BaseLSPlayer", this, "RefreshLinks()"); TVirtualPad::Pad()->GetRange(xRminOld, yRminOld, xRmaxOld, yRmaxOld); xminOld = GetXMin(xRminOld, xRmaxOld); xmaxOld = GetXMax(xRminOld, xRmaxOld); // yminOld = GetYMin(yRminOld, yRmaxOld); ymaxOld = GetYMax(yRminOld, yRmaxOld); if (xRmin < xRminOld || xRmax > xRmaxOld) p1 = true; if (yRmin < yRminOld || yRmax > xRmaxOld) p2 = true; if ( p1 && p2) { pL= true; p1 = false; p2 = false; } } if (p1) { TVirtualPad::Pad()->Range(xRmin, yRminOld, xRmax, yRmaxOld); fAxis->SetX1(BaseLSPlayer::GetXAxis(xmin, xmax)); fAxis->SetX2(BaseLSPlayer::GetXAxis(xmin, xmax)); fAxis->SetY1(0.0); fAxis->SetY2(ymaxOld); fAxis->SetWmin(0.0); fAxis->SetWmax(ymaxOld); } if (p2) { TVirtualPad::Pad()->Range(xRminOld, yRmin, xRmaxOld, yRmax); fPositionLabels = BaseLSPlayer::GetYLabels(ymin, ymax); fAxis->SetX1(BaseLSPlayer::GetXAxis(xminOld, xmaxOld)); fAxis->SetX2(BaseLSPlayer::GetXAxis(xminOld, xmaxOld)); fAxis->SetY1(0.0); fAxis->SetY2(ymax); fAxis->SetWmin(0.0); fAxis->SetWmax(ymax); } if (pL) { TVirtualPad::Pad()->Range(xRmin, yRmin, xRmax, yRmax); fPositionLabels = BaseLSPlayer::GetYLabels(ymin, ymax); fAxis->SetX1(BaseLSPlayer::GetXAxis(xmin, xmax)); fAxis->SetX2(BaseLSPlayer::GetXAxis(xmin, xmax)); fAxis->SetY1(0.0); fAxis->SetY2(ymax); fAxis->SetWmin(0.0); fAxis->SetWmax(ymax); } name->SetNDC(); name->SetX(0.55); name->SetY(0.95); fAxis->Draw(); AppendPad(); fLog << debug << "End drawing list of levels" << dolog; } //__________________________________________________________ void BaseLSPlayer::DoStyle(EDrawStyle style) { // change existing drawing style fDrawStyle = style; TList* list = &GetLinkList(); for (Int_t i = 0; i < list->GetEntries(); ++i) { Link* link = static_cast ( list->At(i) ); Double_t xi = link->GetX()[1]; Double_t xf = link->GetX()[5];; Double_t x, y, offset1 = 0., offset2 = 0., prop; if ( style == kRadware ) { offset1 = TMath::Max(TMath::Abs(link->GetIL()->GetX2() - link->GetIL()->GetX1())/30., link->GetStrength().Get()/2.0); offset2 = TMath::Min(2.5*offset1, TMath::Abs(link->GetIL()->GetX2() - link->GetIL()->GetX1())/2.); } if ( style == kEnsdf ) { offset1 = TMath::Abs(link->GetIL()->GetX2() - link->GetIL()->GetX1())/70.; offset2 = 5*offset1; } prop = 3.0/4.0; if ( link->GetIL() && link->GetFL() ) { x = xi; y = link->GetY()[1]; link->SetPoint(0,x-offset1,y); link->SetPoint(1,x,y); link->SetPoint(2,x+offset1,y); link->SetPoint(8,x-offset1,y); x = xi + prop*(xf-xi); y = link->GetIL()->GetY1() - prop*(link->GetIL()->GetY1() - link->GetFL()->GetY1()); link->SetPoint(3,x+offset1,y); link->SetPoint(4,x+offset2,y); link->SetPoint(6,x-offset2,y); link->SetPoint(7,x-offset1,y); x = xf; y = link->GetFL()->GetY1(); link->SetPoint(5,x,y); } } } //__________________________________________________________ Int_t BaseLSPlayer::ImportLevelScheme(const Char_t* filename, Option_t* opt) { // import file with dedicated readers TString fname(filename); Int_t ok = 0; TString Options(opt); bool Noverbose = Options.Contains("NoVerbose"); Options.ReplaceAll("NoVerbose",""); Bool_t NoGraphical = Options.Contains("NoGraphical"); Options.ReplaceAll("NoGraphical",""); if ( fname.EndsWith(".ags") ) { RadLevelSchemeReader reader(filename, Options.Data()); ok= reader.Import(*fLevelScheme); if(!NoGraphical) DoStyle(kRadware); } if ( fname.EndsWith(".ens") ) { EnsdfLevelSchemeReader reader(filename, Options.Data()); if(Noverbose) reader.SetQuietMode(); ok = reader.Import(*fLevelScheme); if(!NoGraphical) DoStyle(kEnsdf); } return ok; } //__________________________________________________________ Int_t BaseLSPlayer::ReadAGS(const Char_t *filename, Option_t *opt) { // for backward compatibility RadLevelSchemeReader reader(filename, opt); return reader.Import(*fLevelScheme); } //__________________________________________________________ Int_t BaseLSPlayer::ReadENSDF(const Char_t *filename, Option_t *opt) { // for backward compatibility EnsdfLevelSchemeReader reader(filename, opt); return reader.Import(*fLevelScheme); } //----------------------------------------------------------------------------------------- ClassImp(LSaxis) //_______________________________________________ LSaxis::LSaxis() : TGaxis(), fLastX(0), fLastY1(0), fLastY2(0), fFirst1Zoom(true), fFirst2Zoom(true), fLastY1Zoom(0), fLastY2Zoom(0) { SetLabelFont(132); } //__________________________________________________________ void LSaxis::SetY1(Double_t y1) { TGaxis::SetY1(y1); if (fFirst1Zoom) { fLastY1Zoom = (Int_t)y1; fFirst1Zoom = false; if (TVirtualPad::Pad() != 0) { Double_t xRmin, yRmin, xRmax, yRmax; TVirtualPad::Pad()->GetRange(xRmin, yRmin, xRmax, yRmax); fLastX1Zoom = Int_t(BaseLSPlayer::GetXMin(xRmin, xRmax)+0.5); } } } //__________________________________________________________ void LSaxis::SetY2(Double_t y2) { TGaxis::SetY2(y2); if (fFirst2Zoom) { fLastY2Zoom = (Int_t)y2; fFirst2Zoom = false; if (TVirtualPad::Pad() != 0) { Double_t xRmin, yRmin, xRmax, yRmax; TVirtualPad::Pad()->GetRange(xRmin, yRmin, xRmax, yRmax); fLastX2Zoom = Int_t(BaseLSPlayer::GetXMax(xRmin, xRmax)+0.5); } } } //__________________________________________________________ void LSaxis::ExecuteEvent(Int_t eventType, Int_t eventX, Int_t eventY) { // handle cursor mouvement TVirtualPad* pad = TVirtualPad::Pad(); pad->cd(); static Int_t eventYOld = 0; static Bool_t buttonMotion = false; if (eventType == kMouseMotion) { eventYOld = eventY; pad->SetCursor(kHand); } if (eventType == kButton1Down) { fLastX = eventX; fLastY1 = eventY; gVirtualX->SetLineColor(-1); } if (eventType == kButton1Motion) { gVirtualX->DrawBox(fLastX-10, fLastY1, fLastX+10, eventYOld, TVirtualX::kHollow); gVirtualX->DrawBox(fLastX-10, fLastY1, fLastX+10, eventY, TVirtualX::kHollow); eventYOld = eventY; fLastY2 = eventY; buttonMotion = true; } if (eventType == kButton1Up && buttonMotion) { fLastY1 = (Int_t)gPad->AbsPixeltoY(fLastY1); fLastY2 = (Int_t)gPad->AbsPixeltoY(fLastY2); if (fLastY1 > fLastY2) { Int_t tmp = fLastY2; fLastY2 = fLastY1; fLastY1 = tmp; } SetWmin(fLastY1); SetWmax(fLastY2); Double_t yRmin = BaseLSPlayer::GetYRmin(fLastY1, fLastY2); Double_t yRmax = BaseLSPlayer::GetYRmax(fLastY1, fLastY2); Double_t yMin = BaseLSPlayer::GetYMin(yRmin, yRmax); Double_t yMax = BaseLSPlayer::GetYMax(yRmin, yRmax); SetY1(yMin); SetY2(yMax); pad->Range(pad->GetX1(), yRmin, pad->GetX2(), yRmax); pad->Modified(true); buttonMotion = false; } } //__________________________________________________________ void LSaxis::SetRange(Int_t ymin, Int_t ymax, Int_t xmin, Int_t xmax) { TPad* pad = (TPad*)TVirtualPad::Pad(); pad->cd(); SetWmin(ymin); SetWmax(ymax); Double_t yRmin = BaseLSPlayer::GetYRmin(ymin, ymax); Double_t yRmax = BaseLSPlayer::GetYRmax(ymin, ymax); Double_t xRmin = BaseLSPlayer::GetXRmin(xmin, xmax); Double_t xRmax = BaseLSPlayer::GetXRmax(xmin, xmax); Double_t yAxisMin = BaseLSPlayer::GetYMin(yRmin, yRmax); Double_t yAxisMax = BaseLSPlayer::GetYMax(yRmin, yRmax); SetY1(yAxisMin); SetY2(yAxisMax); SetX1(xmin-(xmax-xmin)*0.1); SetX2(xmin-(xmax-xmin)*0.1); pad->Range(xRmin, yRmin, xRmax, yRmax); pad->Modified(true); fLastY1Zoom = ymin; fLastY2Zoom = ymax; fLastX1Zoom = xmin; fLastX2Zoom = xmax; pad->RangeAxisChanged(); } //__________________________________________________________ void LSaxis::UnZoom() { TPad* pad = (TPad*)TVirtualPad::Pad(); pad->cd(); SetWmin(fLastY1Zoom); SetWmax(fLastY2Zoom); Double_t yRmin = BaseLSPlayer::GetYRmin(fLastY1Zoom, fLastY2Zoom); Double_t yRmax = BaseLSPlayer::GetYRmax(fLastY1Zoom, fLastY2Zoom); Double_t yMin = BaseLSPlayer::GetYMin(yRmin, yRmax); Double_t yMax = BaseLSPlayer::GetYMax(yRmin, yRmax); SetY1(yMin); SetY2(yMax); pad->Range(pad->GetX1(), yRmin, pad->GetX2(), yRmax); pad->Modified(); pad->RangeAxisChanged(); } ClassImp(BaseLSPlayer)