[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2213.0. "Smooth Scrolling Question" by KETJE::DIERICK (Are you Motifated today ?) Tue Feb 06 1990 06:32

I am creating a custom widget for Process Control.
It consists of a "running" graph.
A control program adds new samples to the end of the graph, and the
widget takes care of the needed scrolling.
For now I have used XCopyArea to shift the graph and added the last point
with XDrawRectangle. This works fine and smooth, except in two cases :

1. The graph is partially obscured by another window.
2. The graph is partially off screen.

The XCopyArea doesn't work in these cases. Does anybody have a solution
on how I could deal with this, or do I have only one alternative :
redraw the entire graph all time (and taking the flickering as an
unwanted guest) ?


Posted here because Decwindows Programming unavailable.


Thanks,

Dominique
T.RTitleUserPersonal
Name
DateLines
2213.1No pixmaps wanted if possible.KETJE::DIERICKAre you Motifated today ?Tue Feb 06 1990 09:1613
I could use a pixmap as backingstore, but don't want to do this for
a widget (you never know how much of my charts will be created by the
application...).

The only stuff I found satisfactory for the moment is to do an XCopyArea,
generate an exposure with XClearArea and redraw the ENTIRE chart on
exposure. This gives a lot of overhead, but is better then clearing
the window (flicker !) and redrawing the chart. Most interesting would be to
be able to get what part of the window is not VISIBLE. 
I have looked in the reference guides for pointers to get this region,
but I haven't found any. Did I overlook something ?

Dominique
2213.2GraphicsExpose/NoExpose eventsDECWIN::KLEINTue Feb 06 1990 10:5846
The short answer is that you need to recognize and handle the asynchronous
protocol you're generating between the client and the server.

Read up on GraphicsExpose events.  You're generating them and need to
handle them.

Imagine there is a small window covering the middle of the graph.
When the graph is partially occluded, GraphicsExpose events
are generated (by default) by the server and are sent to the client in
response to the CopyArea request.  The client must respond to these
GraphicsExpose requests by sending over a piece of the graph to
fill the "hole".

Now, if you aren't careful, the "hole" will have moved by the time
the client gets around to responding to the GraphicsExpose event,
which, in turn, had been triggered by a CopyArea request issued by the
client a relatively long time ago (a round trip to the server takes
at least 1/100 of a second).

It is easy for the client to send requests faster than the server can
handle them, and there is always a latency.  So the client has to shoot
ahead of the target, so to speak.

The best way I have found to manage this problem is to 
avoid nesting CopyArea requests.  Only have one outstanding at a time.
This helps makes the solution (shoot ahead) tractable.

Another problem to watch out for, that adds complexity, is the handling
of "normal" Expose events.  These will be caused when another window that was
only partially occluding the graph window is pushed behind the graph
window, exposing a portion of the graph window.  Do make this work
properly, while the graph is scrolling, it is important
to synchronize the response to the Expose event with the current
CopyArea request (and its possible GraphicsExpose event response).

The end result is that you need three internal variables representing
the "scroll" position of the graph.  I call them "internal", "requested",
and "external".

You might be interested in looking at the VList widget for an example
of this logic.  As a secondary advantage, the non-nesting of CopyArea
requests allows the widget to scroll much faster, since it will group
together multiple small scroll requests into a single larger one if
the server can't keep up.   Send me mail to get a VList kit.

-steve-
2213.3GraphicsExpose/NoExposeKETJE::DIERICKAre you Motifated today ?Tue Feb 06 1990 11:319
Thanks for your quick answer Steve. I'll have a look in GraphicsExpose.
I suppose what you told in .1 is also valid for a window obscuring
the right hand side of my graph (creating junk space where I do my
CopyArea from). If not correct me please.
As soon as I finished the widget I'll post something in dw_examples (it's
for a customized demo on process control and
online Quality Control. Maybe other people would want it also).

Dominique
2213.4CopyArea will fill-to-backgroundDECWIN::KLEINTue Feb 06 1990 11:4214
>>I suppose what you told in .1 is also valid for a window obscuring
>>the right hand side of my graph (creating junk space where I do my
>>CopyArea from). 

CopyArea will fill-to-background any destination region for which the
corresponding source region is not visible.  This means that rather
than copying "junk", CopyArea will clear the region and send the
client a GraphicsExpose event specifying the destination region
that needs to be filled in by the client.

You will also want to use NoExpose events to help synchronize the
"adjustment" variables with the server state.

-steve-
2213.5Works nowKETJE::DIERICKAre you Motifated today ?Tue Feb 06 1990 12:337
Steve,

Graphics Exposure works like a charm (quark ?). I succeed in drawing
only the needed points from my graph (the one that where in the exposed
region). 

Thanks.
2213.6not so well in some cases..KETJE::DIERICKAre you Motifated today ?Thu Feb 08 1990 09:4814
.5 ....works like a charm.

I have expierienced in the mean time that this works fine for "small scroll
steps". As the values for the chart come in at random x-axis intervals,
sometimes the scroll is quit big (100-500 pixels per step). I found
out that I better redraw the entire chart after the copy area. This gives
some overhead when I have NoExpose, but works smoother at GraphicsExpose.
After all the overhead is not that big, a graph with 1000 pts on it
is not really nice for the end user. So it hardly ever comes to drawing
about 100 points again.
Sorry for posting this X stuff here moderator, but as I told in my
initial entry, DECwindows_programming was down (again).

Dominique