[To reply replace "Aaron.Sloman.XX" with "A.Sloman"]
Daniel J Birks <dqb@cs.bham.ac.uk> writes about a problem using
RCLIB
> when I attempt to set the properties of rc_pic_lines on the fly (in a
> simulation run) ie:
>
> if see_target_flag = 1 then
> [COLOUR 'black' WIDTH 1 [CIRCLE {0 0 1}] ] -> agent.rc_pic_lines;
> else
> [COLOUR ^t_id WIDTH 1 [CIRCLE {0 0 1}] ] -> agent.rc_pic_lines;
> endif;
If you change the specification for drawing a movable picture object (an
instance of rc_linepic_movable) simply by updating its rc_pic_lines
slot, then the window in which it was drawn knows nothing about this.
When you next try to move the object (using rc_move_to or rc_move_by,
etc.) it will try first to undraw then to draw the object both using the
*new* picture specification.
However undrawing with a new specification will leave a mess.
So when you wish to update the appearance of an object you need to
first undraw, then update the drawing specification then redraw.
There should be an example of this in some help file or
in TEACH RC_LINEPIC, but there isn't, though there are examples of
rc_undraw_linepic.
I suggest you define a method called something like
rc_new_appearance for objects of type rc_linepic_movable
which takes an object (pic) and the list structure spec specifying
its appearance and does
rc_undraw_linepic(pic);
spec -> rc_pic_lines(pic);
rc_draw_linepic(pic);
If you update the rc_pic_lines slot ONLY using that method, then you
can regularly change the appearance movable objects
The same applies to rc_pic_strings, if you use that.
Maybe I should provide an autoloadable version of such a procedure.
Alternatively I should redefine the updater of rc_pic_lines for
instances of rc_linepic_movable to do that always.
(That's a more elegant and general solution, but I don't think
call_next_method works for slot access methods, so I would have to
have a different name instead of rc_pic_lines for the actual slot.
Alternatively each movable object could have an extra private slot
remembering the last way it was drawn which is used by
rc_undraw_linepic)
> I get a little blob left at the point at which the colour changed...
> these marks can be removed using rc_redraw_window_object, but as these
> changes occur often I need to continually redraw the screen which just
> slows down the whole thing to a 'flickery' halt - expesicially when I have
> a large no. of agents...
If, as suggested above, you simply redraw individual agents when you
change their appearance, you'll should avoid that problem.
Aaron
==
--
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk (NB: Anti Spam address)
TOOLS: http://www.cs.bham.ac.uk/research/poplog/freepoplog.html
|