[ROOT] Root, Win32 drawing, funny Device Contexts, building root, etc.

From: Gordon Watts (gwatts@epe.phys.washington.edu)
Date: Mon Aug 05 2002 - 07:44:53 MEST


Hi,

  I've a few very quick questions. I really like the idea behind Carrot,
the apache component that allows you to just place a root file in the
web server. I've been thinking about how to implement it in my spare
time in Windows. During a recent plane flight I tackled what I thought
would be the simplest part: getting root to draw a histogram, capturing
that drawing, and rendering it as a gif/jpeg that I could then feed to
the web.

 

  Summary of questions: help understanding how root draws in the win32
build, status of the gdk win32 port, how to build(static libs?)/debug
root from source.

 

  My first attempt was simply to run root in batch mode, generate a
postscript file, and then render it with ghostview. Works, but is
horribly slow.

 

  My second idea was to just screen scrape, basically. Have root draw
onto the screen, find out where it drew it, and then scrape the data
off. Andy Hass, who did ActiveRoot, basically uses this technique. This
works just fine interactively. The problem is you don't want windows
flashing up on your web server machine. Potentially, this is solved by
having the component run as a Windows Service, giving it its own
security ID, and thus its own private desktop. Alas, that doesn't seem
to work either.

 

  So I set out figuring out why and trying to get it to work. Basically,
I suspect that the default screen Device Context (DC) for a service is
not good enough for drawing in some way (too small, mono, etc.). To test
this out, I did the following (slimy) things...

 

  First create a blank canvas. Get the TWin32CanvasImp object from the
new canvas, and extract the size of the screen. Create a full color
bitmap of the correct size, then assign it to the fObjectDC member
variable of the canvas implementation object (slim warning: I had to
make fObjectDC a public instance variable to do this). Then do a
hist->Draw() and a canvas->Update(). Lo, in interactive mode, it works
just fine. Though the window frame pops up, you never see the histogram
drawn, however, the gif/jpeg file written out by the code contains the
histogram's image!

 

  When it is run as a service, however, this does not work. I tried a
few things. For example, I colored the whole bitmap red before I let
root get a hold of it. In interactive mode it is completely overwritten
with the correct image of the histo, when running as a service, nothing
at all is done to it. So it is almost as if either the drawing functions
weren't getting called, or there is something wrong with the pens,
brushes, etc., that are used to draw and nothing gets changed in the bit
map.

 

  I started trying to delve down into source code at this point (I was
looking at version 3.03.07). I discovered the gdk version, and tried
that (3.03.06) - wave of the future, so if I could be an early adopter,
that would be great, however, the interactive version crashed as soon as
I did a "TCanvas c1;" statement, so I gave up on that. That left me with
trying to understand how the graphics calls are actually made. I can't.
I could use some help here: How, exactly, are the draw functions in W32
called? If there is a roottalk mailing already, I'd love to read it
(couldn't find it in my many searches of the mailing list). Also,
someone who knows the internals of this code may well know what the
likely points of failure are.

 

  On a final note, at one point I decided the best way to track this
down was with the debugger. However, I was unable to build root. I
followed the instructions, but since I'm using VC 7... I got stuck on
building libCint.dll (how can you turn off sharable libraries and build
static ones? I didn't see a switch in the configure script) - undefined
symbols: _TI3?Avlength_error@std@@ for example. It is probably something
dumb, but I wasn't able to track it down in the short time I spent
exploring this avenue. BTW, once built, is it easy to run a debugger on
root?

 

  Any help would be appreciated. And I'm more than happy to
show/share/post/etc. code if anyone wants to see it. Many thanks.

 

            Cheers,

                        Gordon.

 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:03 MET