Logo ROOT   6.12/07
Reference Guide
text.cxx
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_v7
3 ///
4 /// \macro_code
5 ///
6 /// \date 2017-10-17
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 Olivier couet <Olivier.Couet@cern.ch>
10 
11 /*************************************************************************
12  * Copyright (C) 1995-2015, 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 
19 R__LOAD_LIBRARY(libGpad);
20 
21 // #include "ROOT/TFile.hxx"
22 #include "ROOT/TCanvas.hxx"
23 #include "ROOT/TColor.hxx"
24 #include "ROOT/TText.hxx"
25 #include "ROOT/TDirectory.hxx"
26 
27 void text()
28 {
29  using namespace ROOT;
30 
31  // Create a canvas to be displayed.
32  auto canvas = Experimental::TCanvas::Create("Canvas Title");
33 
34  auto text = std::make_shared<ROOT::Experimental::TText>("Hello World");
35  canvas->Draw(text).SetFillColor(Experimental::TColor::kRed);
36 
37  // Register the text with ROOT: now it lives even after draw() ends.
39 
40  canvas->Show();
41 
42  // TFile *f = TFile::Open("canv7.root", "recreate");
43  // f->WriteObject(canvas.get(), "canv_text");
44  // delete f;
45 }
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
void Add(std::string_view name, const std::shared_ptr< T > &ptr)
Add an existing object (rather a shared_ptr to it) to the TDirectory.
Definition: TDirectory.hxx:172
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition: TObject.cxx:195
static TDirectory & Heap()
Dedicated, process-wide TDirectory.
Definition: TFile.cxx:23
static constexpr PredefinedRGB kRed
Definition: TColor.hxx:185
#define R__LOAD_LIBRARY(LIBRARY)
Definition: Rtypes.h:470
TText * text
static std::shared_ptr< TCanvas > Create(const std::string &title)
Definition: TCanvas.cxx:63