ROOT
6.07/01
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
bindings
pyroot
JupyROOT
kernel
draw.py
Go to the documentation of this file.
1
# -*- coding:utf-8 -*-
2
#-----------------------------------------------------------------------------
3
# Copyright (c) 2015, ROOT Team.
4
#
5
# Authors: Danilo Piparo <Danilo.Piparo@cern.ch> CERN
6
# Enric Tejedor enric.tejedor.saavedra@cern.ch> CERN
7
# Modified by: Omar Zapata <Omar.Zapata@cern.ch> http://oproject.org
8
# website: http://oproject.org/ROOT+Jupyter+Kernel (information only for ROOT kernel)
9
# Distributed under the terms of the Modified LGPLv3 License.
10
#
11
# The full license is in the file COPYING.rst, distributed with this software.
12
#-----------------------------------------------------------------------------
13
14
from
metakernel.display
import
display,HTML
15
16
import
ROOT
17
18
try
:
19
from
JupyROOT.utils
import
CanvasDrawer
as
CanvasDrawerCore
20
from
JupyROOT.utils
import
enhanceROOTModule
21
except
ImportError:
22
raise
Exception
(
"Error: JupyROOT not found"
)
23
24
class
CanvasDrawer
(CanvasDrawerCore):
25
'''
26
Capture the canvas which is drawn and decide if it should be displayed using
27
jsROOT with metakernel.
28
'''
29
def
__init__
(self, canvas):
30
CanvasDrawerCore.__init__(self,canvas)
31
32
def
_jsDisplay
(self):
33
'''Overloaded method to display with metakernel.display'''
34
display(HTML(self.getJsCode()))
35
36
37
def
_pngDisplay
(self):
38
display(self.getPngImage())
39
40
#required to display using metakernel.display instead IPython.display
41
def
_PyDraw
(thePad):
42
"""
43
Invoke the draw function and intercept the graphics
44
"""
45
drawer =
CanvasDrawer
(thePad)
46
drawer.Draw()
47
48
def
LoadDrawer
():
49
enhanceROOTModule
()
50
ROOT.TCanvas.Draw = _PyDraw
Exception
ROOT::R::TRInterface & Exception()
Definition:
Exception.C:4
JupyROOT.kernel.draw.CanvasDrawer
Definition:
draw.py:24
JupyROOT.utils.enhanceROOTModule
def enhanceROOTModule
Definition:
utils.py:390
JupyROOT.utils
Definition:
utils.py:1
JupyROOT.kernel.draw._PyDraw
def _PyDraw
Definition:
draw.py:41
JupyROOT.kernel.draw.CanvasDrawer.__init__
def __init__
Definition:
draw.py:29
JupyROOT.kernel.draw.CanvasDrawer._pngDisplay
def _pngDisplay
Definition:
draw.py:37
JupyROOT.kernel.draw.CanvasDrawer._jsDisplay
def _jsDisplay
Definition:
draw.py:32
JupyROOT.kernel.draw.LoadDrawer
def LoadDrawer
Definition:
draw.py:48