Skip to content

Commit

Permalink
Merge pull request #336 from rest-for-physics/lobis-browser-icons
Browse files Browse the repository at this point in the history
fix browser for newer root versions (6.26./10) and add icons to buttons
  • Loading branch information
lobis authored Nov 25, 2022
2 parents 9bddfa9 + e715d71 commit 4cf0a2e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
44 changes: 22 additions & 22 deletions source/framework/core/inc/TRestBrowser.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#ifndef RestCore_TRestBrowser
#define RestCore_TRestBrowser

#include <iostream>
#include <TApplication.h>
#include <TBrowser.h>
#include <TCanvas.h>
#include <TGButton.h>
#include <TGComboBox.h>
#include <TGDimension.h>
#include <TGFileDialog.h>
#include <TGFrame.h>
#include <TGLabel.h>
#include <TGNumberEntry.h>
#include <TGTextEntry.h>
#include <TObject.h>
#include <TROOT.h>
#include <TRestEventViewer.h>
#include <TRestRun.h>
#include <TSystem.h>

#include "TApplication.h"
#include "TBrowser.h"
#include "TCanvas.h"
#include "TGButton.h"
#include "TGComboBox.h"
#include "TGDimension.h"
#include "TGFileDialog.h"
#include "TGFrame.h"
#include "TGLabel.h"
#include "TGNumberEntry.h"
#include "TGTextEntry.h"
#include "TObject.h"
#include "TROOT.h"
#include "TRestEventViewer.h"
#include "TRestRun.h"
#include "TSystem.h"
#include <iostream>

/// Event browser for different input file
class TRestBrowser {
Expand All @@ -41,12 +41,12 @@ class TRestBrowser {

TGLabel* fPlotOptionLabel = nullptr; //!
TGTextEntry* fPlotOptionTextBox = nullptr; //! TextBox for plot options
TGTextButton* fButOptPrev = nullptr; //! Previous plot option
TGPictureButton* fButOptPrev = nullptr; //! Previous plot option
TGTextButton* fButOptRefresh = nullptr; //! Refresh plot
TGTextButton* fButOptNext = nullptr; //! Next plot option
TGPictureButton* fButOptNext = nullptr; //! Next plot option

TGPictureButton* fMenuOpen = nullptr; //! Open file button
TGTextButton* fExit = nullptr; //! Exit button
TGPictureButton* fExit = nullptr; //! Exit button

// Frames and buttons on bottom
TGVerticalFrame* fHFrame = nullptr; //!
Expand Down Expand Up @@ -82,7 +82,7 @@ class TRestBrowser {
public:
// tool method
void Initialize(const TString& opt = "FI");
void InitFromConfigFile();
static void InitFromConfigFile();
Bool_t OpenFile(const TString& filename);

// setters
Expand All @@ -94,7 +94,7 @@ class TRestBrowser {

// actions
void LoadFileAction();
void ExitAction();
static void ExitAction();

void RowValueChangedAction(Long_t val);
void IdValueChangedAction(Long_t val);
Expand Down
38 changes: 19 additions & 19 deletions source/framework/core/src/TRestBrowser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ void TRestBrowser::SetViewer(const TString& viewerName) {
}

void TRestBrowser::SetLeftPanelButtons() {
TString icondir = (TString)getenv("ROOTSYS") + "/icons/";

fVFrame = new TGVerticalFrame(frmMain);
fVFrame->Resize(300, 200);

Expand Down Expand Up @@ -176,26 +174,28 @@ void TRestBrowser::SetLeftPanelButtons() {

auto switchButtonBar = new TGHorizontalFrame(fVFrame);
{
fButOptPrev = new TGTextButton(switchButtonBar, "--"); ///< Load Event button
fButOptPrev = new TGPictureButton(switchButtonBar, gClient->GetPicture("bld_undo.png"));
fButOptPrev->Connect("Clicked()", "TRestBrowser", this, "PreviousPlotOptionAction()");
switchButtonBar->AddFrame(fButOptPrev, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

fButOptRefresh = new TGTextButton(switchButtonBar, "Plot"); ///< Load Event button
fButOptRefresh = new TGTextButton(switchButtonBar, "Plot");
fButOptRefresh->Connect("Clicked()", "TRestBrowser", this, "PlotAction()");
switchButtonBar->AddFrame(fButOptRefresh, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

fButOptNext = new TGTextButton(switchButtonBar, "++"); ///< Load Event button
fButOptNext = new TGPictureButton(switchButtonBar, gClient->GetPicture("bld_redo.png"));

fButOptNext->Connect("Clicked()", "TRestBrowser", this, "NextPlotOptionAction()");
switchButtonBar->AddFrame(fButOptNext, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
}
fVFrame->AddFrame(switchButtonBar, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

// tool buttons
fMenuOpen = new TGPictureButton(fVFrame, gClient->GetPicture(icondir + "bld_open.png"));
fMenuOpen = new TGPictureButton(fVFrame, gClient->GetPicture("bld_open.png"));
fMenuOpen->Connect("Clicked()", "TRestBrowser", this, "LoadFileAction()");
fVFrame->AddFrame(fMenuOpen, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

fExit = new TGTextButton(fVFrame, "EXIT"); ///< Exit button
fExit = new TGPictureButton(fVFrame, gClient->GetPicture("bld_exit.png"));

fExit->Connect("Clicked()", "TRestBrowser", this, "ExitAction()");
fVFrame->AddFrame(fExit, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

Expand All @@ -219,17 +219,17 @@ void TRestBrowser::SetBottomPanelButtons() {
fSelectionTextBox = new TGTextEntry(fHFrame, "");
fHFrame->AddFrame(fSelectionTextBox, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

auto bottonsbar = new TGHorizontalFrame(fHFrame);
auto bottomBar = new TGHorizontalFrame(fHFrame);
{
fButEveNext = new TGTextButton(bottonsbar, "Previous Event"); ///< Exit button
fButEveNext = new TGTextButton(bottomBar, "Previous Event"); ///< Exit button
fButEveNext->Connect("Clicked()", "TRestBrowser", this, "PreviousEventAction()");
bottonsbar->AddFrame(fButEveNext, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
bottomBar->AddFrame(fButEveNext, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

fButEvePrev = new TGTextButton(bottonsbar, "Next Event"); ///< Exit button
fButEvePrev = new TGTextButton(bottomBar, "Next Event"); ///< Exit button
fButEvePrev->Connect("Clicked()", "TRestBrowser", this, "NextEventAction()");
bottonsbar->AddFrame(fButEvePrev, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
bottomBar->AddFrame(fButEvePrev, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
}
fHFrame->AddFrame(bottonsbar, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
fHFrame->AddFrame(bottomBar, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

frmBot->AddFrame(fHFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
frmBot->MapSubwindows();
Expand Down Expand Up @@ -380,7 +380,7 @@ Bool_t TRestBrowser::OpenFile(const TString& filename) {

void TRestBrowser::NextPlotOptionAction() {
string text = fPlotOptionTextBox->GetText();
if (text == "") {
if (text.empty()) {
text = "0";
} else if (isANumber(text)) {
text = ToString(StringToInteger(text) + 1);
Expand All @@ -392,7 +392,7 @@ void TRestBrowser::NextPlotOptionAction() {

void TRestBrowser::PreviousPlotOptionAction() {
string text = fPlotOptionTextBox->GetText();
if (text == "") {
if (text.empty()) {
text = "0";
} else if (isANumber(text)) {
text = ToString(StringToInteger(text) - 1);
Expand Down Expand Up @@ -454,15 +454,15 @@ void TRestBrowser::IdValueChangedAction(Long_t val) {

void TRestBrowser::NextEventAction() {
string sel = (string)fSelectionTextBox->GetText();
if (sel == "") {
if (sel.empty()) {
fEventRow++;
LoadEventEntry(fEventRow);
} else {
TRestAnalysisTree* tree = fRestRun->GetAnalysisTree();
TTreeFormula formula("Selection", sel.c_str(), tree);
if (formula.GetNdim() > 0) { // valid expression
fEventRow++;
while (1) {
while (true) {
tree->GetEntry(fEventRow);
if (formula.EvalInstance(fEventRow) == 1) {
LoadEventEntry(fEventRow);
Expand All @@ -484,15 +484,15 @@ void TRestBrowser::NextEventAction() {

void TRestBrowser::PreviousEventAction() {
string sel = (string)fSelectionTextBox->GetText();
if (sel == "") {
if (sel.empty()) {
fEventRow--;
LoadEventEntry(fEventRow);
} else {
TRestAnalysisTree* tree = fRestRun->GetAnalysisTree();
TTreeFormula formula("Selection", sel.c_str(), tree);
if (formula.GetNdim() > 0) { // valid expression
fEventRow--;
while (1) {
while (true) {
tree->GetEntry(fEventRow);
if (formula.EvalInstance(fEventRow) == 1) {
LoadEventEntry(fEventRow);
Expand Down

0 comments on commit 4cf0a2e

Please sign in to comment.