Logo ROOT   6.18/05
Reference Guide
draw_v6.cxx
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_v7
3///
4/// \macro_code
5///
6/// \date 2017-06-02
7/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
8/// is welcome!
9/// \author Axel Naumann <axel@cern.ch>
10
11/*************************************************************************
12 * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
13 * All rights reserved. *
14 * *
15 * For the licensing terms see $ROOTSYS/LICENSE. *
16 * For the list of contributors see $ROOTSYS/README/CREDITS. *
17 *************************************************************************/
18
19R__LOAD_LIBRARY(libGpad);
20
22#include <ROOT/RCanvas.hxx>
23#include <TGraph.h>
24
25#include <iostream>
26
27// Show how to display v6 objects in a v7 RCanvas.
28
29void draw_v6()
30{
31 using namespace ROOT::Experimental;
32
33 static constexpr int npoints = 10;
34 double x[npoints] = { 0., 1., 2., 3., 4., 5., 6., 7., 8., 9. };
35 double y[npoints] = { .1, .2, .3, .4, .3, .2, .1, .2, .3, .4 };
36 auto gr = std::make_shared<TGraph>(npoints, x, y);
37 auto canvas = RCanvas::Create("v7 RCanvas showing a v6 TGraph");
38 canvas->Draw(gr, "AL");
39
40 // canvas->Show("opera"); // one could specify program name which should show canvas (like chromium or firefox)
41 // canvas->Show("/usr/bin/chromium --app=$url &"); // one could use $url parameter, which replaced with canvas URL
42
43 canvas->Show(); // new window in default browser should popup and async update will be triggered
44
45 // synchronous, wait until painting is finished
46 canvas->Update(false,
47 [](bool res) { std::cout << "First Update done = " << (res ? "true" : "false") << std::endl; });
48
49 canvas->Modified(); // invalidate canvas and force repainting with next Update()
50
51 // call Update again, should return immediately if canvas was not modified
52 canvas->Update(false,
53 [](bool res) { std::cout << "Second Update done = " << (res ? "true" : "false") << std::endl; });
54
55 // request to create PNG file in asynchronous mode and specify lambda function as callback
56 // when request processed by the client, callback invoked with result value
57 // canvas->SaveAs("draw.png", true,
58 // [](bool res) { std::cout << "Producing PNG done res = " << (res ? "true" : "false") << std::endl; });
59
60 // this function executed in synchronous mode (async = false is default),
61 // previous file saving will be completed at this point as well
62 // canvas->SaveAs("draw.svg"); // synchronous
63}
#define R__LOAD_LIBRARY(LIBRARY)
Definition: Rtypes.h:473
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
TGraphErrors * gr
Definition: legend1.C:25