Hi @FoxWise ,
I guess you want something like this:
#include <iostream>
#include <thread>
#include <chrono>
#include "TSystem.h"
#include "TH1F.h"
#include "TCanvas.h"
#include "TROOT.h"
int test(){
TCanvas* canvas = new TCanvas("canvas");
canvas->cd();
TH1F* h = new TH1F("name","title", 100, 0, 100);
h->Fill(10.);
h->Fill(20.);
h->Fill(30.);
h->Draw();
canvas->Draw();
while (true) {
gSystem->ProcessEvents();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
return 0;
}
I guess the missing part is to listen for a keypress and exit the ProcessEvents loop if a key (or just Enter) is pressed. You probably need a separate thread for that that communicates with the main thread via a condition variable, or maybe you can use curses or similar for that purpose.
The problem is that you can’t really pause the program: you still want the program to process clicks and interactions with the plot, but you don’t want to proceed further with the program flow.
#include <iostream>
#include <ncurses.h>
#include "TSystem.h"
#include "TH1F.h"
#include "TCanvas.h"
#include "TROOT.h"
int test(){
TCanvas* canvas = new TCanvas("canvas");
canvas->cd();
TH1F* h = new TH1F("name","title", 100, 0, 100);
h->Fill(10.);
h->Fill(20.);
h->Fill(30.);
h->Draw();
canvas->Draw();
while ( true ) {
if (getch() == 'q') break;
gSystem->ProcessEvents();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
but ROOT output:
Processing test.cpp...
IncrementalExecutor::executeFunction: symbol 'stdscr' unresolved while linking [cling interface function]!
IncrementalExecutor::executeFunction: symbol 'wgetch' unresolved while linking [cling interface function]!
The ROOT interpreter doesn’t know that it has to link libcurses against the program. You can probably tell it to, but at this point it might be simpler to use a compiled program.
I’m not sure I understand the question, but if you save the histogram in a ROOT file then you can inspect it from another ROOT session.