RE: Draw histograms in Canvas

From: Valery Fine (Faine) (fine@bnl.gov)
Date: Fri Mar 26 1999 - 16:32:19 MET


>
> Although I sent my question directly to Valery Fine, I think that your
> comment may be interesting for rooters in general because I know
> people who
> already asked me near the same question. I.e. what is the best way to
> update your histograms on screen in on-line applications.
>
> ---------
>
> Hi Valery,
>
> thanks for the answer. It makes things clear, but still I have some more
> specific question. Let's imagine I have an on-line application where an
> user can define a set of canvas with histograms. There is also an
> asin.timer set to update all the histograms once a second or so. Then I
> have a loop inside UpdateTimer.Notify() which basically goes through all
> the canvas and calls Hist[i]->Draw(); for each histogram.

 It is wrong approach. From you Notify you should call only method, namely

                        YouCanvas->Update();

  All Draw() methods must be call "in advance" and "at once". When you
decided
that histogram must be present on that Canvas. I can repeat what I said with
my last reply:

          There is no means to call any Draw() in loop.

Draw method INCLUDES the pointer of your object into the list of the object
of some
particular Pad. Apparently there is no means to include your object into the
said list
SEVERAL times the only result of that could be: your application will work
slow.

> First at all it
> may be a very time consuming, especially if I draw histograms with "fancy"
> options like "cont" for 2D, etc. On the other hand a user can only view a
> certain number of canvas/histograms at once. Moreover canvas can be
> overlapped so that only a few histograms in canvas need to be actually
> redrawn. What can you suggest in this case? Having in mind my experience
> working with other winlibs starting from Borland TurboVision I know that
> Object->Draw() checks if the Object is not hidden by other objects on the
> screen. Then it goes through the actual drawing. Moreover it checks if its
> children is not hidden before calling Children->Draw() for its Z
> buffer. In
> root it seems that Hist->Draw() does much more than just drawing, while
> Hist->Show() does similar things. The problem is that I have to use Draw()
> to update histogram because its content is changing dynamically.
>

  Hello Anton I have explained the "drawing" is performed by TObject::Paint
method.
  and this method is called by TPad, not by user code at all.
  So one can gain nothing playing with Draw methods.
  This matter have been discussed on rootalk many times. Please use "Search"
  facility of the ROOT Web page to get further explanations.

  Hope this helps,
              Valery



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:30 MET