Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TObjectDrawable.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_TObjectDrawable
10#define ROOT7_TObjectDrawable
11
12#include <ROOT/RDrawable.hxx>
13#include <ROOT/RAttrValue.hxx>
14#include <ROOT/RAttrLine.hxx>
15#include <ROOT/RAttrText.hxx>
16#include <ROOT/RAttrMarker.hxx>
17#include <ROOT/RAttrFill.hxx>
18
19class TObject;
20class TColor;
21class TClass;
22
23namespace ROOT {
24namespace Experimental {
25
26class RPadBase;
27class TObjectDisplayItem;
28
29/** \class TObjectDrawable
30\ingroup GpadROOT7
31\brief Provides v7 drawing facilities for TObject types (TGraph, TH1, TH2, etc).
32\author Sergey Linev
33\date 2017-05-31
34\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
35*/
36
37class TObjectDrawable final : public RDrawable {
38private:
39
40 enum {
41 kNone = 0, ///< empty container
42 kObject = 1, ///< plain object
43 };
44
45 int fKind{kNone}; ///< object kind
46 Internal::RIOShared<TObject> fObj; ///< The object to be painted, owned by the drawable
47 const TObject *fExtObj{nullptr}; ///<! external object, managed outside of the drawable, not persistent
48
49 static std::string GetColorCode(TColor *col);
50
51 std::unique_ptr<TObject> CreateSpecials(int kind);
52
53protected:
54
55 void CollectShared(Internal::RIOSharedVector_t &vect) final { vect.emplace_back(&fObj); }
56
57 std::unique_ptr<RDisplayItem> Display(const RDisplayContext &) override;
58
59 void PopulateMenu(RMenuItems &) final;
60
61 void Execute(const std::string &) final;
62
63 static void ExtractObjectColors(std::unique_ptr<TObjectDisplayItem> &item, const TObject *obj);
64
65 static void CheckOwnership(TObject *obj);
66
67 static const char *DetectCssType(const TObject *obj);
68
69public:
70 // special kinds, see TWebSnapshot enums
71 enum EKind {
72 kColors = 4, ///< list of ROOT colors
73 kStyle = 5, ///< instance of TStyle object
74 kPalette = 6 ///< list of colors from palette
75 };
76
77 RAttrLine line{this, "line"}; ///<! object line attributes
78 RAttrFill fill{this, "fill"}; ///<! object fill attributes
79 RAttrMarker marker{this, "marker"}; ///<! object marker attributes
80 RAttrText text{this, "text"}; ///<! object text attributes
81 RAttrValue<std::string> options{this, "options"}; ///<! object draw options
82
84 TObjectDrawable(TObject *obj, bool isowner = false);
85 TObjectDrawable(TObject *obj, const std::string &opt, bool isowner = false);
86 TObjectDrawable(const std::shared_ptr<TObject> &obj);
87 TObjectDrawable(const std::shared_ptr<TObject> &obj, const std::string &opt);
88 TObjectDrawable(EKind kind, bool persistent = false);
89 ~TObjectDrawable() override;
90
91 void Reset();
92
93 void Set(TObject *obj, bool isowner = false);
94 void Set(TObject *obj, const std::string &opt, bool isowner = false);
95
96 const TObject *Get();
97};
98
99} // namespace Experimental
100} // namespace ROOT
101
102
103#endif
Drawing fill attributes for different objects.
Definition RAttrFill.hxx:26
Drawing line attributes for different objects.
Definition RAttrLine.hxx:26
Template class to access single value from drawable or other attributes.
Base class for drawable entities: objects that can be painted on a RPad.
List of items for object context menu.
Provides v7 drawing facilities for TObject types (TGraph, TH1, TH2, etc).
RAttrValue< std::string > options
! object draw options
@ kPalette
list of colors from palette
@ kStyle
instance of TStyle object
static void ExtractObjectColors(std::unique_ptr< TObjectDisplayItem > &item, const TObject *obj)
Check if object has specified color value and store it in display item Ensure that color matches on c...
static void CheckOwnership(TObject *obj)
Checks object ownership - used for TH1 directory handling and TF1 globals lists.
Internal::RIOShared< TObject > fObj
The object to be painted, owned by the drawable.
RAttrText text
! object text attributes
RAttrFill fill
! object fill attributes
std::unique_ptr< TObject > CreateSpecials(int kind)
Create instance of requested special object.
void PopulateMenu(RMenuItems &) final
fill context menu items for the ROOT class
static std::string GetColorCode(TColor *col)
Convert TColor to RGB string for using with SVG.
void CollectShared(Internal::RIOSharedVector_t &vect) final
void Execute(const std::string &) final
Execute object method.
std::unique_ptr< RDisplayItem > Display(const RDisplayContext &) override
Create display item which will be delivered to the client.
const TObject * Get()
Return assigned object.
static const char * DetectCssType(const TObject *obj)
Provide css type.
const TObject * fExtObj
! external object, managed outside of the drawable, not persistent
void Set(TObject *obj, bool isowner=false)
Set object.
RAttrMarker marker
! object marker attributes
~TObjectDrawable() override
Destructor.
RAttrLine line
! object line attributes
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
The color creation and management class.
Definition TColor.h:21
Mother of all ROOT objects.
Definition TObject.h:41
std::vector< RIOSharedBase * > RIOSharedVector_t
Definition RDrawable.hxx:52
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...